almost minish multi currency

This commit is contained in:
Hesabix 2024-11-07 11:58:20 +00:00
parent 66fbd127bd
commit a106075b25
28 changed files with 759 additions and 211 deletions

View file

@ -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'],

View file

@ -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;

View file

@ -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;

View file

@ -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']);

View file

@ -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');

View file

@ -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);
}
}

View file

@ -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'));
@ -544,11 +582,15 @@ class HesabdariController extends AbstractController
'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);
@ -619,7 +661,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'));
@ -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();
@ -774,9 +820,11 @@ class HesabdariController extends AbstractController
private function hasChild(EntityManagerInterface $entityManager, mixed $node)
{
if (count($entityManager->getRepository(HesabdariTable::class)->findBy([
if (
count($entityManager->getRepository(HesabdariTable::class)->findBy([
'upper' => $node
])) != 0)
])) != 0
)
return true;
return false;
}

View file

@ -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
@ -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());
}
}

View file

@ -29,9 +29,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());
}
$items = $entityManager->getRepository(Note::class)->findBy([
'bid' => $acc['bid'],
@ -64,9 +65,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());
}
$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']);

View file

@ -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;

View file

@ -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();

View file

@ -37,12 +37,14 @@ class ReportController extends AbstractController
$docs = $entityManagerInterface->getRepository(HesabdariDoc::class)->findBy([
'year' => $acc['year'],
'bid' => $acc['bid'],
'money' => $acc['money']
]);
} else {
$docs = $entityManagerInterface->getRepository(HesabdariDoc::class)->findBy([
'year' => $acc['year'],
'bid' => $acc['bid'],
'type' => $params['type'],
'money'=> $acc['money']
]);
}
//filter docs by date
@ -52,13 +54,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;
@ -187,12 +192,14 @@ class ReportController extends AbstractController
$docs = $entityManagerInterface->getRepository(HesabdariDoc::class)->findBy([
'year' => $acc['year'],
'bid' => $acc['bid'],
'money'=> $acc['money']
]);
} else {
$docs = $entityManagerInterface->getRepository(HesabdariDoc::class)->findBy([
'year' => $acc['year'],
'bid' => $acc['bid'],
'type' => $params['type'],
'money'=> $acc['money']
]);
}
@ -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 = [];

View file

@ -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;

View file

@ -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;

View file

@ -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]);

View file

@ -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']);

View file

@ -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();

View file

@ -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('سند یافت نشد');

View file

@ -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){

View file

@ -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;
}
}

View file

@ -252,6 +252,12 @@ class Business
#[ORM\OneToMany(mappedBy: 'bid', targetEntity: Project::class, orphanRemoval: true)]
private Collection $projects;
/**
* @var Collection<int, Money>
*/
#[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<int, Money>
*/
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;
}
}

View file

@ -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;
}
}

View file

@ -27,10 +27,37 @@ class Money
#[ORM\OneToMany(mappedBy: 'money', targetEntity: PriceListDetail::class, orphanRemoval: true)]
private Collection $priceListDetails;
/**
* @var Collection<int, Business>
*/
#[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<int, Cashdesk>
*/
#[ORM\OneToMany(mappedBy: 'money', targetEntity: Cashdesk::class)]
private Collection $cashdesks;
/**
* @var Collection<int, Salary>
*/
#[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<int, Business>
*/
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<int, Cashdesk>
*/
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<int, Salary>
*/
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;
}
}

View file

@ -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;
}
}

View file

@ -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;

View file

@ -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;
}
}

View file

@ -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,

View file

@ -47,7 +47,7 @@
<div class="col-md-4">
<div class="column_attr clearfix mobile_align_center" style="padding: 0 4%;">
<h6 style="margin-bottom: 0px;">تلفن</h6>
<h4><a class="themecolor" href="tel:02191031705">021-9103-1705 داخلی ۳</a></h4>
<h4><a class="themecolor" href="tel:08345323211">083-4532-3211</a></h4>
<hr class="no_line" style="margin: 0 auto 15px auto;">
<h6 style="margin-bottom: 0px;">پشتیبانی از طریق شبکه‌های اجتماعی</h6>
<h4>