some progress and bug fix
This commit is contained in:
parent
d5b42b598f
commit
694a06b090
0
hesabixArchive/index.php
Normal file → Executable file
0
hesabixArchive/index.php
Normal file → Executable file
0
hesabixArchive/temp/index.php
Normal file → Executable file
0
hesabixArchive/temp/index.php
Normal file → Executable 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
|
||||
|
|
|
@ -16,72 +16,71 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||
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
|
||||
public function app_bank_list(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
if(!$access->hasRole('banks'))
|
||||
if (!$access->hasRole('banks'))
|
||||
throw $this->createAccessDeniedException();
|
||||
$datas = $entityManager->getRepository(BankAccount::class)->findBy([
|
||||
'bid'=>$request->headers->get('activeBid')
|
||||
'bid' => $request->headers->get('activeBid')
|
||||
]);
|
||||
foreach($datas as $data){
|
||||
foreach ($datas as $data) {
|
||||
$bs = 0;
|
||||
$bd = 0;
|
||||
$items = $entityManager->getRepository(HesabdariRow::class)->findBy([
|
||||
'bank'=>$data
|
||||
'bank' => $data
|
||||
]);
|
||||
foreach ($items as $item){
|
||||
foreach ($items as $item) {
|
||||
$bs += $item->getBs();
|
||||
$bd += $item->getBd();
|
||||
}
|
||||
$data->setBalance($bd - $bs);
|
||||
}
|
||||
return $this->json($provider->ArrayEntity2Array($datas,0));
|
||||
return $this->json($provider->ArrayEntity2Array($datas, 0));
|
||||
}
|
||||
|
||||
#[Route('/api/bank/info/{code}', name: 'app_bank_info')]
|
||||
public function app_bank_info($code,Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse
|
||||
public function app_bank_info($code, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$acc = $access->hasRole('banks');
|
||||
if(!$acc)
|
||||
if (!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
$data = $entityManager->getRepository(BankAccount::class)->findOneBy([
|
||||
'bid'=>$acc['bid'],
|
||||
'code'=>$code
|
||||
'bid' => $acc['bid'],
|
||||
'code' => $code
|
||||
]);
|
||||
return $this->json($provider->Entity2Array($data,0));
|
||||
return $this->json($provider->Entity2Array($data, 0));
|
||||
}
|
||||
|
||||
#[Route('/api/bank/mod/{code}', name: 'app_bank_mod')]
|
||||
public function app_bank_mod(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager,$code = 0): JsonResponse
|
||||
public function app_bank_mod(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager, $code = 0): JsonResponse
|
||||
{
|
||||
$acc = $access->hasRole('banks');
|
||||
if(!$acc)
|
||||
if (!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
$params = json_decode($content, true);
|
||||
}
|
||||
if(!array_key_exists('name',$params))
|
||||
return $this->json(['result'=>-1]);
|
||||
if(count_chars(trim($params['name'])) == 0)
|
||||
return $this->json(['result'=>3]);
|
||||
if($code == 0){
|
||||
if (!array_key_exists('name', $params))
|
||||
return $this->json(['result' => -1]);
|
||||
if (count_chars(trim($params['name'])) == 0)
|
||||
return $this->json(['result' => 3]);
|
||||
if ($code == 0) {
|
||||
$data = $entityManager->getRepository(BankAccount::class)->findOneBy([
|
||||
'name'=>$params['name'],
|
||||
'bid' =>$acc['bid']
|
||||
'name' => $params['name'],
|
||||
'bid' => $acc['bid']
|
||||
]);
|
||||
//check exist before
|
||||
if($data)
|
||||
return $this->json(['result'=>2]);
|
||||
if ($data)
|
||||
return $this->json(['result' => 2]);
|
||||
$data = new BankAccount();
|
||||
$data->setCode($provider->getAccountingCode($request->headers->get('activeBid'),'bank'));
|
||||
}
|
||||
else{
|
||||
$data->setCode($provider->getAccountingCode($request->headers->get('activeBid'), 'bank'));
|
||||
} else {
|
||||
$data = $entityManager->getRepository(BankAccount::class)->findOneBy([
|
||||
'bid'=>$acc['bid'],
|
||||
'code'=>$code
|
||||
'bid' => $acc['bid'],
|
||||
'code' => $code
|
||||
]);
|
||||
if(!$data)
|
||||
if (!$data)
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
$data->setBid($acc['bid']);
|
||||
|
@ -96,7 +95,29 @@ class BankController extends AbstractController
|
|||
$data->setMobileInternetBank($params['mobileInternetbank']);
|
||||
$entityManager->persist($data);
|
||||
$entityManager->flush();
|
||||
$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]);
|
||||
}
|
||||
|
||||
#[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]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,20 +17,20 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||
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
|
||||
public function app_cashdesk_list(Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
if(!$access->hasRole('cashdesk'))
|
||||
if (!$access->hasRole('cashdesk'))
|
||||
throw $this->createAccessDeniedException();
|
||||
$datas = $entityManager->getRepository(Cashdesk::class)->findBy([
|
||||
'bid'=>$request->headers->get('activeBid')
|
||||
'bid' => $request->headers->get('activeBid')
|
||||
]);
|
||||
foreach($datas as $data){
|
||||
foreach ($datas as $data) {
|
||||
$bs = 0;
|
||||
$bd = 0;
|
||||
$items = $entityManager->getRepository(HesabdariRow::class)->findBy([
|
||||
'cashdesk'=>$data
|
||||
'cashdesk' => $data
|
||||
]);
|
||||
foreach ($items as $item){
|
||||
foreach ($items as $item) {
|
||||
$bs += $item->getBs();
|
||||
$bd += $item->getBd();
|
||||
}
|
||||
|
@ -40,49 +40,48 @@ class CashdeskController extends AbstractController
|
|||
}
|
||||
|
||||
#[Route('/api/cashdesk/info/{code}', name: 'app_cashdesk_info')]
|
||||
public function app_cashdesk_info($code,Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse
|
||||
public function app_cashdesk_info($code, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$acc = $access->hasRole('cashdesk');
|
||||
if(!$acc)
|
||||
if (!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
$data = $entityManager->getRepository(Cashdesk::class)->findOneBy([
|
||||
'bid'=>$acc['bid'],
|
||||
'code'=>$code
|
||||
'bid' => $acc['bid'],
|
||||
'code' => $code
|
||||
]);
|
||||
return $this->json($data);
|
||||
}
|
||||
|
||||
#[Route('/api/cashdesk/mod/{code}', name: 'app_cashdesk_mod')]
|
||||
public function app_cashdesk_mod(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager,$code = 0): JsonResponse
|
||||
public function app_cashdesk_mod(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager, $code = 0): JsonResponse
|
||||
{
|
||||
$acc = $access->hasRole('cashdesk');
|
||||
if(!$acc)
|
||||
if (!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
$params = json_decode($content, true);
|
||||
}
|
||||
if(!array_key_exists('name',$params))
|
||||
return $this->json(['result'=>-1]);
|
||||
if(count_chars(trim($params['name'])) == 0)
|
||||
return $this->json(['result'=>3]);
|
||||
if($code == 0){
|
||||
if (!array_key_exists('name', $params))
|
||||
return $this->json(['result' => -1]);
|
||||
if (count_chars(trim($params['name'])) == 0)
|
||||
return $this->json(['result' => 3]);
|
||||
if ($code == 0) {
|
||||
$data = $entityManager->getRepository(Cashdesk::class)->findOneBy([
|
||||
'name'=>$params['name'],
|
||||
'bid' =>$acc['bid']
|
||||
'name' => $params['name'],
|
||||
'bid' => $acc['bid']
|
||||
]);
|
||||
//check exist before
|
||||
if($data)
|
||||
return $this->json(['result'=>2]);
|
||||
if ($data)
|
||||
return $this->json(['result' => 2]);
|
||||
$data = new Cashdesk();
|
||||
$data->setCode($provider->getAccountingCode($request->headers->get('activeBid'),'cashdesk'));
|
||||
}
|
||||
else{
|
||||
$data->setCode($provider->getAccountingCode($request->headers->get('activeBid'), 'cashdesk'));
|
||||
} else {
|
||||
$data = $entityManager->getRepository(Cashdesk::class)->findOneBy([
|
||||
'bid'=>$acc['bid'],
|
||||
'code'=>$code
|
||||
'bid' => $acc['bid'],
|
||||
'code' => $code
|
||||
]);
|
||||
if(!$data)
|
||||
if (!$data)
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
$data->setBid($acc['bid']);
|
||||
|
@ -90,7 +89,28 @@ class CashdeskController extends AbstractController
|
|||
$data->setDes($params['des']);
|
||||
$entityManager->persist($data);
|
||||
$entityManager->flush();
|
||||
$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]);
|
||||
}
|
||||
|
||||
#[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]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,38 +32,39 @@ class HesabdariController extends AbstractController
|
|||
{
|
||||
private array $tableExport = [];
|
||||
#[Route('/api/accounting/doc/get', name: 'app_accounting_doc_get')]
|
||||
public function app_accounting_doc_get(Jdate $jdate,Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse
|
||||
public function app_accounting_doc_get(Jdate $jdate, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
$params = json_decode($content, true);
|
||||
}
|
||||
if(! array_key_exists('code',$params))
|
||||
if (!array_key_exists('code', $params))
|
||||
$this->createNotFoundException();
|
||||
|
||||
|
||||
$acc = $access->hasRole('accounting');
|
||||
if(!$acc)
|
||||
if (!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
||||
'bid'=>$acc['bid'],
|
||||
'year'=>$acc['year'],
|
||||
'code'=>$params['code']
|
||||
'bid' => $acc['bid'],
|
||||
'year' => $acc['year'],
|
||||
'code' => $params['code']
|
||||
]);
|
||||
if(!$doc) throw $this->createNotFoundException();
|
||||
if (!$doc) throw $this->createNotFoundException();
|
||||
$rows = [];
|
||||
$rowsObj = $entityManager->getRepository(HesabdariRow::class)->findBy(
|
||||
['doc'=>$doc]
|
||||
['doc' => $doc]
|
||||
);
|
||||
foreach ($rowsObj as $item){
|
||||
$temp=[];
|
||||
foreach ($rowsObj as $item) {
|
||||
$temp = [];
|
||||
$temp['id'] = $item->getId();
|
||||
$temp['bs'] = $item->getBs();
|
||||
$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()){
|
||||
if ($item->getPerson()) {
|
||||
$temp['typeLabel'] = 'شخص';
|
||||
$temp['type'] = 'person';
|
||||
$temp['ref'] = $item->getPerson()->getNikeName();
|
||||
|
@ -78,11 +79,10 @@ class HesabdariController extends AbstractController
|
|||
'address' => $item->getPerson()->getAddress(),
|
||||
'des' => $item->getPerson()->getDes(),
|
||||
'shomaresabt' => $item->getperson()->getSabt(),
|
||||
'codeeghtesadi' =>$item->getPerson()->getCodeeghtesadi(),
|
||||
'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,17 +100,16 @@ 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();
|
||||
$temp['refCode'] = $item->getCommodity()->getCode();
|
||||
$temp['count'] = $item->getCommdityCount();
|
||||
if($doc->getType() == 'sell')
|
||||
$temp['unitPrice'] = $item->getBs()/$item->getCommdityCount();
|
||||
elseif($doc->getType() == 'buy')
|
||||
$temp['unitPrice'] = $item->getBd()/$item->getCommdityCount();
|
||||
if ($doc->getType() == 'sell')
|
||||
$temp['unitPrice'] = $item->getBs() / $item->getCommdityCount();
|
||||
elseif ($doc->getType() == 'buy')
|
||||
$temp['unitPrice'] = $item->getBd() / $item->getCommdityCount();
|
||||
$temp['commodity'] = [
|
||||
'id' => $item->getCommodity()->getId(),
|
||||
'name' => $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();
|
||||
|
@ -153,7 +149,7 @@ class HesabdariController extends AbstractController
|
|||
}
|
||||
//get related docs
|
||||
$rds = [];
|
||||
foreach ($doc->getRelatedDocs() as $relatedDoc){
|
||||
foreach ($doc->getRelatedDocs() as $relatedDoc) {
|
||||
$temp = [];
|
||||
$temp['amount'] = $relatedDoc->getAmount();
|
||||
$temp['des'] = $relatedDoc->getDes();
|
||||
|
@ -163,81 +159,79 @@ class HesabdariController extends AbstractController
|
|||
$rds[] = $temp;
|
||||
}
|
||||
return $this->json([
|
||||
'doc'=>JsonResp::SerializeHesabdariDoc($doc),
|
||||
'rows'=>$rows,
|
||||
'relatedDocs'=>$rds
|
||||
'doc' => JsonResp::SerializeHesabdariDoc($doc),
|
||||
'rows' => $rows,
|
||||
'relatedDocs' => $rds
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/api/accounting/search', name: 'app_accounting_search')]
|
||||
public function app_accounting_search(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse
|
||||
public function app_accounting_search(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
$params = json_decode($content, true);
|
||||
}
|
||||
if(! array_key_exists('type',$params))
|
||||
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();
|
||||
|
||||
$acc = $access->hasRole($roll);
|
||||
if(!$acc)
|
||||
if (!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
if($params['type'] == 'all'){
|
||||
if ($params['type'] == 'all') {
|
||||
$data = $entityManager->getRepository(HesabdariDoc::class)->findBy([
|
||||
'bid'=>$acc['bid'],
|
||||
'year'=>$acc['year'],
|
||||
],[
|
||||
'id'=>'DESC'
|
||||
'bid' => $acc['bid'],
|
||||
'year' => $acc['year'],
|
||||
], [
|
||||
'id' => 'DESC'
|
||||
]);
|
||||
} else {
|
||||
$data = $entityManager->getRepository(HesabdariDoc::class)->findBy([
|
||||
'bid' => $acc['bid'],
|
||||
'year' => $acc['year'],
|
||||
'type' => $params['type']
|
||||
], [
|
||||
'id' => 'DESC'
|
||||
]);
|
||||
}
|
||||
else{
|
||||
$data = $entityManager->getRepository(HesabdariDoc::class)->findBy([
|
||||
'bid'=>$acc['bid'],
|
||||
'year'=>$acc['year'],
|
||||
'type'=>$params['type']
|
||||
],[
|
||||
'id'=>'DESC'
|
||||
]);
|
||||
}
|
||||
$dataTemp =[];
|
||||
foreach ($data as $item){
|
||||
$dataTemp = [];
|
||||
foreach ($data as $item) {
|
||||
$temp = [
|
||||
'id'=>$item->getId(),
|
||||
'dateSubmit'=>$item->getDateSubmit(),
|
||||
'date'=>$item->getDate(),
|
||||
'type'=>$item->getType(),
|
||||
'code'=>$item->getCode(),
|
||||
'des'=>$item->getDes(),
|
||||
'amount'=>$item->getAmount(),
|
||||
'submitter'=> $item->getSubmitter()->getFullName(),
|
||||
'id' => $item->getId(),
|
||||
'dateSubmit' => $item->getDateSubmit(),
|
||||
'date' => $item->getDate(),
|
||||
'type' => $item->getType(),
|
||||
'code' => $item->getCode(),
|
||||
'des' => $item->getDes(),
|
||||
'amount' => $item->getAmount(),
|
||||
'submitter' => $item->getSubmitter()->getFullName(),
|
||||
];
|
||||
if($params['type'] == 'rfsell' || $params['type'] == 'rfbuy' || $params['type'] == 'buy' || $params['type'] == 'sell'){
|
||||
$mainRow = $entityManager->getRepository(HesabdariRow::class)->getNotEqual($item,'person');
|
||||
if ($params['type'] == 'rfsell' || $params['type'] == 'rfbuy' || $params['type'] == 'buy' || $params['type'] == 'sell') {
|
||||
$mainRow = $entityManager->getRepository(HesabdariRow::class)->getNotEqual($item, 'person');
|
||||
$temp['person'] = '';
|
||||
if($mainRow)
|
||||
if ($mainRow)
|
||||
$temp['person'] = $mainRow->getPerson()->getNikename();
|
||||
}
|
||||
|
||||
//get status of doc
|
||||
$temp['status'] = 'تسویه نشده';
|
||||
$pays = 0;
|
||||
foreach ($item->getRelatedDocs() as $relatedDoc){
|
||||
foreach ($item->getRelatedDocs() as $relatedDoc) {
|
||||
$pays += $relatedDoc->getAmount();
|
||||
|
||||
}
|
||||
if($item->getAmount() <= $pays)
|
||||
if ($item->getAmount() <= $pays)
|
||||
$temp['status'] = 'تسویه شده';
|
||||
|
||||
$dataTemp[] = $temp;
|
||||
|
@ -249,51 +243,52 @@ class HesabdariController extends AbstractController
|
|||
* @throws \ReflectionException
|
||||
*/
|
||||
#[Route('/api/accounting/insert', name: 'app_accounting_insert')]
|
||||
public function app_accounting_insert(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager,Jdate $jdate): JsonResponse
|
||||
public function app_accounting_insert(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager, Jdate $jdate): JsonResponse
|
||||
{
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
$params = json_decode($content, true);
|
||||
}
|
||||
if(! array_key_exists('type',$params))
|
||||
if (!array_key_exists('type', $params))
|
||||
$this->createNotFoundException();
|
||||
$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
|
||||
$roll = $params['type'];
|
||||
|
||||
$acc = $access->hasRole($roll);
|
||||
if(!$acc)
|
||||
if (!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
|
||||
if(!array_key_exists('rows',$params) || count($params['rows']) < 2)
|
||||
if (!array_key_exists('rows', $params) || count($params['rows']) < 2)
|
||||
throw $this->createNotFoundException('rows is to short');
|
||||
if(!array_key_exists('date',$params) || !array_key_exists('des',$params))
|
||||
if (!array_key_exists('date', $params) || !array_key_exists('des', $params))
|
||||
throw $this->createNotFoundException('some params mistake');
|
||||
if(array_key_exists('update',$params) && $params['update'] != ''){
|
||||
if (array_key_exists('update', $params) && $params['update'] != '') {
|
||||
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
||||
'bid'=>$acc['bid'],
|
||||
'year'=>$acc['year'],
|
||||
'code'=>$params['update']
|
||||
'bid' => $acc['bid'],
|
||||
'year' => $acc['year'],
|
||||
'code' => $params['update']
|
||||
]);
|
||||
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());
|
||||
if(array_key_exists('refData',$params))
|
||||
if (array_key_exists('refData', $params))
|
||||
$doc->setRefData($params['refData']);
|
||||
if(array_key_exists('plugin',$params))
|
||||
if (array_key_exists('plugin', $params))
|
||||
$doc->setPlugin($params['plugin']);
|
||||
|
||||
|
||||
$entityManager->persist($doc);
|
||||
$entityManager->flush();
|
||||
$rows = $entityManager->getRepository(HesabdariRow::class)->findBy([
|
||||
'doc'=>$doc
|
||||
'doc' => $doc
|
||||
]);
|
||||
foreach ($rows as $row)
|
||||
$entityManager->remove($row);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$doc = new HesabdariDoc();
|
||||
$doc->setBid($acc['bid']);
|
||||
$doc->setYear($acc['year']);
|
||||
|
@ -303,19 +298,19 @@ class HesabdariController extends AbstractController
|
|||
$doc->setDate($params['date']);
|
||||
$doc->setSubmitter($this->getUser());
|
||||
$doc->setMoney($acc['bid']->getMoney());
|
||||
$doc->setCode($provider->getAccountingCode($acc['bid'],'accounting'));
|
||||
if(array_key_exists('refData',$params))
|
||||
$doc->setCode($provider->getAccountingCode($acc['bid'], 'accounting'));
|
||||
if (array_key_exists('refData', $params))
|
||||
$doc->setRefData($params['refData']);
|
||||
if(array_key_exists('plugin',$params))
|
||||
if (array_key_exists('plugin', $params))
|
||||
$doc->setPlugin($params['plugin']);
|
||||
$entityManager->persist($doc);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
//add document to related docs
|
||||
if(array_key_exists('related',$params)){
|
||||
$relatedDoc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy(['code'=>$params['related'],'bid'=>$doc->getBid()]);
|
||||
if($relatedDoc){
|
||||
if (array_key_exists('related', $params)) {
|
||||
$relatedDoc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy(['code' => $params['related'], 'bid' => $doc->getBid()]);
|
||||
if ($relatedDoc) {
|
||||
$relatedDoc->addRelatedDoc($doc);
|
||||
$entityManager->persist($relatedDoc);
|
||||
$entityManager->flush();
|
||||
|
@ -323,9 +318,9 @@ class HesabdariController extends AbstractController
|
|||
}
|
||||
|
||||
$amount = 0;
|
||||
foreach ($params['rows'] as $row){
|
||||
$row['bs'] = str_replace(',','',$row['bs']);
|
||||
$row['bd'] = str_replace(',','',$row['bd']);
|
||||
foreach ($params['rows'] as $row) {
|
||||
$row['bs'] = str_replace(',', '', $row['bs']);
|
||||
$row['bd'] = str_replace(',', '', $row['bd']);
|
||||
|
||||
$hesabdariRow = new HesabdariRow();
|
||||
$hesabdariRow->setBid($acc['bid']);
|
||||
|
@ -334,26 +329,25 @@ class HesabdariController extends AbstractController
|
|||
$hesabdariRow->setBs($row['bs']);
|
||||
$hesabdariRow->setBd($row['bd']);
|
||||
$ref = $entityManager->getRepository(HesabdariTable::class)->findOneBy([
|
||||
'code'=>$row['table']
|
||||
'code' => $row['table']
|
||||
]);
|
||||
$hesabdariRow->setRef($ref);
|
||||
|
||||
$entityManager->persist($hesabdariRow);
|
||||
|
||||
if(array_key_exists('referral',$row))
|
||||
if (array_key_exists('referral', $row))
|
||||
$hesabdariRow->setReferral($row['referral']);
|
||||
$amount += $row['bs'];
|
||||
//check is type is person
|
||||
if($row['type'] == 'person'){
|
||||
if ($row['type'] == 'person') {
|
||||
$person = $entityManager->getRepository(Person::class)->find($row['id']);
|
||||
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');
|
||||
$hesabdariRow->setPerson($person);
|
||||
}
|
||||
elseif($row['type'] == 'cheque'){
|
||||
} elseif ($row['type'] == 'cheque') {
|
||||
$person = $entityManager->getRepository(Person::class)->findOneBy([
|
||||
'bid'=> $acc['bid'],
|
||||
'id'=>$row['chequeOwner']
|
||||
'bid' => $acc['bid'],
|
||||
'id' => $row['chequeOwner']
|
||||
]);
|
||||
$cheque = new Cheque();
|
||||
echo $hesabdariRow->getRef();
|
||||
|
@ -366,13 +360,13 @@ class HesabdariController extends AbstractController
|
|||
$cheque->setSayadNum($row['chequeSayadNum']);
|
||||
$cheque->setDateSubmit(time());
|
||||
$cheque->setDes($row['des']);
|
||||
$dateArray = explode('-',$row['chequeDate']);
|
||||
$dateGre = strtotime($jdate->jalali_to_gregorian($dateArray['0'],$dateArray['1'],$dateArray['2'],'/'));
|
||||
$dateArray = explode('-', $row['chequeDate']);
|
||||
$dateGre = strtotime($jdate->jalali_to_gregorian($dateArray['0'], $dateArray['1'], $dateArray['2'], '/'));
|
||||
$cheque->setDateStamp($dateGre);
|
||||
$cheque->setPerson($person);
|
||||
$cheque->setRef($entityManager->getRepository(HesabdariTable::class)->findOneBy(['code'=>$row['table']]));
|
||||
$cheque->setRef($entityManager->getRepository(HesabdariTable::class)->findOneBy(['code' => $row['table']]));
|
||||
$cheque->setType($row['chequeType']);
|
||||
if($cheque->getType() == 'input')
|
||||
if ($cheque->getType() == 'input')
|
||||
$cheque->setAmount($hesabdariRow->getBd());
|
||||
else
|
||||
$cheque->setAmount($hesabdariRow->getBs());
|
||||
|
@ -382,233 +376,226 @@ 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');
|
||||
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');
|
||||
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');
|
||||
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']);
|
||||
} 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');
|
||||
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']);
|
||||
}
|
||||
|
||||
if(array_key_exists('plugin',$row))
|
||||
|
||||
if (array_key_exists('plugin', $row))
|
||||
$hesabdariRow->setPlugin($row['plugin']);
|
||||
if(array_key_exists('refData',$row))
|
||||
if (array_key_exists('refData', $row))
|
||||
$hesabdariRow->setRefData($row['refData']);
|
||||
|
||||
|
||||
|
||||
$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
|
||||
);
|
||||
|
||||
return $this->json([
|
||||
'result'=>1,
|
||||
'doc'=>$provider->Entity2Array($doc,0)
|
||||
'result' => 1,
|
||||
'doc' => $provider->Entity2Array($doc, 0)
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/api/accounting/remove', name: 'app_accounting_remove_doc')]
|
||||
public function app_accounting_remove_doc(Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse
|
||||
public function app_accounting_remove_doc(Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
$params = json_decode($content, true);
|
||||
}
|
||||
if(! array_key_exists('code',$params))
|
||||
if (!array_key_exists('code', $params))
|
||||
$this->createNotFoundException();
|
||||
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
||||
'code'=>$params['code'],
|
||||
'bid'=>$request->headers->get('activeBid')
|
||||
'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';
|
||||
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);
|
||||
if(!$acc)
|
||||
if (!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
$rows = $entityManager->getRepository(HesabdariRow::class)->findBy([
|
||||
'doc'=>$doc
|
||||
'doc' => $doc
|
||||
]);
|
||||
if($doc->getPlugin() == 'plugNoghreOrder'){
|
||||
if ($doc->getPlugin() == 'plugNoghreOrder') {
|
||||
$order = $entityManager->getRepository(PlugNoghreOrder::class)->findOneBy([
|
||||
'doc'=>$doc
|
||||
'doc' => $doc
|
||||
]);
|
||||
if($order)
|
||||
if ($order)
|
||||
$entityManager->remove($order);
|
||||
}
|
||||
//check wallet online transactions
|
||||
$tempPays = $entityManager->getRepository(PayInfoTemp::class)->findOneBy(['doc'=>$doc]);
|
||||
if($tempPays){
|
||||
$tempPays = $entityManager->getRepository(PayInfoTemp::class)->findOneBy(['doc' => $doc]);
|
||||
if ($tempPays) {
|
||||
//doc has transaction
|
||||
return $this->json([
|
||||
'result'=>2,
|
||||
'message'=>'سند به دلیل داشتن تراکنش پرداخت آنلاین قابل حذف نیست.'
|
||||
'result' => 2,
|
||||
'message' => 'سند به دلیل داشتن تراکنش پرداخت آنلاین قابل حذف نیست.'
|
||||
]);
|
||||
}
|
||||
//check storeroom tickets
|
||||
$tickets = $entityManager->getRepository(StoreroomTicket::class)->findBy(['doc'=>$doc]);
|
||||
$tickets = $entityManager->getRepository(StoreroomTicket::class)->findBy(['doc' => $doc]);
|
||||
foreach ($tickets as $ticket)
|
||||
$entityManager->remove($ticket);
|
||||
//remove rows and check sub systems
|
||||
foreach ($rows as $row){
|
||||
if($row->getCheque()){
|
||||
if($row->getCheque()->isLocked()){
|
||||
foreach ($rows as $row) {
|
||||
if ($row->getCheque()) {
|
||||
if ($row->getCheque()->isLocked()) {
|
||||
//doc has transaction
|
||||
return $this->json([
|
||||
'result'=>2,
|
||||
'message'=>'سند به دلیل داشتن تراکنش مرتبط با چک بانکی قابل حذف نیست.'
|
||||
'result' => 2,
|
||||
'message' => 'سند به دلیل داشتن تراکنش مرتبط با چک بانکی قابل حذف نیست.'
|
||||
]);
|
||||
}
|
||||
$log->insert('بانکداری','چک شماره شماره ' . $row->getCheque()->getNumber() . ' حذف شد.',$this->getUser(),$request->headers->get('activeBid'));
|
||||
$log->insert('بانکداری', 'چک شماره شماره ' . $row->getCheque()->getNumber() . ' حذف شد.', $this->getUser(), $request->headers->get('activeBid'));
|
||||
$entityManager->remove($row->getCheque());
|
||||
}
|
||||
$entityManager->remove($row);
|
||||
}
|
||||
|
||||
foreach ($doc->getRelatedDocs() as $relatedDoc){
|
||||
if($relatedDoc->getType() != 'walletPay'){
|
||||
$items = $entityManager->getRepository(HesabdariRow::class)->findBy(['doc'=>$relatedDoc]);
|
||||
|
||||
foreach ($doc->getRelatedDocs() as $relatedDoc) {
|
||||
if ($relatedDoc->getType() != 'walletPay') {
|
||||
$items = $entityManager->getRepository(HesabdariRow::class)->findBy(['doc' => $relatedDoc]);
|
||||
foreach ($items as $item)
|
||||
$entityManager->remove($item);
|
||||
$entityManager->remove($relatedDoc);
|
||||
$log->insert('حسابداری','سند حسابداری شماره ' . $relatedDoc->getCode() . ' حذف شد.',$this->getUser(),$request->headers->get('activeBid'));
|
||||
$log->insert('حسابداری', 'سند حسابداری شماره ' . $relatedDoc->getCode() . ' حذف شد.', $this->getUser(), $request->headers->get('activeBid'));
|
||||
}
|
||||
}
|
||||
|
||||
//delete logs from documents
|
||||
$logs = $entityManager->getRepository(EntityLog::class)->findBy(['doc'=>$doc]);
|
||||
foreach($logs as $item){
|
||||
$logs = $entityManager->getRepository(EntityLog::class)->findBy(['doc' => $doc]);
|
||||
foreach ($logs as $item) {
|
||||
$item->setDoc(null);
|
||||
$entityManager->persist($item);
|
||||
$entityManager->flush();
|
||||
}
|
||||
$entityManager->remove($doc);
|
||||
$entityManager->flush();
|
||||
$log->insert('حسابداری','سند حسابداری شماره ' . $doc->getCode() . ' حذف شد.',$this->getUser(),$request->headers->get('activeBid'));
|
||||
return $this->json(['result'=>1]);
|
||||
$log->insert('حسابداری', 'سند حسابداری شماره ' . $doc->getCode() . ' حذف شد.', $this->getUser(), $request->headers->get('activeBid'));
|
||||
return $this->json(['result' => 1]);
|
||||
}
|
||||
|
||||
#[Route('/api/accounting/rows/search', name: 'app_accounting_rows_search')]
|
||||
public function app_accounting_rows_search(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse
|
||||
public function app_accounting_rows_search(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
$params = json_decode($content, true);
|
||||
}
|
||||
if(! array_key_exists('type',$params))
|
||||
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();
|
||||
|
||||
$acc = $access->hasRole($roll);
|
||||
if(!$acc)
|
||||
if (!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
if($params['type'] == 'person'){
|
||||
if ($params['type'] == 'person') {
|
||||
$person = $entityManager->getRepository(Person::class)->findOneBy([
|
||||
'bid'=>$acc['bid'],
|
||||
'code'=>$params['id'],
|
||||
'bid' => $acc['bid'],
|
||||
'code' => $params['id'],
|
||||
]);
|
||||
if(!$person)
|
||||
if (!$person)
|
||||
throw $this->createNotFoundException();
|
||||
|
||||
$data = $entityManager->getRepository(HesabdariRow::class)->findBy([
|
||||
'person'=> $person,
|
||||
],[
|
||||
'id'=>'DESC'
|
||||
'person' => $person,
|
||||
], [
|
||||
'id' => 'DESC'
|
||||
]);
|
||||
}
|
||||
elseif($params['type'] == 'bank'){
|
||||
} elseif ($params['type'] == 'bank') {
|
||||
$bank = $entityManager->getRepository(BankAccount::class)->findOneBy([
|
||||
'bid'=>$acc['bid'],
|
||||
'code'=>$params['id'],
|
||||
'bid' => $acc['bid'],
|
||||
'code' => $params['id'],
|
||||
]);
|
||||
if(!$bank)
|
||||
if (!$bank)
|
||||
throw $this->createNotFoundException();
|
||||
|
||||
$data = $entityManager->getRepository(HesabdariRow::class)->findBy([
|
||||
'bank'=> $bank,
|
||||
],[
|
||||
'id'=>'DESC'
|
||||
'bank' => $bank,
|
||||
], [
|
||||
'id' => 'DESC'
|
||||
]);
|
||||
}
|
||||
elseif($params['type'] == 'cashdesk'){
|
||||
} elseif ($params['type'] == 'cashdesk') {
|
||||
$cashdesk = $entityManager->getRepository(Cashdesk::class)->findOneBy([
|
||||
'bid'=>$acc['bid'],
|
||||
'code'=>$params['id'],
|
||||
'bid' => $acc['bid'],
|
||||
'code' => $params['id'],
|
||||
]);
|
||||
if(!$cashdesk)
|
||||
if (!$cashdesk)
|
||||
throw $this->createNotFoundException();
|
||||
|
||||
$data = $entityManager->getRepository(HesabdariRow::class)->findBy([
|
||||
'cashdesk'=> $cashdesk,
|
||||
],[
|
||||
'id'=>'DESC'
|
||||
'cashdesk' => $cashdesk,
|
||||
], [
|
||||
'id' => 'DESC'
|
||||
]);
|
||||
}
|
||||
elseif($params['type'] == 'salary'){
|
||||
} elseif ($params['type'] == 'salary') {
|
||||
$salary = $entityManager->getRepository(Salary::class)->findOneBy([
|
||||
'bid'=>$acc['bid'],
|
||||
'code'=>$params['id'],
|
||||
'bid' => $acc['bid'],
|
||||
'code' => $params['id'],
|
||||
]);
|
||||
if(!$salary)
|
||||
if (!$salary)
|
||||
throw $this->createNotFoundException();
|
||||
|
||||
$data = $entityManager->getRepository(HesabdariRow::class)->findBy([
|
||||
'salary'=> $salary,
|
||||
],[
|
||||
'id'=>'DESC'
|
||||
'salary' => $salary,
|
||||
], [
|
||||
'id' => 'DESC'
|
||||
]);
|
||||
}
|
||||
$dataTemp =[];
|
||||
foreach ($data as $item){
|
||||
$dataTemp = [];
|
||||
foreach ($data as $item) {
|
||||
$temp = [
|
||||
'id'=>$item->getId(),
|
||||
'dateSubmit'=>$item->getDoc()->getDateSubmit(),
|
||||
'date'=>$item->getDoc()->getDate(),
|
||||
'type'=>$item->getDoc()->getType(),
|
||||
'ref'=>$item->getRef()->getName(),
|
||||
'des'=>$item->getDes(),
|
||||
'bs'=>$item->getBs(),
|
||||
'bd'=>$item->getBd(),
|
||||
'code'=>$item->getDoc()->getCode(),
|
||||
'submitter'=> $item->getDoc()->getSubmitter()->getFullName()
|
||||
'id' => $item->getId(),
|
||||
'dateSubmit' => $item->getDoc()->getDateSubmit(),
|
||||
'date' => $item->getDoc()->getDate(),
|
||||
'type' => $item->getDoc()->getType(),
|
||||
'ref' => $item->getRef()->getName(),
|
||||
'des' => $item->getDes(),
|
||||
'bs' => $item->getBs(),
|
||||
'bd' => $item->getBd(),
|
||||
'code' => $item->getDoc()->getCode(),
|
||||
'submitter' => $item->getDoc()->getSubmitter()->getFullName()
|
||||
];
|
||||
$dataTemp[] = $temp;
|
||||
}
|
||||
|
@ -616,24 +603,23 @@ class HesabdariController extends AbstractController
|
|||
}
|
||||
|
||||
#[Route('/api/accounting/table/get', name: 'app_accounting_table_get')]
|
||||
public function app_accounting_table_get(Jdate $jdate,Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse
|
||||
public function app_accounting_table_get(Jdate $jdate, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
|
||||
$acc = $access->hasRole('accounting');
|
||||
if(!$acc)
|
||||
if (!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
$temp =[];
|
||||
$temp = [];
|
||||
$nodes = $entityManager->getRepository(HesabdariTable::class)->findAll();
|
||||
foreach ($nodes as $node){
|
||||
if($this->hasChild($entityManager,$node)){
|
||||
$temp[$node->getCode()]=[
|
||||
'text'=>$node->getName(),
|
||||
'children'=>$this->getChildsLabel($entityManager,$node)
|
||||
foreach ($nodes as $node) {
|
||||
if ($this->hasChild($entityManager, $node)) {
|
||||
$temp[$node->getCode()] = [
|
||||
'text' => $node->getName(),
|
||||
'children' => $this->getChildsLabel($entityManager, $node)
|
||||
];
|
||||
}
|
||||
else{
|
||||
$temp[$node->getCode()]=[
|
||||
'text'=>$node->getName(),
|
||||
} else {
|
||||
$temp[$node->getCode()] = [
|
||||
'text' => $node->getName(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -641,30 +627,30 @@ class HesabdariController extends AbstractController
|
|||
}
|
||||
|
||||
#[Route('/api/accounting/table/childs/{type}', name: 'app_accounting_table_childs')]
|
||||
public function app_accounting_table_childs(string $type,Jdate $jdate,Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse
|
||||
public function app_accounting_table_childs(string $type, Jdate $jdate, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$acc = $access->hasRole($type);
|
||||
if(!$acc)
|
||||
if (!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
|
||||
if($type == 'cost'){
|
||||
$cost= $entityManager->getRepository(HesabdariTable::class)->findOneBy(['code'=>67]);
|
||||
return $this->json($this->getChilds($entityManager,$cost));
|
||||
}
|
||||
elseif($type == 'income'){
|
||||
$income= $entityManager->getRepository(HesabdariTable::class)->findOneBy(['code'=>56]);
|
||||
return $this->json($this->getChilds($entityManager,$income));
|
||||
if ($type == 'cost') {
|
||||
$cost = $entityManager->getRepository(HesabdariTable::class)->findOneBy(['code' => 67]);
|
||||
return $this->json($this->getChilds($entityManager, $cost));
|
||||
} elseif ($type == 'income') {
|
||||
$income = $entityManager->getRepository(HesabdariTable::class)->findOneBy(['code' => 56]);
|
||||
return $this->json($this->getChilds($entityManager, $income));
|
||||
}
|
||||
|
||||
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
|
||||
'upper' => $node
|
||||
]);
|
||||
$temp = [];
|
||||
foreach ($childs as $child){
|
||||
foreach ($childs as $child) {
|
||||
$temp[] = $child->getCode();
|
||||
}
|
||||
return $temp;
|
||||
|
@ -672,37 +658,35 @@ class HesabdariController extends AbstractController
|
|||
|
||||
private function hasChild(EntityManagerInterface $entityManager, mixed $node)
|
||||
{
|
||||
if(count($entityManager->getRepository(HesabdariTable::class)->findBy([
|
||||
'upper'=>$node
|
||||
]))!= 0)
|
||||
if (count($entityManager->getRepository(HesabdariTable::class)->findBy([
|
||||
'upper' => $node
|
||||
])) != 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private function getChilds(EntityManagerInterface $entityManager, mixed $node){
|
||||
private function getChilds(EntityManagerInterface $entityManager, mixed $node)
|
||||
{
|
||||
$childs = $entityManager->getRepository(HesabdariTable::class)->findBy([
|
||||
'upper'=>$node
|
||||
'upper' => $node
|
||||
]);
|
||||
$temp = [];
|
||||
foreach ($childs as $child){
|
||||
if ($child->getType() == 'calc'){
|
||||
if($this->hasChild($entityManager,$child)){
|
||||
$temp[]=[
|
||||
'id'=>$child->getCode(),
|
||||
'label'=>$child->getName(),
|
||||
'children'=>$this->getChilds($entityManager,$child)
|
||||
foreach ($childs as $child) {
|
||||
if ($child->getType() == 'calc') {
|
||||
if ($this->hasChild($entityManager, $child)) {
|
||||
$temp[] = [
|
||||
'id' => $child->getCode(),
|
||||
'label' => $child->getName(),
|
||||
'children' => $this->getChilds($entityManager, $child)
|
||||
];
|
||||
}
|
||||
else{
|
||||
$temp[]=[
|
||||
'id'=>$child->getCode(),
|
||||
'label'=>$child->getName(),
|
||||
} else {
|
||||
$temp[] = [
|
||||
'id' => $child->getCode(),
|
||||
'label' => $child->getName(),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $temp;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -17,21 +17,21 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||
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
|
||||
public function app_salary_list(Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
//باگ دارد تمام سال مالی برگشت داده می شود
|
||||
if(!$access->hasRole('salary'))
|
||||
if (!$access->hasRole('salary'))
|
||||
throw $this->createAccessDeniedException();
|
||||
$datas = $entityManager->getRepository(Salary::class)->findBy([
|
||||
'bid'=>$request->headers->get('activeBid')
|
||||
'bid' => $request->headers->get('activeBid')
|
||||
]);
|
||||
foreach($datas as $data){
|
||||
foreach ($datas as $data) {
|
||||
$bs = 0;
|
||||
$bd = 0;
|
||||
$items = $entityManager->getRepository(HesabdariRow::class)->findBy([
|
||||
'salary'=>$data
|
||||
'salary' => $data
|
||||
]);
|
||||
foreach ($items as $item){
|
||||
foreach ($items as $item) {
|
||||
$bs += $item->getBs();
|
||||
$bd += $item->getBd();
|
||||
}
|
||||
|
@ -41,49 +41,48 @@ class SalaryController extends AbstractController
|
|||
}
|
||||
|
||||
#[Route('/api/salary/info/{code}', name: 'app_salary_info')]
|
||||
public function app_salary_info($code,Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse
|
||||
public function app_salary_info($code, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$acc = $access->hasRole('salary');
|
||||
if(!$acc)
|
||||
if (!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
$data = $entityManager->getRepository(Salary::class)->findOneBy([
|
||||
'bid'=>$acc['bid'],
|
||||
'code'=>$code
|
||||
'bid' => $acc['bid'],
|
||||
'code' => $code
|
||||
]);
|
||||
return $this->json($data);
|
||||
}
|
||||
|
||||
#[Route('/api/salary/mod/{code}', name: 'app_salary_mod')]
|
||||
public function app_salary_mod(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager,$code = 0): JsonResponse
|
||||
public function app_salary_mod(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager, $code = 0): JsonResponse
|
||||
{
|
||||
$acc = $access->hasRole('salary');
|
||||
if(!$acc)
|
||||
if (!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
$params = json_decode($content, true);
|
||||
}
|
||||
if(!array_key_exists('name',$params))
|
||||
return $this->json(['result'=>-1]);
|
||||
if(count_chars(trim($params['name'])) == 0)
|
||||
return $this->json(['result'=>3]);
|
||||
if($code == 0){
|
||||
if (!array_key_exists('name', $params))
|
||||
return $this->json(['result' => -1]);
|
||||
if (count_chars(trim($params['name'])) == 0)
|
||||
return $this->json(['result' => 3]);
|
||||
if ($code == 0) {
|
||||
$data = $entityManager->getRepository(Salary::class)->findOneBy([
|
||||
'name'=>$params['name'],
|
||||
'bid' =>$acc['bid']
|
||||
'name' => $params['name'],
|
||||
'bid' => $acc['bid']
|
||||
]);
|
||||
//check exist before
|
||||
if($data)
|
||||
return $this->json(['result'=>2]);
|
||||
if ($data)
|
||||
return $this->json(['result' => 2]);
|
||||
$data = new Salary();
|
||||
$data->setCode($provider->getAccountingCode($request->headers->get('activeBid'),'salary'));
|
||||
}
|
||||
else{
|
||||
$data->setCode($provider->getAccountingCode($request->headers->get('activeBid'), 'salary'));
|
||||
} else {
|
||||
$data = $entityManager->getRepository(Salary::class)->findOneBy([
|
||||
'bid'=>$acc['bid'],
|
||||
'code'=>$code
|
||||
'bid' => $acc['bid'],
|
||||
'code' => $code
|
||||
]);
|
||||
if(!$data)
|
||||
if (!$data)
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
$data->setBid($acc['bid']);
|
||||
|
@ -91,7 +90,28 @@ class SalaryController extends AbstractController
|
|||
$data->setDes($params['des']);
|
||||
$entityManager->persist($data);
|
||||
$entityManager->flush();
|
||||
$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]);
|
||||
}
|
||||
|
||||
#[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]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ class SMS
|
|||
private Settings $settings;
|
||||
private registryMGR $registryMGR;
|
||||
|
||||
private int $smsPrice = 2500;
|
||||
private int $smsPrice = 1250;
|
||||
|
||||
/**
|
||||
* @param EntityManagerInterface $entityManager
|
||||
|
|
Loading…
Reference in a new issue