diff --git a/hesabixCore/src/Controller/SellController.php b/hesabixCore/src/Controller/SellController.php index 5e57227..42e913e 100644 --- a/hesabixCore/src/Controller/SellController.php +++ b/hesabixCore/src/Controller/SellController.php @@ -759,6 +759,23 @@ class SellController extends AbstractController } } $pdfPid = 0; + + // فیلد جدید وضعیت حساب مشتری + $personItems = $entityManager->getRepository(HesabdariRow::class)->findBy(['bid' => $acc['bid'], 'person' => $person]); + $accountStatus = []; + $bs = 0; + $bd = 0; + foreach ($personItems as $item) { + $bs += $item->getBs(); + $bd += $item->getBd(); + } + if ($bs > $bd) { + $accountStatus['label'] = 'بستانکار'; + $accountStatus['value'] = $bs - $bd; + } else { + $accountStatus['label'] = 'بدهکار'; + $accountStatus['value'] = $bd - $bs; + } if ($params['pdf'] == true || $params['printers'] == true) { $note = ''; if ($printSettings) { @@ -768,6 +785,7 @@ class SellController extends AbstractController $acc['bid'], $this->getUser(), $this->renderView('pdf/printers/sell.html.twig', [ + 'accountStatus' => $accountStatus, 'bid' => $acc['bid'], 'doc' => $doc, 'rows' => array_map(function ($row) { @@ -1221,10 +1239,10 @@ class SellController extends AbstractController 'result' => 1, 'message' => 'فاکتور با موفقیت ثبت شد', 'data' => [ - 'id' => $doc->getCode(), - 'code' => $doc->getCode(), - 'shortlink' => $doc->getShortlink() - ] + 'id' => $doc->getCode(), + 'code' => $doc->getCode(), + 'shortlink' => $doc->getShortlink() + ] ]); } catch (\Exception $e) { diff --git a/hesabixCore/templates/pdf/printers/sell.html.twig b/hesabixCore/templates/pdf/printers/sell.html.twig index 0b85e62..c3c12ab 100644 --- a/hesabixCore/templates/pdf/printers/sell.html.twig +++ b/hesabixCore/templates/pdf/printers/sell.html.twig @@ -70,7 +70,7 @@

نام: - {{ bid.legalName }} + {% if bid.legalName is not empty %}{{ bid.legalName }}{% endif %}

@@ -78,27 +78,27 @@ شناسه ملی: - {{ bid.shenasemeli }} + {% if bid.shenasemeli is not empty %}{{ bid.shenasemeli }}{% endif %}

شماره ثبت: - {{ bid.shomaresabt }} + {% if bid.shomaresabt is not empty %}{{ bid.shomaresabt }}{% endif %}

شماره اقتصادی: - {{ bid.codeeghtesadi }} + {% if bid.codeeghtesadi is not empty %}{{ bid.codeeghtesadi }}{% endif %}

تلفن / نمابر: - {{ bid.tel }} + {% if bid.tel is not empty %}{{ bid.tel }}{% endif %}

@@ -106,17 +106,14 @@

کد پستی: - {{ bid.postalcode }} + {% if bid.postalcode is not empty %}{{ bid.postalcode }}{% endif %}

آدرس: - استان - {{ bid.ostan }}، شهر - {{ bid.shahrestan }}، - {{ bid.address }} + {% if bid.ostan is not empty %}استان {{ bid.ostan }}{% endif %}{% if bid.shahrestan is not empty %}، شهر {{ bid.shahrestan }}{% endif %}{% if bid.address is not empty %}، {{ bid.address }}{% endif %}

@@ -138,34 +135,34 @@ نام: {% if person.prelabel is not null %}{{ person.prelabel.label }}{% endif %} - {{ person.nikename }} + {% if person.nikename is not empty %}{{ person.nikename }}{% endif %}

شناسه ملی: - {{ person.shenasemeli }} + {% if person.shenasemeli is not empty %}{{ person.shenasemeli }}{% endif %}

شماره ثبت: - {{ person.sabt }} + {% if person.sabt is not empty %}{{ person.sabt }}{% endif %}

شماره اقتصادی: - {{ person.codeeghtesadi }} + {% if person.codeeghtesadi is not empty %}{{ person.codeeghtesadi }}{% endif %}

تلفن / نمابر: - {{ person.tel }} + {% if person.tel is not empty %}{{ person.tel }}{% endif %}

@@ -173,17 +170,14 @@

کد پستی: - {{ person.postalcode }} + {% if person.postalcode is not empty %}{{ person.postalcode }}{% endif %}

آدرس: - استان - {{ person.ostan }}، شهر - {{ person.shahr }}، - {{ person.address }} + {% if person.ostan is not empty %}استان {{ person.ostan }}{% endif %}{% if person.shahr is not empty %}، شهر {{ person.shahr }}{% endif %}{% if person.address is not empty %}، {{ person.address }}{% endif %}

@@ -310,6 +304,17 @@ {% endif %} + {# فیلد جدید وضعیت حساب مشتری #} + {% if accountStatus is defined %} +

+ وضعیت حساب مشتری با احتساب این فاکتور: + {{ accountStatus.value | number_format}} + {{ doc.money.shortName }} + {{ accountStatus.label }} + +

+ + {% endif %}