start working on pre invoices

This commit is contained in:
Hesabix 2024-11-09 09:40:49 +00:00
parent a106075b25
commit f85d73e195
15 changed files with 200 additions and 112 deletions

View file

@ -147,6 +147,37 @@ class AdminController extends AbstractController
return $this->json($resp); 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')] #[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 public function admin_settings_sms_info(Jdate $jdate, #[CurrentUser] ?User $user, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, Request $request): Response
{ {

View file

@ -0,0 +1,18 @@
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class PreinvoiceController extends AbstractController
{
#[Route('/preinvoice', name: 'app_preinvoice')]
public function index(): Response
{
return $this->render('preinvoice/index.html.twig', [
'controller_name' => 'PreinvoiceController',
]);
}
}

View file

@ -39,22 +39,36 @@ class BusinessRepository extends ServiceEntityRepository
} }
} }
// /** /**
// * @return Business[] Returns an array of Business objects * @return Business[] Returns an array of Business objects
// */ */
// public function findByExampleField($value): array public function findByPage($page = 0, $take = 25, $search = ''): array
// { {
// return $this->createQueryBuilder('b') $query = $this->createQueryBuilder('b')
// ->andWhere('b.exampleField = :val') ->setFirstResult($page * $take)
// ->setParameter('val', $value) ->orderBy('b.id', 'DESC')
// ->orderBy('b.id', 'ASC') ->setMaxResults($take);
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?Business if ($search != '') {
$query->andWhere("b.name LIKE :search")
->setParameter('search', '%' . $search . '%');
}
return $query->getQuery()->getResult();
}
/**
* @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') // return $this->createQueryBuilder('b')
// ->andWhere('b.exampleField = :val') // ->andWhere('b.exampleField = :val')
@ -64,14 +78,15 @@ class BusinessRepository extends ServiceEntityRepository
// ; // ;
// } // }
public function findLast(){ public function findLast()
$res = $this->createQueryBuilder('p') {
$res = $this->createQueryBuilder('p')
->orderBy('p.id', 'ASC') ->orderBy('p.id', 'ASC')
->getQuery() ->getQuery()
->getResult() ->getResult()
; ;
if(count($res) > 0) if (count($res) > 0)
return $res[count($res) -1]; return $res[count($res) - 1];
return null; return null;
} }
} }

View file

@ -74,7 +74,7 @@
مشاهده لیست دستگاه های تعمیری مشاهده لیست دستگاه های تعمیری
</li> </li>
<li> <li>
درج سریال/پلاک دستگاه های تعمیری درقبض پذیرش درج س{{doc.money.shortName}}/پلاک دستگاه های تعمیری درقبض پذیرش
</li> </li>
<li> <li>
ارسال پیامک خودکار هنگام تغییر وضعیت دستگاه به آماده تحویل ارسال پیامک خودکار هنگام تغییر وضعیت دستگاه به آماده تحویل

View file

@ -96,7 +96,7 @@
text-align: right; text-align: right;
} }
.total.price::after { .total.price::after {
content: " ریال "; content: " {{doc.money.shortName}} ";
} }
.line { .line {
border-top: 1px solid black !important; border-top: 1px solid black !important;

View file

@ -98,7 +98,7 @@
text-align: right; text-align: right;
} }
.total.price::after { .total.price::after {
content: " ریال "; content: " {{doc.money.shortName}} ";
} }
.line { .line {
border-top: 1px solid black !important; border-top: 1px solid black !important;

View file

@ -98,7 +98,7 @@
text-align: right; text-align: right;
} }
.total.price::after { .total.price::after {
content: " ریال "; content: " {{doc.money.shortName}} ";
} }
.line { .line {
border-top: 1px solid black !important; border-top: 1px solid black !important;

View file

@ -98,7 +98,7 @@
text-align: right; text-align: right;
} }
.total.price::after { .total.price::after {
content: " ریال "; content: " {{doc.money.shortName}} ";
} }
.line { .line {
border-top: 1px solid black !important; border-top: 1px solid black !important;

View file

@ -98,7 +98,7 @@
text-align: right; text-align: right;
} }
.total.price::after { .total.price::after {
content: " ریال "; content: " {{doc.money.shortName}} ";
} }
.line { .line {
border-top: 1px solid black !important; border-top: 1px solid black !important;

View file

@ -98,7 +98,7 @@
text-align: right; text-align: right;
} }
.total.price::after { .total.price::after {
content: " ریال "; content: " {{doc.money.shortName}} ";
} }
.line { .line {
border-top: 1px solid black !important; border-top: 1px solid black !important;

View file

@ -96,7 +96,7 @@
text-align: right; text-align: right;
} }
.total.price::after { .total.price::after {
content: " ریال "; content: " {{doc.money.shortName}} ";
} }
.line { .line {
border-top: 1px solid black !important; border-top: 1px solid black !important;

View file

@ -96,7 +96,7 @@
text-align: right; text-align: right;
} }
.total.price::after { .total.price::after {
content: " ریال "; content: " {{doc.money.shortName}} ";
} }
.line { .line {
border-top: 1px solid black !important; border-top: 1px solid black !important;

View file

@ -96,7 +96,7 @@
text-align: right; text-align: right;
} }
.total.price::after { .total.price::after {
content: " ریال "; content: " {{doc.money.shortName}} ";
} }
.line { .line {
border-top: 1px solid black !important; border-top: 1px solid black !important;

View file

@ -0,0 +1,20 @@
{% extends 'base.html.twig' %}
{% block title %}Hello PreinvoiceController!{% endblock %}
{% block body %}
<style>
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
</style>
<div class="example-wrapper">
<h1>Hello {{ controller_name }}! ✅</h1>
This friendly message is coming from:
<ul>
<li>Your controller at <code>/var/www/next.hesabix.ir/hesabixCore/src/Controller/PreinvoiceController.php</code></li>
<li>Your template at <code>/var/www/next.hesabix.ir/hesabixCore/templates/preinvoice/index.html.twig</code></li>
</ul>
</div>
{% endblock %}

View file

@ -31,31 +31,32 @@
{{doc.code}} {{doc.code}}
</span> </span>
</h3> </h3>
<div class="block-options"> <div
class="block-options">
<!-- Print Page functionality is initialized dmPrint() --> <!-- Print Page functionality is initialized dmPrint() -->
<a class="btn btn-sm btn-alt-secondary me-3" type="button" target="_blank" href="{{path('shortlinks_pdf',{bid:bid.id,link:link})}}"> <a class="btn btn-sm btn-alt-secondary me-3" type="button" target="_blank" href="{{path('shortlinks_pdf',{bid:bid.id,link:link})}}">
<i class="si si-printer me-1"></i> <i class="si si-printer me-1"></i>
چاپ فاکتور چاپ فاکتور
</a> </a>
{% if (totalPays < doc.amount) and bid.walletEnable %} {% if (totalPays < doc.amount) and bid.walletEnable and doc.money.name == 'IRR' %}
<a href="{{ path('pay_sell',{'id':doc.id}) }}" class="btn btn-sm btn-success"> <a href="{{ path('pay_sell',{'id':doc.id}) }}" class="btn btn-sm btn-success">
<i class="fa fa-credit-card"></i> <i class="fa fa-credit-card"></i>
پرداخت آنلاین مبلغ پرداخت آنلاین مبلغ
{{ (doc.amount - totalPays) | number_format }} {{ (doc.amount - totalPays) | number_format }}
ریال {{doc.money.shortName}}
</a> </a>
{% endif %} {% endif %}
</div> </div>
</div> </div>
<div class="block-content"> <div class="block-content">
{% if msg == 'success' %} {% if msg == 'success' %}
<div class="alert alert-success alert-dismissible" role="alert"> <div class="alert alert-success alert-dismissible" role="alert">
<h3 class="alert-heading fs-4 my-2"> <h3 class="alert-heading fs-4 my-2">
<i class="fa fa-check"></i> <i class="fa fa-check"></i>
نتیجه پرداخت آنلاین</h3> نتیجه پرداخت آنلاین</h3>
<button aria-label="Close" class="btn-close" data-bs-dismiss="alert" type="button"></button> <button aria-label="Close" class="btn-close" data-bs-dismiss="alert" type="button"></button>
<p class="mb-0">پرداخت فاکتور با موفقیت انجام شد. هم‌اکنون می‌توانید شماره پیگیری را از بخش پرداخت‌ها مشاهده نمایید</p> <p class="mb-0">پرداخت فاکتور با موفقیت انجام شد. هم‌اکنون می‌توانید شماره پیگیری را از بخش پرداخت‌ها مشاهده نمایید</p>
</div> </div>
{% elseif msg == 'fail' %} {% elseif msg == 'fail' %}
<div class="alert alert-danger alert-dismissible" role="alert"> <div class="alert alert-danger alert-dismissible" role="alert">
<h3 class="alert-heading fs-4 my-2"> <h3 class="alert-heading fs-4 my-2">
@ -65,7 +66,8 @@
<p class="mb-0">پرداخت فاکتور ناموفق بود. برای پرداخت مجدد می‌توانید دوباره سعی نمایید.</p> <p class="mb-0">پرداخت فاکتور ناموفق بود. برای پرداخت مجدد می‌توانید دوباره سعی نمایید.</p>
</div> </div>
{% endif %} {% endif %}
<div class="p-sm-2 p-xl-1"> <div
class="p-sm-2 p-xl-1">
<!-- Invoice Info --> <!-- Invoice Info -->
<div <div
class="row mb-5"> class="row mb-5">
@ -77,7 +79,7 @@
{{bid.name}} {{bid.name}}
</p> </p>
<address>آدرس : <address>آدرس :
استان استان
{{bid.ostan}} {{bid.ostan}}
شهرستان شهرستان
{{bid.shahrestan}} {{bid.shahrestan}}
@ -105,7 +107,7 @@
{{ person.nikename }} {{ person.nikename }}
</p> </p>
<address>آدرس : <address>آدرس :
استان استان
{{person.ostan}} {{person.ostan}}
شهرستان شهرستان
{{person.shahr}} {{person.shahr}}
@ -132,54 +134,54 @@
<!-- Table --> <!-- Table -->
<div class="table-responsive push text-center"> <div class="table-responsive push text-center">
<table class="table table-bordered"> <table class="table table-bordered">
<thead> <thead>
<tr class="bg-body"> <tr class="bg-body">
<th class="text-dark">ردیف</th> <th class="text-dark">ردیف</th>
<th class="text-dark">کالا/خدمات</th> <th class="text-dark">کالا/خدمات</th>
<th class="text-dark">شرح</th> <th class="text-dark">شرح</th>
<th class="text-dark">تعداد / مقدار</th> <th class="text-dark">تعداد / مقدار</th>
<th class="text-dark">مبلغ واحد</th> <th class="text-dark">مبلغ واحد</th>
<th class="text-dark">تخفیف</th> <th class="text-dark">تخفیف</th>
<th class="text-dark">مالیات</th> <th class="text-dark">مالیات</th>
<th class="text-dark">مبلغ کل</th> <th class="text-dark">مبلغ کل</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% set taxAll = 0 %} {% set taxAll = 0 %}
{% set rowIndex = 0 %} {% set rowIndex = 0 %}
{% for item in rows%} {% for item in rows%}
{% if item.commodity %} {% if item.commodity %}
{% set taxAll = taxAll + item.tax %} {% set taxAll = taxAll + item.tax %}
{% set rowIndex = rowIndex + 1 %} {% set rowIndex = rowIndex + 1 %}
<tr> <tr>
<td >{{rowIndex}}</td> <td>{{rowIndex}}</td>
<td > <td>
{{ item.commodity.code }} {{ item.commodity.code }}
- -
{{ item.commodity.name }}</td> {{ item.commodity.name }}</td>
<td >{{ item.des }}</td> <td>{{ item.des }}</td>
<td > <td>
{{ item.commdityCount }} {{ item.commdityCount }}
{{ item.commodity.unit.name }} {{ item.commodity.unit.name }}
</td> </td>
<td >{{ ((item.bs - item.tax + item.discount) / item.commdityCount) | number_format }}</td> <td>{{ ((item.bs - item.tax + item.discount) / item.commdityCount) | number_format }}</td>
<td >{{ item.discount | number_format }}</td> <td>{{ item.discount | number_format }}</td>
<td >{{ item.tax | number_format}}</td> <td>{{ item.tax | number_format}}</td>
<td >{{ item.bs| number_format }}</td> <td>{{ item.bs| number_format }}</td>
</tr> </tr>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</div> </div>
<!-- END Table --> <!-- END Table -->
<div class="block block-rounded"> <div class="block block-rounded">
جمع کل فاکتور: جمع کل فاکتور:
{{ doc.amount | number_format }} {{ doc.amount | number_format }}
</div> </div>
<div class="block block-rounded"> <div class="block block-rounded">
توضیحات: توضیحات:
{{ doc.des }} {{ doc.des }}
</div> </div>
<div class="block block-rounded"> <div class="block block-rounded">
<div class="block-header block-header-default"> <div class="block-header block-header-default">
@ -199,36 +201,38 @@
<div class="table-responsive push text-center"> <div class="table-responsive push text-center">
<table class="table table-bordered"> <table class="table table-bordered">
<thead class="bg-body"> <thead class="bg-body">
<tr> <tr>
<th class="text-center" style="width: 60px;">ردیف</th> <th class="text-center" style="width: 60px;">ردیف</th>
<th>روش پرداخت</th> <th>روش پرداخت</th>
<th>تاریخ</th> <th>تاریخ</th>
<th class="text-center">مبلغ</th> <th class="text-center">مبلغ</th>
<th class="text-center">شماره پیگیری/سند</th> <th class="text-center">شماره پیگیری/سند</th>
<th class="text-center">توضیحات</th> <th class="text-center">توضیحات</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for item in doc.relatedDocs %} {% for item in doc.relatedDocs %}
<tr> <tr>
<td>{{ loop.index }}</td> <td>{{ loop.index }}</td>
{% if item.type == 'walletPay' %} {% if item.type == 'walletPay' %}
<td class="text-success"><i class="fa fa-wallet"></i>پرداخت آنلاین</td> <td class="text-success">
{% else %} <i class="fa fa-wallet"></i>پرداخت آنلاین</td>
<td class="text-primary"><i class="fa fa-file"></i>سند حسابداری</td> {% else %}
{% endif %} <td class="text-primary">
<td>{{ item.date}}</td> <i class="fa fa-file"></i>سند حسابداری</td>
<td>{{ item.amount | number_format }}</td> {% endif %}
<td>{{ item.code }}</td> <td>{{ item.date}}</td>
<td>{{ item.des }}</td> <td>{{ item.amount | number_format }}</td>
<td>{{ item.code }}</td>
<td>{{ item.des }}</td>
</tr>
{% endfor %}
<tr class="">
<td class="fw-bold text-uppercase text-end bg-body-light" colspan="5">جمع کل</td>
<td class="fw-bold text-end bg-body-light">{{ totalPays | number_format }}
{{doc.money.shortName}}
</td>
</tr> </tr>
{% endfor %}
<tr class="">
<td class="fw-bold text-uppercase text-end bg-body-light" colspan="5">جمع کل</td>
<td class="fw-bold text-end bg-body-light">{{ totalPays | number_format }}
ریال
</td>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>