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 %}
شماره ثبت: - {{ 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 %}
کد پستی: - {{ 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 %}
شناسه ملی: - {{ 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 %}
کد پستی: - {{ 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 %}