credit note

This commit is contained in:
edmondlang
2023-08-01 01:15:11 +08:00
parent 5d1c537147
commit aa6f6a5581
5 changed files with 107 additions and 1 deletions
@@ -0,0 +1,54 @@
<?php
namespace App\Classes\Modules\Transactions\ControllersLogic;
use App\Classes\Modules\Transactions\Processors\CreateSupplierTransactionProcessor;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
use App\Classes\Modules\Companies\Services\FetchesCompany;
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
class GenerateCreditNotePdfLogic
{
/** @var FetchesTransaction */
private $fetchesTransaction;
/** @var CreateSupplierTransactionProcessor */
private $createSupplierTransactionProcessor;
/**
* DownloadMockUpWhiteFormPdfLogic constructor.
* @param FetchesTransaction $fetchesTransaction
* @param CreateSupplierTransactionProcessor $createSupplierTransactionProcessor
*/
public function __construct(FetchesTransaction $fetchesTransaction, CreateSupplierTransactionProcessor $createSupplierTransactionProcessor)
{
$this->fetchesTransaction = $fetchesTransaction;
$this->createSupplierTransactionProcessor = $createSupplierTransactionProcessor;
}
/**
* @param Request $request
* @return string|\Symfony\Component\HttpFoundation\Response
* @throws \App\Classes\Exceptions\MalformedRequestException
*/
public function execute(Request $request)
{
ini_set('memory_limit', '-1');
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
// $pdf = LaravelMpdf::loadView('pages.pdfs.credit_note', ['transaction' => $transaction]);
// return $pdf->stream('MockUpWhiteForm.pdf');
$pdf = LaravelMpdf::loadView('pages.pdfs.credit_note', ['transaction' => $transaction]);
$pdfContent = $pdf->output();
// Pass the PDF content variable to the view
return view('pages.pdf_view', ['pdfContent' => $pdfContent]);
}
}
@@ -0,0 +1,15 @@
<?php
namespace App\Http\Controllers\Transactions;
use Illuminate\Http\Request;
use App\Classes\Modules\Transactions\ControllersLogic\GenerateCreditNotePdfLogic;
use Illuminate\Http\JsonResponse;
class GenerateCreditNotePdfController
{
public function download(Request $request, GenerateCreditNotePdfLogic $logic) {
return $logic->execute($request);
}
}
@@ -22,7 +22,7 @@
<div class="row bg-white padding-10 m-b-10 rounded" v-for="(item, index) in transaction" v-bind:key="item.id" :data="item">
<div class="col-2 fs-12">{{item.created_at}}</div>
<div class="col-3 fs-12">{{ convertTransactionType(item.type) }} {{ item.payment_reference ? ' - ' + item.payment_reference : '' }}</div>
<div class="col-3 fs-12">{{ convertTransactionType(item.type) }} {{ item.payment_reference ? ' - ' + item.payment_reference : '' }} <a v-if="[9,11].includes(item.type) " :href="route('transaction.credit_note.download', item.id)">Download Document</a></div>
<div class="col fs-12"><a :href="route('booking.details', item.booking_marking)">{{item.booking_marking}}</a></div>
<div class="col-2 text-success text-center">{{[5, 9].includes(parseFloat(item.type)) ? (Math.round((parseFloat(item.amount) + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : ''}}</div>
<div class="col-2 text-danger text-center">{{[1, 11].includes(parseFloat(item.type)) ? '- ' + (Math.round((parseFloat(item.amount) + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : ''}}</div>
@@ -0,0 +1,35 @@
@extends('layouts.base_pdf')
@section('inner_content')
<br>
<htmlpageheader name="page-header">
<br><br>
<div class="separator"><strong><i>{{ $transaction->bill_no }}</i></strong></div>
</htmlpageheader>
<table>
<tr>
<td class="header-logo">
<img src="{{ asset('images/ri_1.png') }}" alt="logo" id="logo" class="logo">
</td>
<td class="header-cief-address">
<span class="company-name">
<strong>
CIEF WORLDWIDE SDN BHD
</strong>
</span>
<span class="company-reg">(1134596-M)</span><br>
No. 72-3, Jalan Jalil 1,<br>
The Earth Bukit Jalil,<br>
57000 Kuala Lumpur<br>
Tel: 03-8082 1252
</td>
</table>
<htmlpagefooter name="page-footer">
<table width="100%">
<tr>
<td style="text-align: right; ">This is generated by computer. No signature required.</td>
<td style="text-align: right; ">Page {PAGENO} of {nbpg}</td>
</tr>
</table>
</htmlpagefooter>
@endsection
+2
View File
@@ -667,3 +667,5 @@ Route::get('/customer/vouchers/{marking}', function ($marking) {
$id = \App\Models\Company::where('reference', '=', $marking)->first()->employees->first()->id;
return view('pages.customers.reward', ['id' => $id]);
})->name('customer.reward');
Route::get('transaction/{id}/credit_note/download', 'Transactions\GenerateCreditNotePdfController@download')->name('transaction.credit_note.download');