From f85d73e195f6e9b12cd7b0cbeb0b76fba42c33ca Mon Sep 17 00:00:00 2001 From: Babak Alizadeh Date: Sat, 9 Nov 2024 09:40:49 +0000 Subject: [PATCH] start working on pre invoices --- .../src/Controller/AdminController.php | 31 ++++ .../src/Controller/PreinvoiceController.php | 18 ++ .../src/Repository/BusinessRepository.php | 53 ++++-- .../templates/general/repservice.html.twig | 2 +- .../templates/pdf/posPrinters/buy.html.twig | 2 +- .../pdf/posPrinters/cashdesk.html.twig | 2 +- .../pdf/posPrinters/justBuy.html.twig | 2 +- .../pdf/posPrinters/justRfbuy.html.twig | 2 +- .../pdf/posPrinters/justRfsellhtml.twig | 2 +- .../pdf/posPrinters/justSell.html.twig | 2 +- .../templates/pdf/posPrinters/rfbuy.html.twig | 2 +- .../pdf/posPrinters/rfsell.html.twig | 2 +- .../templates/pdf/posPrinters/sell.html.twig | 2 +- .../templates/preinvoice/index.html.twig | 20 +++ .../templates/shortlinks/sell.html.twig | 170 +++++++++--------- 15 files changed, 200 insertions(+), 112 deletions(-) create mode 100644 hesabixCore/src/Controller/PreinvoiceController.php create mode 100644 hesabixCore/templates/preinvoice/index.html.twig diff --git a/hesabixCore/src/Controller/AdminController.php b/hesabixCore/src/Controller/AdminController.php index 4754c2f..dc4dafc 100644 --- a/hesabixCore/src/Controller/AdminController.php +++ b/hesabixCore/src/Controller/AdminController.php @@ -147,6 +147,37 @@ class AdminController extends AbstractController return $this->json($resp); } + #[Route('/api/admin/business/count', name: 'admin_business_count')] + public function admin_business_count(Jdate $jdate, #[CurrentUser] ?User $user, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, Request $request): Response + { + return $this->json($entityManager->getRepository(Business::class)->countAll()); + } + + #[Route('/api/admin/business/search', name: 'admin_business_list_search')] + public function admin_business_list_search(Jdate $jdate, #[CurrentUser] ?User $user, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, Request $request): Response + { + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + $items = $entityManager->getRepository(Business::class)->findByPage($params['options']['page'],$params['options']['rowsPerPage'],$params['search']); + $resp = []; + foreach ($items as $item) { + $temp = []; + $temp['id'] = $item->getId(); + $temp['name'] = $item->getName(); + $temp['owner'] = $item->getOwner()->getFullName(); + $temp['ownerMobile'] = $item->getOwner()->getMobile(); + $temp['dateRegister'] = $jdate->jdate('Y/n/d', $item->getDateSubmit()); + $temp['commodityCount'] = count($entityManager->getRepository(Commodity::class)->findBy(['bid' => $item])); + $temp['personsCount'] = count($entityManager->getRepository(Person::class)->findBy(['bid' => $item])); + $temp['hesabdariDocsCount'] = count($entityManager->getRepository(HesabdariDoc::class)->findBy(['bid' => $item])); + $temp['StoreroomDocsCount'] = count($entityManager->getRepository(StoreroomTicket::class)->findBy(['bid' => $item])); + $resp[] = $temp; + } + return $this->json($resp); + } + #[Route('/api/admin/settings/sms/info', name: 'admin_settings_sms_info')] public function admin_settings_sms_info(Jdate $jdate, #[CurrentUser] ?User $user, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, Request $request): Response { diff --git a/hesabixCore/src/Controller/PreinvoiceController.php b/hesabixCore/src/Controller/PreinvoiceController.php new file mode 100644 index 0000000..fb06ea9 --- /dev/null +++ b/hesabixCore/src/Controller/PreinvoiceController.php @@ -0,0 +1,18 @@ +render('preinvoice/index.html.twig', [ + 'controller_name' => 'PreinvoiceController', + ]); + } +} diff --git a/hesabixCore/src/Repository/BusinessRepository.php b/hesabixCore/src/Repository/BusinessRepository.php index fe93f4c..d7c6b94 100644 --- a/hesabixCore/src/Repository/BusinessRepository.php +++ b/hesabixCore/src/Repository/BusinessRepository.php @@ -39,22 +39,36 @@ class BusinessRepository extends ServiceEntityRepository } } -// /** -// * @return Business[] Returns an array of Business objects -// */ -// public function findByExampleField($value): array -// { -// return $this->createQueryBuilder('b') -// ->andWhere('b.exampleField = :val') -// ->setParameter('val', $value) -// ->orderBy('b.id', 'ASC') -// ->setMaxResults(10) -// ->getQuery() -// ->getResult() -// ; -// } + /** + * @return Business[] Returns an array of Business objects + */ + public function findByPage($page = 0, $take = 25, $search = ''): array + { + $query = $this->createQueryBuilder('b') + ->setFirstResult($page * $take) + ->orderBy('b.id', 'DESC') + ->setMaxResults($take); + + if ($search != '') { + $query->andWhere("b.name LIKE :search") + ->setParameter('search', '%' . $search . '%'); + } + return $query->getQuery()->getResult(); + } -// public function findOneBySomeField($value): ?Business + /** + * @return integer Returns an integer of Business objects + */ + public function countAll(): int + { + return $this->createQueryBuilder('b') + ->select('count(b.id)') + ->getQuery() + ->getSingleScalarResult() + ; + } + + // public function findOneBySomeField($value): ?Business // { // return $this->createQueryBuilder('b') // ->andWhere('b.exampleField = :val') @@ -64,14 +78,15 @@ class BusinessRepository extends ServiceEntityRepository // ; // } - public function findLast(){ - $res = $this->createQueryBuilder('p') + public function findLast() + { + $res = $this->createQueryBuilder('p') ->orderBy('p.id', 'ASC') ->getQuery() ->getResult() ; - if(count($res) > 0) - return $res[count($res) -1]; + if (count($res) > 0) + return $res[count($res) - 1]; return null; } } diff --git a/hesabixCore/templates/general/repservice.html.twig b/hesabixCore/templates/general/repservice.html.twig index dcff379..5d073e1 100644 --- a/hesabixCore/templates/general/repservice.html.twig +++ b/hesabixCore/templates/general/repservice.html.twig @@ -74,7 +74,7 @@ مشاهده لیست دستگاه های تعمیری
  • - درج سریال/پلاک دستگاه های تعمیری درقبض پذیرش + درج س{{doc.money.shortName}}/پلاک دستگاه های تعمیری درقبض پذیرش
  • ارسال پیامک خودکار هنگام تغییر وضعیت دستگاه به آماده تحویل diff --git a/hesabixCore/templates/pdf/posPrinters/buy.html.twig b/hesabixCore/templates/pdf/posPrinters/buy.html.twig index b48e835..4dadc8c 100644 --- a/hesabixCore/templates/pdf/posPrinters/buy.html.twig +++ b/hesabixCore/templates/pdf/posPrinters/buy.html.twig @@ -96,7 +96,7 @@ text-align: right; } .total.price::after { - content: " ریال "; + content: " {{doc.money.shortName}} "; } .line { border-top: 1px solid black !important; diff --git a/hesabixCore/templates/pdf/posPrinters/cashdesk.html.twig b/hesabixCore/templates/pdf/posPrinters/cashdesk.html.twig index 4a4082e..a1905cf 100644 --- a/hesabixCore/templates/pdf/posPrinters/cashdesk.html.twig +++ b/hesabixCore/templates/pdf/posPrinters/cashdesk.html.twig @@ -98,7 +98,7 @@ text-align: right; } .total.price::after { - content: " ریال "; + content: " {{doc.money.shortName}} "; } .line { border-top: 1px solid black !important; diff --git a/hesabixCore/templates/pdf/posPrinters/justBuy.html.twig b/hesabixCore/templates/pdf/posPrinters/justBuy.html.twig index 1e3dc83..f7add2d 100644 --- a/hesabixCore/templates/pdf/posPrinters/justBuy.html.twig +++ b/hesabixCore/templates/pdf/posPrinters/justBuy.html.twig @@ -98,7 +98,7 @@ text-align: right; } .total.price::after { - content: " ریال "; + content: " {{doc.money.shortName}} "; } .line { border-top: 1px solid black !important; diff --git a/hesabixCore/templates/pdf/posPrinters/justRfbuy.html.twig b/hesabixCore/templates/pdf/posPrinters/justRfbuy.html.twig index 3c639da..7177fdf 100644 --- a/hesabixCore/templates/pdf/posPrinters/justRfbuy.html.twig +++ b/hesabixCore/templates/pdf/posPrinters/justRfbuy.html.twig @@ -98,7 +98,7 @@ text-align: right; } .total.price::after { - content: " ریال "; + content: " {{doc.money.shortName}} "; } .line { border-top: 1px solid black !important; diff --git a/hesabixCore/templates/pdf/posPrinters/justRfsellhtml.twig b/hesabixCore/templates/pdf/posPrinters/justRfsellhtml.twig index 3c639da..7177fdf 100644 --- a/hesabixCore/templates/pdf/posPrinters/justRfsellhtml.twig +++ b/hesabixCore/templates/pdf/posPrinters/justRfsellhtml.twig @@ -98,7 +98,7 @@ text-align: right; } .total.price::after { - content: " ریال "; + content: " {{doc.money.shortName}} "; } .line { border-top: 1px solid black !important; diff --git a/hesabixCore/templates/pdf/posPrinters/justSell.html.twig b/hesabixCore/templates/pdf/posPrinters/justSell.html.twig index 79fad43..ec1590b 100644 --- a/hesabixCore/templates/pdf/posPrinters/justSell.html.twig +++ b/hesabixCore/templates/pdf/posPrinters/justSell.html.twig @@ -98,7 +98,7 @@ text-align: right; } .total.price::after { - content: " ریال "; + content: " {{doc.money.shortName}} "; } .line { border-top: 1px solid black !important; diff --git a/hesabixCore/templates/pdf/posPrinters/rfbuy.html.twig b/hesabixCore/templates/pdf/posPrinters/rfbuy.html.twig index b48e835..4dadc8c 100644 --- a/hesabixCore/templates/pdf/posPrinters/rfbuy.html.twig +++ b/hesabixCore/templates/pdf/posPrinters/rfbuy.html.twig @@ -96,7 +96,7 @@ text-align: right; } .total.price::after { - content: " ریال "; + content: " {{doc.money.shortName}} "; } .line { border-top: 1px solid black !important; diff --git a/hesabixCore/templates/pdf/posPrinters/rfsell.html.twig b/hesabixCore/templates/pdf/posPrinters/rfsell.html.twig index b48e835..4dadc8c 100644 --- a/hesabixCore/templates/pdf/posPrinters/rfsell.html.twig +++ b/hesabixCore/templates/pdf/posPrinters/rfsell.html.twig @@ -96,7 +96,7 @@ text-align: right; } .total.price::after { - content: " ریال "; + content: " {{doc.money.shortName}} "; } .line { border-top: 1px solid black !important; diff --git a/hesabixCore/templates/pdf/posPrinters/sell.html.twig b/hesabixCore/templates/pdf/posPrinters/sell.html.twig index b48e835..4dadc8c 100644 --- a/hesabixCore/templates/pdf/posPrinters/sell.html.twig +++ b/hesabixCore/templates/pdf/posPrinters/sell.html.twig @@ -96,7 +96,7 @@ text-align: right; } .total.price::after { - content: " ریال "; + content: " {{doc.money.shortName}} "; } .line { border-top: 1px solid black !important; diff --git a/hesabixCore/templates/preinvoice/index.html.twig b/hesabixCore/templates/preinvoice/index.html.twig new file mode 100644 index 0000000..d87be34 --- /dev/null +++ b/hesabixCore/templates/preinvoice/index.html.twig @@ -0,0 +1,20 @@ +{% extends 'base.html.twig' %} + +{% block title %}Hello PreinvoiceController!{% endblock %} + +{% block body %} + + +
    +

    Hello {{ controller_name }}! ✅

    + + This friendly message is coming from: +
      +
    • Your controller at /var/www/next.hesabix.ir/hesabixCore/src/Controller/PreinvoiceController.php
    • +
    • Your template at /var/www/next.hesabix.ir/hesabixCore/templates/preinvoice/index.html.twig
    • +
    +
    +{% endblock %} diff --git a/hesabixCore/templates/shortlinks/sell.html.twig b/hesabixCore/templates/shortlinks/sell.html.twig index 9c3c2a2..1a1bfc1 100644 --- a/hesabixCore/templates/shortlinks/sell.html.twig +++ b/hesabixCore/templates/shortlinks/sell.html.twig @@ -31,31 +31,32 @@ {{doc.code}} -
    +
    - + چاپ فاکتور - {% if (totalPays < doc.amount) and bid.walletEnable %} + {% if (totalPays < doc.amount) and bid.walletEnable and doc.money.name == 'IRR' %} پرداخت آنلاین مبلغ {{ (doc.amount - totalPays) | number_format }} - ریال + {{doc.money.shortName}} {% endif %}
    {% if msg == 'success' %} - + {% elseif msg == 'fail' %} {% endif %} -
    +
    @@ -77,7 +79,7 @@ {{bid.name}}

    آدرس : - استان + استان {{bid.ostan}} شهرستان {{bid.shahrestan}} @@ -105,7 +107,7 @@ {{ person.nikename }}

    آدرس : - استان + استان {{person.ostan}} شهرستان {{person.shahr}} @@ -132,54 +134,54 @@
    - - - - - - - - - - - - - - {% set taxAll = 0 %} - {% set rowIndex = 0 %} - {% for item in rows%} - {% if item.commodity %} - {% set taxAll = taxAll + item.tax %} - {% set rowIndex = rowIndex + 1 %} - - - - - - - - - - - {% endif %} - {% endfor %} - + + + + + + + + + + + + + + {% set taxAll = 0 %} + {% set rowIndex = 0 %} + {% for item in rows%} + {% if item.commodity %} + {% set taxAll = taxAll + item.tax %} + {% set rowIndex = rowIndex + 1 %} + + + + + + + + + + + {% endif %} + {% endfor %} +
    ردیفکالا/خدماتشرحتعداد / مقدارمبلغ واحدتخفیفمالیاتمبلغ کل
    {{rowIndex}} - {{ item.commodity.code }} - - - {{ item.commodity.name }}{{ item.des }} - {{ item.commdityCount }} - {{ item.commodity.unit.name }} - {{ ((item.bs - item.tax + item.discount) / item.commdityCount) | number_format }}{{ item.discount | number_format }}{{ item.tax | number_format}}{{ item.bs| number_format }}
    ردیفکالا/خدماتشرحتعداد / مقدارمبلغ واحدتخفیفمالیاتمبلغ کل
    {{rowIndex}} + {{ item.commodity.code }} + - + {{ item.commodity.name }}{{ item.des }} + {{ item.commdityCount }} + {{ item.commodity.unit.name }} + {{ ((item.bs - item.tax + item.discount) / item.commdityCount) | number_format }}{{ item.discount | number_format }}{{ item.tax | number_format}}{{ item.bs| number_format }}
    - جمع کل فاکتور: - {{ doc.amount | number_format }} + جمع کل فاکتور: + {{ doc.amount | number_format }}
    - توضیحات: - {{ doc.des }} + توضیحات: + {{ doc.des }}
    @@ -199,36 +201,38 @@
    - - - - - - - - + + + + + + + + - {% for item in doc.relatedDocs %} - - - {% if item.type == 'walletPay' %} - - {% else %} - - {% endif %} - - - - + {% for item in doc.relatedDocs %} + + + {% if item.type == 'walletPay' %} + + {% else %} + + {% endif %} + + + + + + {% endfor %} + + + - {% endfor %} - - - -
    ردیفروش پرداختتاریخمبلغشماره پیگیری/سندتوضیحات
    ردیفروش پرداختتاریخمبلغشماره پیگیری/سندتوضیحات
    {{ loop.index }}پرداخت آنلاینسند حسابداری{{ item.date}}{{ item.amount | number_format }}{{ item.code }}{{ item.des }}
    {{ loop.index }} + پرداخت آنلاین + سند حسابداری{{ item.date}}{{ item.amount | number_format }}{{ item.code }}{{ item.des }}
    جمع کل{{ totalPays | number_format }} + {{doc.money.shortName}} +
    جمع کل{{ totalPays | number_format }} - ریال -