credit note

This commit is contained in:
edmondlang
2023-08-01 01:46:46 +08:00
parent a21ac646e2
commit 6357c7ef9f
2 changed files with 59 additions and 4 deletions
@@ -9,6 +9,7 @@ use Illuminate\Support\Facades\DB;
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
use App\Classes\Modules\Companies\Services\FetchesCompany;
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
use App\Classes\ValueObjects\Constants\TransactionType;
class GenerateCreditNotePdfLogic
{
@@ -16,17 +17,22 @@ class GenerateCreditNotePdfLogic
/** @var FetchesTransaction */
private $fetchesTransaction;
/** @var FetchesCompany */
private $fetchesCompany;
/** @var CreateSupplierTransactionProcessor */
private $createSupplierTransactionProcessor;
/**
* DownloadMockUpWhiteFormPdfLogic constructor.
* GenerateCreditNotePdfLogic constructor.
* @param FetchesTransaction $fetchesTransaction
* @param FetchesCompany $fetchesCompany
* @param CreateSupplierTransactionProcessor $createSupplierTransactionProcessor
*/
public function __construct(FetchesTransaction $fetchesTransaction, CreateSupplierTransactionProcessor $createSupplierTransactionProcessor)
public function __construct(FetchesTransaction $fetchesTransaction, FetchesCompany $fetchesCompany, CreateSupplierTransactionProcessor $createSupplierTransactionProcessor)
{
$this->fetchesTransaction = $fetchesTransaction;
$this->fetchesCompany = $fetchesCompany;
$this->createSupplierTransactionProcessor = $createSupplierTransactionProcessor;
}
@@ -39,7 +45,14 @@ class GenerateCreditNotePdfLogic
{
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
$pdf = LaravelMpdf::loadView('pages.pdfs.credit_note', ['transaction' => $transaction]);
$purchaseOrder = $transaction->owner()->transactions()
->where('type', TransactionType::PURCHASE_ORDER)
->complete()
->first();
$supplier = $this->fetchesCompany->execute(['id' => $transaction->receiver]);
$pdf = LaravelMpdf::loadView('pages.pdfs.credit_note', ['transaction' => $transaction, 'po_order_transaction' => $purchaseOrder, 'supplier' => $supplier]);
return $pdf->stream('MockUpWhiteForm.pdf');
}
@@ -22,7 +22,49 @@
57000 Kuala Lumpur<br>
Tel: 03-8082 1252
</td>
<td class="header-details">
<div class="title">
<strong>
{{ $transaction->type == 9 ? 'Credit' : 'Debit' }} Note
</strong>
</div>
<div class="number">EI#: {{ $transaction->bill_no }}</div>
<div class="ref">Ref# {{ $po_order_transaction->booking->marking }}</div>
<div class="date">Date: {{ $transaction->created_at }}</div>
<div>&nbsp;</div>
</div>
</td>
<tr>
<td colspan="3" class="bill-to">
<span class="sub-title">
{{ $transaction->type == 9 ? 'Credit' : 'Debit' }} To
</span>
</td>
</tr>
<tr>
<td colspan="3" class="address">
<div class="label">
{{ $supplier->name }}
</div>
<div class="address">
@php
$addresses = $supplier->addresses()->where('billing', '=', true)->first();
@endphp
{{ $addresses->street_one }}
{{ $addresses->street_two }} ,
{{ $addresses->district()->first()->name }},
{{ $addresses->postcode }}
{{ $addresses->state()->first()->name }},
{{ $addresses->country()->first()->name }}
</div>
<div>
Phone: {{ $supplier->contacts()->first()->phone }}
</div>
</td>
</tr>
</table>
<htmlpagefooter name="page-footer">
<table width="100%">