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

View file

@ -77,8 +77,7 @@ class SalaryController extends AbstractController
return $this->json(['result' => 2]);
$data = new Salary();
$data->setCode($provider->getAccountingCode($request->headers->get('activeBid'), 'salary'));
}
else{
} else {
$data = $entityManager->getRepository(Salary::class)->findOneBy([
'bid' => $acc['bid'],
'code' => $code
@ -94,4 +93,25 @@ class SalaryController extends AbstractController
$log->insert('بانک', 'تنخواه گردان با نام ' . $params['name'] . ' افزوده/ویرایش شد.', $this->getUser(), $request->headers->get('activeBid'));
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 registryMGR $registryMGR;
private int $smsPrice = 2500;
private int $smsPrice = 1250;
/**
* @param EntityManagerInterface $entityManager