diff --git a/hesabixCore/src/Controller/BankController.php b/hesabixCore/src/Controller/BankController.php index bfc3c21..20dc4ab 100644 --- a/hesabixCore/src/Controller/BankController.php +++ b/hesabixCore/src/Controller/BankController.php @@ -5,6 +5,7 @@ namespace App\Controller; use App\Entity\BankAccount; use App\Entity\HesabdariRow; use App\Service\Access; +use App\Service\Explore; use App\Service\Log; use App\Service\Provider; use Doctrine\ORM\EntityManagerInterface; @@ -18,10 +19,25 @@ class BankController extends AbstractController #[Route('/api/bank/list', name: 'app_bank_list')] public function app_bank_list(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse { - if (!$access->hasRole('banks')) + $acc = $access->hasRole('banks'); + if (!$acc) throw $this->createAccessDeniedException(); + + //bug fix for bank with no money type $datas = $entityManager->getRepository(BankAccount::class)->findBy([ - 'bid' => $request->headers->get('activeBid') + 'bid' => $request->headers->get('activeBid'), + 'money'=>null + ]); + foreach ($datas as $data) { + $data->setMoney($acc['bid']->getMoney()); + $entityManager->persist($data); + } + $entityManager->flush(); + //end of bug fix + + $datas = $entityManager->getRepository(BankAccount::class)->findBy([ + 'bid' => $request->headers->get('activeBid'), + 'money'=>$acc['money'] ]); foreach ($datas as $data) { $bs = 0; @@ -46,9 +62,10 @@ class BankController extends AbstractController throw $this->createAccessDeniedException(); $data = $entityManager->getRepository(BankAccount::class)->findOneBy([ 'bid' => $acc['bid'], + 'money'=>$acc['money'], 'code' => $code ]); - return $this->json($provider->Entity2Array($data, 0)); + return $this->json(data: Explore::ExploreBank($data)); } #[Route('/api/bank/mod/{code}', name: 'app_bank_mod')] @@ -75,6 +92,7 @@ class BankController extends AbstractController return $this->json(['result' => 2]); $data = new BankAccount(); $data->setCode($provider->getAccountingCode($request->headers->get('activeBid'), 'bank')); + $data->setMoney($acc['money']); } else { $data = $entityManager->getRepository(BankAccount::class)->findOneBy([ 'bid' => $acc['bid'], diff --git a/hesabixCore/src/Controller/BusinessController.php b/hesabixCore/src/Controller/BusinessController.php index 45ee8d7..4f018bd 100644 --- a/hesabixCore/src/Controller/BusinessController.php +++ b/hesabixCore/src/Controller/BusinessController.php @@ -70,19 +70,13 @@ class BusinessController extends AbstractController return $this->json($extractor->operationSuccess()); } #[Route('/api/business/list', name: 'api_bussiness_list')] - public function api_bussiness_list(#[CurrentUser] ?User $user, Access $access, EntityManagerInterface $entityManager, Provider $provider): Response + public function api_bussiness_list(#[CurrentUser] ?User $user, Access $access,Explore $explore, EntityManagerInterface $entityManager, Provider $provider): Response { $buss = $entityManager->getRepository(Permission::class)->findBy(['user' => $user]); $response = []; foreach ($buss as $bus) { - //echo $bus->getBid()->getId(); - $temp = []; - $temp['id'] = $bus->getBid()->getId(); - $temp['owner'] = $bus->getBid()->getOwner()->getFullName(); - $temp['name'] = $bus->getBid()->getName(); - $temp['legal_name'] = $bus->getBid()->getLegalName(); - $response[] = $temp; + $response[] = Explore::ExploreBusiness($bus->getBid()); } return $this->json($response); } @@ -102,48 +96,7 @@ class BusinessController extends AbstractController ]); if (!$perms) throw $this->createAccessDeniedException(); - $response = []; - $response['id'] = $bus->getId(); - $response['name'] = $bus->getName(); - $response['owner'] = $bus->getOwner()->getFullName(); - $response['legal_name'] = $bus->getLegalName(); - $response['field'] = $bus->getField(); - $response['shenasemeli'] = $bus->getShenasemeli(); - $response['codeeqtesadi'] = $bus->getCodeeghtesadi(); - $response['shomaresabt'] = $bus->getShomaresabt(); - $response['country'] = $bus->getCountry(); - $response['ostan'] = $bus->getOstan(); - $response['shahrestan'] = $bus->getShahrestan(); - $response['postalcode'] = $bus->getPostalcode(); - $response['tel'] = $bus->getTel(); - $response['mobile'] = $bus->getMobile(); - $response['address'] = $bus->getAddress(); - $response['website'] = $bus->getWesite(); - $response['email'] = $bus->getEmail(); - $response['maliyatafzode'] = $bus->getMaliyatafzode(); - $response['arzmain'] = Explore::ExploreMoney($bus->getMoney()); - $response['type'] = $bus->getType(); - $response['zarinpalCode'] = $bus->getZarinpalCode(); - $response['smsCharge'] = $bus->getSmsCharge(); - $response['shortlinks'] = $bus->isShortLinks(); - $response['walletEnabled'] = $bus->isWalletEnable(); - $response['walletMatchBank'] = null; - $response['updateSellPrice'] = $bus->isCommodityUpdateSellPriceAuto(); - $response['updateBuyPrice'] = $bus->isCommodityUpdateBuyPriceAuto(); - if (!$bus->getProfitCalctype()) { - $response['profitCalcType'] = 'lis'; - } else { - $response['profitCalcType'] = $bus->getProfitCalctype(); - } - if ($bus->isWalletEnable()) - $response['walletMatchBank'] = $provider->Entity2Array($bus->getWalletMatchBank(), 0); - $year = $entityManager->getRepository(Year::class)->findOneBy([ - 'bid' => $bus, - 'head' => true - ]); - $response['year'] = Explore::ExploreYear($year); - - return $this->json($response); + return $this->json(Explore::ExploreBusiness($bus)); } #[Route('/api/business/list/count', name: 'api_bussiness_list_count')] @@ -669,8 +622,12 @@ class BusinessController extends AbstractController } #[Route('/api/business/stat', name: 'api_business_stat')] - public function api_business_stat(Jdate $jdate, Request $request, #[CurrentUser] ?User $user, EntityManagerInterface $entityManager): Response + public function api_business_stat(Access $access,Jdate $jdate, Request $request, #[CurrentUser] ?User $user, EntityManagerInterface $entityManager): Response { + $acc = $access->hasRole('join'); + if(!$acc) + throw $this->createAccessDeniedException(); + $dateNow = $jdate->jdate('Y/m/d', time()); $buss = $entityManager->getRepository(Business::class)->find( $request->headers->get('activeBid') @@ -693,6 +650,7 @@ class BusinessController extends AbstractController $docs = $entityManager->getRepository(HesabdariDoc::class)->findBy([ 'bid' => $buss, 'year' => $year, + 'money'=> $acc['money'] ]); $rows = $entityManager->getRepository(HesabdariRow::class)->findBy([ @@ -706,6 +664,8 @@ class BusinessController extends AbstractController 'bid' => $buss, 'year' => $year, 'type' => 'buy', + 'money'=> $acc['money'] + ]); $buysTotal = 0; $buysToday = 0; @@ -727,6 +687,7 @@ class BusinessController extends AbstractController 'bid' => $buss, 'year' => $year, 'type' => 'sell', + 'money'=> $acc['money'] ]); $sellsTotal = 0; $sellsToday = 0; @@ -748,6 +709,7 @@ class BusinessController extends AbstractController 'bid' => $buss, 'year' => $year, 'type' => 'person_send', + 'money'=> $acc['money'] ]); $sendsTotal = 0; $sendsToday = 0; @@ -769,6 +731,7 @@ class BusinessController extends AbstractController 'bid' => $buss, 'year' => $year, 'type' => 'person_receive', + 'money'=> $acc['money'] ]); $recsTotal = 0; $recsToday = 0; diff --git a/hesabixCore/src/Controller/BuyController.php b/hesabixCore/src/Controller/BuyController.php index 155845e..2575464 100644 --- a/hesabixCore/src/Controller/BuyController.php +++ b/hesabixCore/src/Controller/BuyController.php @@ -76,7 +76,8 @@ class BuyController extends AbstractController $invoices = $entityManager->getRepository(HesabdariDoc::class)->findBy([ 'bid'=>$acc['bid'], 'year'=>$acc['year'], - 'type'=>'buy' + 'type'=>'buy', + 'money'=> $acc['money'] ]); return $this->json(Explore::ExploreBuyDocsList($invoices)); } @@ -100,7 +101,8 @@ class BuyController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], 'year' => $acc['year'], - 'code' => $params['update'] + 'code' => $params['update'], + 'money'=> $acc['money'] ]); if (!$doc) return $this->json($extractor->notFound()); @@ -116,7 +118,7 @@ class BuyController extends AbstractController $doc->setDateSubmit(time()); $doc->setType('buy'); $doc->setSubmitter($this->getUser()); - $doc->setMoney($acc['bid']->getMoney()); + $doc->setMoney($acc['money']); $doc->setCode($provider->getAccountingCode($acc['bid'], 'accounting')); } if($params['transferCost'] != 0){ @@ -243,7 +245,8 @@ class BuyController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], 'year' => $acc['year'], - 'code' => $item['code'] + 'code' => $item['code'], + 'money'=> $acc['money'] ]); if (!$doc) return $this->json($extractor->notFound()); if ($params['label'] != 'clear') { @@ -286,7 +289,8 @@ class BuyController extends AbstractController $data = $entityManager->getRepository(HesabdariDoc::class)->findBy([ 'bid' => $acc['bid'], 'year' => $acc['year'], - 'type' => 'buy' + 'type' => 'buy', + 'money'=> $acc['money'] ], [ 'id' => 'DESC' ]); @@ -350,7 +354,8 @@ class BuyController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], - 'code' => $params['code'] + 'code' => $params['code'], + 'money'=> $acc['money'] ]); if (!$doc) throw $this->createNotFoundException(); $pdfPid = 0; @@ -413,7 +418,8 @@ class BuyController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], - 'code' => $params['code'] + 'code' => $params['code'], + 'money'=> $acc['money'] ]); if (!$doc) throw $this->createNotFoundException(); $person = null; diff --git a/hesabixCore/src/Controller/CashdeskController.php b/hesabixCore/src/Controller/CashdeskController.php index 288ef7b..3a65a25 100644 --- a/hesabixCore/src/Controller/CashdeskController.php +++ b/hesabixCore/src/Controller/CashdeskController.php @@ -5,6 +5,7 @@ namespace App\Controller; use App\Entity\Cashdesk; use App\Entity\HesabdariRow; use App\Service\Access; +use App\Service\Explore; use App\Service\Log; use App\Service\Provider; use Doctrine\ORM\EntityManagerInterface; @@ -19,11 +20,26 @@ class CashdeskController extends AbstractController #[Route('/api/cashdesk/list', name: 'app_cashdesk_list')] public function app_cashdesk_list(Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse { - if (!$access->hasRole('cashdesk')) + $acc = $access->hasRole('cashdesk'); + if (!$acc) throw $this->createAccessDeniedException(); + //bug fix for bank with no money type $datas = $entityManager->getRepository(Cashdesk::class)->findBy([ - 'bid' => $request->headers->get('activeBid') + 'bid' => $request->headers->get('activeBid'), + 'money' => null ]); + foreach ($datas as $data) { + $data->setMoney($acc['bid']->getMoney()); + $entityManager->persist($data); + } + $entityManager->flush(); + //end of bug fix + + $datas = $entityManager->getRepository(Cashdesk::class)->findBy([ + 'bid' => $request->headers->get('activeBid'), + 'money' => $acc['money'] + ]); + $resp = []; foreach ($datas as $data) { $bs = 0; $bd = 0; @@ -35,8 +51,9 @@ class CashdeskController extends AbstractController $bd += $item->getBd(); } $data->setBalance($bd - $bs); + $resp[] = Explore::ExploreCashdesk($data); } - return $this->json($datas); + return $this->json($resp); } #[Route('/api/cashdesk/info/{code}', name: 'app_cashdesk_info')] @@ -47,9 +64,10 @@ class CashdeskController extends AbstractController throw $this->createAccessDeniedException(); $data = $entityManager->getRepository(Cashdesk::class)->findOneBy([ 'bid' => $acc['bid'], - 'code' => $code + 'code' => $code, + 'money' => $acc['money'] ]); - return $this->json($data); + return $this->json(Explore::ExploreCashdesk($data)); } #[Route('/api/cashdesk/mod/{code}', name: 'app_cashdesk_mod')] @@ -76,6 +94,7 @@ class CashdeskController extends AbstractController return $this->json(['result' => 2]); $data = new Cashdesk(); $data->setCode($provider->getAccountingCode($request->headers->get('activeBid'), 'cashdesk')); + $data->setMoney($acc['money']); } else { $data = $entityManager->getRepository(Cashdesk::class)->findOneBy([ 'bid' => $acc['bid'], @@ -83,6 +102,9 @@ class CashdeskController extends AbstractController ]); if (!$data) throw $this->createNotFoundException(); + if (!$data->getMoney()) { + $data->setMoney($acc['money']); + } } $data->setBid($acc['bid']); $data->setname($params['name']); diff --git a/hesabixCore/src/Controller/ChequeController.php b/hesabixCore/src/Controller/ChequeController.php index b7dca0e..1837423 100644 --- a/hesabixCore/src/Controller/ChequeController.php +++ b/hesabixCore/src/Controller/ChequeController.php @@ -132,7 +132,7 @@ class ChequeController extends AbstractController $hesabdariDoc->setBid($acc['bid']); $hesabdariDoc->setSubmitter($this->getUser()); $hesabdariDoc->setYear($acc['year']); - $hesabdariDoc->setMoney($acc['bid']->getMoney()); + $hesabdariDoc->setMoney($acc['money']); $hesabdariDoc->setDateSubmit(time()); $hesabdariDoc->setDate($params['date']); $hesabdariDoc->setType('pass_cheque'); diff --git a/hesabixCore/src/Controller/CommodityController.php b/hesabixCore/src/Controller/CommodityController.php index ff7cb26..75f6ae9 100644 --- a/hesabixCore/src/Controller/CommodityController.php +++ b/hesabixCore/src/Controller/CommodityController.php @@ -229,7 +229,7 @@ class CommodityController extends AbstractController } else { $spd = new PriceListDetail; $spd->setList($list); - $spd->setMoney($acc['bid']->getMoney()); + $spd->setMoney($acc['money']); $spd->setCommodity($item); $spd->setPriceBuy(0); $spd->setPriceSell(0); @@ -362,7 +362,7 @@ class CommodityController extends AbstractController } else { $spd = new PriceListDetail; $spd->setList($item); - $spd->setMoney($acc['bid']->getMoney()); + $spd->setMoney($acc['money']); $spd->setCommodity($data); $spd->setPriceBuy(0); $spd->setPriceSell(0); @@ -496,7 +496,7 @@ class CommodityController extends AbstractController $detail->setCommodity($data); $detail->setPriceSell($item['priceSell']); $detail->setPriceBuy(0); - $detail->setMoney($acc['bid']->getMoney()); + $detail->setMoney($acc['money']); $entityManager->persist($detail); } } @@ -628,7 +628,7 @@ class CommodityController extends AbstractController $detail->setCommodity($data); $detail->setPriceSell($item['priceSell']); $detail->setPriceBuy(0); - $detail->setMoney($acc['bid']->getMoney()); + $detail->setMoney($acc['money']); $entityManager->persist($detail); } } diff --git a/hesabixCore/src/Controller/HesabdariController.php b/hesabixCore/src/Controller/HesabdariController.php index eab6c97..ade6888 100644 --- a/hesabixCore/src/Controller/HesabdariController.php +++ b/hesabixCore/src/Controller/HesabdariController.php @@ -49,9 +49,11 @@ class HesabdariController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], 'year' => $acc['year'], - 'code' => $params['code'] + 'code' => $params['code'], + 'money' => $acc['money'] ]); - if (!$doc) throw $this->createNotFoundException(); + if (!$doc) + throw $this->createNotFoundException(); $rows = []; $rowsObj = $entityManager->getRepository(HesabdariRow::class)->findBy( ['doc' => $doc] @@ -176,15 +178,24 @@ class HesabdariController extends AbstractController if (!array_key_exists('type', $params)) $this->createNotFoundException(); $roll = ''; - if ($params['type'] == 'person_receive' || $params['type'] == 'person_send') $roll = 'person'; - elseif ($params['type'] == 'cost') $roll = 'cost'; - elseif ($params['type'] == 'income') $roll = 'income'; - elseif ($params['type'] == 'buy') $roll = 'buy'; - elseif ($params['type'] == 'rfbuy') $roll = 'plugAccproRfbuy'; - elseif ($params['type'] == 'transfer') $roll = 'transfer'; - elseif ($params['type'] == 'sell') $roll = 'sell'; - elseif ($params['type'] == 'rfsell') $roll = 'plugAccproRfsell'; - elseif ($params['type'] == 'all') $roll = 'accounting'; + if ($params['type'] == 'person_receive' || $params['type'] == 'person_send') + $roll = 'person'; + elseif ($params['type'] == 'cost') + $roll = 'cost'; + elseif ($params['type'] == 'income') + $roll = 'income'; + elseif ($params['type'] == 'buy') + $roll = 'buy'; + elseif ($params['type'] == 'rfbuy') + $roll = 'plugAccproRfbuy'; + elseif ($params['type'] == 'transfer') + $roll = 'transfer'; + elseif ($params['type'] == 'sell') + $roll = 'sell'; + elseif ($params['type'] == 'rfsell') + $roll = 'plugAccproRfsell'; + elseif ($params['type'] == 'all') + $roll = 'accounting'; else $this->createNotFoundException(); @@ -195,6 +206,7 @@ class HesabdariController extends AbstractController $data = $entityManager->getRepository(HesabdariDoc::class)->findBy([ 'bid' => $acc['bid'], 'year' => $acc['year'], + 'money' => $acc['money'] ], [ 'id' => 'DESC' ]); @@ -202,7 +214,8 @@ class HesabdariController extends AbstractController $data = $entityManager->getRepository(HesabdariDoc::class)->findBy([ 'bid' => $acc['bid'], 'year' => $acc['year'], - 'type' => $params['type'] + 'type' => $params['type'], + 'money' => $acc['money'] ], [ 'id' => 'DESC' ]); @@ -260,9 +273,12 @@ class HesabdariController extends AbstractController if (!array_key_exists('type', $params)) $this->createNotFoundException(); $roll = ''; - if ($params['type'] == 'person_receive' || $params['type'] == 'person_send') $roll = 'person'; - elseif ($params['type'] == 'sell_receive') $roll = 'sell'; - elseif ($params['type'] == 'buy_send') $roll = 'buy'; + if ($params['type'] == 'person_receive' || $params['type'] == 'person_send') + $roll = 'person'; + elseif ($params['type'] == 'sell_receive') + $roll = 'sell'; + elseif ($params['type'] == 'buy_send') + $roll = 'buy'; else $roll = $params['type']; @@ -278,12 +294,14 @@ class HesabdariController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], 'year' => $acc['year'], - 'code' => $params['update'] + 'code' => $params['update'], + 'money' => $acc['money'] ]); - if (!$doc) throw $this->createNotFoundException('document not found.'); + if (!$doc) + throw $this->createNotFoundException('document not found.'); $doc->setDes($params['des']); $doc->setDate($params['date']); - $doc->setMoney($acc['bid']->getMoney()); + $doc->setMoney($acc['money']); if (array_key_exists('refData', $params)) $doc->setRefData($params['refData']); if (array_key_exists('plugin', $params)) @@ -305,7 +323,7 @@ class HesabdariController extends AbstractController $doc->setType($params['type']); $doc->setDate($params['date']); $doc->setSubmitter($this->getUser()); - $doc->setMoney($acc['bid']->getMoney()); + $doc->setMoney($acc['money']); $doc->setCode($provider->getAccountingCode($acc['bid'], 'accounting')); if (array_key_exists('refData', $params)) $doc->setRefData($params['refData']); @@ -317,7 +335,11 @@ class HesabdariController extends AbstractController //add document to related docs if (array_key_exists('related', $params)) { - $relatedDoc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy(['code' => $params['related'], 'bid' => $doc->getBid()]); + $relatedDoc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ + 'code' => $params['related'], + 'bid' => $doc->getBid(), + 'money' => $acc['money'] + ]); if ($relatedDoc) { $relatedDoc->addRelatedDoc($doc); $entityManager->persist($relatedDoc); @@ -349,8 +371,10 @@ class HesabdariController extends AbstractController //check is type is person if ($row['type'] == 'person') { $person = $entityManager->getRepository(Person::class)->find($row['id']); - if (!$person) throw $this->createNotFoundException('person not found'); - elseif ($person->getBid()->getId() != $acc['bid']->getId()) throw $this->createAccessDeniedException('person is not in this business'); + if (!$person) + throw $this->createNotFoundException('person not found'); + elseif ($person->getBid()->getId() != $acc['bid']->getId()) + throw $this->createAccessDeniedException('person is not in this business'); $hesabdariRow->setPerson($person); } elseif ($row['type'] == 'cheque') { $person = $entityManager->getRepository(Person::class)->findOneBy([ @@ -386,24 +410,32 @@ class HesabdariController extends AbstractController $hesabdariRow->setCheque($cheque); } elseif ($row['type'] == 'bank') { $bank = $entityManager->getRepository(BankAccount::class)->find($row['id']); - if (!$bank) throw $this->createNotFoundException('bank not found'); - elseif ($bank->getBid()->getId() != $acc['bid']->getId()) throw $this->createAccessDeniedException('bank is not in this business'); + if (!$bank) + throw $this->createNotFoundException('bank not found'); + elseif ($bank->getBid()->getId() != $acc['bid']->getId()) + throw $this->createAccessDeniedException('bank is not in this business'); $hesabdariRow->setBank($bank); } elseif ($row['type'] == 'salary') { $salary = $entityManager->getRepository(Salary::class)->find($row['id']); - if (!$salary) throw $this->createNotFoundException('salary not found'); - elseif ($salary->getBid()->getId() != $acc['bid']->getId()) throw $this->createAccessDeniedException('bank is not in this business'); + if (!$salary) + throw $this->createNotFoundException('salary not found'); + elseif ($salary->getBid()->getId() != $acc['bid']->getId()) + throw $this->createAccessDeniedException('bank is not in this business'); $hesabdariRow->setSalary($salary); } elseif ($row['type'] == 'cashdesk') { $cashdesk = $entityManager->getRepository(Cashdesk::class)->find($row['id']); - if (!$cashdesk) throw $this->createNotFoundException('cashdesk not found'); - elseif ($cashdesk->getBid()->getId() != $acc['bid']->getId()) throw $this->createAccessDeniedException('bank is not in this business'); + if (!$cashdesk) + throw $this->createNotFoundException('cashdesk not found'); + elseif ($cashdesk->getBid()->getId() != $acc['bid']->getId()) + throw $this->createAccessDeniedException('bank is not in this business'); $hesabdariRow->setCashdesk($cashdesk); } elseif ($row['type'] == 'commodity') { $row['count'] = str_replace(',', '', $row['count']); $commodity = $entityManager->getRepository(Commodity::class)->find($row['commodity']['id']); - if (!$commodity) throw $this->createNotFoundException('commodity not found'); - elseif ($commodity->getBid()->getId() != $acc['bid']->getId()) throw $this->createAccessDeniedException('$commodity is not in this business'); + if (!$commodity) + throw $this->createNotFoundException('commodity not found'); + elseif ($commodity->getBid()->getId() != $acc['bid']->getId()) + throw $this->createAccessDeniedException('$commodity is not in this business'); $hesabdariRow->setCommodity($commodity); $hesabdariRow->setCommdityCount($row['count']); } @@ -448,11 +480,15 @@ class HesabdariController extends AbstractController 'code' => $params['code'], 'bid' => $request->headers->get('activeBid') ]); - if (!$doc) throw $this->createNotFoundException(); + if (!$doc) + throw $this->createNotFoundException(); $roll = ''; - if ($doc->getType() == 'person_receive' || $doc->getType() == 'person_send') $roll = 'person'; - elseif ($doc->getType() == 'sell_receive') $roll = 'sell'; - elseif ($doc->getType() == 'buy_send') $roll = 'buy'; + if ($doc->getType() == 'person_receive' || $doc->getType() == 'person_send') + $roll = 'person'; + elseif ($doc->getType() == 'sell_receive') + $roll = 'sell'; + elseif ($doc->getType() == 'buy_send') + $roll = 'buy'; else $roll = $doc->getType(); $acc = $access->hasRole($roll); @@ -523,7 +559,9 @@ class HesabdariController extends AbstractController $entityManager->flush(); } $code = $doc->getCode(); - foreach($doc->getNotes() as $note){ $entityManager->remove($note);} + foreach ($doc->getNotes() as $note) { + $entityManager->remove($note); + } $entityManager->remove($doc); $entityManager->flush(); $log->insert('حسابداری', 'سند حسابداری شماره ' . $code . ' حذف شد.', $this->getUser(), $request->headers->get('activeBid')); @@ -539,16 +577,20 @@ class HesabdariController extends AbstractController } if (!array_key_exists('items', $params)) $this->createNotFoundException(); - foreach($params['items'] as $item){ + foreach ($params['items'] as $item) { $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'code' => $item['code'], 'bid' => $request->headers->get('activeBid') ]); - if (!$doc) throw $this->createNotFoundException(); + if (!$doc) + throw $this->createNotFoundException(); $roll = ''; - if ($doc->getType() == 'person_receive' || $doc->getType() == 'person_send') $roll = 'person'; - elseif ($doc->getType() == 'sell_receive') $roll = 'sell'; - elseif ($doc->getType() == 'buy_send') $roll = 'buy'; + if ($doc->getType() == 'person_receive' || $doc->getType() == 'person_send') + $roll = 'person'; + elseif ($doc->getType() == 'sell_receive') + $roll = 'sell'; + elseif ($doc->getType() == 'buy_send') + $roll = 'buy'; else $roll = $doc->getType(); $acc = $access->hasRole($roll); @@ -592,7 +634,7 @@ class HesabdariController extends AbstractController } $entityManager->remove($row); } - + foreach ($doc->getRelatedDocs() as $relatedDoc) { if ($relatedDoc->getType() != 'walletPay') { $items = $entityManager->getRepository(HesabdariRow::class)->findBy(['doc' => $relatedDoc]); @@ -610,7 +652,7 @@ class HesabdariController extends AbstractController $log->insert('حسابداری', 'سند حسابداری شماره ' . $code . ' حذف شد.', $this->getUser(), $request->headers->get('activeBid')); } } - + //delete logs from documents $logs = $entityManager->getRepository(EntityLog::class)->findBy(['doc' => $doc]); foreach ($logs as $item) { @@ -619,11 +661,13 @@ class HesabdariController extends AbstractController $entityManager->flush(); } $code = $doc->getCode(); - foreach($doc->getNotes() as $note){ $entityManager->remove($note);} + foreach ($doc->getNotes() as $note) { + $entityManager->remove($note); + } $entityManager->remove($doc); $entityManager->flush(); $log->insert('حسابداری', 'سند حسابداری شماره ' . $code . ' حذف شد.', $this->getUser(), $request->headers->get('activeBid')); - + } return $this->json(['result' => 1]); } @@ -638,8 +682,10 @@ class HesabdariController extends AbstractController if (!array_key_exists('type', $params)) $this->createNotFoundException(); $roll = ''; - if ($params['type'] == 'person') $roll = 'person'; - elseif ($params['type'] == 'all') $roll = 'accounting'; + if ($params['type'] == 'person') + $roll = 'person'; + elseif ($params['type'] == 'all') + $roll = 'accounting'; else $this->createNotFoundException(); @@ -762,7 +808,7 @@ class HesabdariController extends AbstractController private function getChildsLabel(EntityManagerInterface $entityManager, mixed $node) { - $childs = $entityManager->getRepository(HesabdariTable::class)->findBy([ + $childs = $entityManager->getRepository(HesabdariTable::class)->findBy([ 'upper' => $node ]); $temp = []; @@ -774,16 +820,18 @@ class HesabdariController extends AbstractController private function hasChild(EntityManagerInterface $entityManager, mixed $node) { - if (count($entityManager->getRepository(HesabdariTable::class)->findBy([ - 'upper' => $node - ])) != 0) + if ( + count($entityManager->getRepository(HesabdariTable::class)->findBy([ + 'upper' => $node + ])) != 0 + ) return true; return false; } private function getChilds(EntityManagerInterface $entityManager, mixed $node) { - $childs = $entityManager->getRepository(HesabdariTable::class)->findBy([ + $childs = $entityManager->getRepository(HesabdariTable::class)->findBy([ 'upper' => $node ]); $temp = []; diff --git a/hesabixCore/src/Controller/MoneyController.php b/hesabixCore/src/Controller/MoneyController.php index 91310a6..ed7840a 100644 --- a/hesabixCore/src/Controller/MoneyController.php +++ b/hesabixCore/src/Controller/MoneyController.php @@ -2,10 +2,17 @@ namespace App\Controller; +use App\Entity\Business; +use App\Entity\HesabdariDoc; use App\Entity\Money; +use App\Service\Access; +use App\Service\Explore; +use App\Service\Log; +use App\Service\Extractor; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; class MoneyController extends AbstractController @@ -15,7 +22,7 @@ class MoneyController extends AbstractController { $result = $entityManager->getRepository(Money::class)->findAll(); $out = []; - foreach ($result as $item){ + foreach ($result as $item) { $temp = []; $temp['name'] = $item->getName(); $temp['label'] = $item->getLabel(); @@ -23,4 +30,103 @@ class MoneyController extends AbstractController } return $this->json($out); } + + #[Route('/api/money/get/info', name: 'app_money_get_info')] + public function app_money_get_info(Log $log, Request $request, Extractor $extractor, EntityManagerInterface $entityManager, Access $access): JsonResponse + { + $acc = $access->hasRole('join'); + if (!$acc) + throw $this->createAccessDeniedException(); + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + if (!array_key_exists('name', $params)) + return $this->json($extractor->paramsNotSend()); + $money = $entityManager->getRepository(Money::class)->findOneBy([ + 'name' => $params['name'] + ]); + if (!$money) + throw $this->createNotFoundException(); + return $this->json(Explore::ExploreMoney($money)); + + } + #[Route('/api/money/remove', name: 'app_money_remove')] + public function app_money_remove(Log $log, Request $request, Extractor $extractor, EntityManagerInterface $entityManager, Access $access): JsonResponse + { + $acc = $access->hasRole('owner'); + if (!$acc) + throw $this->createAccessDeniedException(); + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + if (!array_key_exists('name', $params)) + return $this->json($extractor->paramsNotSend()); + + $money = $entityManager->getRepository(Money::class)->findOneBy([ + 'name' => $params['name'] + ]); + if (!$money) + throw $this->createNotFoundException(); + + $docs = $entityManager->getRepository(HesabdariDoc::class)->findBy([ + 'bid' => $acc['bid'], + 'money' => $money + ]); + if (count($docs) != 0) { + return $this->json($extractor->operationFail('این ارز دارای تاریخچه اسناد حسابداری است.')); + } + if ($acc['bid']->getMoney()->getId() == $money->getId()) { + return $this->json($extractor->operationFail('ارز پیشفرض کسب و کار قابل حذف نیست.')); + } + + $bid = $entityManager->getRepository(Business::class)->findOneBy([ + 'id' => $acc['bid']->getId(), + ]); + $bid->removeExtraMoney($money); + $entityManager->persist($bid); + $entityManager->flush(); + //add log to system + $log->insert('تنظیمات پایه', 'یک ارز جانبی با نام ' . $money->getLabel() . ' حذف شد.', $this->getUser(), $acc['bid']); + + return $this->json($extractor->operationSuccess()); + } + + #[Route('/api/money/add/to/business', name: 'app_money_ad_to_business')] + public function app_money_ad_to_business(Log $log, Request $request, Extractor $extractor, EntityManagerInterface $entityManager, Access $access): JsonResponse + { + $acc = $access->hasRole('owner'); + if (!$acc) + throw $this->createAccessDeniedException(); + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + if (!array_key_exists('name', $params)) + return $this->json($extractor->paramsNotSend()); + + $money = $entityManager->getRepository(Money::class)->findOneBy([ + 'name' => $params['name'] + ]); + if (!$money) + throw $this->createNotFoundException(); + + foreach ($acc['bid']->getExtraMoney() as $mo) { + if ($money->getName() == $mo->getName() || $acc['bid']->getMoney()->getName() == $mo->getName()) { + //added before + return $this->json($extractor->operationFail('این ارز قبلا افزوده شده است.')); + } + } + $bid = $entityManager->getRepository(Business::class)->findOneBy([ + 'id' => $acc['bid']->getId(), + ]); + $bid->addExtraMoney($money); + $entityManager->persist($bid); + $entityManager->flush(); + //add log to system + $log->insert('تنظیمات پایه', 'یک ارز جانبی با نام ' . $money->getLabel() . ' افزوده شد.', $this->getUser(), $acc['bid']); + + return $this->json($extractor->operationSuccess()); + } } diff --git a/hesabixCore/src/Controller/NotesController.php b/hesabixCore/src/Controller/NotesController.php index 05c11d0..5696249 100644 --- a/hesabixCore/src/Controller/NotesController.php +++ b/hesabixCore/src/Controller/NotesController.php @@ -16,7 +16,7 @@ use Symfony\Component\HttpFoundation\Request; class NotesController extends AbstractController { #[Route('/api/notes/list', name: 'api_notes_list')] - public function api_notes_list(Extractor $extractor,Request $request, Access $access, Jdate $jdate, EntityManagerInterface $entityManager, Log $log): JsonResponse + public function api_notes_list(Extractor $extractor, Request $request, Access $access, Jdate $jdate, EntityManagerInterface $entityManager, Log $log): JsonResponse { $acc = $access->hasRole('join'); if (!$acc) @@ -25,13 +25,14 @@ class NotesController extends AbstractController if ($content = $request->getContent()) { $params = json_decode($content, true); } - if($params['code'] != 0){ + if ($params['code'] != 0) { $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], 'code' => $params['code'], - + 'money' => $acc['money'] ]); - if(!$doc) return $this->json($extractor->notFound()); + if (!$doc) + return $this->json($extractor->notFound()); } $items = $entityManager->getRepository(Note::class)->findBy([ 'bid' => $acc['bid'], @@ -41,17 +42,17 @@ class NotesController extends AbstractController $result = []; foreach ($items as $item) { $result[] = [ - 'id'=>$item->getId(), - 'des'=>$item->getDes(), - 'submitter'=>$item->getSubmitter()->getFullName(), - 'date' => $jdate->jdate('Y/n/d',$item->getDate()) + 'id' => $item->getId(), + 'des' => $item->getDes(), + 'submitter' => $item->getSubmitter()->getFullName(), + 'date' => $jdate->jdate('Y/n/d', $item->getDate()) ]; } return $this->json($result); } #[Route('/api/notes/count', name: 'api_notes_count')] - public function api_notes_count(Extractor $extractor,Request $request, Access $access, Jdate $jdate, EntityManagerInterface $entityManager, Log $log): JsonResponse + public function api_notes_count(Extractor $extractor, Request $request, Access $access, Jdate $jdate, EntityManagerInterface $entityManager, Log $log): JsonResponse { $acc = $access->hasRole('join'); if (!$acc) @@ -60,13 +61,14 @@ class NotesController extends AbstractController if ($content = $request->getContent()) { $params = json_decode($content, true); } - if($params['code'] != 0){ + if ($params['code'] != 0) { $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], 'code' => $params['code'], - + 'money' => $acc['money'] ]); - if(!$doc) return $this->json($extractor->notFound()); + if (!$doc) + return $this->json($extractor->notFound()); } $items = $entityManager->getRepository(Note::class)->findBy([ 'bid' => $acc['bid'], @@ -89,9 +91,10 @@ class NotesController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], 'code' => $params['code'], - + 'money' => $acc['money'] ]); - if(!$doc) return $this->json($extractor->notFound()); + if (!$doc) + return $this->json($extractor->notFound()); $note = new Note(); $note->setDoc($doc); $note->setBid($acc['bid']); diff --git a/hesabixCore/src/Controller/PersonsController.php b/hesabixCore/src/Controller/PersonsController.php index e11710e..33bf2ed 100644 --- a/hesabixCore/src/Controller/PersonsController.php +++ b/hesabixCore/src/Controller/PersonsController.php @@ -892,7 +892,8 @@ class PersonsController extends AbstractController $items = $entityManager->getRepository(HesabdariDoc::class)->findBy([ 'bid' => $acc['bid'], 'type' => 'person_receive', - 'year' => $acc['year'] + 'year' => $acc['year'], + 'money'=> $acc['money'] ]); } else { $items = []; @@ -901,7 +902,8 @@ class PersonsController extends AbstractController 'id' => $param['id'], 'bid' => $acc['bid'], 'type' => 'person_receive', - 'year' => $acc['year'] + 'year' => $acc['year'], + 'money'=> $acc['money'] ]); if ($prs) $items[] = $prs; @@ -934,7 +936,8 @@ class PersonsController extends AbstractController [ 'bid' => $acc['bid'], 'type' => 'person_receive', - 'year' => $acc['year'] + 'year' => $acc['year'], + 'money'=> $acc['money'] ], ['id' => 'DESC'] ); @@ -977,7 +980,8 @@ class PersonsController extends AbstractController $items = $entityManager->getRepository(HesabdariDoc::class)->findBy([ 'bid' => $acc['bid'], 'type' => 'person_receive', - 'year' => $acc['year'] + 'year' => $acc['year'], + 'money'=> $acc['money'] ]); } else { $items = []; @@ -986,7 +990,8 @@ class PersonsController extends AbstractController 'id' => $param['id'], 'bid' => $acc['bid'], 'type' => 'person_receive', - 'year' => $acc['year'] + 'year' => $acc['year'], + 'money'=> $acc['money'] ]); if ($prs) $items[] = $prs; @@ -1009,7 +1014,8 @@ class PersonsController extends AbstractController $items = $entityManager->getRepository(HesabdariDoc::class)->findBy([ 'bid' => $acc['bid'], 'type' => 'person_send', - 'year' => $acc['year'] + 'year' => $acc['year'], + 'money'=> $acc['money'] ]); } else { $items = []; @@ -1018,7 +1024,8 @@ class PersonsController extends AbstractController 'id' => $param['id'], 'bid' => $acc['bid'], 'type' => 'person_send', - 'year' => $acc['year'] + 'year' => $acc['year'], + 'money'=> $acc['money'] ]); if ($prs) $items[] = $prs; @@ -1051,7 +1058,8 @@ class PersonsController extends AbstractController [ 'bid' => $acc['bid'], 'type' => 'person_send', - 'year' => $acc['year'] + 'year' => $acc['year'], + 'money'=> $acc['money'] ], ['id' => 'DESC'] ); @@ -1094,7 +1102,8 @@ class PersonsController extends AbstractController $items = $entityManager->getRepository(HesabdariDoc::class)->findBy([ 'bid' => $acc['bid'], 'type' => 'person_send', - 'year' => $acc['year'] + 'year' => $acc['year'], + 'money'=> $acc['money'] ]); } else { $items = []; @@ -1103,7 +1112,8 @@ class PersonsController extends AbstractController 'id' => $param['id'], 'bid' => $acc['bid'], 'type' => 'person_send', - 'year' => $acc['year'] + 'year' => $acc['year'], + 'money'=> $acc['money'] ]); if ($prs) $items[] = $prs; diff --git a/hesabixCore/src/Controller/Plugins/PlugNoghreController.php b/hesabixCore/src/Controller/Plugins/PlugNoghreController.php index 26d9d88..5aa8499 100644 --- a/hesabixCore/src/Controller/Plugins/PlugNoghreController.php +++ b/hesabixCore/src/Controller/Plugins/PlugNoghreController.php @@ -114,7 +114,8 @@ class PlugNoghreController extends AbstractController throw $this->createAccessDeniedException(); $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'code'=>$id, - 'bid'=>$acc['bid'] + 'bid'=>$acc['bid'], + 'money'=> $acc['money'] ]); if(!$doc) throw $this->createNotFoundException(); @@ -267,7 +268,7 @@ class PlugNoghreController extends AbstractController $doc->setDes('سفارش ساخت منسوجات نقره: ' . $params['des']); $doc->setBid($acc['bid']); $doc->setPlugin('plugNoghreOrder'); - $doc->setMoney($acc['bid']->getMoney()); + $doc->setMoney($acc['money']); $doc->setDate($params['dateSubmit']); $doc->setYear($acc['year']); $doc->setType('plug_noghre_order'); @@ -561,7 +562,8 @@ class PlugNoghreController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'code'=>$code, 'plugin'=>'plugNoghrePay', - 'bid'=>$acc['bid'] + 'bid'=>$acc['bid'], + 'money'=> $acc['money'] ]); if(!$doc) throw $this->createNotFoundException(); diff --git a/hesabixCore/src/Controller/ReportController.php b/hesabixCore/src/Controller/ReportController.php index 755c867..fe85158 100644 --- a/hesabixCore/src/Controller/ReportController.php +++ b/hesabixCore/src/Controller/ReportController.php @@ -36,13 +36,15 @@ class ReportController extends AbstractController if ($params['type'] == 'all') { $docs = $entityManagerInterface->getRepository(HesabdariDoc::class)->findBy([ 'year' => $acc['year'], - 'bid' => $acc['bid'], + 'bid' => $acc['bid'], + 'money' => $acc['money'] ]); } else { $docs = $entityManagerInterface->getRepository(HesabdariDoc::class)->findBy([ 'year' => $acc['year'], - 'bid' => $acc['bid'], + 'bid' => $acc['bid'], 'type' => $params['type'], + 'money'=> $acc['money'] ]); } //filter docs by date @@ -52,18 +54,21 @@ class ReportController extends AbstractController foreach ($docs as $doc) { $canAdd = true; if ($dateStart) { - if ($provider->shamsiDateToTimestamp($doc->getDate()) < $dateStart) $canAdd = false; + if ($provider->shamsiDateToTimestamp($doc->getDate()) < $dateStart) + $canAdd = false; } if ($dateEnd) { - if ($provider->shamsiDateToTimestamp($doc->getDate()) > $dateEnd) $canAdd = false; + if ($provider->shamsiDateToTimestamp($doc->getDate()) > $dateEnd) + $canAdd = false; } - if ($canAdd) $result[] = $doc; + if ($canAdd) + $result[] = $doc; } $docs = $result; $person = $entityManagerInterface->getRepository(Person::class)->findOneBy([ - 'bid' => $acc['bid']->getId(), + 'bid' => $acc['bid']->getId(), 'code' => $params['person'], ]); $result = []; @@ -119,7 +124,7 @@ class ReportController extends AbstractController } #[Route('/api/report/person/buysell/export/excel', name: 'app_report_person_buysell_export_excell')] - public function app_report_person_buysell_export_excell(Provider $provider, Access $access, Request $request, EntityManagerInterface $entityManagerInterface): BinaryFileResponse | JsonResponse | StreamedResponse + public function app_report_person_buysell_export_excell(Provider $provider, Access $access, Request $request, EntityManagerInterface $entityManagerInterface): BinaryFileResponse|JsonResponse|StreamedResponse { $acc = $access->hasRole('report'); if (!$acc) @@ -186,19 +191,21 @@ class ReportController extends AbstractController if ($params['type'] == 'all') { $docs = $entityManagerInterface->getRepository(HesabdariDoc::class)->findBy([ 'year' => $acc['year'], - 'bid' => $acc['bid'], + 'bid' => $acc['bid'], + 'money'=> $acc['money'] ]); } else { $docs = $entityManagerInterface->getRepository(HesabdariDoc::class)->findBy([ 'year' => $acc['year'], - 'bid' => $acc['bid'], + 'bid' => $acc['bid'], 'type' => $params['type'], + 'money'=> $acc['money'] ]); } $commodity = $entityManagerInterface->getRepository(Commodity::class)->findOneBy([ - 'bid' => $acc['bid']->getId(), + 'bid' => $acc['bid']->getId(), 'code' => $params['commodity'], ]); //filter docs by date @@ -208,13 +215,16 @@ class ReportController extends AbstractController foreach ($docs as $doc) { $canAdd = true; if ($dateStart) { - if ($provider->shamsiDateToTimestamp($doc->getDate()) < $dateStart) $canAdd = false; + if ($provider->shamsiDateToTimestamp($doc->getDate()) < $dateStart) + $canAdd = false; } if ($dateEnd) { - if ($provider->shamsiDateToTimestamp($doc->getDate()) > $dateEnd) $canAdd = false; + if ($provider->shamsiDateToTimestamp($doc->getDate()) > $dateEnd) + $canAdd = false; } - if ($canAdd) $result[] = $doc; + if ($canAdd) + $result[] = $doc; } $docs = $result; $result = []; diff --git a/hesabixCore/src/Controller/RfbuyController.php b/hesabixCore/src/Controller/RfbuyController.php index 7fadd2b..4269823 100644 --- a/hesabixCore/src/Controller/RfbuyController.php +++ b/hesabixCore/src/Controller/RfbuyController.php @@ -35,7 +35,8 @@ class RfbuyController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], - 'code' => $code + 'code' => $code, + 'money'=> $acc['money'] ]); //check related documents if (count($doc->getRelatedDocs()) != 0) @@ -58,7 +59,8 @@ class RfbuyController extends AbstractController throw $this->createAccessDeniedException(); $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], - 'code' => $code + 'code' => $code, + 'money'=> $acc['money'] ]); if (!$doc) throw $this->createNotFoundException(); @@ -85,7 +87,8 @@ class RfbuyController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], 'year' => $acc['year'], - 'code' => $params['update'] + 'code' => $params['update'], + 'money'=> $acc['money'] ]); if (!$doc) return $this->json($extractor->notFound()); @@ -101,7 +104,7 @@ class RfbuyController extends AbstractController $doc->setDateSubmit(time()); $doc->setType('rfbuy'); $doc->setSubmitter($this->getUser()); - $doc->setMoney($acc['bid']->getMoney()); + $doc->setMoney($acc['money']); $doc->setCode($provider->getAccountingCode($acc['bid'], 'accounting')); } if($params['transferCost'] != 0){ @@ -222,7 +225,8 @@ class RfbuyController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], 'year' => $acc['year'], - 'code' => $item['code'] + 'code' => $item['code'], + 'money'=> $acc['money'] ]); if (!$doc) return $this->json($extractor->notFound()); if ($params['label'] != 'clear') { @@ -265,7 +269,8 @@ class RfbuyController extends AbstractController $data = $entityManager->getRepository(HesabdariDoc::class)->findBy([ 'bid' => $acc['bid'], 'year' => $acc['year'], - 'type' => 'rfbuy' + 'type' => 'rfbuy', + 'money'=> $acc['money'] ], [ 'id' => 'DESC' ]); @@ -329,7 +334,8 @@ class RfbuyController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], - 'code' => $params['code'] + 'code' => $params['code'], + 'money'=> $acc['money'] ]); if (!$doc) throw $this->createNotFoundException(); $pdfPid = 0; @@ -392,7 +398,8 @@ class RfbuyController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], - 'code' => $params['code'] + 'code' => $params['code'], + 'money'=> $acc['money'] ]); if (!$doc) throw $this->createNotFoundException(); $person = null; diff --git a/hesabixCore/src/Controller/RfsellController.php b/hesabixCore/src/Controller/RfsellController.php index fde2819..ceaa58d 100644 --- a/hesabixCore/src/Controller/RfsellController.php +++ b/hesabixCore/src/Controller/RfsellController.php @@ -36,7 +36,8 @@ class RfsellController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid'=>$acc['bid'], - 'code'=>$code + 'code'=>$code, + 'money'=> $acc['money'] ]); //check related documents if(count($doc->getRelatedDocs()) != 0) @@ -59,7 +60,8 @@ class RfsellController extends AbstractController throw $this->createAccessDeniedException(); $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid'=>$acc['bid'], - 'code'=>$code + 'code'=>$code, + 'money'=> $acc['money'] ]); if(!$doc) throw $this->createNotFoundException(); @@ -76,7 +78,8 @@ class RfsellController extends AbstractController $invoices = $entityManager->getRepository(HesabdariDoc::class)->findBy([ 'bid'=>$acc['bid'], 'year'=>$acc['year'], - 'type'=>'rfsell' + 'type'=>'rfsell', + 'money'=> $acc['money'] ]); return $this->json(Explore::ExploreBuyDocsList($invoices)); } @@ -100,7 +103,8 @@ class RfsellController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], 'year' => $acc['year'], - 'code' => $params['update'] + 'code' => $params['update'], + 'money'=> $acc['money'] ]); if (!$doc) return $this->json($extractor->notFound()); @@ -116,7 +120,7 @@ class RfsellController extends AbstractController $doc->setDateSubmit(time()); $doc->setType('rfsell'); $doc->setSubmitter($this->getUser()); - $doc->setMoney($acc['bid']->getMoney()); + $doc->setMoney($acc['money']); $doc->setCode($provider->getAccountingCode($acc['bid'], 'accounting')); } if($params['transferCost'] != 0){ @@ -237,7 +241,8 @@ class RfsellController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], 'year' => $acc['year'], - 'code' => $item['code'] + 'code' => $item['code'], + 'money'=> $acc['money'] ]); if (!$doc) return $this->json($extractor->notFound()); if ($params['label'] != 'clear') { @@ -280,7 +285,8 @@ class RfsellController extends AbstractController $data = $entityManager->getRepository(HesabdariDoc::class)->findBy([ 'bid' => $acc['bid'], 'year' => $acc['year'], - 'type' => 'rfsell' + 'type' => 'rfsell', + 'money'=> $acc['money'] ], [ 'id' => 'DESC' ]); @@ -344,7 +350,8 @@ class RfsellController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], - 'code' => $params['code'] + 'code' => $params['code'], + 'money'=> $acc['money'] ]); if (!$doc) throw $this->createNotFoundException(); $pdfPid = 0; @@ -407,7 +414,8 @@ class RfsellController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], - 'code' => $params['code'] + 'code' => $params['code'], + 'money'=> $acc['money'] ]); if (!$doc) throw $this->createNotFoundException(); $person = null; diff --git a/hesabixCore/src/Controller/SMSController.php b/hesabixCore/src/Controller/SMSController.php index df3f4b6..141229f 100644 --- a/hesabixCore/src/Controller/SMSController.php +++ b/hesabixCore/src/Controller/SMSController.php @@ -237,7 +237,8 @@ class SMSController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'id' => $id, 'bid' => $bid, - 'type' => 'sell' + 'type' => 'sell', + 'money'=> $acc['money'] ]); if (!$doc) return $this->json(['result' => 3]); diff --git a/hesabixCore/src/Controller/SalaryController.php b/hesabixCore/src/Controller/SalaryController.php index d0d036a..abe667d 100644 --- a/hesabixCore/src/Controller/SalaryController.php +++ b/hesabixCore/src/Controller/SalaryController.php @@ -5,6 +5,7 @@ namespace App\Controller; use App\Entity\HesabdariRow; use App\Entity\Salary; use App\Service\Access; +use App\Service\Explore; use App\Service\Log; use App\Service\Provider; use Doctrine\ORM\EntityManagerInterface; @@ -19,12 +20,26 @@ class SalaryController extends AbstractController #[Route('/api/salary/list', name: 'app_salary_list')] public function app_salary_list(Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse { - //باگ دارد تمام سال مالی برگشت داده می شود - if (!$access->hasRole('salary')) + $acc = $access->hasRole('salary'); + if (!$acc) throw $this->createAccessDeniedException(); + //bug fix for bank with no money type $datas = $entityManager->getRepository(Salary::class)->findBy([ - 'bid' => $request->headers->get('activeBid') + 'bid' => $request->headers->get('activeBid'), + 'money' => null ]); + foreach ($datas as $data) { + $data->setMoney($acc['bid']->getMoney()); + $entityManager->persist($data); + } + $entityManager->flush(); + //end of bug fix + + $datas = $entityManager->getRepository(Salary::class)->findBy([ + 'bid' => $request->headers->get('activeBid'), + 'money' => $acc['money'] + ]); + $resp = []; foreach ($datas as $data) { $bs = 0; $bd = 0; @@ -36,8 +51,9 @@ class SalaryController extends AbstractController $bd += $item->getBd(); } $data->setBalance($bd - $bs); + $resp[] = Explore::ExploreSalary($data); } - return $this->json($datas); + return $this->json($resp); } #[Route('/api/salary/info/{code}', name: 'app_salary_info')] @@ -50,7 +66,7 @@ class SalaryController extends AbstractController 'bid' => $acc['bid'], 'code' => $code ]); - return $this->json($data); + return $this->json(Explore::ExploreSalary($data)); } #[Route('/api/salary/mod/{code}', name: 'app_salary_mod')] @@ -77,6 +93,7 @@ class SalaryController extends AbstractController return $this->json(['result' => 2]); $data = new Salary(); $data->setCode($provider->getAccountingCode($request->headers->get('activeBid'), 'salary')); + $data->setMoney($acc['money']); } else { $data = $entityManager->getRepository(Salary::class)->findOneBy([ 'bid' => $acc['bid'], @@ -84,6 +101,9 @@ class SalaryController extends AbstractController ]); if (!$data) throw $this->createNotFoundException(); + if (!$data->getMoney()) { + $data->setMoney($acc['money']); + } } $data->setBid($acc['bid']); $data->setname($params['name']); diff --git a/hesabixCore/src/Controller/SellController.php b/hesabixCore/src/Controller/SellController.php index beb20d1..a23b524 100644 --- a/hesabixCore/src/Controller/SellController.php +++ b/hesabixCore/src/Controller/SellController.php @@ -38,7 +38,8 @@ class SellController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], - 'code' => $code + 'code' => $code, + 'money'=> $acc['money'] ]); //check related documents if (count($doc->getRelatedDocs()) != 0) @@ -61,7 +62,8 @@ class SellController extends AbstractController throw $this->createAccessDeniedException(); $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], - 'code' => $code + 'code' => $code, + 'money'=> $acc['money'] ]); if (!$doc) throw $this->createNotFoundException(); @@ -133,14 +135,13 @@ class SellController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], 'year' => $acc['year'], - 'code' => $params['update'] + 'code' => $params['update'], + 'money'=> $acc['money'] ]); if (!$doc) return $this->json($extractor->notFound()); - - $rows = $entityManager->getRepository(HesabdariRow::class)->findBy([ - 'doc' => $doc - ]); + + $rows = $doc->getHesabdariRows(); foreach ($rows as $row) $entityManager->remove($row); } else { @@ -150,7 +151,7 @@ class SellController extends AbstractController $doc->setDateSubmit(time()); $doc->setType('sell'); $doc->setSubmitter($this->getUser()); - $doc->setMoney($acc['bid']->getMoney()); + $doc->setMoney($acc['money']); $doc->setCode($provider->getAccountingCode($acc['bid'], 'accounting')); } if ($params['transferCost'] != 0) { @@ -245,6 +246,12 @@ class SellController extends AbstractController $entityManager->persist($doc); $entityManager->flush(); + if(!$doc->getShortlink()){ + $doc->setShortlink($doc->getId()); + } + $entityManager->persist($doc); + $entityManager->flush(); + $log->insert( 'حسابداری', 'سند حسابداری شماره ' . $doc->getCode() . ' ثبت / ویرایش شد.', @@ -259,7 +266,7 @@ class SellController extends AbstractController return $this->json([ 'result' => $SMS->sendByBalance( - [$person->getnikename(), 'sell/' . $acc['bid']->getId() . '/' . $doc->getShortLink(), $acc['bid']->getName(), $acc['bid']->getTel()], + [$person->getnikename(), 'sell/' . $acc['bid']->getId() . '/' . $doc->getId(), $acc['bid']->getName(), $acc['bid']->getTel()], $registryMGR->get('sms', 'plugAccproSharefaktor'), $person->getMobile(), $acc['bid'], @@ -271,7 +278,7 @@ class SellController extends AbstractController return $this->json([ 'result' => $SMS->sendByBalance( - [$acc['bid']->getName(), 'sell/' . $acc['bid']->getId() . '/' . $doc->getShortLink()], + [$acc['bid']->getName(), 'sell/' . $acc['bid']->getId() . '/' . $doc->getId()], $registryMGR->get('sms', 'sharefaktor'), $person->getMobile(), $acc['bid'], @@ -308,7 +315,8 @@ class SellController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], 'year' => $acc['year'], - 'code' => $item['code'] + 'code' => $item['code'], + 'money'=> $acc['money'] ]); if (!$doc) return $this->json($extractor->notFound()); @@ -352,7 +360,8 @@ class SellController extends AbstractController $data = $entityManager->getRepository(HesabdariDoc::class)->findBy([ 'bid' => $acc['bid'], 'year' => $acc['year'], - 'type' => 'sell' + 'type' => 'sell', + 'money'=> $acc['money'] ], [ 'id' => 'DESC' ]); @@ -462,7 +471,8 @@ class SellController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], - 'code' => $params['code'] + 'code' => $params['code'], + 'money'=> $acc['money'] ]); if (!$doc) throw $this->createNotFoundException(); @@ -527,7 +537,8 @@ class SellController extends AbstractController $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], - 'code' => $params['code'] + 'code' => $params['code'], + 'money'=> $acc['money'] ]); if (!$doc) throw $this->createNotFoundException(); diff --git a/hesabixCore/src/Controller/StoreroomController.php b/hesabixCore/src/Controller/StoreroomController.php index 7c7a557..da74e02 100644 --- a/hesabixCore/src/Controller/StoreroomController.php +++ b/hesabixCore/src/Controller/StoreroomController.php @@ -121,7 +121,8 @@ class StoreroomController extends AbstractController throw $this->createAccessDeniedException(); $buys = $entityManager->getRepository(HesabdariDoc::class)->findBy([ 'bid' => $acc['bid'], - 'type' => 'buy' + 'type' => 'buy', + 'money'=> $acc['money'] ]); $buysForExport = []; foreach ($buys as $buy) { @@ -141,7 +142,8 @@ class StoreroomController extends AbstractController $sells = $entityManager->getRepository(HesabdariDoc::class)->findBy([ 'bid' => $acc['bid'], - 'type' => 'sell' + 'type' => 'sell', + 'money'=> $acc['money'] ]); $sellsForExport = []; foreach ($sells as $sell) { @@ -161,7 +163,8 @@ class StoreroomController extends AbstractController $rfsells = $entityManager->getRepository(HesabdariDoc::class)->findBy([ 'bid' => $acc['bid'], - 'type' => 'rfsell' + 'type' => 'rfsell', + 'money'=> $acc['money'] ]); $rfsellsForExport = []; foreach ($rfsells as $sell) { @@ -181,7 +184,8 @@ class StoreroomController extends AbstractController $rfbuys = $entityManager->getRepository(HesabdariDoc::class)->findBy([ 'bid' => $acc['bid'], - 'type' => 'rfbuy' + 'type' => 'rfbuy', + 'money'=> $acc['money'] ]); $rfbuysForExport = []; foreach ($rfbuys as $buy) { @@ -238,7 +242,8 @@ class StoreroomController extends AbstractController throw $this->createAccessDeniedException(); $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'bid' => $acc['bid'], - 'code' => $id + 'code' => $id, + 'money'=> $acc['money'] ]); if (!$doc) throw $this->createNotFoundException('سند یافت نشد.'); @@ -351,7 +356,8 @@ class StoreroomController extends AbstractController //going to save $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ 'id' => $params['doc']['id'], - 'bid' => $acc['bid'] + 'bid' => $acc['bid'], + 'money'=> $acc['money'] ]); if (!$doc) throw $this->createNotFoundException('سند یافت نشد'); diff --git a/hesabixCore/src/Controller/TransferController.php b/hesabixCore/src/Controller/TransferController.php index fd52c9a..e558fb4 100644 --- a/hesabixCore/src/Controller/TransferController.php +++ b/hesabixCore/src/Controller/TransferController.php @@ -25,7 +25,8 @@ class TransferController extends AbstractController $items = $entityManager->getRepository(HesabdariDoc::class)->findBy([ 'bid'=>$acc['bid'], 'type'=>'transfer', - 'year'=>$acc['year'] + 'year'=>$acc['year'], + 'money'=> $acc['money'] ]); $resp = []; foreach ($items as $item){ diff --git a/hesabixCore/src/Entity/BankAccount.php b/hesabixCore/src/Entity/BankAccount.php index 6f4c21e..b30a13b 100644 --- a/hesabixCore/src/Entity/BankAccount.php +++ b/hesabixCore/src/Entity/BankAccount.php @@ -61,6 +61,9 @@ class BankAccount #[ORM\OneToMany(mappedBy: 'bank', targetEntity: Cheque::class)] private Collection $cheques; + #[ORM\ManyToOne] + private ?Money $money = null; + public function __construct() { $this->hesabdariRows = new ArrayCollection(); @@ -275,4 +278,16 @@ class BankAccount return $this; } + + public function getMoney(): ?Money + { + return $this->money; + } + + public function setMoney(?Money $money): static + { + $this->money = $money; + + return $this; + } } diff --git a/hesabixCore/src/Entity/Business.php b/hesabixCore/src/Entity/Business.php index 44cba94..8ebc29b 100644 --- a/hesabixCore/src/Entity/Business.php +++ b/hesabixCore/src/Entity/Business.php @@ -252,6 +252,12 @@ class Business #[ORM\OneToMany(mappedBy: 'bid', targetEntity: Project::class, orphanRemoval: true)] private Collection $projects; + /** + * @var Collection + */ + #[ORM\ManyToMany(targetEntity: Money::class, inversedBy: 'bids')] + private Collection $extraMoney; + public function __construct() { $this->logs = new ArrayCollection(); @@ -287,6 +293,7 @@ class Business $this->priceLists = new ArrayCollection(); $this->printOptions = new ArrayCollection(); $this->projects = new ArrayCollection(); + $this->extraMoney = new ArrayCollection(); } public function getId(): ?int @@ -1787,4 +1794,28 @@ class Business return $this; } + + /** + * @return Collection + */ + public function getExtraMoney(): Collection + { + return $this->extraMoney; + } + + public function addExtraMoney(Money $extraMoney): static + { + if (!$this->extraMoney->contains($extraMoney)) { + $this->extraMoney->add($extraMoney); + } + + return $this; + } + + public function removeExtraMoney(Money $extraMoney): static + { + $this->extraMoney->removeElement($extraMoney); + + return $this; + } } diff --git a/hesabixCore/src/Entity/Cashdesk.php b/hesabixCore/src/Entity/Cashdesk.php index e44b180..cfbec98 100644 --- a/hesabixCore/src/Entity/Cashdesk.php +++ b/hesabixCore/src/Entity/Cashdesk.php @@ -37,6 +37,9 @@ class Cashdesk #[ORM\Column(length: 255, nullable: true)] private ?string $balance = null; + #[ORM\ManyToOne(inversedBy: 'cashdesks')] + private ?Money $money = null; + public function __construct() { $this->hesabdariRows = new ArrayCollection(); @@ -136,4 +139,16 @@ class Cashdesk return $this; } + + public function getMoney(): ?Money + { + return $this->money; + } + + public function setMoney(?Money $money): static + { + $this->money = $money; + + return $this; + } } diff --git a/hesabixCore/src/Entity/Money.php b/hesabixCore/src/Entity/Money.php index bf4034f..d59d781 100644 --- a/hesabixCore/src/Entity/Money.php +++ b/hesabixCore/src/Entity/Money.php @@ -27,10 +27,37 @@ class Money #[ORM\OneToMany(mappedBy: 'money', targetEntity: PriceListDetail::class, orphanRemoval: true)] private Collection $priceListDetails; + /** + * @var Collection + */ + #[ORM\ManyToMany(targetEntity: Business::class, mappedBy: 'extraMoney')] + private Collection $bids; + + #[ORM\Column(length: 255)] + private ?string $symbol = null; + + #[ORM\Column(length: 255)] + private ?string $shortName = null; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'money', targetEntity: Cashdesk::class)] + private Collection $cashdesks; + + /** + * @var Collection + */ + #[ORM\OneToMany(mappedBy: 'money', targetEntity: Salary::class)] + private Collection $salaries; + public function __construct() { $this->businesses = new ArrayCollection(); $this->priceListDetails = new ArrayCollection(); + $this->bids = new ArrayCollection(); + $this->cashdesks = new ArrayCollection(); + $this->salaries = new ArrayCollection(); } public function getId(): ?int @@ -121,4 +148,115 @@ class Money return $this; } + + /** + * @return Collection + */ + public function getBids(): Collection + { + return $this->bids; + } + + public function addBid(Business $bid): static + { + if (!$this->bids->contains($bid)) { + $this->bids->add($bid); + $bid->addExtraMoney($this); + } + + return $this; + } + + public function removeBid(Business $bid): static + { + if ($this->bids->removeElement($bid)) { + $bid->removeExtraMoney($this); + } + + return $this; + } + + public function getSymbol(): ?string + { + return $this->symbol; + } + + public function setSymbol(string $symbol): static + { + $this->symbol = $symbol; + + return $this; + } + + public function getShortName(): ?string + { + return $this->shortName; + } + + public function setShortName(string $shortName): static + { + $this->shortName = $shortName; + + return $this; + } + + /** + * @return Collection + */ + public function getCashdesks(): Collection + { + return $this->cashdesks; + } + + public function addCashdesk(Cashdesk $cashdesk): static + { + if (!$this->cashdesks->contains($cashdesk)) { + $this->cashdesks->add($cashdesk); + $cashdesk->setMoney($this); + } + + return $this; + } + + public function removeCashdesk(Cashdesk $cashdesk): static + { + if ($this->cashdesks->removeElement($cashdesk)) { + // set the owning side to null (unless already changed) + if ($cashdesk->getMoney() === $this) { + $cashdesk->setMoney(null); + } + } + + return $this; + } + + /** + * @return Collection + */ + public function getSalaries(): Collection + { + return $this->salaries; + } + + public function addSalary(Salary $salary): static + { + if (!$this->salaries->contains($salary)) { + $this->salaries->add($salary); + $salary->setMoney($this); + } + + return $this; + } + + public function removeSalary(Salary $salary): static + { + if ($this->salaries->removeElement($salary)) { + // set the owning side to null (unless already changed) + if ($salary->getMoney() === $this) { + $salary->setMoney(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Entity/Salary.php b/hesabixCore/src/Entity/Salary.php index 84f1ba9..21dd50b 100644 --- a/hesabixCore/src/Entity/Salary.php +++ b/hesabixCore/src/Entity/Salary.php @@ -38,6 +38,9 @@ class Salary #[ORM\Column(length: 255, nullable: true)] private ?string $balance = null; + #[ORM\ManyToOne(inversedBy: 'salaries')] + private ?Money $money = null; + public function __construct() { $this->hesabdariRows = new ArrayCollection(); @@ -137,4 +140,16 @@ class Salary return $this; } + + public function getMoney(): ?Money + { + return $this->money; + } + + public function setMoney(?Money $money): static + { + $this->money = $money; + + return $this; + } } diff --git a/hesabixCore/src/Service/Access.php b/hesabixCore/src/Service/Access.php index 0086dcc..b56fa01 100644 --- a/hesabixCore/src/Service/Access.php +++ b/hesabixCore/src/Service/Access.php @@ -4,6 +4,7 @@ namespace App\Service; use App\Entity\APIToken; use App\Entity\Business; +use App\Entity\Money; use App\Entity\Permission; use App\Entity\UserToken; use App\Entity\Year; @@ -69,12 +70,27 @@ class Access ]); } + if ($this->request->headers->get('activeMoney')) { + $money = $this->em->getRepository(Money::class)->findOneBy([ + 'name' => $this->request->headers->get('activeMoney'), + ]); + if (!$money) { return false; } + } + else{ + $money = $this->em->getRepository(Money::class)->findOneBy([ + 'name' => $bid->getMoney(), + ]); + if (!$money) { return false; } + } + $accessArray = [ 'bid'=>$bid, 'user'=>$this->user, 'year'=>$year, - 'access'=>true + 'access'=>true, + 'money'=>$money ]; + if($bid->getOwner()->getEmail() === $this->user->getUserIdentifier()){ //user is owner return $accessArray; diff --git a/hesabixCore/src/Service/Explore.php b/hesabixCore/src/Service/Explore.php index de2fd2d..054a856 100644 --- a/hesabixCore/src/Service/Explore.php +++ b/hesabixCore/src/Service/Explore.php @@ -236,6 +236,16 @@ class Explore 'id' => $item->getId(), 'code' => $item->getCode(), 'name' => $item->getName(), + 'cardNum' => $item->getCardNum(), + 'shaba' => $item->getShaba(), + 'accountNum' => $item->getAccountNum(), + 'owner' => $item->getOwner(), + 'shobe' => $item->getShobe(), + 'posNum' => $item->getPosNum(), + 'des' => $item->getDes(), + 'mobileInternetBank' => $item->getMobileInternetBank(), + 'balance' => null, + 'money' => self::ExploreMoney($item->getMoney()) ]; return null; } @@ -247,7 +257,9 @@ class Explore 'id' => $item->getId(), 'code' => $item->getCode(), 'name' => $item->getName(), - 'des' => $item->getDes() + 'des' => $item->getDes(), + 'balance' => $item->getBalance(), + 'money' => self::ExploreMoney($item->getMoney()) ]; return null; } @@ -258,7 +270,9 @@ class Explore 'id' => $item->getId(), 'code' => $item->getCode(), 'name' => $item->getName(), - 'des' => $item->getDes() + 'des' => $item->getDes(), + 'balance' => $item->getBalance(), + 'money' => self::ExploreMoney($item->getMoney()) ]; return null; } @@ -341,6 +355,8 @@ class Explore 'id' => $money->getId(), 'label' => $money->getLabel(), 'name' => $money->getName(), + 'shortName' => $money->getShortName(), + 'symbol' => $money->getSymbol() ]; } public static function ExploreYear(Year|null $year) @@ -467,4 +483,55 @@ class Explore } return $result; } + + public static function ExploreBusiness(Business $item) + { + $res = [ + 'id' => $item->getId(), + 'owner' => $item->getOwner()->getFullName(), + 'name' => $item->getName(), + 'legal_name' => $item->getLegalName(), + 'field' => $item->getField(), + 'shenasemeli' => $item->getShenasemeli(), + 'codeeqtesadi' => $item->getCodeeghtesadi(), + 'shomaresabt' => $item->getShomaresabt(), + 'country' => $item->getCountry(), + 'ostan' => $item->getOstan(), + 'shahrestan' => $item->getShahrestan(), + 'postalcode' => $item->getPostalcode(), + 'tel' => $item->getTel(), + 'mobile' => $item->getMobile(), + 'address' => $item->getAddress(), + 'website' => $item->getWesite(), + 'maliyatafzode' => $item->getMaliyatafzode(), + 'arzmain' => self::ExploreMoney($item->getMoney()), + 'zarinpalCode' => $item->getZarinpalCode(), + 'smsCharge' => $item->getSmsCharge(), + 'shortlinks' => $item->isShortlinks(), + 'walletEnabled' => $item->isWalletEnable(), + 'walletMatchBank' => null, + 'updateSellPrice' => $item->isCommodityUpdateSellPriceAuto(), + 'updateBuyPrice' => $item->isCommodityUpdateBuyPriceAuto(), + ]; + if (!$item->getProfitCalctype()) { + $res['profitCalcType'] = 'lis'; + } else { + $res['profitCalcType'] = $item->getProfitCalctype(); + } + + foreach ($item->getYears() as $year) { + if ($year->isHead()) { + $res['year'] = Explore::ExploreYear($year); + } + } + + $res['moneys'] = [ + self::ExploreMoney($item->getMoney()) + ]; + foreach ($item->getExtraMoney() as $money) { + $res['moneys'][] = self::ExploreMoney($money); + } + + return $res; + } } diff --git a/hesabixCore/src/Service/Extractor.php b/hesabixCore/src/Service/Extractor.php index 58b67f3..872bfc6 100644 --- a/hesabixCore/src/Service/Extractor.php +++ b/hesabixCore/src/Service/Extractor.php @@ -28,6 +28,15 @@ class Extractor ]; } + public function operationFail($message='operaition fail',$code=404, $data = ''){ + return [ + 'Success'=>false, + 'code' => $code, + 'data' =>$data, + 'message'=>$message, + + ]; + } public function notFound($data = ''){ return [ 'code' => 404, diff --git a/hesabixCore/templates/general/contact.html.twig b/hesabixCore/templates/general/contact.html.twig index 7e46f3e..f7aeebd 100644 --- a/hesabixCore/templates/general/contact.html.twig +++ b/hesabixCore/templates/general/contact.html.twig @@ -47,7 +47,7 @@
تلفن
-

021-9103-1705 داخلی ۳

+

083-4532-3211


پشتیبانی از طریق شبکه‌های اجتماعی