some progress and bug fix

This commit is contained in:
Hesabix 2024-05-10 13:10:56 +00:00
parent d5b42b598f
commit 694a06b090
8 changed files with 388 additions and 342 deletions

0
hesabixArchive/index.php Normal file → Executable file
View file

0
hesabixArchive/temp/index.php Normal file → Executable file
View file

View file

@ -255,6 +255,7 @@ class ArchiveController extends AbstractController
$newFilename $newFilename
);} catch (FileException $e) { );} catch (FileException $e) {
// ... handle exception if something happens during file upload // ... handle exception if something happens during file upload
return $this->json("error");
} }
// updates the 'brochureFilename' property to store the PDF file name // updates the 'brochureFilename' property to store the PDF file name

View file

@ -75,8 +75,7 @@ class BankController extends AbstractController
return $this->json(['result' => 2]); return $this->json(['result' => 2]);
$data = new BankAccount(); $data = new BankAccount();
$data->setCode($provider->getAccountingCode($request->headers->get('activeBid'), 'bank')); $data->setCode($provider->getAccountingCode($request->headers->get('activeBid'), 'bank'));
} } else {
else{
$data = $entityManager->getRepository(BankAccount::class)->findOneBy([ $data = $entityManager->getRepository(BankAccount::class)->findOneBy([
'bid' => $acc['bid'], 'bid' => $acc['bid'],
'code' => $code 'code' => $code
@ -99,4 +98,26 @@ class BankController extends AbstractController
$log->insert('بانک', 'حساب بانکی با نام ' . $params['name'] . ' افزوده/ویرایش شد.', $this->getUser(), $request->headers->get('activeBid')); $log->insert('بانک', 'حساب بانکی با نام ' . $params['name'] . ' افزوده/ویرایش شد.', $this->getUser(), $request->headers->get('activeBid'));
return $this->json(['result' => 1]); return $this->json(['result' => 1]);
} }
#[Route('/api/bank/delete/{code}', name: 'app_bank_delete')]
public function app_bank_delete(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager, $code = 0): JsonResponse
{
$acc = $access->hasRole('banks');
if (!$acc)
throw $this->createAccessDeniedException();
$bank = $entityManager->getRepository(BankAccount::class)->findOneBy(['bid' => $acc['bid'], 'code' => $code]);
if (!$bank)
throw $this->createNotFoundException();
//check accounting docs
$rows = $entityManager->getRepository(HesabdariRow::class)->findby(['bid' => $acc['bid'], 'bank' => $bank]);
if (count($rows) > 0)
return $this->json(['result' => 2]);
if ($acc['bid']->getWalletMatchBank()->getId() == $bank->getId())
return $this->json(['result' => 3]);
$name = $bank->getName();
$entityManager->remove($bank);
$log->insert('بانکداری', ' حساب بانکی با نام ' . $name . ' حذف شد. ', $this->getUser(), $acc['bid']->getId());
return $this->json(['result' => 1]);
}
} }

View file

@ -76,8 +76,7 @@ class CashdeskController extends AbstractController
return $this->json(['result' => 2]); return $this->json(['result' => 2]);
$data = new Cashdesk(); $data = new Cashdesk();
$data->setCode($provider->getAccountingCode($request->headers->get('activeBid'), 'cashdesk')); $data->setCode($provider->getAccountingCode($request->headers->get('activeBid'), 'cashdesk'));
} } else {
else{
$data = $entityManager->getRepository(Cashdesk::class)->findOneBy([ $data = $entityManager->getRepository(Cashdesk::class)->findOneBy([
'bid' => $acc['bid'], 'bid' => $acc['bid'],
'code' => $code 'code' => $code
@ -93,4 +92,25 @@ class CashdeskController extends AbstractController
$log->insert('بانک‌داری', ' صندوق با نام ' . $params['name'] . ' افزوده/ویرایش شد.', $this->getUser(), $request->headers->get('activeBid')); $log->insert('بانک‌داری', ' صندوق با نام ' . $params['name'] . ' افزوده/ویرایش شد.', $this->getUser(), $request->headers->get('activeBid'));
return $this->json(['result' => 1]); return $this->json(['result' => 1]);
} }
#[Route('/api/cashdesk/delete/{code}', name: 'app_cashdesk_delete')]
public function app_cashdesk_delete(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager, $code = 0): JsonResponse
{
$acc = $access->hasRole('cashdesk');
if (!$acc)
throw $this->createAccessDeniedException();
$cashdesk = $entityManager->getRepository(Cashdesk::class)->findOneBy(['bid' => $acc['bid'], 'code' => $code]);
if (!$cashdesk)
throw $this->createNotFoundException();
//check accounting docs
$rows = $entityManager->getRepository(HesabdariRow::class)->findby(['bid' => $acc['bid'], 'cashdesk' => $cashdesk]);
if (count($rows) > 0)
return $this->json(['result' => 2]);
$name = $cashdesk->getName();
$entityManager->remove($cashdesk);
$log->insert('بانکداری', ' صندوق با نام ' . $name . ' حذف شد. ', $this->getUser(), $acc['bid']->getId());
return $this->json(['result' => 1]);
}
} }

View file

@ -62,6 +62,7 @@ class HesabdariController extends AbstractController
$temp['bd'] = $item->getBd(); $temp['bd'] = $item->getBd();
$temp['des'] = $item->getDes(); $temp['des'] = $item->getDes();
$temp['table'] = $item->getRef()->getName(); $temp['table'] = $item->getRef()->getName();
$temp['tableCode'] = $item->getRef()->getCode();
$temp['referral'] = $item->getReferral(); $temp['referral'] = $item->getReferral();
if ($item->getPerson()) { if ($item->getPerson()) {
$temp['typeLabel'] = 'شخص'; $temp['typeLabel'] = 'شخص';
@ -81,8 +82,7 @@ class HesabdariController extends AbstractController
'codeeghtesadi' => $item->getPerson()->getCodeeghtesadi(), 'codeeghtesadi' => $item->getPerson()->getCodeeghtesadi(),
'postalcode' => $item->getPerson()->getPostalCode() 'postalcode' => $item->getPerson()->getPostalCode()
]; ];
} } elseif ($item->getBank()) {
elseif($item->getBank()){
$temp['typeLabel'] = 'حسابهای بانکی'; $temp['typeLabel'] = 'حسابهای بانکی';
$temp['type'] = 'bank'; $temp['type'] = 'bank';
$temp['ref'] = $item->getBank()->getName(); $temp['ref'] = $item->getBank()->getName();
@ -100,8 +100,7 @@ class HesabdariController extends AbstractController
'mobileInternetBank' => $item->getBank()->getMobileInternetBank(), 'mobileInternetBank' => $item->getBank()->getMobileInternetBank(),
'code' => $item->getBank()->getCode(), 'code' => $item->getBank()->getCode(),
]; ];
} } elseif ($item->getCommodity()) {
elseif($item->getCommodity()){
$temp['typeLabel'] = 'موجودی کالا'; $temp['typeLabel'] = 'موجودی کالا';
$temp['type'] = 'commodity'; $temp['type'] = 'commodity';
$temp['ref'] = $item->getCommodity()->getName(); $temp['ref'] = $item->getCommodity()->getName();
@ -118,8 +117,7 @@ class HesabdariController extends AbstractController
'code' => $item->getCommodity()->getCode(), 'code' => $item->getCommodity()->getCode(),
'unit' => $item->getCommodity()->getUnit()->getName(), 'unit' => $item->getCommodity()->getUnit()->getName(),
]; ];
} } elseif ($item->getSalary()) {
elseif($item->getSalary()){
$temp['typeLabel'] = 'تنخواه گردان'; $temp['typeLabel'] = 'تنخواه گردان';
$temp['type'] = 'salary'; $temp['type'] = 'salary';
$temp['ref'] = $item->getSalary()->getName(); $temp['ref'] = $item->getSalary()->getName();
@ -130,8 +128,7 @@ class HesabdariController extends AbstractController
'des' => $item->getSalary()->getDes(), 'des' => $item->getSalary()->getDes(),
'code' => $item->getSalary()->getCode(), 'code' => $item->getSalary()->getCode(),
]; ];
} } elseif ($item->getCashdesk()) {
elseif($item->getCashdesk()){
$temp['typeLabel'] = 'صندوق'; $temp['typeLabel'] = 'صندوق';
$temp['type'] = 'cashdesk'; $temp['type'] = 'cashdesk';
$temp['ref'] = $item->getCashdesk()->getName(); $temp['ref'] = $item->getCashdesk()->getName();
@ -142,8 +139,7 @@ class HesabdariController extends AbstractController
'des' => $item->getCashdesk()->getDes(), 'des' => $item->getCashdesk()->getDes(),
'code' => $item->getCashdesk()->getCode(), 'code' => $item->getCashdesk()->getCode(),
]; ];
} } else {
else{
$temp['typeLabel'] = $item->getRef()->getName(); $temp['typeLabel'] = $item->getRef()->getName();
$temp['type'] = 'calc'; $temp['type'] = 'calc';
$temp['ref'] = $item->getRef()->getName(); $temp['ref'] = $item->getRef()->getName();
@ -201,8 +197,7 @@ class HesabdariController extends AbstractController
], [ ], [
'id' => 'DESC' 'id' => 'DESC'
]); ]);
} } else {
else{
$data = $entityManager->getRepository(HesabdariDoc::class)->findBy([ $data = $entityManager->getRepository(HesabdariDoc::class)->findBy([
'bid' => $acc['bid'], 'bid' => $acc['bid'],
'year' => $acc['year'], 'year' => $acc['year'],
@ -235,7 +230,6 @@ class HesabdariController extends AbstractController
$pays = 0; $pays = 0;
foreach ($item->getRelatedDocs() as $relatedDoc) { foreach ($item->getRelatedDocs() as $relatedDoc) {
$pays += $relatedDoc->getAmount(); $pays += $relatedDoc->getAmount();
} }
if ($item->getAmount() <= $pays) if ($item->getAmount() <= $pays)
$temp['status'] = 'تسویه شده'; $temp['status'] = 'تسویه شده';
@ -259,6 +253,8 @@ class HesabdariController extends AbstractController
$this->createNotFoundException(); $this->createNotFoundException();
$roll = ''; $roll = '';
if ($params['type'] == 'person_receive' || $params['type'] == 'person_send') $roll = 'person'; 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 else
$roll = $params['type']; $roll = $params['type'];
@ -292,8 +288,7 @@ class HesabdariController extends AbstractController
]); ]);
foreach ($rows as $row) foreach ($rows as $row)
$entityManager->remove($row); $entityManager->remove($row);
} } else {
else{
$doc = new HesabdariDoc(); $doc = new HesabdariDoc();
$doc->setBid($acc['bid']); $doc->setBid($acc['bid']);
$doc->setYear($acc['year']); $doc->setYear($acc['year']);
@ -349,8 +344,7 @@ class HesabdariController extends AbstractController
if (!$person) throw $this->createNotFoundException('person not found'); if (!$person) throw $this->createNotFoundException('person not found');
elseif ($person->getBid()->getId() != $acc['bid']->getId()) throw $this->createAccessDeniedException('person is not in this business'); elseif ($person->getBid()->getId() != $acc['bid']->getId()) throw $this->createAccessDeniedException('person is not in this business');
$hesabdariRow->setPerson($person); $hesabdariRow->setPerson($person);
} } elseif ($row['type'] == 'cheque') {
elseif($row['type'] == 'cheque'){
$person = $entityManager->getRepository(Person::class)->findOneBy([ $person = $entityManager->getRepository(Person::class)->findOneBy([
'bid' => $acc['bid'], 'bid' => $acc['bid'],
'id' => $row['chequeOwner'] 'id' => $row['chequeOwner']
@ -382,26 +376,22 @@ class HesabdariController extends AbstractController
$entityManager->persist($cheque); $entityManager->persist($cheque);
$entityManager->flush(); $entityManager->flush();
$hesabdariRow->setCheque($cheque); $hesabdariRow->setCheque($cheque);
} } elseif ($row['type'] == 'bank') {
elseif ($row['type'] == 'bank'){
$bank = $entityManager->getRepository(BankAccount::class)->find($row['id']); $bank = $entityManager->getRepository(BankAccount::class)->find($row['id']);
if (!$bank) throw $this->createNotFoundException('bank not found'); if (!$bank) throw $this->createNotFoundException('bank not found');
elseif ($bank->getBid()->getId() != $acc['bid']->getId()) throw $this->createAccessDeniedException('bank is not in this business'); elseif ($bank->getBid()->getId() != $acc['bid']->getId()) throw $this->createAccessDeniedException('bank is not in this business');
$hesabdariRow->setBank($bank); $hesabdariRow->setBank($bank);
} } elseif ($row['type'] == 'salary') {
elseif ($row['type'] == 'salary'){
$salary = $entityManager->getRepository(Salary::class)->find($row['id']); $salary = $entityManager->getRepository(Salary::class)->find($row['id']);
if (!$salary) throw $this->createNotFoundException('salary not found'); if (!$salary) throw $this->createNotFoundException('salary not found');
elseif ($salary->getBid()->getId() != $acc['bid']->getId()) throw $this->createAccessDeniedException('bank is not in this business'); elseif ($salary->getBid()->getId() != $acc['bid']->getId()) throw $this->createAccessDeniedException('bank is not in this business');
$hesabdariRow->setSalary($salary); $hesabdariRow->setSalary($salary);
} } elseif ($row['type'] == 'cashdesk') {
elseif ($row['type'] == 'cashdesk'){
$cashdesk = $entityManager->getRepository(Cashdesk::class)->find($row['id']); $cashdesk = $entityManager->getRepository(Cashdesk::class)->find($row['id']);
if (!$cashdesk) throw $this->createNotFoundException('cashdesk not found'); if (!$cashdesk) throw $this->createNotFoundException('cashdesk not found');
elseif ($cashdesk->getBid()->getId() != $acc['bid']->getId()) throw $this->createAccessDeniedException('bank is not in this business'); elseif ($cashdesk->getBid()->getId() != $acc['bid']->getId()) throw $this->createAccessDeniedException('bank is not in this business');
$hesabdariRow->setCashdesk($cashdesk); $hesabdariRow->setCashdesk($cashdesk);
} } elseif ($row['type'] == 'commodity') {
elseif ($row['type'] == 'commodity'){
$row['count'] = str_replace(',', '', $row['count']); $row['count'] = str_replace(',', '', $row['count']);
$commodity = $entityManager->getRepository(Commodity::class)->find($row['commodity']['id']); $commodity = $entityManager->getRepository(Commodity::class)->find($row['commodity']['id']);
if (!$commodity) throw $this->createNotFoundException('commodity not found'); if (!$commodity) throw $this->createNotFoundException('commodity not found');
@ -419,14 +409,13 @@ class HesabdariController extends AbstractController
$hesabdariRow->setDes($row['des']); $hesabdariRow->setDes($row['des']);
$entityManager->persist($hesabdariRow); $entityManager->persist($hesabdariRow);
$entityManager->flush(); $entityManager->flush();
} }
$doc->setAmount($amount); $doc->setAmount($amount);
$entityManager->persist($doc); $entityManager->persist($doc);
$entityManager->flush(); $entityManager->flush();
$log->insert( $log->insert(
'حسابداری','سند حسابداری شماره ' . $doc->getCode() . ' ثبت / ویرایش شد.', 'حسابداری',
'سند حسابداری شماره ' . $doc->getCode() . ' ثبت / ویرایش شد.',
$this->getUser(), $this->getUser(),
$request->headers->get('activeBid'), $request->headers->get('activeBid'),
$doc $doc
@ -453,8 +442,9 @@ class HesabdariController extends AbstractController
]); ]);
if (!$doc) throw $this->createNotFoundException(); if (!$doc) throw $this->createNotFoundException();
$roll = ''; $roll = '';
if($doc->getType() == 'person_receive' || $doc->getType() == 'person_send') if ($doc->getType() == 'person_receive' || $doc->getType() == 'person_send') $roll = 'person';
$roll = 'person'; elseif ($doc->getType() == 'sell_receive') $roll = 'sell';
elseif ($doc->getType() == 'buy_send') $roll = 'buy';
else else
$roll = $doc->getType(); $roll = $doc->getType();
$acc = $access->hasRole($roll); $acc = $access->hasRole($roll);
@ -553,8 +543,7 @@ class HesabdariController extends AbstractController
], [ ], [
'id' => 'DESC' 'id' => 'DESC'
]); ]);
} } elseif ($params['type'] == 'bank') {
elseif($params['type'] == 'bank'){
$bank = $entityManager->getRepository(BankAccount::class)->findOneBy([ $bank = $entityManager->getRepository(BankAccount::class)->findOneBy([
'bid' => $acc['bid'], 'bid' => $acc['bid'],
'code' => $params['id'], 'code' => $params['id'],
@ -567,8 +556,7 @@ class HesabdariController extends AbstractController
], [ ], [
'id' => 'DESC' 'id' => 'DESC'
]); ]);
} } elseif ($params['type'] == 'cashdesk') {
elseif($params['type'] == 'cashdesk'){
$cashdesk = $entityManager->getRepository(Cashdesk::class)->findOneBy([ $cashdesk = $entityManager->getRepository(Cashdesk::class)->findOneBy([
'bid' => $acc['bid'], 'bid' => $acc['bid'],
'code' => $params['id'], 'code' => $params['id'],
@ -581,8 +569,7 @@ class HesabdariController extends AbstractController
], [ ], [
'id' => 'DESC' 'id' => 'DESC'
]); ]);
} } elseif ($params['type'] == 'salary') {
elseif($params['type'] == 'salary'){
$salary = $entityManager->getRepository(Salary::class)->findOneBy([ $salary = $entityManager->getRepository(Salary::class)->findOneBy([
'bid' => $acc['bid'], 'bid' => $acc['bid'],
'code' => $params['id'], 'code' => $params['id'],
@ -630,8 +617,7 @@ class HesabdariController extends AbstractController
'text' => $node->getName(), 'text' => $node->getName(),
'children' => $this->getChildsLabel($entityManager, $node) 'children' => $this->getChildsLabel($entityManager, $node)
]; ];
} } else {
else{
$temp[$node->getCode()] = [ $temp[$node->getCode()] = [
'text' => $node->getName(), 'text' => $node->getName(),
]; ];
@ -650,8 +636,7 @@ class HesabdariController extends AbstractController
if ($type == 'cost') { if ($type == 'cost') {
$cost = $entityManager->getRepository(HesabdariTable::class)->findOneBy(['code' => 67]); $cost = $entityManager->getRepository(HesabdariTable::class)->findOneBy(['code' => 67]);
return $this->json($this->getChilds($entityManager, $cost)); return $this->json($this->getChilds($entityManager, $cost));
} } elseif ($type == 'income') {
elseif($type == 'income'){
$income = $entityManager->getRepository(HesabdariTable::class)->findOneBy(['code' => 56]); $income = $entityManager->getRepository(HesabdariTable::class)->findOneBy(['code' => 56]);
return $this->json($this->getChilds($entityManager, $income)); return $this->json($this->getChilds($entityManager, $income));
} }
@ -659,7 +644,8 @@ class HesabdariController extends AbstractController
return $this->json([]); return $this->json([]);
} }
private function getChildsLabel(EntityManagerInterface $entityManager, mixed $node){ private function getChildsLabel(EntityManagerInterface $entityManager, mixed $node)
{
$childs = $entityManager->getRepository(HesabdariTable::class)->findBy([ $childs = $entityManager->getRepository(HesabdariTable::class)->findBy([
'upper' => $node 'upper' => $node
]); ]);
@ -679,7 +665,8 @@ class HesabdariController extends AbstractController
return false; return false;
} }
private function getChilds(EntityManagerInterface $entityManager, mixed $node){ private function getChilds(EntityManagerInterface $entityManager, mixed $node)
{
$childs = $entityManager->getRepository(HesabdariTable::class)->findBy([ $childs = $entityManager->getRepository(HesabdariTable::class)->findBy([
'upper' => $node 'upper' => $node
]); ]);
@ -692,8 +679,7 @@ class HesabdariController extends AbstractController
'label' => $child->getName(), 'label' => $child->getName(),
'children' => $this->getChilds($entityManager, $child) 'children' => $this->getChilds($entityManager, $child)
]; ];
} } else {
else{
$temp[] = [ $temp[] = [
'id' => $child->getCode(), 'id' => $child->getCode(),
'label' => $child->getName(), 'label' => $child->getName(),
@ -703,6 +689,4 @@ class HesabdariController extends AbstractController
} }
return $temp; return $temp;
} }
} }

View file

@ -77,8 +77,7 @@ class SalaryController extends AbstractController
return $this->json(['result' => 2]); return $this->json(['result' => 2]);
$data = new Salary(); $data = new Salary();
$data->setCode($provider->getAccountingCode($request->headers->get('activeBid'), 'salary')); $data->setCode($provider->getAccountingCode($request->headers->get('activeBid'), 'salary'));
} } else {
else{
$data = $entityManager->getRepository(Salary::class)->findOneBy([ $data = $entityManager->getRepository(Salary::class)->findOneBy([
'bid' => $acc['bid'], 'bid' => $acc['bid'],
'code' => $code 'code' => $code
@ -94,4 +93,25 @@ class SalaryController extends AbstractController
$log->insert('بانک', 'تنخواه گردان با نام ' . $params['name'] . ' افزوده/ویرایش شد.', $this->getUser(), $request->headers->get('activeBid')); $log->insert('بانک', 'تنخواه گردان با نام ' . $params['name'] . ' افزوده/ویرایش شد.', $this->getUser(), $request->headers->get('activeBid'));
return $this->json(['result' => 1]); return $this->json(['result' => 1]);
} }
#[Route('/api/salary/delete/{code}', name: 'app_salary_delete')]
public function app_salary_delete(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager, $code = 0): JsonResponse
{
$acc = $access->hasRole('salary');
if (!$acc)
throw $this->createAccessDeniedException();
$salary = $entityManager->getRepository(Salary::class)->findOneBy(['bid' => $acc['bid'], 'code' => $code]);
if (!$salary)
throw $this->createNotFoundException();
//check accounting docs
$rows = $entityManager->getRepository(HesabdariRow::class)->findby(['bid' => $acc['bid'], 'salary' => $salary]);
if (count($rows) > 0)
return $this->json(['result' => 2]);
$name = $salary->getName();
$entityManager->remove($salary);
$log->insert('بانکداری', ' تنخواه‌گردان با نام ' . $name . ' حذف شد. ', $this->getUser(), $acc['bid']->getId());
return $this->json(['result' => 1]);
}
} }

View file

@ -13,7 +13,7 @@ class SMS
private Settings $settings; private Settings $settings;
private registryMGR $registryMGR; private registryMGR $registryMGR;
private int $smsPrice = 2500; private int $smsPrice = 1250;
/** /**
* @param EntityManagerInterface $entityManager * @param EntityManagerInterface $entityManager