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);
}
#[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
{

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
// */
// 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;
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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