mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 20:44:19 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 99f4699260 | |||
| 0ea52048e1 | |||
| a47bb95e50 | |||
| 431aed18d3 | |||
| 6ab289057b |
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
|
||||
class GenerateCreditNotePdfLogic
|
||||
{
|
||||
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/**
|
||||
* GenerateCreditNotePdfLogic constructor.
|
||||
* @param FetchesTransaction $fetchesTransaction
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
*/
|
||||
public function __construct(FetchesTransaction $fetchesTransaction, FetchesCompanyModule $fetchesCompanyModule)
|
||||
{
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return string|\Symfony\Component\HttpFoundation\Response
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Request $request)
|
||||
{
|
||||
$transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
|
||||
|
||||
$supplier = $this->fetchesCompanyModule->execute(['id' => $transaction->receiver]);
|
||||
|
||||
$pdf = LaravelMpdf::loadView('pages.pdfs.credit_note', ['transaction' => $transaction, 'supplier' => $supplier]);
|
||||
|
||||
return $pdf->stream('CreditNote.pdf');
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ use App\Classes\Modules\Wallets\Services\UpdatesWallet;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
|
||||
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
@@ -29,6 +30,9 @@ class CreditWalletLogic extends AbstractControllerLogic
|
||||
}
|
||||
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
@@ -62,6 +66,7 @@ class CreditWalletLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function __construct(
|
||||
FetchesCompany $fetchesCompany,
|
||||
FetchesCompanyModule $fetchesCompanyModule,
|
||||
GeneratesWalletCode $generatesWalletCode,
|
||||
CreatesWallet $createsWallet,
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
@@ -71,6 +76,7 @@ class CreditWalletLogic extends AbstractControllerLogic
|
||||
)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->generatesWalletCode = $generatesWalletCode;
|
||||
$this->createsWallet = $createsWallet;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
@@ -88,13 +94,13 @@ class CreditWalletLogic extends AbstractControllerLogic
|
||||
{
|
||||
$amount = floatval(str_replace(',', '', $request->input('amount')));
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]);
|
||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
||||
|
||||
$reference = $request->input('reference');
|
||||
|
||||
$type = $request->input('transaction_type');
|
||||
|
||||
$wallet = $this->creditWalletProcessor->execute($company, $type, $amount, $reference);
|
||||
$wallet = $this->creditWalletProcessor->execute($companyModule, $type, $amount, $reference);
|
||||
|
||||
return $this->resourceResponse(new WalletResource($wallet));
|
||||
}
|
||||
|
||||
@@ -11,9 +11,11 @@ use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionableTransaction;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Models\CompanyModule;
|
||||
|
||||
class CreditWalletProcessor
|
||||
{
|
||||
@@ -29,6 +31,9 @@ class CreditWalletProcessor
|
||||
/** @var CreatesTransaction */
|
||||
private $createsTransaction;
|
||||
|
||||
/** @var CreatesTransactionableTransaction */
|
||||
private $createsTransactionableTransaction;
|
||||
|
||||
/** @var UpdatesWallet */
|
||||
private $updatesWallet;
|
||||
|
||||
@@ -38,6 +43,7 @@ class CreditWalletProcessor
|
||||
* @param CreatesWallet $createsWallet
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
|
||||
* @param CreatesTransaction $createsTransaction
|
||||
* @param CreatesTransactionableTransaction $createsTransactionableTransaction
|
||||
* @param UpdatesWallet $updatesWallet
|
||||
*/
|
||||
public function __construct(
|
||||
@@ -45,6 +51,7 @@ class CreditWalletProcessor
|
||||
CreatesWallet $createsWallet,
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
CreatesTransaction $createsTransaction,
|
||||
CreatesTransactionableTransaction $createsTransactionableTransaction,
|
||||
UpdatesWallet $updatesWallet
|
||||
)
|
||||
{
|
||||
@@ -52,32 +59,33 @@ class CreditWalletProcessor
|
||||
$this->createsWallet = $createsWallet;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsTransaction = $createsTransaction;
|
||||
$this->createsTransactionableTransaction = $createsTransactionableTransaction;
|
||||
$this->updatesWallet = $updatesWallet;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Company $company
|
||||
* @param CompanyModule $companyModule
|
||||
* @param int $transactionType
|
||||
* @param float $amount
|
||||
* @param string $reference
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Company $company, int $transactionType, float $amount, string $reference)
|
||||
public function execute(CompanyModule $companyModule, int $transactionType, float $amount, string $reference)
|
||||
{
|
||||
if (!$company->wallets()->first()) {
|
||||
$object = new WalletObject($company->id, 1, $this->generatesWalletCode->execute());
|
||||
$this->createsWallet->execute($object, $company);
|
||||
if (!$companyModule->wallets()->first()) {
|
||||
$object = new WalletObject($companyModule->id, 1, $this->generatesWalletCode->execute());
|
||||
$this->createsWallet->execute($object, $companyModule);
|
||||
}
|
||||
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $company->wallets()->first();
|
||||
$wallet = $companyModule->wallets()->first();
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute($transactionType === 2 ? 'DEBIT-NOTE-' : 'CREDIT-NOTE-');
|
||||
|
||||
$transaction_object = new TransactionObject($billNumber, $transactionType === 2 ? TransactionType::DEBIT_NOTE : TransactionType::CREDIT_NOTE, 1, $wallet->owner->id, 1, PaymentMethodType::CASH, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], $reference);
|
||||
$transaction = $this->createsTransaction->execute($wallet, $transaction_object);
|
||||
$transaction = $this->createsTransactionableTransaction->execute($wallet, $transaction_object);
|
||||
|
||||
$updateWalletAmount = $transactionType === 2 ? ($wallet->amount - $transaction->amount) : ($wallet->amount + $transaction->amount);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,7 @@ class WalletTransactionResource extends JsonResource
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => (int) $this->id,
|
||||
'type' => (int) $this->type,
|
||||
'marking' => $this->owner->owner->reference,
|
||||
'bill_no' => $this->bill_no,
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
<div class="col">
|
||||
<div class="row" v-if="section === 'customerPendingPaymentInvoiceComponent'">
|
||||
<div class="col m-b-15">
|
||||
<wallet-component :company_module_id="company_module_id" section="billingWalletSection"></wallet-component>
|
||||
<wallet-component :company_module_id="company_module_id" section="billingWalletSection" :creditable=true></wallet-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="b-a b-grey rounded padding-25 bg-white">
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
this.canSubmitChanges = !this.canSubmitChanges;
|
||||
this.parameters.transaction_details = this.details;
|
||||
|
||||
console.log(this.parameters.transaction_details);
|
||||
// console.log(this.parameters.transaction_details);
|
||||
|
||||
this.submit(this.route('api.transaction.invoice.update', this.data.id), 'put', this.section, true, true);
|
||||
}
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@
|
||||
|
||||
<div class="row bg-white padding-10 m-b-10 rounded align-items-center" v-for="(item, index) in wallet.transactions" v-bind:key="item.id" :data="item">
|
||||
<div class="col-3 fs-12">{{item.created_at}}</div>
|
||||
<div class="col fs-12" v-html="item.description"></div>
|
||||
<div class="col fs-12"><span v-html="item.description"></span> <a target=”_blank” v-if="[9,11].includes(item.type) " :href="route('transaction.credit_note.download', item.id)"><i class="fa fa-download fs-11 m-l-5 text-secondary hover-primary"></i></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">{{[2, 11].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-right">{{remainingBalance(index)}}</div>
|
||||
@@ -52,7 +52,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<wallet-component :data="wallet" :company_module_id="id" section="CompanyWalletTransactionSection"></wallet-component>
|
||||
<wallet-component :data="wallet" :company_module_id="id" section="CompanyWalletTransactionSection" :creditable=true></wallet-component>
|
||||
<div class="row m-t-20">
|
||||
<div class="col">
|
||||
<div class="row m-b-10">
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
@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>
|
||||
<td class="header-details">
|
||||
<div class="title">
|
||||
<strong>
|
||||
{{ $transaction->type == 9 ? 'Credit' : 'Debit' }} Note
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
<div class="date">Date: {{ $transaction->created_at }}</div>
|
||||
<div> </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('type', 1)->first();
|
||||
@endphp
|
||||
{{ $addresses->street_one }}
|
||||
{{ $addresses->street_two }} ,
|
||||
{{ $addresses->district()->first()->name }},
|
||||
{{ $addresses->postcode }}
|
||||
{{ $addresses->state()->first()->name }},
|
||||
{{ $addresses->country()->first()->name }}
|
||||
</div>
|
||||
<div>
|
||||
@php
|
||||
$contact = $supplier->contacts()->first();
|
||||
@endphp
|
||||
Phone: {{ $contact ? $contact->phone : '' }}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
<br>
|
||||
<table class="line-table" style="overflow: wrap" autosize="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%">No</th>
|
||||
<th class="description">Description</th>
|
||||
<th width="10%">Quantity</th>
|
||||
<th width="15%">Unit Price (RM)</th>
|
||||
<th width="10%">Total Amount<br>(RM)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td width="5%" class="center top">1</td>
|
||||
<td class="description">{{ ucfirst($transaction->payment_reference) }}</td>
|
||||
<td width="10%" class="center top">1</td>
|
||||
<td width="15%" class="center top">
|
||||
{{ number_format($transaction->amount, 2) }}
|
||||
</td>
|
||||
<td width="20%" class="right top">
|
||||
{{ number_format($transaction->amount, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="3"></td>
|
||||
<td class="right middle">Total</td>
|
||||
<td class="total right middle">
|
||||
{{ number_format($transaction->amount, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</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
|
||||
@@ -1189,4 +1189,6 @@ Route::get('/duplicate-package-clean-up', function(){
|
||||
|
||||
});
|
||||
|
||||
Route::get('transaction/{id}/credit_note/download', 'Transactions\GenerateCreditNotePdfController@download')->name('transaction.credit_note.download');
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user