From 77b2d21e68300a1501935dce090e14980b843d23 Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Sun, 2 Jan 2022 15:01:52 +0800 Subject: [PATCH 01/69] add calculation service charge for transaction bill --- .../CreateSupplierTransactionLogic.php | 49 +++++++++++-------- .../CalculatesTransactionServiceCharge.php | 19 +++++++ .../pdfs/currency_vendor_order.blade.php | 22 ++++++++- 3 files changed, 68 insertions(+), 22 deletions(-) create mode 100644 app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php index f496ab4f..20dfa9da 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php @@ -3,31 +3,32 @@ namespace App\Classes\Modules\Transactions\ControllersLogic; +use Carbon\Carbon; +use App\Models\Document; +use Barryvdh\DomPDF\PDF; +use App\Models\Transaction; +use Illuminate\Support\Str; +use Illuminate\Http\Request; +use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\Storage; +use Meneses\LaravelMpdf\Facades\LaravelMpdf; +use App\Classes\ValueObjects\Constants\DocumentType; +use App\Classes\ValueObjects\Constants\ApprovalStatus; +use App\Classes\ValueObjects\Constants\TransactionType; +use App\Classes\Modules\Documents\Services\CreatesFiles; +use App\Classes\ValueObjects\Constants\PaymentMethodType; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Companies\Services\FetchesCompany; -use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; -use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject; +use Meneses\LaravelLaravelMpdf\Facades\LaravelLaravelMpdf; +use App\Classes\Modules\Documents\Services\CreatesDocument; use App\Classes\Modules\Transactions\Services\CreatesTransaction; use App\Classes\Modules\Transactions\Services\FetchesTransaction; -use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber; +use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject; use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; -use App\Classes\Modules\Documents\Services\CreatesDocument; -use App\Classes\Modules\Documents\Services\CreatesFiles; -use App\Classes\ValueObjects\Constants\ApprovalStatus; -use App\Classes\ValueObjects\Constants\PaymentMethodType; -use App\Classes\ValueObjects\Constants\TransactionType; -use App\Classes\ValueObjects\Constants\DocumentType; -use App\Models\Document; -use App\Models\Transaction; -use Barryvdh\DomPDF\PDF; -use Carbon\Carbon; -use Illuminate\Http\JsonResponse; -use Illuminate\Http\Request; -use Illuminate\Support\Facades\Storage; -use Illuminate\Support\Str; -use Meneses\LaravelLaravelMpdf\Facades\LaravelLaravelMpdf; -use Meneses\LaravelMpdf\Facades\LaravelMpdf; +use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; +use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber; +use App\Classes\Modules\Transactions\Services\CalculatesTransactionServiceCharge; class CreateSupplierTransactionLogic extends AbstractControllerLogic { @@ -64,6 +65,9 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic /** @var GeneratesTransactionBillNumber */ private $generatesTransactionBillNumber; + /** @var CalculatesTransactionServiceCharge */ + private $calculatesTransactionServiceCharge; + /** @var PDF */ private $pdf; @@ -74,9 +78,10 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic * @param UpdatesTransactionStatus $updatesTransactionStatus * @param CreatesTransaction $createsTransaction * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber + * @param CalculatesTransactionServiceCharge $calculatesTransactionServiceCharge * @param PDF $pdf */ - public function __construct(FetchesCompany $fetchesCompany, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, CreatesTransaction $createsTransaction, CreatesDocument $createsDocument, CreatesFiles $createsFile, GeneratesTransactionBillNumber $generatesTransactionBillNumber, PDF $pdf) + public function __construct(FetchesCompany $fetchesCompany, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, CreatesTransaction $createsTransaction, CreatesDocument $createsDocument, CreatesFiles $createsFile, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculatesTransactionServiceCharge $calculatesTransactionServiceCharge, PDF $pdf) { $this->fetchesCompany = $fetchesCompany; @@ -86,6 +91,7 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic $this->createsDocument = $createsDocument; $this->createsFile = $createsFile; $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; + $this->calculatesTransactionServiceCharge = $calculatesTransactionServiceCharge; $this->pdf = $pdf; } @@ -106,10 +112,11 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic $this->updatesTransactionStatus->execute($payment, ApprovalStatus::COMPLETED); $billNumber = $this->generatesTransactionBillNumber->execute('SPLR-'); + $serviceCharge = $this->calculatesTransactionServiceCharge->execute($payment->original_amount, $rate); $object = new TransactionObject($billNumber, TransactionType::BILL, $supplier->id, 1, $supplier->banks()->where('default', true)->first()->id, PaymentMethodType::CASH, $payment->original_amount * (1 / $rate), $payment->original_amount, 1, $payment->original_currency_id, - $rate, 0, 0, null, ApprovalStatus::PENDING_VERIFICATION); + $rate, 0, $supplier->id == 2 ? 0 : $serviceCharge, null, ApprovalStatus::PENDING_VERIFICATION); $transactions[] = $this->createsTransaction->execute($payment->booking, $object); } diff --git a/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php b/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php new file mode 100644 index 00000000..3dbabc30 --- /dev/null +++ b/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php @@ -0,0 +1,19 @@ + - Total amount: + Sub total booking amount: + RMB {{number_format((float)$transactions->sum('original_amount'), 2, '.', '')}} + + + Transfer fee (0.002%): + RMB {{number_format((float)$transactions->sum('original_amount') * 0.002 / 100, 2, '.', '')}} + + + Total booking amount: + RMB {{number_format((float) ($transactions->sum('original_amount') +($transactions->sum('original_amount') * 0.002 / 100)), 2, '.', '')}} + + + Sub total amount: MYR {{number_format((float)$transactions->sum('amount'), 2, '.', '')}} + + Service charge ({{ $supplier->id == 2 ? 0 : '0.75%' }}): + MYR {{number_format((float)$transactions->sum('service_charge'), 2, '.', '')}} + + + Total amount: + MYR {{number_format((float) ($transactions->sum('amount') + $transactions->sum('service_charge')), 2, '.', '')}} + From d2d92f668e7d56d462c9dc2e3d6a681274c6def9 Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Sat, 8 Jan 2022 03:28:18 +0800 Subject: [PATCH 02/69] add transfer fee transaction and fixed currency_vendor_order pdf calculation --- .../CreateSupplierTransactionLogic.php | 20 ++- .../CalculatesTransactionServiceCharge.php | 6 +- .../CalculatesTransactionTransferFee.php | 17 +++ .../Constants/TransactionType.php | 2 + .../pdfs/currency_vendor_order.blade.php | 115 +++++++++++------- 5 files changed, 109 insertions(+), 51 deletions(-) create mode 100644 app/Classes/Modules/Transactions/Services/CalculatesTransactionTransferFee.php diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php index 20dfa9da..6b5110ec 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php @@ -28,6 +28,7 @@ use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber; +use App\Classes\Modules\Transactions\Services\CalculatesTransactionTransferFee; use App\Classes\Modules\Transactions\Services\CalculatesTransactionServiceCharge; class CreateSupplierTransactionLogic extends AbstractControllerLogic @@ -68,6 +69,9 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic /** @var CalculatesTransactionServiceCharge */ private $calculatesTransactionServiceCharge; + /** @var CalculatesTransactionTransferFee */ + private $calculatesTransactionTransferFee; + /** @var PDF */ private $pdf; @@ -79,9 +83,10 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic * @param CreatesTransaction $createsTransaction * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber * @param CalculatesTransactionServiceCharge $calculatesTransactionServiceCharge + * @param CalculatesTransactionTransferFee $calculatesTransactionTransferFee * @param PDF $pdf */ - public function __construct(FetchesCompany $fetchesCompany, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, CreatesTransaction $createsTransaction, CreatesDocument $createsDocument, CreatesFiles $createsFile, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculatesTransactionServiceCharge $calculatesTransactionServiceCharge, PDF $pdf) + public function __construct(FetchesCompany $fetchesCompany, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, CreatesTransaction $createsTransaction, CreatesDocument $createsDocument, CreatesFiles $createsFile, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculatesTransactionServiceCharge $calculatesTransactionServiceCharge, CalculatesTransactionTransferFee $calculatesTransactionTransferFee, PDF $pdf) { $this->fetchesCompany = $fetchesCompany; @@ -92,6 +97,7 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic $this->createsFile = $createsFile; $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; $this->calculatesTransactionServiceCharge = $calculatesTransactionServiceCharge; + $this->calculatesTransactionTransferFee = $calculatesTransactionTransferFee; $this->pdf = $pdf; } @@ -102,6 +108,7 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic $rate = $request->input('rate'); $transactions = collect(); + $transferFeeTransactions = collect(); foreach($request->input('payments') as $payment){ @@ -119,11 +126,20 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic $rate, 0, $supplier->id == 2 ? 0 : $serviceCharge, null, ApprovalStatus::PENDING_VERIFICATION); $transactions[] = $this->createsTransaction->execute($payment->booking, $object); + + $transferFeeNumber = $this->generatesTransactionBillNumber->execute('TRFR-'); + $trasferFee = $this->calculatesTransactionTransferFee->execute($payment->original_amount); + $object = new TransactionObject($transferFeeNumber, TransactionType::TRANSFER_FEE, 1, $supplier->id, + $supplier->banks()->where('default', true)->first()->id, PaymentMethodType::CASH, + $payment->original_amount, $payment->original_amount, $payment->original_currency_id, $payment->original_currency_id, + 1, 0, $trasferFee, null, ApprovalStatus::PENDING_VERIFICATION); + + $transferFeeTransactions[] = $this->createsTransaction->execute($payment->booking, $object); } if(!count($transactions)) return $this->response([]); - $pdf = LaravelMpdf::loadView('pages.pdfs.currency_vendor_order', ['transactions' => $transactions, 'supplier' => $supplier]); + $pdf = LaravelMpdf::loadView('pages.pdfs.currency_vendor_order', ['transactions' => $transactions, 'transferFeeTransactions' => $transferFeeTransactions, 'supplier' => $supplier]); $path = Str::studly($supplier->name).'_'.Carbon::now()->format('Y_m_d_h_s_i').'.pdf'; diff --git a/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php b/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php index 3dbabc30..641e3903 100644 --- a/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php +++ b/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php @@ -8,12 +8,12 @@ class CalculatesTransactionServiceCharge /** * @param float $amount * @param float $rate - * @param float $transfer_fee * @param float $service_charge + * @param float $transfer_fee * @return float */ - public function execute(float $amount, float $rate, ?float $transfer_fee = 0.002, ?float $service_charge = 0.75) { - return (($amount + ($amount * $transfer_fee/100)) * (1/$rate)) * $service_charge / 100; + public function execute(float $amount, float $rate, ?float $service_charge = 0.75, ?float $transfer_fee = 0.00) { + return (($amount + $transfer_fee) * (1/$rate)) * $service_charge / 100; } } \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/Services/CalculatesTransactionTransferFee.php b/app/Classes/Modules/Transactions/Services/CalculatesTransactionTransferFee.php new file mode 100644 index 00000000..14f77b84 --- /dev/null +++ b/app/Classes/Modules/Transactions/Services/CalculatesTransactionTransferFee.php @@ -0,0 +1,17 @@ + - table, th, td { - border: 1px solid black; - border-collapse: collapse; - } - th, td { - padding: 15px; - } - + +
+
- -
- - +
+ - -
{{$supplier->name}} {{\Carbon\Carbon::now('Asia/Singapore')->format('d-m-Y h:s')}}
-
-
- - + +
+
+
+ + @@ -32,50 +36,69 @@ @foreach($transactions as $transaction) - - - - - - - + + + + + + + @endforeach - -
Reference MarkingBank in Details
{{$transaction->booking->marking}}{{$transaction->booking->company->reference}}{{$transaction->currency_rate}}{{$transaction->currency->short_code}} {{number_format((float)$transaction->amount, 2, '.', '')}}Account Holder Name: {{$transaction->booking->bank->holder_name}}
{{$transaction->booking->bank->bank_name}}: {{$transaction->booking->bank->account_no}} -
Branch: {{$transaction->booking->bank->bank_branch}}
Bank in Amount: {{$transaction->original_currency->short_code}} {{$transaction->original_amount}}
{{$transaction->booking->marking}}{{$transaction->booking->company->reference}}{{$transaction->currency_rate}}{{$transaction->currency->short_code}} {{number_format((float)$transaction->amount, 2, '.', '')}}Account Holder Name: {{$transaction->booking->bank->holder_name}}
{{$transaction->booking->bank->bank_name}}: {{$transaction->booking->bank->account_no}} +
Branch: {{$transaction->booking->bank->bank_branch}}
Bank in Amount: {{$transaction->original_currency->short_code}} {{$transaction->original_amount}} +
- - + +
+ + - + @php + $sub_total_booking_amount = number_format((float)$transactions->sum('original_amount'), 2, '.', ''); + @endphp + - + @php + $transfer_fee = number_format((float)$transferFeeTransactions->sum('service_charge'), 2, '.', ''); + @endphp + - + @php + $total_booking_amount = number_format((float) ($transactions->sum('original_amount') + $transfer_fee), 2, '.', ''); + @endphp + - + @php + $sub_total_amount = number_format((float)$transactions->sum('amount') + ($transfer_fee * 1/$transactions[0]->currency_rate), 2, '.', ''); + @endphp + - - + + @php + $service_charge = number_format((float)$sub_total_amount * 0.75 / 100, 2, '.', ''); + @endphp + - + @php + $total_amount = number_format((float)$sub_total_amount + $service_charge, 2, '.', ''); + @endphp + + + +
Sub total booking amount: RMB {{number_format((float)$transactions->sum('original_amount'), 2, '.', '')}}RMB {{$sub_total_booking_amount}}
Transfer fee (0.002%): RMB {{number_format((float)$transactions->sum('original_amount') * 0.002 / 100, 2, '.', '')}}RMB {{$transfer_fee}}
Total booking amount: RMB {{number_format((float) ($transactions->sum('original_amount') +($transactions->sum('original_amount') * 0.002 / 100)), 2, '.', '')}}RMB {{$total_booking_amount}}
Sub total amount: MYR {{number_format((float)$transactions->sum('amount'), 2, '.', '')}}MYR {{$sub_total_amount}}
Service charge ({{ $supplier->id == 2 ? 0 : '0.75%' }}): MYR {{number_format((float)$transactions->sum('service_charge'), 2, '.', '')}}Service charge ({{ $supplier->id == 2 ? '0.00' : '0.75%' }}): MYR {{$service_charge}}
Total amount: MYR {{number_format((float) ($transactions->sum('amount') + $transactions->sum('service_charge')), 2, '.', '')}}MYR {{$total_amount}}
+ + + + -
Page {PAGENO} of {nbpg}
- - - - - -
Page {PAGENO} of {nbpg}
-
+
@endsection \ No newline at end of file From 36c659c84e58cc8982e68d8ffe169e4460ca0c3f Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Tue, 11 Jan 2022 23:07:49 +0800 Subject: [PATCH 03/69] Transfer Fee Transaction - Company Balance Account API --- .../CreateSupplierTransactionLogic.php | 4 +- .../FetchCompanyAccountBalanceLogic.php | 46 +++++++++++++++++++ .../GeneratesCompanyBalanceAccount.php | 41 +++++++++++++++++ .../FetchCompanyAccountBalanceController.php | 21 +++++++++ app/Models/Company.php | 7 +++ app/Models/Transaction.php | 11 ++++- routes/transaction.php | 1 + 7 files changed, 128 insertions(+), 3 deletions(-) create mode 100644 app/Classes/Modules/Transactions/ControllersLogic/FetchCompanyAccountBalanceLogic.php create mode 100644 app/Classes/Modules/Transactions/Services/GeneratesCompanyBalanceAccount.php create mode 100644 app/Http/Controllers/Transactions/FetchCompanyAccountBalanceController.php diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php index 6b5110ec..b524b3e9 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php @@ -125,7 +125,7 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic $payment->original_amount * (1 / $rate), $payment->original_amount, 1, $payment->original_currency_id, $rate, 0, $supplier->id == 2 ? 0 : $serviceCharge, null, ApprovalStatus::PENDING_VERIFICATION); - $transactions[] = $this->createsTransaction->execute($payment->booking, $object); + $transactions[] = $billTransaction = $this->createsTransaction->execute($payment->booking, $object); $transferFeeNumber = $this->generatesTransactionBillNumber->execute('TRFR-'); $trasferFee = $this->calculatesTransactionTransferFee->execute($payment->original_amount); @@ -134,7 +134,7 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic $payment->original_amount, $payment->original_amount, $payment->original_currency_id, $payment->original_currency_id, 1, 0, $trasferFee, null, ApprovalStatus::PENDING_VERIFICATION); - $transferFeeTransactions[] = $this->createsTransaction->execute($payment->booking, $object); + $transferFeeTransactions[] = $this->createsTransaction->execute($billTransaction, $object); } if(!count($transactions)) return $this->response([]); diff --git a/app/Classes/Modules/Transactions/ControllersLogic/FetchCompanyAccountBalanceLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/FetchCompanyAccountBalanceLogic.php new file mode 100644 index 00000000..b73f5ca3 --- /dev/null +++ b/app/Classes/Modules/Transactions/ControllersLogic/FetchCompanyAccountBalanceLogic.php @@ -0,0 +1,46 @@ + 'Retrieved Company Balance Account', + 'message' => 'You have successfully retrieved company balance account' + ]; + } + + /** @var GeneratesCompanyBalanceAccount */ + private $generatesCompanyBalanceAccount; + + /** + * FetchCompanyAccountBalanceLogic constructor. + * @param GeneratesCompanyBalanceAccount $generatesCompanyBalanceAccount + */ + public function __construct(GeneratesCompanyBalanceAccount $generatesCompanyBalanceAccount) + { + $this->generatesCompanyBalanceAccount = $generatesCompanyBalanceAccount; + } + + public function logic(Request $request) : JsonResponse + { + $company = Company::find($request->route('id')); + + return $this->response(['data' => $this->generatesCompanyBalanceAccount->execute($company)]); + + } + + + +} diff --git a/app/Classes/Modules/Transactions/Services/GeneratesCompanyBalanceAccount.php b/app/Classes/Modules/Transactions/Services/GeneratesCompanyBalanceAccount.php new file mode 100644 index 00000000..51c71cb1 --- /dev/null +++ b/app/Classes/Modules/Transactions/Services/GeneratesCompanyBalanceAccount.php @@ -0,0 +1,41 @@ +checksIfTransactionBillNumberExists = $checksIfTransactionBillNumberExists; + } + + + /** + * @param Company $company + */ + public function execute(Company $company) { + $transferFeeTransactions = $company->issuerTransactions()->where('transactions.type', TransactionType::TRANSFER_FEE)->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->orderBy('id', 'DESC')->get(); + return [ + 'company' => new CompanyResource($company), + 'transferFeeTransactions' => $transferFeeTransactions, + 'account_balance' => $transferFeeTransactions->sum('amount'), + ]; + + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/Transactions/FetchCompanyAccountBalanceController.php b/app/Http/Controllers/Transactions/FetchCompanyAccountBalanceController.php new file mode 100644 index 00000000..d36b0605 --- /dev/null +++ b/app/Http/Controllers/Transactions/FetchCompanyAccountBalanceController.php @@ -0,0 +1,21 @@ +execute($request); + } +} diff --git a/app/Models/Company.php b/app/Models/Company.php index 7b8e4387..e18bbf85 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -101,6 +101,13 @@ class Company extends AbstractModel implements Documentable { return $this->hasManyDeep(Transaction::class, [Booking::class], ['company_id', 'owner_id'], ['id', 'id']); } + /** + * @return HasMany + */ + public function issuerTransactions(): HasMany + { + return $this->HasMany(Transaction::class, 'issuer'); + } /** * @return MorphMany diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index a3e16c79..450d9545 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -3,6 +3,7 @@ namespace App\Models; use App\Classes\General\Interfaces\Documentable; +use App\Classes\General\Interfaces\Transactionable; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\TransactionType; use Carbon\Carbon; @@ -16,7 +17,7 @@ use Illuminate\Database\Eloquent\Relations\MorphMany; use Illuminate\Database\Eloquent\Relations\MorphTo; -class Transaction extends AbstractModel implements Documentable +class Transaction extends AbstractModel implements Documentable, Transactionable { use SoftDeletes; @@ -27,6 +28,14 @@ class Transaction extends AbstractModel implements Documentable return $this->morphTo(); } + /** + * @return MorphMany + */ + public function transactions(): MorphMany + { + return $this->MorphMany(Transaction::class, 'owner'); + } + /** * @return MorphMany */ diff --git a/routes/transaction.php b/routes/transaction.php index 578b02c2..d3ce05b2 100644 --- a/routes/transaction.php +++ b/routes/transaction.php @@ -16,4 +16,5 @@ Route::group(['prefix' => 'transactions', 'namespace' => 'Transactions', 'as' => Route::post('booking/{id}/details/update', 'CreatePurchaseOrderTransactionController@create')->name('po.create'); + Route::get('/company/{id}/account/balance', 'FetchCompanyAccountBalanceController@fetch')->name('company.account.balance'); }); \ No newline at end of file From 6a2d0dc2a42c5a614404c0d4af27f5390bf840c0 Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Thu, 27 Jan 2022 22:46:36 +0800 Subject: [PATCH 04/69] Fixed transfer fee count (status == approve only and deduct credit note) --- .../Services/GeneratesCompanyBalanceAccount.php | 13 +++++++++++-- app/Models/Transaction.php | 8 ++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/Classes/Modules/Transactions/Services/GeneratesCompanyBalanceAccount.php b/app/Classes/Modules/Transactions/Services/GeneratesCompanyBalanceAccount.php index 51c71cb1..cfbe8ee2 100644 --- a/app/Classes/Modules/Transactions/Services/GeneratesCompanyBalanceAccount.php +++ b/app/Classes/Modules/Transactions/Services/GeneratesCompanyBalanceAccount.php @@ -8,6 +8,7 @@ use App\Http\Resources\CompanyResource; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\TransactionType; use App\Classes\Modules\Transactions\Services\ChecksIfTransactionBillNumberExists; +use Illuminate\Database\Eloquent\Collection; class GeneratesCompanyBalanceAccount { @@ -29,11 +30,19 @@ class GeneratesCompanyBalanceAccount * @param Company $company */ public function execute(Company $company) { - $transferFeeTransactions = $company->issuerTransactions()->where('transactions.type', TransactionType::TRANSFER_FEE)->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->orderBy('id', 'DESC')->get(); + $transferFeeTransactions = $company->issuerTransactions()->where('transactions.type', TransactionType::TRANSFER_FEE)->whereIn('transactions.status', [ApprovalStatus::APPROVED])->orderBy('id', 'DESC')->get(); + + $creditNoteTransactions = []; + foreach($transferFeeTransactions as $transferFeeTransaction){ + $creditNoteTransactions[] = $transferFeeTransaction->creditNoteTransaction; + } + $creditNoteTransactions = new Collection($creditNoteTransactions); + return [ 'company' => new CompanyResource($company), 'transferFeeTransactions' => $transferFeeTransactions, - 'account_balance' => $transferFeeTransactions->sum('amount'), + 'creditNoteTransactions' => $creditNoteTransactions, + 'account_balance' => $transferFeeTransactions->sum('amount') - $creditNoteTransactions->sum('amount'), ]; } diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index 450d9545..730da377 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -36,6 +36,14 @@ class Transaction extends AbstractModel implements Documentable, Transactionable return $this->MorphMany(Transaction::class, 'owner'); } + /** + * @return MorphOne + */ + public function creditNoteTransaction() + { + return $this->MorphOne(Transaction::class, 'owner')->where('type', TransactionType::CREDIT_NOTE); + } + /** * @return MorphMany */ From ae392dd052be11d94c2ac7f8d3ca9364fca09ade Mon Sep 17 00:00:00 2001 From: glovetleong Date: Mon, 21 Feb 2022 08:57:39 +0800 Subject: [PATCH 05/69] debtor --- .../UpdateCompanyDebtorLogic.php | 66 +++++++++++++++++++ .../Services/UpdatesCompanyDebtor.php | 23 +++++++ .../UpdateCompanyDebtorController.php | 20 ++++++ ...0_203803_add_debtor_to_companies_table.php | 32 +++++++++ routes/company.php | 2 + 5 files changed, 143 insertions(+) create mode 100644 app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyDebtorLogic.php create mode 100644 app/Classes/Modules/Companies/Services/UpdatesCompanyDebtor.php create mode 100644 app/Http/Controllers/Companies/UpdateCompanyDebtorController.php create mode 100644 database/migrations/2022_02_20_203803_add_debtor_to_companies_table.php diff --git a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyDebtorLogic.php b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyDebtorLogic.php new file mode 100644 index 00000000..49938efd --- /dev/null +++ b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyDebtorLogic.php @@ -0,0 +1,66 @@ + 'Updated Company', + 'message' => 'You have successfully updated the Company' + ]; + } + + /** @var CanUpdateCompany */ + private $canUpdateCompany; + + /** @var UpdatesCompanyDebtor */ + private $updatesCompanyDebtor; + + /** @var FetchesCompany */ + private $fetchesCompany; + + /** + * UpdateCompanyControllersLogic constructor. + * @param CanUpdateCompany $canUpdateCompany + * @param UpdatesCompanyDebtor $updatesCompanyDebtor + * @param FetchesCompany $fetchesCompany + */ + public function __construct(CanUpdateCompany $canUpdateCompany, UpdatesCompanyDebtor $updatesCompanyDebtor, FetchesCompany $fetchesCompany) + { + $this->canUpdateCompany = $canUpdateCompany; + $this->updatesCompanyDebtor = $updatesCompanyDebtor; + $this->fetchesCompany = $fetchesCompany; + } + + + /** + * @param Request $request + * @return JsonResponse + * @throws ErrorException + */ + public function logic(Request $request) : JsonResponse + { + $debtor = $request->input('debtor'); + + $query = $this->fetchesCompany->execute(['id' => $request->route('id')]); + + $query = $this->updatesCompanyDebtor->execute($query, $debtor); + + return $this->resourceResponse(new CompanyResource($query)); + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Companies/Services/UpdatesCompanyDebtor.php b/app/Classes/Modules/Companies/Services/UpdatesCompanyDebtor.php new file mode 100644 index 00000000..4cb43a9f --- /dev/null +++ b/app/Classes/Modules/Companies/Services/UpdatesCompanyDebtor.php @@ -0,0 +1,23 @@ +debtor = $debtor; + return $this->handler($model); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Companies/UpdateCompanyDebtorController.php b/app/Http/Controllers/Companies/UpdateCompanyDebtorController.php new file mode 100644 index 00000000..af62c4f9 --- /dev/null +++ b/app/Http/Controllers/Companies/UpdateCompanyDebtorController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/database/migrations/2022_02_20_203803_add_debtor_to_companies_table.php b/database/migrations/2022_02_20_203803_add_debtor_to_companies_table.php new file mode 100644 index 00000000..2798b9e7 --- /dev/null +++ b/database/migrations/2022_02_20_203803_add_debtor_to_companies_table.php @@ -0,0 +1,32 @@ +string('debtor')->nullable()->after('reference'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('companies', function (Blueprint $table) { + + }); + } +} diff --git a/routes/company.php b/routes/company.php index f5c4dfbc..a0ca19a5 100644 --- a/routes/company.php +++ b/routes/company.php @@ -9,6 +9,8 @@ Route::group(['prefix' => 'company', 'as' => 'company.', 'namespace' => 'Compani Route::put('/update/{id}', 'UpdateCompanyController@update')->name('update'); Route::delete('/delete/{id}', 'DeleteCompanyController@destroy')->name('delete'); + Route::put('/update/debtor/{id}', 'UpdateCompanyDebtorController@update')->name('delete'); + Route::post('/team/create', 'AddNewMemberController@create')->name('team.create'); Route::group(['prefix' => '{id}/segment', 'as' => 'segment.'], function () { From 592024d4622b09dd6c5b71ab670ee8a123db81c6 Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Tue, 22 Feb 2022 11:35:12 +0800 Subject: [PATCH 06/69] Create api to get bank account balance by bank id --- .../FetchBankAccountBalanceLogic.php | 46 ++++++++++++++++ .../Services/GeneratesBankBalanceAccount.php | 52 +++++++++++++++++++ .../FetchBankAccountBalanceController.php | 21 ++++++++ app/Models/Bank.php | 13 ++++- app/Models/Company.php | 1 + routes/transaction.php | 2 + 6 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 app/Classes/Modules/Transactions/ControllersLogic/FetchBankAccountBalanceLogic.php create mode 100644 app/Classes/Modules/Transactions/Services/GeneratesBankBalanceAccount.php create mode 100644 app/Http/Controllers/Transactions/FetchBankAccountBalanceController.php diff --git a/app/Classes/Modules/Transactions/ControllersLogic/FetchBankAccountBalanceLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/FetchBankAccountBalanceLogic.php new file mode 100644 index 00000000..5ffa11bf --- /dev/null +++ b/app/Classes/Modules/Transactions/ControllersLogic/FetchBankAccountBalanceLogic.php @@ -0,0 +1,46 @@ + 'Retrieved Bank Balance Account', + 'message' => 'You have successfully retrieved bank balance account' + ]; + } + + /** @var GeneratesBankBalanceAccount */ + private $generatesBankBalanceAccount; + + /** + * FetchCompanyAccountBalanceLogic constructor. + * @param GeneratesBankBalanceAccount $generatesBankBalanceAccount + */ + public function __construct(GeneratesBankBalanceAccount $generatesBankBalanceAccount) + { + $this->generatesBankBalanceAccount = $generatesBankBalanceAccount; + } + + public function logic(Request $request) : JsonResponse + { + $bank = Bank::find($request->route('id')); + + return $this->response(['data' => $this->generatesBankBalanceAccount->execute($bank)]); + + } + + + +} diff --git a/app/Classes/Modules/Transactions/Services/GeneratesBankBalanceAccount.php b/app/Classes/Modules/Transactions/Services/GeneratesBankBalanceAccount.php new file mode 100644 index 00000000..39b49276 --- /dev/null +++ b/app/Classes/Modules/Transactions/Services/GeneratesBankBalanceAccount.php @@ -0,0 +1,52 @@ +checksIfTransactionBillNumberExists = $checksIfTransactionBillNumberExists; + } + + + /** + * @param Bank $bank + */ + public function execute(Bank $bank) { + $floatTransactions = $bank->recipientTransactions()->where('transactions.type', TransactionType::BILL)->whereIn('transactions.status', [ApprovalStatus::APPROVED])->orderBy('id', 'DESC')->get(); + $transferFeeTransactions = $bank->recipientTransactions()->where('transactions.type', TransactionType::TRANSFER_FEE)->whereIn('transactions.status', [ApprovalStatus::APPROVED])->orderBy('id', 'DESC')->get(); + + $creditNoteTransactions = []; + foreach($transferFeeTransactions as $transferFeeTransaction){ + $creditNoteTransactions[] = $transferFeeTransaction->creditNoteTransaction; + } + $creditNoteTransactions = new Collection($creditNoteTransactions); + + return [ + 'bank' => new BankResource($bank), + 'floatTransactions' => $floatTransactions, + 'transferFeeTransactions' => $transferFeeTransactions, + 'creditNoteTransactions' => $creditNoteTransactions, + 'account_balance' => $floatTransactions->sum('amount') + $transferFeeTransactions->sum('amount') - $creditNoteTransactions->sum('amount'), + ]; + + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/Transactions/FetchBankAccountBalanceController.php b/app/Http/Controllers/Transactions/FetchBankAccountBalanceController.php new file mode 100644 index 00000000..0d8c89b4 --- /dev/null +++ b/app/Http/Controllers/Transactions/FetchBankAccountBalanceController.php @@ -0,0 +1,21 @@ +execute($request); + } +} diff --git a/app/Models/Bank.php b/app/Models/Bank.php index 9381b94a..3b0bb915 100644 --- a/app/Models/Bank.php +++ b/app/Models/Bank.php @@ -2,11 +2,12 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; - use Illuminate\Database\Eloquent\Relations\HasOne; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\BelongsTo; + /** * Class Bank * @package App\Models @@ -41,4 +42,12 @@ class Bank extends AbstractModel { return $this->BelongsTo(Company::class, 'company_id', 'id'); } + + /** + * @return HasMany + */ + public function recipientTransactions(): HasMany + { + return $this->HasMany(Transaction::class, 'recipient_bank_account_id'); + } } diff --git a/app/Models/Company.php b/app/Models/Company.php index e18bbf85..def72720 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -101,6 +101,7 @@ class Company extends AbstractModel implements Documentable { return $this->hasManyDeep(Transaction::class, [Booking::class], ['company_id', 'owner_id'], ['id', 'id']); } + /** * @return HasMany */ diff --git a/routes/transaction.php b/routes/transaction.php index d3ce05b2..83392e4e 100644 --- a/routes/transaction.php +++ b/routes/transaction.php @@ -17,4 +17,6 @@ Route::group(['prefix' => 'transactions', 'namespace' => 'Transactions', 'as' => Route::post('booking/{id}/details/update', 'CreatePurchaseOrderTransactionController@create')->name('po.create'); Route::get('/company/{id}/account/balance', 'FetchCompanyAccountBalanceController@fetch')->name('company.account.balance'); + + Route::get('/bank/{id}/account/balance', 'FetchBankAccountBalanceController@fetch')->name('bank.account.balance'); }); \ No newline at end of file From dd0b1422383890a56e99fe6332f50e8a82915bee Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Sun, 27 Feb 2022 12:51:21 +0800 Subject: [PATCH 07/69] Create api to create and update service change setting --- app/Classes/ValueObjects/Constants/BusinessType.php | 2 ++ app/Classes/ValueObjects/Constants/SegmentConstants.php | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/app/Classes/ValueObjects/Constants/BusinessType.php b/app/Classes/ValueObjects/Constants/BusinessType.php index d24b975d..831568e9 100644 --- a/app/Classes/ValueObjects/Constants/BusinessType.php +++ b/app/Classes/ValueObjects/Constants/BusinessType.php @@ -10,4 +10,6 @@ final class BusinessType { public const CURRENCY_VENDOR = 3; + public const TRANSFER_AGENT = 4; + } diff --git a/app/Classes/ValueObjects/Constants/SegmentConstants.php b/app/Classes/ValueObjects/Constants/SegmentConstants.php index 80e9cb71..dd6b093a 100644 --- a/app/Classes/ValueObjects/Constants/SegmentConstants.php +++ b/app/Classes/ValueObjects/Constants/SegmentConstants.php @@ -20,4 +20,8 @@ class SegmentConstants public const CUSTOM_SERVICE_TYPE = 'CUSTOM_SERVICE_TYPE'; + public const SERVICE_CHARGE = 'SERVICE_CHARGE'; + + public const TRANSFER_FEE = 'TRANSFER_FEE'; + } \ No newline at end of file From af3ff46a20b5eb693bd933b2e2b4e0c4f13f0d08 Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Mon, 28 Feb 2022 22:40:16 +0800 Subject: [PATCH 08/69] Grab service charge from setting for calculate supplier transaction --- .../Eloquent/Filters/ServiceCharge.php | 21 +++++ .../CreateSegmentConstantLogic.php | 70 +++++++++++++++ .../FetchSegmentConstantLogic.php | 51 +++++++++++ .../UpdateSegmentConstantLogic.php | 88 +++++++++++++++++++ .../CreateSupplierTransactionLogic.php | 15 +++- .../CreateSegmentConstantController.php | 19 ++++ .../FetchSegmentConstantController.php | 20 +++++ .../UpdateSegmentConstantController.php | 20 +++++ app/Http/Resources/CompanyResource.php | 1 + app/Models/SegmentConstant.php | 4 + routes/api.php | 2 + routes/segment_constant.php | 17 ++-- 12 files changed, 317 insertions(+), 11 deletions(-) create mode 100644 app/Classes/General/Eloquent/Filters/ServiceCharge.php create mode 100644 app/Classes/Modules/SegmentConstants/ControllersLogic/CreateSegmentConstantLogic.php create mode 100644 app/Classes/Modules/SegmentConstants/ControllersLogic/FetchSegmentConstantLogic.php create mode 100644 app/Classes/Modules/SegmentConstants/ControllersLogic/UpdateSegmentConstantLogic.php create mode 100644 app/Http/Controllers/SegmentConstants/CreateSegmentConstantController.php create mode 100644 app/Http/Controllers/SegmentConstants/FetchSegmentConstantController.php create mode 100644 app/Http/Controllers/SegmentConstants/UpdateSegmentConstantController.php diff --git a/app/Classes/General/Eloquent/Filters/ServiceCharge.php b/app/Classes/General/Eloquent/Filters/ServiceCharge.php new file mode 100644 index 00000000..de8cdded --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/ServiceCharge.php @@ -0,0 +1,21 @@ +where('reference', SegmentConstants::SERVICE_CHARGE)->where('detail->id', $value); + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentConstants/ControllersLogic/CreateSegmentConstantLogic.php b/app/Classes/Modules/SegmentConstants/ControllersLogic/CreateSegmentConstantLogic.php new file mode 100644 index 00000000..12b26ad6 --- /dev/null +++ b/app/Classes/Modules/SegmentConstants/ControllersLogic/CreateSegmentConstantLogic.php @@ -0,0 +1,70 @@ + 'Created Segment Constant', + 'message' => 'You have successfully created a new Segment Constant' + ]; + } + + /** @var CanCreateConstant */ + private $canCreateConstant; + + /** @var CreatesConstant */ + private $createsConstant; + + /** @var FetchesSegment */ + private $fetchesSegment; + + + /** + * CreateSegmentLogic constructor. + * @param CanCreateConstant $canCreateConstant + * @param CreatesConstant $createsConstant + */ + public function __construct(CanCreateConstant $canCreateConstant, CreatesConstant $createsConstant, FetchesSegment $fetchesSegment) + { + $this->canCreateConstant = $canCreateConstant; + $this->createsConstant = $createsConstant; + $this->fetchesSegment = $fetchesSegment; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException + * @throws \App\Classes\Exceptions\RequestValidationException + */ + public function logic(Request $request) : JsonResponse + { + $constant_object = new ConstantObject($request->input('name'), $request->input('reference'), $request->input('detail')); + + $segment = $this->fetchesSegment->execute(['id' => $request->input('segment_id')]); + + $this->canCreateConstant->passes($constant_object); + $constant = $this->createsConstant->execute($segment, $constant_object); + + return $this->resourceResponse(new ConstantResource($constant)); + + } +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentConstants/ControllersLogic/FetchSegmentConstantLogic.php b/app/Classes/Modules/SegmentConstants/ControllersLogic/FetchSegmentConstantLogic.php new file mode 100644 index 00000000..43c10039 --- /dev/null +++ b/app/Classes/Modules/SegmentConstants/ControllersLogic/FetchSegmentConstantLogic.php @@ -0,0 +1,51 @@ + 'Retrieved Segment Constant', + 'message' => 'You have successfully retrieved a segment constant' + ]; + } + + /** @var FetchesConstant */ + private $fetchesConstant; + + /** + * FetchSegmentLogic constructor. + * @param FetchesConstant $fetchesConstant + */ + public function __construct(FetchesConstant $fetchesConstant) + { + $this->fetchesConstant = $fetchesConstant; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\RequestValidationException + */ + public function logic(Request $request) : JsonResponse + { + $query = $this->fetchesConstant->execute(['id' => $request->route('id')]); + + return $this->resourceResponse(new ConstantResource($query)); + + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentConstants/ControllersLogic/UpdateSegmentConstantLogic.php b/app/Classes/Modules/SegmentConstants/ControllersLogic/UpdateSegmentConstantLogic.php new file mode 100644 index 00000000..49897e95 --- /dev/null +++ b/app/Classes/Modules/SegmentConstants/ControllersLogic/UpdateSegmentConstantLogic.php @@ -0,0 +1,88 @@ + 'Updated Segment Constant', + 'message' => 'You have successfully updated the Segment Constant' + ]; + } + + /** @var CanUpdateConstant */ + private $canUpdateConstant; + + /** @var UpdatesConstant */ + private $updatesConstant; + + /** @var FetchesConstant */ + private $fetchesConstant; + + + /** + * UpdateSegmentLogic constructor. + * @param CanUpdateConstant $canUpdateConstant + * @param UpdatesConstant $updatesConstant + * @param FetchesConstant $fetchesConstant + */ + public function __construct( + CanUpdateConstant $canUpdateConstant, + UpdatesConstant $updatesConstant, + FetchesConstant $fetchesConstant + ) + { + $this->canUpdateConstant = $canUpdateConstant; + $this->updatesConstant = $updatesConstant; + $this->fetchesConstant = $fetchesConstant; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws ErrorException + */ + public function logic(Request $request) : JsonResponse + { + try { + DB::beginTransaction(); + + $constant_query = $this->fetchesConstant->execute(['id' => $request->route('id')]); + + $constant_object = new ConstantObject( + $request->input('name', $constant_query->name), + $request->input('reference', $constant_query->reference), + $request->input('detail', (array) $constant_query->detail)); + $this->canUpdateConstant->passes($constant_object); + $constant_query = $this->updatesConstant->execute($constant_query, $constant_object); + + DB::commit(); + + return $this->resourceResponse(new ConstantResource($constant_query)); + + } catch (\Exception $exception){ + throw new ErrorException($exception->getMessage(), $exception->getCode()); + } + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php index b524b3e9..9cb671a8 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php @@ -3,12 +3,14 @@ namespace App\Classes\Modules\Transactions\ControllersLogic; +use DB; use Carbon\Carbon; use App\Models\Document; use Barryvdh\DomPDF\PDF; use App\Models\Transaction; use Illuminate\Support\Str; use Illuminate\Http\Request; +use App\Models\SegmentConstant; use Illuminate\Http\JsonResponse; use Illuminate\Support\Facades\Storage; use Meneses\LaravelMpdf\Facades\LaravelMpdf; @@ -16,16 +18,18 @@ use App\Classes\ValueObjects\Constants\DocumentType; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\TransactionType; use App\Classes\Modules\Documents\Services\CreatesFiles; +use App\Classes\ValueObjects\Constants\SegmentConstants; use App\Classes\ValueObjects\Constants\PaymentMethodType; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Companies\Services\FetchesCompany; +use App\Classes\Modules\Segments\Services\FetchesConstant; use Meneses\LaravelLaravelMpdf\Facades\LaravelLaravelMpdf; use App\Classes\Modules\Documents\Services\CreatesDocument; use App\Classes\Modules\Transactions\Services\CreatesTransaction; + use App\Classes\Modules\Transactions\Services\FetchesTransaction; use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject; use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; - use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber; use App\Classes\Modules\Transactions\Services\CalculatesTransactionTransferFee; @@ -79,6 +83,7 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic * CreateSupplierTransactionLogic constructor. * @param FetchesCompany $fetchesCompany * @param FetchesTransaction $fetchesTransaction + * @param FetchesConstant $fetchesConstant * @param UpdatesTransactionStatus $updatesTransactionStatus * @param CreatesTransaction $createsTransaction * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber @@ -86,11 +91,12 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic * @param CalculatesTransactionTransferFee $calculatesTransactionTransferFee * @param PDF $pdf */ - public function __construct(FetchesCompany $fetchesCompany, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, CreatesTransaction $createsTransaction, CreatesDocument $createsDocument, CreatesFiles $createsFile, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculatesTransactionServiceCharge $calculatesTransactionServiceCharge, CalculatesTransactionTransferFee $calculatesTransactionTransferFee, PDF $pdf) + public function __construct(FetchesCompany $fetchesCompany, FetchesTransaction $fetchesTransaction, FetchesConstant $fetchesConstant, UpdatesTransactionStatus $updatesTransactionStatus, CreatesTransaction $createsTransaction, CreatesDocument $createsDocument, CreatesFiles $createsFile, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculatesTransactionServiceCharge $calculatesTransactionServiceCharge, CalculatesTransactionTransferFee $calculatesTransactionTransferFee, PDF $pdf) { $this->fetchesCompany = $fetchesCompany; $this->fetchesTransaction = $fetchesTransaction; + $this->fetchesConstant = $fetchesConstant; $this->updatesTransactionStatus = $updatesTransactionStatus; $this->createsTransaction = $createsTransaction; $this->createsDocument = $createsDocument; @@ -119,7 +125,10 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic $this->updatesTransactionStatus->execute($payment, ApprovalStatus::COMPLETED); $billNumber = $this->generatesTransactionBillNumber->execute('SPLR-'); - $serviceCharge = $this->calculatesTransactionServiceCharge->execute($payment->original_amount, $rate); + // $constant = $this->fetchesConstant->execute(['service_charge' => $supplier->id]); + $constant = SegmentConstant::where('reference', SegmentConstants::SERVICE_CHARGE)->where('detail->id', $supplier->id)->first(); + $serviceCharge = $this->calculatesTransactionServiceCharge->execute($payment->original_amount, $rate, $constant ? $constant->detail->service_charge->amount : 0.75); + $object = new TransactionObject($billNumber, TransactionType::BILL, $supplier->id, 1, $supplier->banks()->where('default', true)->first()->id, PaymentMethodType::CASH, $payment->original_amount * (1 / $rate), $payment->original_amount, 1, $payment->original_currency_id, diff --git a/app/Http/Controllers/SegmentConstants/CreateSegmentConstantController.php b/app/Http/Controllers/SegmentConstants/CreateSegmentConstantController.php new file mode 100644 index 00000000..7520e1d1 --- /dev/null +++ b/app/Http/Controllers/SegmentConstants/CreateSegmentConstantController.php @@ -0,0 +1,19 @@ +execute($request); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/SegmentConstants/FetchSegmentConstantController.php b/app/Http/Controllers/SegmentConstants/FetchSegmentConstantController.php new file mode 100644 index 00000000..67532d3f --- /dev/null +++ b/app/Http/Controllers/SegmentConstants/FetchSegmentConstantController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/SegmentConstants/UpdateSegmentConstantController.php b/app/Http/Controllers/SegmentConstants/UpdateSegmentConstantController.php new file mode 100644 index 00000000..c34914dc --- /dev/null +++ b/app/Http/Controllers/SegmentConstants/UpdateSegmentConstantController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/app/Http/Resources/CompanyResource.php b/app/Http/Resources/CompanyResource.php index 54ab047d..50a2da9c 100644 --- a/app/Http/Resources/CompanyResource.php +++ b/app/Http/Resources/CompanyResource.php @@ -55,6 +55,7 @@ class CompanyResource extends JsonResource 'default' => new BankResource($this->banks->where('type', BankAccountType::EXTERNAL)->where('default', true)->first()) ], 'segments' => SegmentResource::collection($this->segments), + 'service_charges' => SegmentConstant::where('reference', SegmentConstants::SERVICE_CHARGE)->where('detail->id', $this->id)->first(), 'services' => (new FetchesCompanyServices())->getServices($this->servicesConfigurations()), 'currencies' => $this->when($this->business_type === BusinessType::CURRENCY_VENDOR, function(){ $segment = SegmentConstant::where('reference', SegmentConstants::SUPPLIER_CURRENCIES)->where('detail->id', $this->id)->first(); diff --git a/app/Models/SegmentConstant.php b/app/Models/SegmentConstant.php index 08c8b2af..b7fda276 100644 --- a/app/Models/SegmentConstant.php +++ b/app/Models/SegmentConstant.php @@ -20,6 +20,10 @@ class SegmentConstant extends AbstractModel protected $table = 'segment_constants'; protected $dates = ['deleted_at']; + + // protected $casts = [ + // 'detail' => 'array', + // ]; public function getDetailAttribute($value) { diff --git a/routes/api.php b/routes/api.php index cf5838f3..10c0fb80 100644 --- a/routes/api.php +++ b/routes/api.php @@ -35,6 +35,8 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function require __DIR__ . '/segment.php'; + require __DIR__ . '/segment_constant.php'; + require __DIR__ . '/currency.php'; require __DIR__ . '/bank.php'; diff --git a/routes/segment_constant.php b/routes/segment_constant.php index e49e9e97..e393e3f3 100644 --- a/routes/segment_constant.php +++ b/routes/segment_constant.php @@ -2,19 +2,20 @@ use Illuminate\Support\Facades\Route; -Route::group(['namespace' => 'StandardSegmentConstants'], function () { - Route::group(['middleware' => 'valid.token'], function () { - Route::group(['prefix' => 'standard-segment-constant'], function () { - Route::get('/list', 'ListStandardSegmentConstantsController@list')->name('standard_segment.update'); - Route::put('/update/{id}', 'UpdateStandardSegmentConstantController@update')->name('standard_segment_constant.update'); - }); - }); -}); +// Route::group(['namespace' => 'StandardSegmentConstants'], function () { +// Route::group(['middleware' => 'valid.token'], function () { +// Route::group(['prefix' => 'standard-segment-constant'], function () { +// Route::get('/list', 'ListStandardSegmentConstantsController@list')->name('standard_segment.update'); +// Route::put('/update/{id}', 'UpdateStandardSegmentConstantController@update')->name('standard_segment_constant.update'); +// }); +// }); +// }); Route::group(['namespace' => 'SegmentConstants'], function () { Route::group(['middleware' => 'valid.token'], function () { Route::group(['prefix' => 'segment-constant'], function () { + Route::get('/{id}/show', 'FetchSegmentConstantController@fetch')->name('segment_constant.show'); Route::post('/create', 'CreateSegmentConstantController@create')->name('segment_constant.create'); Route::put('/update/{id}', 'UpdateSegmentConstantController@update')->name('segment_constant.update'); }); From da7271dddfc1893eebea4d464f081e9f9b618008 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Tue, 1 Mar 2022 09:36:36 +0800 Subject: [PATCH 09/69] fix transaction model duplicated methods --- app/Models/Transaction.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index f89ae6ef..429449a6 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -39,7 +39,7 @@ class Transaction extends AbstractModel implements Documentable, Transactionable } /** - * @return MorphOne + * @return \Illuminate\Database\Eloquent\Relations\MorphOne */ public function creditNoteTransaction() { @@ -47,21 +47,13 @@ class Transaction extends AbstractModel implements Documentable, Transactionable } /** - * @return MorphMany + * @return BelongsTo */ public function booking(): BelongsTo { return $this->BelongsTo(Booking::class, 'owner_id', 'id'); } - /** - * @return MorphMany - */ - public function transactions(): MorphMany - { - return $this->MorphMany(Transaction::class, 'owner'); - } - /** * @return BelongsTo */ From 016de0cd473d6081db10327ac29721106b8ab4f2 Mon Sep 17 00:00:00 2001 From: ahmedsophyudden Date: Tue, 1 Mar 2022 16:04:38 +0800 Subject: [PATCH 10/69] Create update refund status api and credit wallet processor --- .../CreateSupplierTransactionLogic.php | 2 +- .../UpdateRefundTransactionStatusLogic.php | 85 ++++++++++++++++++ .../ControllersLogic/CreditWalletLogic.php | 59 ++++++------ .../Processors/CreditWalletProcessor.php | 89 +++++++++++++++++++ ...pdateRefundTransactionStatusController.php | 14 +++ app/Models/Transaction.php | 8 -- routes/transaction.php | 1 + 7 files changed, 215 insertions(+), 43 deletions(-) create mode 100644 app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php create mode 100644 app/Classes/Modules/Wallets/Processors/CreditWalletProcessor.php create mode 100644 app/Http/Controllers/Transactions/UpdateRefundTransactionStatusController.php diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php index 5a7e76b4..93caf8d1 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php @@ -128,7 +128,7 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic $billNumber = $this->generatesTransactionBillNumber->execute('SPLR-'); // $constant = $this->fetchesConstant->execute(['service_charge' => $supplier->id]); $constant = SegmentConstant::where('reference', SegmentConstants::SERVICE_CHARGE)->where('detail->id', $supplier->id)->first(); - $serviceCharge = $this->calculatesTransactionServiceCharge->execute($payment->original_amount, $rate, $constant ? $constant->detail->service_charge->amount : 0.75); + $serviceCharge = $this->calculatesTransactionServiceCharge->execute($payment->original_amount, $rate, $constant ? $constant->detail->service_charge->amount : 0); $object = new TransactionObject($billNumber, TransactionType::BILL, $supplier->id, 1, $supplier->banks()->where('default', true)->first()->id, PaymentMethodType::CASH, diff --git a/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php new file mode 100644 index 00000000..d760b05d --- /dev/null +++ b/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php @@ -0,0 +1,85 @@ + 'Updated Transaction', + 'message' => 'You have successfully updated a transaction' + ]; + } + + /** @var FetchesCompany */ + private $fetchesCompany; + + /** @var FetchesTransaction */ + private $fetchesTransaction; + + /** @var UpdatesTransactionStatus */ + private $updatesTransactionStatus; + + /** @var DeletesDocument */ + private $deletesDocument; + + /** @var CreditWalletProcessor */ + private $creditWalletProcessor; + + /** + * CreatePaymentVerificationDocumentLogic constructor. + * @param FetchesCompany $fetchesCompany + * @param FetchesTransaction $fetchesTransaction + * @param UpdatesTransactionStatus $updatesTransactionStatus + * @param DeletesDocument $deletesDocument + * @param CreditWalletProcessor $creditWalletProcessor + */ + public function __construct(FetchesCompany $fetchesCompany, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, DeletesDocument $deletesDocument, CreditWalletProcessor $creditWalletProcessor) + { + $this->fetchesCompany = $fetchesCompany; + $this->fetchesTransaction = $fetchesTransaction; + $this->updatesTransactionStatus = $updatesTransactionStatus; + $this->deletesDocument = $deletesDocument; + $this->creditWalletProcessor = $creditWalletProcessor; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\MalformedRequestException + */ + public function logic(Request $request) : JsonResponse + { + $transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]); + + $transaction = $this->updatesTransactionStatus->execute($transaction, $request->input('status')); + + $company = $this->fetchesCompany->execute(['id' => $transaction->booking->company_id]); + + $reference = 'Refund for booking reference '.$transaction->booking->marking; + + if ($transaction->status == ApprovalStatus::APPROVED) { + // add to credit wallet + $this->creditWalletProcessor->execute($company, $transaction->type, $transaction->amount, $reference); + } + + return $this->response([]); + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Wallets/ControllersLogic/CreditWalletLogic.php b/app/Classes/Modules/Wallets/ControllersLogic/CreditWalletLogic.php index 1e7b3ceb..3bd908d0 100644 --- a/app/Classes/Modules/Wallets/ControllersLogic/CreditWalletLogic.php +++ b/app/Classes/Modules/Wallets/ControllersLogic/CreditWalletLogic.php @@ -2,25 +2,26 @@ namespace App\Classes\Modules\Wallets\ControllersLogic; -use App\Classes\General\Abstracts\AbstractControllerLogic; -use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject; -use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; -use App\Classes\Modules\Companies\Services\FetchesCompany; -use App\Classes\Modules\Wallets\Services\CreatesWallet; -use App\Classes\Modules\Wallets\Services\GeneratesWalletCode; -use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber; -use App\Classes\Modules\Transactions\Services\CreatesTransaction; -use App\Classes\Modules\Wallets\Services\UpdatesWallet; - -use App\Classes\ValueObjects\Constants\TransactionType; -use App\Classes\ValueObjects\Constants\PaymentMethodType; -use App\Classes\ValueObjects\Constants\ApprovalStatus; -use App\Http\Resources\WalletResource; - use ErrorException; -use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; +use Illuminate\Http\JsonResponse; use Illuminate\Support\Facades\DB; +use App\Http\Resources\WalletResource; +use App\Classes\ValueObjects\Constants\ApprovalStatus; +use App\Classes\Modules\Wallets\Services\CreatesWallet; +use App\Classes\Modules\Wallets\Services\UpdatesWallet; +use App\Classes\ValueObjects\Constants\TransactionType; + +use App\Classes\ValueObjects\Constants\PaymentMethodType; +use App\Classes\General\Abstracts\AbstractControllerLogic; +use App\Classes\Modules\Companies\Services\FetchesCompany; +use App\Classes\Modules\Wallets\Services\GeneratesWalletCode; + +use App\Classes\Modules\Transactions\Services\CreatesTransaction; +use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject; +use App\Classes\Modules\Wallets\Processors\CreditWalletProcessor; +use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; +use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber; class CreditWalletLogic extends AbstractControllerLogic { @@ -53,6 +54,9 @@ class CreditWalletLogic extends AbstractControllerLogic /** @var UpdatesWallet */ private $updatesWallet; + /** @var CreditWalletProcessor */ + private $creditWalletProcessor; + /** * CreateWalletLogic constructor. * @param FetchesCompany $fetchesCompany @@ -61,6 +65,7 @@ class CreditWalletLogic extends AbstractControllerLogic * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber * @param CreatesTransaction $createsTransaction * @param UpdatesWallet $updatesWallet + * @param CreditWalletProcessor $creditWalletProcessor */ public function __construct( FetchesCompany $fetchesCompany, @@ -68,7 +73,8 @@ class CreditWalletLogic extends AbstractControllerLogic CreatesWallet $createsWallet, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction, - UpdatesWallet $updatesWallet + UpdatesWallet $updatesWallet, + CreditWalletProcessor $creditWalletProcessor ) { $this->fetchesCompany = $fetchesCompany; @@ -77,6 +83,7 @@ class CreditWalletLogic extends AbstractControllerLogic $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; $this->createsTransaction = $createsTransaction; $this->updatesWallet = $updatesWallet; + $this->creditWalletProcessor = $creditWalletProcessor; } /** @@ -94,23 +101,7 @@ class CreditWalletLogic extends AbstractControllerLogic $type = $request->input('transaction_type'); - if (!$company->wallets()->first()) { - $object = new WalletObject($company->id, 1, $this->generatesWalletCode->execute()); - $this->createsWallet->execute($object, $company); - } - - $wallet = $company->wallets()->first(); - - $billNumber = $this->generatesTransactionBillNumber->execute($type === 2 ? 'DEBIT-NOTE-' : 'CREDIT-NOTE-'); - - $transaction_object = new TransactionObject($billNumber, $type === 2 ? TransactionType::DEBIT_NOTE : TransactionType::CREDIT_NOTE, 1, $wallet->company->id, 1, PaymentMethodType::CASH, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], $reference); - $transaction = $this->createsTransaction->execute($wallet, $transaction_object); - - $updateWalletAmount = $type === 2 ? ($wallet->amount - $transaction->amount) : ($wallet->amount + $transaction->amount); - - $walletObject = new WalletObject($wallet->company->id, $wallet->currency_id, $wallet->code, $updateWalletAmount); - - $wallet = $this->updatesWallet->execute($wallet, $walletObject); + $wallet = $this->creditWalletProcessor->execute($company, $type, $amount, $reference); return $this->resourceResponse(new WalletResource($wallet)); } diff --git a/app/Classes/Modules/Wallets/Processors/CreditWalletProcessor.php b/app/Classes/Modules/Wallets/Processors/CreditWalletProcessor.php new file mode 100644 index 00000000..2b303938 --- /dev/null +++ b/app/Classes/Modules/Wallets/Processors/CreditWalletProcessor.php @@ -0,0 +1,89 @@ +generatesWalletCode = $generatesWalletCode; + $this->createsWallet = $createsWallet; + $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; + $this->createsTransaction = $createsTransaction; + $this->updatesWallet = $updatesWallet; + } + + + /** + * @param Company $company + * @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) + { + if (!$company->wallets()->first()) { + $object = new WalletObject($company->id, 1, $this->generatesWalletCode->execute()); + $wallet = $this->createsWallet->execute($object, $company); + } + + $wallet = $company->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); + + $updateWalletAmount = $transactionType === 2 ? ($wallet->amount - $transaction->amount) : ($wallet->amount + $transaction->amount); + + $walletObject = new WalletObject($wallet->owner->id, $wallet->currency_id, $wallet->code, $updateWalletAmount); + + $wallet = $this->updatesWallet->execute($wallet, $walletObject); + + return $wallet; + } +} diff --git a/app/Http/Controllers/Transactions/UpdateRefundTransactionStatusController.php b/app/Http/Controllers/Transactions/UpdateRefundTransactionStatusController.php new file mode 100644 index 00000000..919fadd1 --- /dev/null +++ b/app/Http/Controllers/Transactions/UpdateRefundTransactionStatusController.php @@ -0,0 +1,14 @@ +execute($request); + } +} \ No newline at end of file diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index f89ae6ef..2806d782 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -54,14 +54,6 @@ class Transaction extends AbstractModel implements Documentable, Transactionable return $this->BelongsTo(Booking::class, 'owner_id', 'id'); } - /** - * @return MorphMany - */ - public function transactions(): MorphMany - { - return $this->MorphMany(Transaction::class, 'owner'); - } - /** * @return BelongsTo */ diff --git a/routes/transaction.php b/routes/transaction.php index 2012a045..c3402b47 100644 --- a/routes/transaction.php +++ b/routes/transaction.php @@ -11,6 +11,7 @@ Route::group(['prefix' => 'transactions', 'namespace' => 'Transactions', 'as' => route::post('{id}/bill/verification', 'CreatePaymentProofDocumentController@verify')->name('bill.verification'); route::post('{id}/bill/pay', 'CreatePaymentProofDocumentController@pay')->name('bill.pay'); Route::put('/{id}/bill/{status}', 'UpdatePaymentTransactionStatusController@update')->where('status', 'pending|complete')->name('bill.status'); + Route::put('/{id}/refund/status/update', 'UpdateRefundTransactionStatusController@update')->name('refund.status.update'); route::delete('{id}/bill/delete', 'DeletePaymentProofDocumentController@delete')->name('bill.delete'); From 6d624d3196a29ea3e9963b8151e7fc9ebf85be81 Mon Sep 17 00:00:00 2001 From: glovetleong Date: Wed, 2 Mar 2022 09:54:12 +0800 Subject: [PATCH 11/69] export and import --- .gitignore | 5 +- app/Classes/General/ExcelHandel.php | 87 +++++++++++++++ .../Exports/Services/ExportsNullDebtors.php | 100 ++++++++++++++++++ .../Imports/Services/ImportsDebtor.php | 44 ++++++++ .../ExportCustomersToExcelController.php | 7 ++ .../Imports/ImportUpdateDebtorController.php | 25 +++++ routes/web.php | 3 + storage/app/public/.gitignore | 2 - 8 files changed, 270 insertions(+), 3 deletions(-) create mode 100644 app/Classes/General/ExcelHandel.php create mode 100644 app/Classes/Modules/Exports/Services/ExportsNullDebtors.php create mode 100644 app/Classes/Modules/Imports/Services/ImportsDebtor.php create mode 100644 app/Http/Controllers/Imports/ImportUpdateDebtorController.php delete mode 100644 storage/app/public/.gitignore diff --git a/.gitignore b/.gitignore index 95d268cf..476bf6a0 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,7 @@ db/* docker-compose.yml package-lock.json public/* -/public/* \ No newline at end of file +/public/* +/storage/app/public +public +/storage/framework/laravel-excel diff --git a/app/Classes/General/ExcelHandel.php b/app/Classes/General/ExcelHandel.php new file mode 100644 index 00000000..3060ed8b --- /dev/null +++ b/app/Classes/General/ExcelHandel.php @@ -0,0 +1,87 @@ +makeDirectory($path); + return $folder; + } + + public static function insertExcel($path = '', $base64Set = []) + { + $file_info = []; + $folder_path = ExcelHandel::generateFolder('excels/' . $path); + + foreach ($base64Set as $key => $row) { + + $exceldata = $row; + $filename = (string) Str::uuid(); + + $f = finfo_open(); + $mime_type = finfo_file($f, $exceldata, FILEINFO_MIME_TYPE); + + $extension = 'xls'; + + switch ($mime_type) { + case 'application/vnd.ms-excel': + $extension = 'xls'; + break; + case 'application/zip': + $extension = 'xlsx'; + break; + } + + if (empty($extension)) { + return false; + } + + $exceldata = explode('base64,', $exceldata); + $exceldata = base64_decode($exceldata[1]); + + $filename_with_ext = $filename . '.' . $extension; + + $file = ExcelHandel::generateExcel($path, $exceldata, $filename, $extension); + + $file_info[] = [ + 'path' => $path, + 'filename' => $filename_with_ext, + 'mime_type' => $mime_type, + 'extension' => $extension, + 'file_info' => empty($file) ? [] : $file, + ]; + } + + return $file_info; + } + + public static function generateExcel($path = '', $exceldata = '', $filename = '', $extension = '') + { + $file_info = []; + $file = \Storage::disk('public')->put('excels/' . $path . '/' . $filename . '.' . $extension, $exceldata); + $file_info['original']['file'] = storage_path('app/public/excels/' . $path . '/' . $filename . '.' . $extension); + + return $file_info; + } + + public static function removeExcel($excel_info = []) + { + $excel_info = json_decode(json_encode($excel_info), true); + foreach ($excel_info as $key => $row) { + if (!empty($row['path'])) { + \File::delete([$row['file_info']['original']['file']]); + } + } + return true; + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Exports/Services/ExportsNullDebtors.php b/app/Classes/Modules/Exports/Services/ExportsNullDebtors.php new file mode 100644 index 00000000..e585275c --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportsNullDebtors.php @@ -0,0 +1,100 @@ +reference, //Code + $company->name, //CompanyName + '', //Desc2 + '', //AreaCode + '', //SalesAgent + '', //DebtorType + '', //DisplayTerm + '', //AgingOn + '', //StatementType + 'MYR', //CurrencyCode + $company->reference, //RegisterNo + '', //Address1 + '', //Address2 + '', //Address3 + '', //Address4 + '', //PostCode + '', //DeliverAddr1 + '', //DeliverAddr2 + '', //DeliverAddr3 + '', //DeliverAddr4 + '', //DeliverPostCode + '', //Attention + '', //Phone1 + '', //Phone2 + '', //Fax1 + '', //Fax2 + '', //ExemptNo + '', //ExpiryDate + '', //PriceCategory + ]; + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Imports/Services/ImportsDebtor.php b/app/Classes/Modules/Imports/Services/ImportsDebtor.php new file mode 100644 index 00000000..7a44dbb6 --- /dev/null +++ b/app/Classes/Modules/Imports/Services/ImportsDebtor.php @@ -0,0 +1,44 @@ +first(); + + if ($company) { + $company->debtor = $debtor; + $company->update(); + } + + return []; + } + + public function batchSize(): int + { + return 100; + } + + public function rules(): array + { + return [ + + ]; + } +} diff --git a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php index cdd1c49a..366bf0c7 100644 --- a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php +++ b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Exports; use App\Classes\Modules\Exports\Services\ExportsCustomers; use App\Classes\Modules\Exports\Services\ExportsTransactions; +use App\Classes\Modules\Exports\Services\ExportsNullDebtors; use App\Models\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -24,4 +25,10 @@ class ExportCustomersToExcelController $request->headers->set('Authorization', 'Bearer '.$token); return $exportsTransactions->download('transactions.csv', Excel::CSV, ['Content-Type' => 'text/csv']); } + + public function nullDebtor(ExportsNullDebtors $exportsNullDebtors, Request $request){ + $token = Auth::fromUser(User::find(1)); + $request->headers->set('Authorization', 'Bearer '.$token); + return $exportsNullDebtors->download('nullDebtor.csv', Excel::CSV, ['Content-Type' => 'text/csv']); + } } \ No newline at end of file diff --git a/app/Http/Controllers/Imports/ImportUpdateDebtorController.php b/app/Http/Controllers/Imports/ImportUpdateDebtorController.php new file mode 100644 index 00000000..83d1effd --- /dev/null +++ b/app/Http/Controllers/Imports/ImportUpdateDebtorController.php @@ -0,0 +1,25 @@ +headers->set('Authorization', 'Bearer '.$token); + + $excel_file = $request->input('excel_file'); + + $excel_file = ExcelHandel::insertExcel('debtor', $excel_file); + + return $import = Excel::import(new ImportsDebtor(), $excel_file[0]['file_info']['original']['file']); + } +} \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index e26ef4d8..eda5a7c8 100644 --- a/routes/web.php +++ b/routes/web.php @@ -168,6 +168,9 @@ Route::get('billplz/bills/{bill_no}', function($bill_no){ Route::get('/export/customers/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@export'); Route::get('/export/transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@transactions'); +Route::get('/export/null-debtor/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@nullDebtor'); + +Route::get('/import/update-debtor/f614e339d7058904a831aad742e24d55', 'Imports\ImportUpdateDebtorController@import'); Route::get('/products', function (\App\Classes\Modules\Exports\Services\ExportsProducts $exportsProducts) { return $exportsProducts->download('products.csv', Excel::CSV, ['Content-Type' => 'text/csv']); diff --git a/storage/app/public/.gitignore b/storage/app/public/.gitignore deleted file mode 100644 index d6b7ef32..00000000 --- a/storage/app/public/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore From ba542c17608334b575a67ced314e2f9399b5282d Mon Sep 17 00:00:00 2001 From: glovetleong Date: Wed, 2 Mar 2022 14:18:52 +0800 Subject: [PATCH 12/69] reference --- app/Classes/Modules/Imports/Services/ImportsDebtor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Classes/Modules/Imports/Services/ImportsDebtor.php b/app/Classes/Modules/Imports/Services/ImportsDebtor.php index 7a44dbb6..ad91a689 100644 --- a/app/Classes/Modules/Imports/Services/ImportsDebtor.php +++ b/app/Classes/Modules/Imports/Services/ImportsDebtor.php @@ -17,8 +17,8 @@ class ImportsDebtor implements ToModel, WithHeadingRow, WithBatchInserts, WithVa public function model($row = []) { - $reference = str_replace('/CIEF', '', $row['2nd_description']); - + $reference = preg_split('(-|\(|\)|\/)', $row['2nd_description']); + $reference = $reference[array_key_last($reference)]; $debtor = $row['code']; $company = Company::where('reference', $reference)->first(); From f9a3bdcd677f49aa74deb47418f2fdd04df1351c Mon Sep 17 00:00:00 2001 From: omair saleh Date: Wed, 2 Mar 2022 21:01:42 +0800 Subject: [PATCH 13/69] merge master into development --- .../Modules/Wallets/ControllersLogic/CreditWalletLogic.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/app/Classes/Modules/Wallets/ControllersLogic/CreditWalletLogic.php b/app/Classes/Modules/Wallets/ControllersLogic/CreditWalletLogic.php index 3bd908d0..8ed8aa08 100644 --- a/app/Classes/Modules/Wallets/ControllersLogic/CreditWalletLogic.php +++ b/app/Classes/Modules/Wallets/ControllersLogic/CreditWalletLogic.php @@ -2,25 +2,18 @@ namespace App\Classes\Modules\Wallets\ControllersLogic; -use ErrorException; use Illuminate\Http\Request; use Illuminate\Http\JsonResponse; -use Illuminate\Support\Facades\DB; use App\Http\Resources\WalletResource; -use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\Modules\Wallets\Services\CreatesWallet; use App\Classes\Modules\Wallets\Services\UpdatesWallet; -use App\Classes\ValueObjects\Constants\TransactionType; -use App\Classes\ValueObjects\Constants\PaymentMethodType; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Companies\Services\FetchesCompany; use App\Classes\Modules\Wallets\Services\GeneratesWalletCode; use App\Classes\Modules\Transactions\Services\CreatesTransaction; -use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject; use App\Classes\Modules\Wallets\Processors\CreditWalletProcessor; -use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber; class CreditWalletLogic extends AbstractControllerLogic From 79b4431ef7594c077c2edf62741af454f0ba4105 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Wed, 2 Mar 2022 21:32:58 +0800 Subject: [PATCH 14/69] update billings design --- .../bookings/elements/BillingComponent.vue | 6 +++--- .../bookings/elements/BillingDocumentComponent.vue | 14 +++++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/resources/assets/vue/components/bookings/elements/BillingComponent.vue b/resources/assets/vue/components/bookings/elements/BillingComponent.vue index bfa8b2d9..6e03c040 100644 --- a/resources/assets/vue/components/bookings/elements/BillingComponent.vue +++ b/resources/assets/vue/components/bookings/elements/BillingComponent.vue @@ -11,7 +11,7 @@
- {{parameters.type}} + {{parameters.type.replaceAll('_', ' ')}}
@@ -27,10 +27,10 @@
-
+
-
{{document}}
+
{{document.replaceAll('_', ' ')}}
diff --git a/resources/assets/vue/components/bookings/elements/BillingDocumentComponent.vue b/resources/assets/vue/components/bookings/elements/BillingDocumentComponent.vue index 64f96d0e..095f574f 100644 --- a/resources/assets/vue/components/bookings/elements/BillingDocumentComponent.vue +++ b/resources/assets/vue/components/bookings/elements/BillingDocumentComponent.vue @@ -40,11 +40,15 @@
{{item.owner.amount}} {{item.owner.fixed_currency.short_code}}
- - - +
+
+ + + +
+
From 62e2e3be2dcc7b26bbe04b87bbdf42bcf227334b Mon Sep 17 00:00:00 2001 From: glovetleong Date: Wed, 2 Mar 2022 23:27:46 +0800 Subject: [PATCH 15/69] transaction invoice export --- .../Services/ExportsInvoiceTransactions.php | 115 ++++++++++++++++++ .../ExportCustomersToExcelController.php | 10 +- routes/web.php | 1 + 3 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php diff --git a/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php b/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php new file mode 100644 index 00000000..7f02135f --- /dev/null +++ b/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php @@ -0,0 +1,115 @@ +request = $request; + } + + public function headings(): array + { + return [ + 'DocNo', + 'DocDate', + 'DebtorCode', + 'Ref', + 'Note', + 'ShipInfo', + 'Numbering', + 'AccNo', + 'DetailDescription', + 'FutherDEscription', + 'YourPONo', + 'YourPODate', + 'ProjNo', + 'UOM', + 'Qty', + 'UnitPrice', + 'SubTotal' + ]; + } + + /** + * @return \Illuminate\Support\Collection|mixed + */ + public function query() + { + $start_date = $this->request->input('start_date', null); + if ($start_date) { + $start_date = Carbon::parse($this->request->input('start_date'))->format('Y-m-d'); + } + + $end_date = $this->request->input('end_date', null); + if ($end_date) { + $end_date = Carbon::parse($this->request->input('end_date'))->format('Y-m-d'); + } + + $query = Transaction::query(); + + $query->where('type', TransactionType::INVOICE); + $query->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); + + if($start_date && $end_date) { + $query->whereBetween('created_at', [ + Carbon::parse($start_date)->format('Y-m-d 0:00:00'), + Carbon::parse($end_date)->format('Y-m-d 23:59:59') + ]); + } + elseif($start_date && !$end_date) { + $query->where('created_at', '>=', Carbon::parse($start_date)->format('Y-m-d 0:00:00')); + } + elseif(!$start_date && $end_date) { + $query->where('created_at', '<=', Carbon::parse($end_date)->format('Y-m-d 23:59:59')); + } + + return $query; + } + + /** + * @param Company $transaction + * + * @return array + */ + public function map($transaction): array + { + $booking = $transaction->owner()->first(); + $company = $booking->company()->first(); + + return [ + '<>', + $transaction->updated_at, + $company->debtor, + '', + '', + $booking->marking, + '', + '500-0000', + 'PLEASE REFER TO THE ATTACHED APPENDIX REF ' . $booking->marking, + '', + '', + '', + '', + '', + 1, + $transaction->amount, + $transaction->amount, + ]; + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php index 366bf0c7..3ae0a9bd 100644 --- a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php +++ b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php @@ -6,6 +6,8 @@ namespace App\Http\Controllers\Exports; use App\Classes\Modules\Exports\Services\ExportsCustomers; use App\Classes\Modules\Exports\Services\ExportsTransactions; use App\Classes\Modules\Exports\Services\ExportsNullDebtors; +use App\Classes\Modules\Exports\Services\ExportsInvoiceTransactions; + use App\Models\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -13,7 +15,6 @@ use Maatwebsite\Excel\Excel; class ExportCustomersToExcelController { - public function export(ExportsCustomers $exportsCustomers, Request $request){ $token = Auth::fromUser(User::find(1)); $request->headers->set('Authorization', 'Bearer '.$token); @@ -31,4 +32,11 @@ class ExportCustomersToExcelController $request->headers->set('Authorization', 'Bearer '.$token); return $exportsNullDebtors->download('nullDebtor.csv', Excel::CSV, ['Content-Type' => 'text/csv']); } + + public function invoicetransactions(Request $request){ + $token = Auth::fromUser(User::find(1)); + $request->headers->set('Authorization', 'Bearer '.$token); + $exportsTransactions = new ExportsInvoiceTransactions($request); + return $exportsTransactions->download('invoice-transactions.csv', Excel::CSV, ['Content-Type' => 'text/csv']); + } } \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 42babb4f..0a3b012f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -143,6 +143,7 @@ Route::get('billplz/bills/{bill_no}', function($bill_no){ Route::get('/export/customers/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@export'); Route::get('/export/transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@transactions'); Route::get('/export/null-debtor/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@nullDebtor'); +Route::get('/export/invoice-transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@invoicetransactions'); Route::get('/import/update-debtor/f614e339d7058904a831aad742e24d55', 'Imports\ImportUpdateDebtorController@import'); From 0c317a1139679ace402ad9108c9520c9bcff6286 Mon Sep 17 00:00:00 2001 From: azumiru Date: Thu, 3 Mar 2022 00:21:01 +0800 Subject: [PATCH 16/69] add refund tab in dashboard --- .../views/pages/dashboards/admin.blade.php | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/resources/views/pages/dashboards/admin.blade.php b/resources/views/pages/dashboards/admin.blade.php index 7e8275f3..d6edde28 100644 --- a/resources/views/pages/dashboards/admin.blade.php +++ b/resources/views/pages/dashboards/admin.blade.php @@ -9,7 +9,7 @@
-
+
+
+
+
+ +
+
+
+
+
Refunds
+
+
+
@@ -71,6 +86,23 @@
+
+
+
+
+
+
+ + + +
+
+
+
+
+
From a4f442d681b4e3e3a5c130dc04fedc7b68ce0fef Mon Sep 17 00:00:00 2001 From: glovetleong Date: Thu, 3 Mar 2022 10:05:37 +0800 Subject: [PATCH 17/69] payment name --- ...iceTransactions.php => ExportsPaymentTransactions.php} | 4 ++-- .../Exports/ExportCustomersToExcelController.php | 8 ++++---- routes/web.php | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) rename app/Classes/Modules/Exports/Services/{ExportsInvoiceTransactions.php => ExportsPaymentTransactions.php} (96%) diff --git a/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php b/app/Classes/Modules/Exports/Services/ExportsPaymentTransactions.php similarity index 96% rename from app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php rename to app/Classes/Modules/Exports/Services/ExportsPaymentTransactions.php index 7f02135f..606d3a76 100644 --- a/app/Classes/Modules/Exports/Services/ExportsInvoiceTransactions.php +++ b/app/Classes/Modules/Exports/Services/ExportsPaymentTransactions.php @@ -12,7 +12,7 @@ use Maatwebsite\Excel\Concerns\WithMapping; use Illuminate\Http\Request; use Carbon\Carbon; -class ExportsInvoiceTransactions implements FromQuery, WithHeadingRow, WithMapping +class ExportsPaymentTransactions implements FromQuery, WithHeadingRow, WithMapping { use Exportable; @@ -63,7 +63,7 @@ class ExportsInvoiceTransactions implements FromQuery, WithHeadingRow, WithMappi $query = Transaction::query(); - $query->where('type', TransactionType::INVOICE); + $query->where('type', TransactionType::PAYMENT); $query->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]); if($start_date && $end_date) { diff --git a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php index 3ae0a9bd..3df1e004 100644 --- a/app/Http/Controllers/Exports/ExportCustomersToExcelController.php +++ b/app/Http/Controllers/Exports/ExportCustomersToExcelController.php @@ -6,7 +6,7 @@ namespace App\Http\Controllers\Exports; use App\Classes\Modules\Exports\Services\ExportsCustomers; use App\Classes\Modules\Exports\Services\ExportsTransactions; use App\Classes\Modules\Exports\Services\ExportsNullDebtors; -use App\Classes\Modules\Exports\Services\ExportsInvoiceTransactions; +use App\Classes\Modules\Exports\Services\ExportsPaymentTransactions; use App\Models\User; use Illuminate\Http\Request; @@ -33,10 +33,10 @@ class ExportCustomersToExcelController return $exportsNullDebtors->download('nullDebtor.csv', Excel::CSV, ['Content-Type' => 'text/csv']); } - public function invoicetransactions(Request $request){ + public function paymentTransactions(Request $request){ $token = Auth::fromUser(User::find(1)); $request->headers->set('Authorization', 'Bearer '.$token); - $exportsTransactions = new ExportsInvoiceTransactions($request); - return $exportsTransactions->download('invoice-transactions.csv', Excel::CSV, ['Content-Type' => 'text/csv']); + $exportsTransactions = new ExportsPaymentTransactions($request); + return $exportsTransactions->download('payment-transactions.csv', Excel::CSV, ['Content-Type' => 'text/csv']); } } \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 0a3b012f..03435aee 100644 --- a/routes/web.php +++ b/routes/web.php @@ -143,7 +143,7 @@ Route::get('billplz/bills/{bill_no}', function($bill_no){ Route::get('/export/customers/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@export'); Route::get('/export/transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@transactions'); Route::get('/export/null-debtor/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@nullDebtor'); -Route::get('/export/invoice-transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@invoicetransactions'); +Route::get('/export/payment-transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@paymentTransactions'); Route::get('/import/update-debtor/f614e339d7058904a831aad742e24d55', 'Imports\ImportUpdateDebtorController@import'); From f08603609969ace38dc59650bc34409e4932cfdd Mon Sep 17 00:00:00 2001 From: edmondlang Date: Thu, 3 Mar 2022 21:39:55 +0800 Subject: [PATCH 18/69] update booking type in refund --- resources/views/pages/dashboards/admin.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/pages/dashboards/admin.blade.php b/resources/views/pages/dashboards/admin.blade.php index d6edde28..a412ff8a 100644 --- a/resources/views/pages/dashboards/admin.blade.php +++ b/resources/views/pages/dashboards/admin.blade.php @@ -92,9 +92,9 @@
- +
From bc43a54194068bf242b2bffab9d50223c24894a9 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Thu, 3 Mar 2022 22:10:45 +0800 Subject: [PATCH 19/69] fix bug on payments and refund section - showing both section on first load --- .../views/pages/dashboards/admin.blade.php | 113 ++++++++---------- 1 file changed, 53 insertions(+), 60 deletions(-) diff --git a/resources/views/pages/dashboards/admin.blade.php b/resources/views/pages/dashboards/admin.blade.php index a412ff8a..19ea48a7 100644 --- a/resources/views/pages/dashboards/admin.blade.php +++ b/resources/views/pages/dashboards/admin.blade.php @@ -5,62 +5,59 @@
-
-
-
-
-
-
-
- -
-
-
-
-
Payments
-
-
+
+
+
+ +
+
+
-
-
-
- -
-
-
-
-
Refunds
-
-
+
+
+
+
Payments
-
-
-
-
-
-
- -
-
-
-
-
Supplier Bills
-
-
+
+
+
+
+ +
+
+
+
+
Refunds
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
Supplier Bills
@@ -69,24 +66,20 @@
-
+
-
-
- - - -
-
+ + +
-
+
From 833476776672d72cb28804bdac6ddc86a601530f Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 4 Mar 2022 11:58:48 +0800 Subject: [PATCH 20/69] fix timer for transaction --- .../Modules/Wallets/ControllersLogic/TopUpWalletLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php b/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php index 9bbe6073..2129d6dd 100644 --- a/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php +++ b/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php @@ -103,7 +103,7 @@ class TopUpWalletLogic extends AbstractControllerLogic } $billPlzBill = $this->createsBillplzBill->execute($user->name, $user->email, 'This payment is credit topup for company ref. ' . $company->reference, $amount, $billNumber, $request->input('bank_code'), true); - +dd($billPlzBill); $transaction_object = new TransactionObject($billNumber, TransactionType::TOP_UP, 1, $company->id, 1, PaymentMethodType::PAYMENT_GATEWAY, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, [], $billPlzBill->id); $transaction = $this->createsTransaction->execute($wallet, $transaction_object); From 3666b27b76ed356514f2db5fd91e817a53150ef0 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 4 Mar 2022 12:01:27 +0800 Subject: [PATCH 21/69] fix timer for transaction --- app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php | 2 +- .../Modules/Wallets/ControllersLogic/TopUpWalletLogic.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php index 5b331fca..69255ed9 100644 --- a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php +++ b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php @@ -35,7 +35,7 @@ class CreatesBillplzBill 'reference_2_label' => 'Bill Number', 'reference_2' => $billNumber ]); - +dd($response); if($response->successful()){ $data = $response->json(); diff --git a/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php b/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php index 2129d6dd..9bbe6073 100644 --- a/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php +++ b/app/Classes/Modules/Wallets/ControllersLogic/TopUpWalletLogic.php @@ -103,7 +103,7 @@ class TopUpWalletLogic extends AbstractControllerLogic } $billPlzBill = $this->createsBillplzBill->execute($user->name, $user->email, 'This payment is credit topup for company ref. ' . $company->reference, $amount, $billNumber, $request->input('bank_code'), true); -dd($billPlzBill); + $transaction_object = new TransactionObject($billNumber, TransactionType::TOP_UP, 1, $company->id, 1, PaymentMethodType::PAYMENT_GATEWAY, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, [], $billPlzBill->id); $transaction = $this->createsTransaction->execute($wallet, $transaction_object); From 840110e489f0202930985d1b0644cb3ac7991b35 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 4 Mar 2022 12:14:57 +0800 Subject: [PATCH 22/69] fix timer for transaction --- app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php index 69255ed9..0d07aeee 100644 --- a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php +++ b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php @@ -22,6 +22,7 @@ class CreatesBillplzBill public function execute(string $name, string $email, string $description, float $amount, string $billNumber, ?string $bankCode = null, ?bool $wallet = null) { try{ // config('billplz.maybank') + dd(config('billplz.api_key')); $response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [ 'collection_id' => $wallet ? config('billplz.wallet_collection_id') : config('billplz.collection_id'), 'name' => $name, @@ -35,7 +36,7 @@ class CreatesBillplzBill 'reference_2_label' => 'Bill Number', 'reference_2' => $billNumber ]); -dd($response); + if($response->successful()){ $data = $response->json(); From 8cd019b64b89c44eb8d4cf2201f965388d90d8f9 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 4 Mar 2022 12:18:28 +0800 Subject: [PATCH 23/69] fix timer for transaction --- .env.example | 8 ++++---- .../Modules/Billplzs/Services/CreatesBillplzBill.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index 78c079f5..b1273290 100644 --- a/.env.example +++ b/.env.example @@ -53,7 +53,7 @@ JWT_TTL=1440 IS_PRODUCTION=false BILLPLZ_BASE_URL="https://www.billplz-sandbox.com" -BILLPLZ_API_KEY="0fa4c710-761b-4a7a-a501-c2c2d02643d5" -BILLPLZ_X_SIGNATURE_KEY="S-pbNVthVRsvnPfZlgLwqqOg" -BILLPLZ_COLLECTION_ID="hev2wdjy" -BILLPLZ_WALLET_COLLECTION_ID="hev2wdjy" +BILLPLZ_API_KEY="c8a55af1-08ee-4ed6-bb18-6e5078300d9e" +BILLPLZ_X_SIGNATURE_KEY="S-hcT93TLVGAv9TYWfpTCcWQ" +BILLPLZ_COLLECTION_ID="t0cggbdd" +BILLPLZ_WALLET_COLLECTION_ID="t0cggbdd" diff --git a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php index 0d07aeee..08c41668 100644 --- a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php +++ b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php @@ -22,7 +22,7 @@ class CreatesBillplzBill public function execute(string $name, string $email, string $description, float $amount, string $billNumber, ?string $bankCode = null, ?bool $wallet = null) { try{ // config('billplz.maybank') - dd(config('billplz.api_key')); + dd(config('billplz.api_key'), config('billplz.base_url').'/api/v3/bills'); $response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [ 'collection_id' => $wallet ? config('billplz.wallet_collection_id') : config('billplz.collection_id'), 'name' => $name, From 5e9d852a84b6b791201944c8aaa12ca703b14bb6 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 4 Mar 2022 12:20:28 +0800 Subject: [PATCH 24/69] fix wallet insufficient credit --- app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php index 08c41668..5b331fca 100644 --- a/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php +++ b/app/Classes/Modules/Billplzs/Services/CreatesBillplzBill.php @@ -22,7 +22,6 @@ class CreatesBillplzBill public function execute(string $name, string $email, string $description, float $amount, string $billNumber, ?string $bankCode = null, ?bool $wallet = null) { try{ // config('billplz.maybank') - dd(config('billplz.api_key'), config('billplz.base_url').'/api/v3/bills'); $response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [ 'collection_id' => $wallet ? config('billplz.wallet_collection_id') : config('billplz.collection_id'), 'name' => $name, From 90f2bb178d796a029137129fe76bb11b48d12175 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 4 Mar 2022 12:25:22 +0800 Subject: [PATCH 25/69] fix wallet insufficient credit --- .../bookings/forms/BookingPaymentQuotationComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue index d43eb47b..ca515606 100644 --- a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue +++ b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue @@ -529,7 +529,7 @@ computed: { walletOutstanding(){ let walletBalance = this.data.company.wallet ? this.data.company.wallet.amount : 0; - return walletBalance - this.calculation.total; + return (walletBalance - this.calculation.total).toFixed(2); } }, methods: { From a6326b11efa8a2bb2b61345d357c66c0a688a645 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Fri, 4 Mar 2022 12:32:16 +0800 Subject: [PATCH 26/69] fix wallet insufficient credit --- .../Bookings/ControllersLogic/CreateBookingPaymentLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php index 38080fff..87e6866f 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingPaymentLogic.php @@ -121,7 +121,7 @@ class CreateBookingPaymentLogic extends AbstractControllerLogic /** @var Wallet $wallet */ $wallet = $booking->company->wallets()->first(); - if($wallet->amount < $amount){ + if($wallet->amount < round($amount, 2)){ throw new MalformedRequestException('Insufficient wallet balance. Please Top up your wallet.'); } From 4e3365ba977f0fd45ced9f57e6851ab69098d7e8 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sat, 5 Mar 2022 17:01:57 +0800 Subject: [PATCH 27/69] Update copyright year using php to get current year --- resources/views/partials/footer.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/partials/footer.blade.php b/resources/views/partials/footer.blade.php index 8d4fbcb3..89caae21 100644 --- a/resources/views/partials/footer.blade.php +++ b/resources/views/partials/footer.blade.php @@ -3,7 +3,7 @@
- Copyright © 2021 CIEF Exchange. All rights reserved. + Copyright © {{ date('Y') }} CIEF Exchange. All rights reserved.
From ee85127c96dad89e1ddae9c454b3ce57868f8a6f Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sun, 6 Mar 2022 00:17:16 +0800 Subject: [PATCH 28/69] implemtn api on segment_constants service chrages --- .../companies/elements/SupplierComponent.vue | 18 ++++ .../SupplierServiceChargeFormComponent.vue | 88 +++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 resources/assets/vue/components/companies/forms/SupplierServiceChargeFormComponent.vue diff --git a/resources/assets/vue/components/companies/elements/SupplierComponent.vue b/resources/assets/vue/components/companies/elements/SupplierComponent.vue index 6b2961c2..8f0090fd 100644 --- a/resources/assets/vue/components/companies/elements/SupplierComponent.vue +++ b/resources/assets/vue/components/companies/elements/SupplierComponent.vue @@ -34,15 +34,33 @@
+
+
+
+
Service Charge
+
+
+
+
+
0.00
+
+
+
+ + + + diff --git a/resources/assets/vue/components/companies/forms/SupplierServiceChargeFormComponent.vue b/resources/assets/vue/components/companies/forms/SupplierServiceChargeFormComponent.vue new file mode 100644 index 00000000..74c02a91 --- /dev/null +++ b/resources/assets/vue/components/companies/forms/SupplierServiceChargeFormComponent.vue @@ -0,0 +1,88 @@ + + \ No newline at end of file From 29e926867e9c25dc188021fc611b070b8c5e0235 Mon Sep 17 00:00:00 2001 From: azumiru Date: Sun, 6 Mar 2022 13:54:35 +0800 Subject: [PATCH 29/69] refund-ui-payment - update validations --- .../elements/PaymentHistoryComponent.vue | 6 ++-- .../elements/RefundConfirmationComponent.vue | 34 +++++++++++-------- .../forms/ValidationErrorComponent.vue | 12 ++++--- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue index af7eab83..ab0bb5c4 100644 --- a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue +++ b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue @@ -176,9 +176,9 @@
-
+
- + @@ -294,7 +294,7 @@ expandPaymentDetails: false, expandRefund: false, refundMethod: { - name: 'Fully Refund', + name: 'Partially Refund', status: false }, amount: (Math.round(1000 * 100) / 100).toFixed(2), diff --git a/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue b/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue index 9a810def..215c626f 100644 --- a/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue +++ b/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue @@ -10,7 +10,7 @@
-
+
@@ -64,12 +64,12 @@
-->
-
- Fully Refund -
-
+
Partially Refund
+
+ Fully Refund +
@@ -92,14 +92,14 @@
-
+
@@ -253,7 +253,7 @@ import FormHandler from '../../../general/mixins/formHandler'; // import ConfirmBookingComponent from "../forms/confirmBookingComponent"; import ModalFormHandler from '../../../general/mixins/modalFormHandler'; - import { required } from "vuelidate/lib/validators"; + import { required, maxValue } from "vuelidate/lib/validators"; export default { // components: {ConfirmBookingComponent}, data(){ @@ -264,20 +264,26 @@ account_no: '', parameters: { bankAccount: '', - refundAmount: this.data.booking.amount, + refundAmount: this.data.booking.refundAmount, bank_id: '', }, expandRefund: false, refundMethod: { - name: 'Fully Refund', + name: 'Partially Refund', status: false }, + refundMaxValue: this.data.booking.amount } }, - validations: { - parameters: { - bankAccount: { required }, - refundAmount: { required }, + validations() { + return { + parameters: { + bankAccount: { required }, + refundAmount: { + required, + maxValue: maxValue(this.refundMaxValue) + }, + } } }, computed: { diff --git a/resources/assets/vue/components/general/forms/ValidationErrorComponent.vue b/resources/assets/vue/components/general/forms/ValidationErrorComponent.vue index 3c5f6bb0..d85e38a4 100644 --- a/resources/assets/vue/components/general/forms/ValidationErrorComponent.vue +++ b/resources/assets/vue/components/general/forms/ValidationErrorComponent.vue @@ -1,9 +1,10 @@ @@ -21,7 +22,8 @@ required: 'this field is required', email: 'enter a valid email address', minLength: 'this field must have at least', - sameAs: 'this field must match the' + sameAs: 'this field must match the', + maxValue: 'this value must not exceeds' }, } }, From 8b9c6d55c656e5884f02916aea2256d821f6705f Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sun, 6 Mar 2022 16:03:25 +0800 Subject: [PATCH 30/69] update booking refund design and remove dd --- .../CreateBookingRefundLogic.php | 2 +- .../elements/RefundConfirmationComponent.vue | 256 ++---------------- 2 files changed, 17 insertions(+), 241 deletions(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php index 411b9163..7f0d7e7d 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php @@ -89,7 +89,7 @@ class CreateBookingRefundLogic extends AbstractControllerLogic } $refund = $this->calculatesBookingRefundAmount->execute($booking, $booking->fix_currency_id, $transaction->bill_no); - dd($refund); + // dd($refund); if($refund + $request->input('amount') > $transaction->original_amount) throw new MalformedRequestException('Your refund must not be greater than '. $transaction->original_amount .'.'); diff --git a/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue b/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue index 215c626f..34d97d3b 100644 --- a/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue +++ b/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue @@ -10,7 +10,7 @@
-
+
@@ -23,61 +23,22 @@
Refund Type:
- - -
-
+
+
Partially Refund
-
+
Fully Refund
-
+ +
- +
@@ -90,61 +51,6 @@
-
-
- -
-
-
-
-
-
-
- -
-
-
-
-
-
{{bank.reference ? bank.reference + ' - ':''}}{{bank.holder_name}}
-
-
-
-
-
{{bank.account_no}} {{bank.bank_name}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
- - -
-
@@ -153,95 +59,11 @@
-
-
-
-
-
-
-
Amount you are Transferring
-
-
- -
short_code
-
-
- -
amount
-
-
-
-
-
Exchange Rate
-
-
-
-
-
- -
rate
-
-
-
-
-
Money Transfer Fee
-
-
-
MYR
-
-
- -
amount
-
-
-
-
-
Sub-Total
-
-
-
MYR
-
-
- -
Sub-Total
-
-
-
-
-
Tax
-
-
- -
some%
-
-
- -
some tax
-
-
-
-
-
Amount you are Paying
-
-
-
MYR
-
-
- -
payming amount
-
-
-
-
-
-
-
-
@@ -251,23 +73,15 @@ diff --git a/resources/views/pages/dashboards/admin.blade.php b/resources/views/pages/dashboards/admin.blade.php index 19ea48a7..d3f92e42 100644 --- a/resources/views/pages/dashboards/admin.blade.php +++ b/resources/views/pages/dashboards/admin.blade.php @@ -83,15 +83,11 @@
-
-
- - - -
-
+ + +
From 08d22a59ceda26f1d4cb159886291866b2a82e60 Mon Sep 17 00:00:00 2001 From: azumiru Date: Thu, 10 Mar 2022 17:35:30 +0800 Subject: [PATCH 35/69] refund-ui-tab update refund component --- .../elements/RefundVerificationComponent.vue | 99 ++++++++++++++++++- .../views/pages/dashboards/admin.blade.php | 4 +- 2 files changed, 96 insertions(+), 7 deletions(-) diff --git a/resources/assets/vue/components/bookings/elements/RefundVerificationComponent.vue b/resources/assets/vue/components/bookings/elements/RefundVerificationComponent.vue index 11aa1ff5..b947f571 100644 --- a/resources/assets/vue/components/bookings/elements/RefundVerificationComponent.vue +++ b/resources/assets/vue/components/bookings/elements/RefundVerificationComponent.vue @@ -1,7 +1,93 @@ @@ -10,13 +96,16 @@ import componentHandler from '../../../general/mixins/componentHandler'; import staticFormHandler from '../../../general/mixins/staticFormHandler' export default { - props: { - no_action: Boolean + data() { + return { + status: '' + } }, methods: { - approvePayment(status){ + approveRefund(status){ this.isLoading = true; - this.submit(this.route('api.booking.payment', this.item.booking.id, this.item.id, status), 'put', 'identificationVerificationSection', true, true); + this.status = status; + this.submit(this.route('api.transaction.refund.status.update', this.data.id), 'put', 'listRefundTransactionSection', true, true); }, }, mixins: [componentHandler, staticFormHandler] diff --git a/resources/views/pages/dashboards/admin.blade.php b/resources/views/pages/dashboards/admin.blade.php index d3f92e42..256be0dd 100644 --- a/resources/views/pages/dashboards/admin.blade.php +++ b/resources/views/pages/dashboards/admin.blade.php @@ -83,9 +83,9 @@
- +
From a7646fb4eba1b419bf0088d17cb45aabf2bb9439 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 11 Mar 2022 10:27:40 +0800 Subject: [PATCH 36/69] update refund section --- app/Http/Resources/BookingResource.php | 1 + .../elements/PaymentHistoryComponent.vue | 133 ++---------------- .../elements/RefundVerificationComponent.vue | 26 ++-- .../views/pages/dashboards/admin.blade.php | 2 +- 4 files changed, 28 insertions(+), 134 deletions(-) diff --git a/app/Http/Resources/BookingResource.php b/app/Http/Resources/BookingResource.php index dd951fff..0eeb9670 100644 --- a/app/Http/Resources/BookingResource.php +++ b/app/Http/Resources/BookingResource.php @@ -46,6 +46,7 @@ class BookingResource extends JsonResource ], 'status' => $this->status, 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y'), + 'created_at_with_time' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A'), $this->mergeWhen($this->relationLoaded('transactions'), [ 'purchase_order' => new TransactionResource($this->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first()), 'payment_attempts' => TransactionResource::collection( diff --git a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue index ab0bb5c4..af43a8b7 100644 --- a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue +++ b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue @@ -4,16 +4,19 @@
-
+
Status
{{ item.status === 1 ? 'Pending Verification' : item.status === 4 ? 'Rejected' : 'Processing Payment'}}
+
+ {{ item.status === 1 ? 'Pending Verification' : item.status === 4 ? 'Rejected' : 'Processing Payment'}} +
-
Payment Amount
+
{{ item.type === 6 ? 'Refund' : 'Payment' }} Amount
{{item.currency.short_code}} {{(Math.round((item.amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
@@ -25,7 +28,7 @@
-
+
@@ -176,7 +179,7 @@
-
+
@@ -186,102 +189,6 @@
- -
-
-
-
-
Refund Type:
-
-
-
- {{refundMethod.name}} -
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
Fully Refund
-
-
-
-
-
-
-
-
-
Partially Refund
-
-
-
-
-
-
-
-
-
-
-
-
- - - - -
-
-
-
-
{{''}}
-
-
-
-
-
-
- - - - -
-
-
-
-
{{''}}
-
-
-
-
-
-
-
- - -
-
-
-
-
- -
-
- -
-
-
-
@@ -292,41 +199,17 @@ data(){ return { expandPaymentDetails: false, - expandRefund: false, - refundMethod: { - name: 'Partially Refund', - status: false - }, amount: (Math.round(1000 * 100) / 100).toFixed(2), parameters: { amount: (Math.round(1000 * 100) / 100).toFixed(2), bank_id: 1 }, - expanded: false, section: 'bookingDetailSection', } }, methods: { - submitForm(){ - this.submit(this.route('api.booking.refund.create', this.data.booking.id, this.data.id), 'post', this.section, true, true); - }, - requestRefund(){ - this.expandRefund = !this.expandRefund; - this.expandPaymentDetails = !this.expandPaymentDetails; - }, clickExpand(){ - if (this.expandPaymentDetails === false && this.expandRefund === false) { - this.expandPaymentDetails = !this.expandPaymentDetails; - } else { - this.expandRefund = false; - this.expandPaymentDetails = false; - } - }, - updateRefundType(refund){ - this.refundMethod = { - name: refund.name, - status: !this.refundMethod.status - } + this.expandPaymentDetails = !this.expandPaymentDetails; }, }, mixins: [componentHandler] diff --git a/resources/assets/vue/components/bookings/elements/RefundVerificationComponent.vue b/resources/assets/vue/components/bookings/elements/RefundVerificationComponent.vue index b947f571..914cb47a 100644 --- a/resources/assets/vue/components/bookings/elements/RefundVerificationComponent.vue +++ b/resources/assets/vue/components/bookings/elements/RefundVerificationComponent.vue @@ -10,7 +10,13 @@
Date
- {{ data.booking.created_at }} + {{ data.booking.created_at_with_time }} +
+
+
+
reference
+
-
+
Amount
-
- {{ data.booking.amount }} +
+ {{(Math.round((data.booking.amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
+
+
-
Reject
+
Reject
@@ -73,7 +81,7 @@
Cancel
-
Approve
+
Approve
@@ -98,13 +106,15 @@ export default { data() { return { - status: '' + parameters: { + status: null, + } } }, methods: { approveRefund(status){ this.isLoading = true; - this.status = status; + this.parameters.status = status; this.submit(this.route('api.transaction.refund.status.update', this.data.id), 'put', 'listRefundTransactionSection', true, true); }, }, diff --git a/resources/views/pages/dashboards/admin.blade.php b/resources/views/pages/dashboards/admin.blade.php index 256be0dd..40ffa8ff 100644 --- a/resources/views/pages/dashboards/admin.blade.php +++ b/resources/views/pages/dashboards/admin.blade.php @@ -83,7 +83,7 @@
- + From eb466ef2270d2148f603f40017eb1ed0c060a98f Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 11 Mar 2022 10:34:27 +0800 Subject: [PATCH 37/69] add transfer date notice --- .../ControllersLogic/FetchBookingPaymentQuotationLogic.php | 3 ++- .../Modules/Bookings/Services/GeneratesBookingQuotation.php | 6 +++++- .../ControllersLogic/FetchCompanyBookingQuotationLogic.php | 3 ++- .../bookings/forms/CurrencyConverterComponent.vue | 5 +++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/FetchBookingPaymentQuotationLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/FetchBookingPaymentQuotationLogic.php index 5885d560..eaac0adc 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/FetchBookingPaymentQuotationLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/FetchBookingPaymentQuotationLogic.php @@ -72,7 +72,8 @@ class FetchBookingPaymentQuotationLogic extends AbstractControllerLogic return $this->response(['data' => $this->generatesBookingQuotation->execute( $this->fetchBookingQuotation->execute($booking->company, $conversionObject), - $this->fetchesCompanyPaymentAttemptLimit->execute($booking->company) + $this->fetchesCompanyPaymentAttemptLimit->execute($booking->company), + $conversionObject )]); } diff --git a/app/Classes/Modules/Bookings/Services/GeneratesBookingQuotation.php b/app/Classes/Modules/Bookings/Services/GeneratesBookingQuotation.php index 8f40187b..7d6c018e 100644 --- a/app/Classes/Modules/Bookings/Services/GeneratesBookingQuotation.php +++ b/app/Classes/Modules/Bookings/Services/GeneratesBookingQuotation.php @@ -4,6 +4,7 @@ namespace App\Classes\Modules\Bookings\Services; use App\Classes\Modules\Bookings\DataTransferObjects\CalculationObject; +use App\Classes\Modules\Currencies\DataTransferObjects\CurrencyConversionObject; use App\Http\Resources\BankResource; use App\Models\Bank; use Carbon\Carbon; @@ -12,12 +13,14 @@ use Carbon\CarbonInterval; class GeneratesBookingQuotation { - public function execute(CalculationObject $calculationObject, ?int $paymentAttemptLimit = 0){ + public function execute(CalculationObject $calculationObject, ?int $paymentAttemptLimit = 0, ?CurrencyConversionObject $currencyConversionObject = null){ $date = Carbon::now(); $days = $date->diffInDays($date->copy()->addMinutes($paymentAttemptLimit)); $hours = $date->diffInHours($date->copy()->addMinutes($paymentAttemptLimit)->subDays($days)) ; $minutes = $date->diffInMinutes($date->copy()->addMinutes($paymentAttemptLimit)->subDays($days)->subHours($hours)); + $receive_date = $currencyConversionObject ? Carbon::now()->endOfDay()->addWeekdays($currencyConversionObject->getServiceId() === 1 ? 1 : 3)->timezone('Asia/Singapore')->format('4:00 \P\M, jS M, Y \G\M\T T') : null; + return [ 'bank' => new BankResource(Bank::find($calculationObject->getConfigurations()->getBankId())), 'rate' => $calculationObject->getConfigurations()->getRate(), @@ -30,6 +33,7 @@ class GeneratesBookingQuotation 'sub_total' => $calculationObject->getSubTotal(), 'total' => $calculationObject->getTotal(), 'date' => Carbon::now()->timezone('Asia/Singapore')->format('h:i a, jS M, Y \G\M\T T'), + 'receive_date' => $receive_date, 'payment_attempt_limit' => CarbonInterval::days($days)->hours($hours)->minutes($minutes)->forHumans() ]; } diff --git a/app/Classes/Modules/Companies/ControllersLogic/FetchCompanyBookingQuotationLogic.php b/app/Classes/Modules/Companies/ControllersLogic/FetchCompanyBookingQuotationLogic.php index 37225631..926acaae 100644 --- a/app/Classes/Modules/Companies/ControllersLogic/FetchCompanyBookingQuotationLogic.php +++ b/app/Classes/Modules/Companies/ControllersLogic/FetchCompanyBookingQuotationLogic.php @@ -14,6 +14,7 @@ use App\Models\Company; use App\Models\Currency; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; +use Carbon\Carbon; class FetchCompanyBookingQuotationLogic extends AbstractControllerLogic { @@ -71,7 +72,7 @@ class FetchCompanyBookingQuotationLogic extends AbstractControllerLogic if($calculationObject->getConvertibleTotal() < $calculationObject->getConfigurations()->getMinLimit()) throw new RequestValidationException('Your transfer is below the minimum amount allowed of '.$calculationObject->getConfigurations()->getMinLimit().' '.$currency->short_code); //TODO add po limit validation - return $this->response(['data' => $this->generatesBookingQuotation->execute($calculationObject)]); + return $this->response(['data' => $this->generatesBookingQuotation->execute($calculationObject, 0, $conversionObject)]); } diff --git a/resources/assets/vue/components/bookings/forms/CurrencyConverterComponent.vue b/resources/assets/vue/components/bookings/forms/CurrencyConverterComponent.vue index 29b05824..df8d0ef2 100644 --- a/resources/assets/vue/components/bookings/forms/CurrencyConverterComponent.vue +++ b/resources/assets/vue/components/bookings/forms/CurrencyConverterComponent.vue @@ -6,6 +6,11 @@ {{error}}
+
+
+
The recipient will receive the transfer amount by
{{ this.calculation.receive_date }}
+
+
From 09e3dc03ba99b32b55e40d1370b0e75b96f5d76c Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 11 Mar 2022 19:52:18 +0800 Subject: [PATCH 38/69] update bank account form component for ali pay --- .../banks/forms/BankAccountFormComponent.vue | 9 +- .../banks/forms/PhoneAccountFormComponent.vue | 157 ++++++++++++++++++ .../elements/BookingConfirmationComponent.vue | 5 +- 3 files changed, 167 insertions(+), 4 deletions(-) create mode 100644 resources/assets/vue/components/banks/forms/PhoneAccountFormComponent.vue diff --git a/resources/assets/vue/components/banks/forms/BankAccountFormComponent.vue b/resources/assets/vue/components/banks/forms/BankAccountFormComponent.vue index c91cf482..7e529be8 100644 --- a/resources/assets/vue/components/banks/forms/BankAccountFormComponent.vue +++ b/resources/assets/vue/components/banks/forms/BankAccountFormComponent.vue @@ -33,12 +33,12 @@
- +
-
+
@@ -117,6 +117,11 @@ country_id: { type: Number, default: 1 + }, + serviceType: { + type: Object, + required: false, + default: null } }, data(){ diff --git a/resources/assets/vue/components/banks/forms/PhoneAccountFormComponent.vue b/resources/assets/vue/components/banks/forms/PhoneAccountFormComponent.vue new file mode 100644 index 00000000..dffc1b2d --- /dev/null +++ b/resources/assets/vue/components/banks/forms/PhoneAccountFormComponent.vue @@ -0,0 +1,157 @@ + + \ No newline at end of file diff --git a/resources/assets/vue/components/bookings/elements/BookingConfirmationComponent.vue b/resources/assets/vue/components/bookings/elements/BookingConfirmationComponent.vue index dbb106e5..6d98fa3c 100644 --- a/resources/assets/vue/components/bookings/elements/BookingConfirmationComponent.vue +++ b/resources/assets/vue/components/bookings/elements/BookingConfirmationComponent.vue @@ -79,7 +79,7 @@
- +
@@ -124,7 +124,8 @@
- + +
From 3c2686bbf2007f53b3e47d99dbf18e8d45dcb538 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 11 Mar 2022 19:56:40 +0800 Subject: [PATCH 39/69] update currency vendor order blade --- .../views/pages/pdfs/currency_vendor_order.blade.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/views/pages/pdfs/currency_vendor_order.blade.php b/resources/views/pages/pdfs/currency_vendor_order.blade.php index cdac2d4e..922d7a7f 100644 --- a/resources/views/pages/pdfs/currency_vendor_order.blade.php +++ b/resources/views/pages/pdfs/currency_vendor_order.blade.php @@ -37,12 +37,12 @@ @foreach($transactions as $transaction) - {{$transaction->owner()->first()->booking->marking}} - {{$transaction->owner()->first()->booking->company->reference}} + {{$transaction->owner->marking}} + {{$transaction->owner->company->reference}} {{$transaction->currency_rate}} {{$transaction->currency->short_code}} {{number_format((float)$transaction->amount, 2, '.', '')}} - Account Holder Name: {{$transaction->owner()->first()->booking->bank->holder_name}}
{{$transaction->owner()->first()->booking->bank->bank_name}}: {{$transaction->owner()->first()->booking->bank->account_no}} -
Branch: {{$transaction->owner()->first()->booking->bank->bank_branch}}
Bank in Amount: {{$transaction->original_currency->short_code}} {{$transaction->original_amount}} + Account Holder Name: {{$transaction->owner->bank->holder_name}}
{{$transaction->owner->bank->bank_name}}: {{$transaction->owner->bank->account_no}} +
Branch: {{$transaction->owner->bank->bank_branch}}
Bank in Amount: {{$transaction->original_currency->short_code}} {{$transaction->original_amount}} @endforeach From c9e56cb030af22bc010eaccce165427dcfbaaba9 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 11 Mar 2022 20:58:55 +0800 Subject: [PATCH 40/69] tidy up customer mobile responsive view --- .../accounts/sections/OnboardingSectionComponent.vue | 4 ++-- .../companies/sections/CustomerDashboardSectionComponent.vue | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/assets/vue/components/accounts/sections/OnboardingSectionComponent.vue b/resources/assets/vue/components/accounts/sections/OnboardingSectionComponent.vue index 8b9e6171..5f2fb8e9 100644 --- a/resources/assets/vue/components/accounts/sections/OnboardingSectionComponent.vue +++ b/resources/assets/vue/components/accounts/sections/OnboardingSectionComponent.vue @@ -10,14 +10,14 @@
-
+
-
+
diff --git a/resources/assets/vue/components/companies/sections/CustomerDashboardSectionComponent.vue b/resources/assets/vue/components/companies/sections/CustomerDashboardSectionComponent.vue index b8e92fc1..9d11ecd0 100644 --- a/resources/assets/vue/components/companies/sections/CustomerDashboardSectionComponent.vue +++ b/resources/assets/vue/components/companies/sections/CustomerDashboardSectionComponent.vue @@ -200,7 +200,7 @@
-
+
From b1fc858f797182b4d2512fd332e9332eaa77f845 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 11 Mar 2022 21:00:53 +0800 Subject: [PATCH 41/69] display Recipient receive transfer date notice on booking quotation compoennt --- .../bookings/forms/BookingPaymentQuotationComponent.vue | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue index ca515606..a0e13ff2 100644 --- a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue +++ b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue @@ -399,6 +399,11 @@
{{this.data.fixed_currency.short_code}} {{(Math.round(((this.data.outstanding_amount - parseFloat(amount.replace(',', '')))+ Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
+
+
+
The recipient will receive the transfer amount by
{{ this.calculation.receive_date }}
+
+
Recipient Gets
From ee7e1840acc522e9c355b8dcc396993215d75bf8 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 11 Mar 2022 21:06:36 +0800 Subject: [PATCH 42/69] update spelling error for Alipay warning message --- .../vue/components/banks/forms/PhoneAccountFormComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/vue/components/banks/forms/PhoneAccountFormComponent.vue b/resources/assets/vue/components/banks/forms/PhoneAccountFormComponent.vue index dffc1b2d..206190e7 100644 --- a/resources/assets/vue/components/banks/forms/PhoneAccountFormComponent.vue +++ b/resources/assets/vue/components/banks/forms/PhoneAccountFormComponent.vue @@ -40,7 +40,7 @@
-
Warning: We do not encourage to transfer to non-chinese receipient Ali Pay account ! Procced Anyway.
+
Warning: We do not encourage to transfer to non-chinese recipient Alipay account ! Proceed Anyway.
    From 36d6d03836c1ed616a5ede38bdbad9524e01740a Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 11 Mar 2022 22:35:59 +0800 Subject: [PATCH 43/69] Create Mock Up White Form - ui and API --- .../DownloadMockUpWhiteFormPdfLogic.php | 125 ++++++++++++++++++ .../DownloadMockUpWhiteFormPdfController.php | 15 +++ .../forms/SupplierPlaceOrderFormComponent.vue | 12 ++ routes/web.php | 4 +- 4 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 app/Classes/Modules/Transactions/ControllersLogic/DownloadMockUpWhiteFormPdfLogic.php create mode 100644 app/Http/Controllers/Transactions/DownloadMockUpWhiteFormPdfController.php diff --git a/app/Classes/Modules/Transactions/ControllersLogic/DownloadMockUpWhiteFormPdfLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/DownloadMockUpWhiteFormPdfLogic.php new file mode 100644 index 00000000..d3561244 --- /dev/null +++ b/app/Classes/Modules/Transactions/ControllersLogic/DownloadMockUpWhiteFormPdfLogic.php @@ -0,0 +1,125 @@ + 'Create Mock Up White Form', + 'message' => 'You have successfully created Mock Up White Form' + ]; + } + + /** @var FetchesCompany */ + private $fetchesCompany; + + /** @var CreatesTransaction */ + private $createsTransaction; + + /** @var GeneratesTransactionBillNumber */ + private $generatesTransactionBillNumber; + + /** @var CalculatesTransactionServiceCharge */ + private $calculatesTransactionServiceCharge; + + /** @var CalculatesTransactionTransferFee */ + private $calculatesTransactionTransferFee; + + /** + * CreateSupplierTransactionLogic constructor. + * @param FetchesCompany $fetchesCompany + * @param FetchesConstant $fetchesConstant + * @param CreatesTransaction $createsTransaction + * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber + * @param CalculatesTransactionServiceCharge $calculatesTransactionServiceCharge + * @param CalculatesTransactionTransferFee $calculatesTransactionTransferFee + */ + public function __construct(FetchesCompany $fetchesCompany, FetchesConstant $fetchesConstant, CreatesTransaction $createsTransaction, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculatesTransactionServiceCharge $calculatesTransactionServiceCharge, CalculatesTransactionTransferFee $calculatesTransactionTransferFee) + { + + $this->fetchesCompany = $fetchesCompany; + $this->fetchesConstant = $fetchesConstant; + $this->createsTransaction = $createsTransaction; + $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; + $this->calculatesTransactionServiceCharge = $calculatesTransactionServiceCharge; + $this->calculatesTransactionTransferFee = $calculatesTransactionTransferFee; + } + + public function logic(Request $request) : JsonResponse + { + $supplier = $this->fetchesCompany->execute(['id' => $request->route('id')]); + + $rate = $request->route('rate'); + + $transactions = collect(); + $transferFeeTransactions = collect(); + + $payment_ids = explode(",", $request->route('payment_ids')); + + DB::beginTransaction(); + + foreach($payment_ids as $payment_id){ + + /** @var Transaction $payment */ + $payment = Transaction::find($payment_id); + + if($payment->status !== ApprovalStatus::APPROVED) continue; + + $billNumber = $this->generatesTransactionBillNumber->execute('SPLR-'); + $constant = SegmentConstant::where('reference', SegmentConstants::SERVICE_CHARGE)->where('detail->id', $supplier->id)->first(); + $serviceCharge = $this->calculatesTransactionServiceCharge->execute($payment->original_amount, $rate, $constant ? $constant->detail->service_charge->amount : 0); + + $object = new TransactionObject($billNumber, TransactionType::BILL, $supplier->id, 1, + $supplier->banks()->where('default', true)->first()->id, PaymentMethodType::CASH, + $payment->original_amount * (1 / $rate), $payment->original_amount, 1, $payment->original_currency_id, + $rate, 0, $supplier->id == 2 ? 0 : $serviceCharge, null, ApprovalStatus::PENDING_VERIFICATION); + + $transactions[] = $billTransaction = $this->createsTransaction->execute($payment->booking, $object); + + $transferFeeNumber = $this->generatesTransactionBillNumber->execute('TRFR-'); + $trasferFee = $this->calculatesTransactionTransferFee->execute($payment->original_amount); + $object = new TransactionObject($transferFeeNumber, TransactionType::TRANSFER_FEE, 1, $supplier->id, + $supplier->banks()->where('default', true)->first()->id, PaymentMethodType::CASH, + $payment->original_amount, $payment->original_amount, $payment->original_currency_id, $payment->original_currency_id, + 1, 0, $trasferFee, null, ApprovalStatus::PENDING_VERIFICATION); + + $transferFeeTransactions[] = $this->createsTransaction->execute($billTransaction, $object); + } + + + if(!count($transactions)) return $this->response([]); + + $pdf = LaravelMpdf::loadView('pages.pdfs.currency_vendor_order', ['transactions' => $transactions, 'transferFeeTransactions' => $transferFeeTransactions, 'supplier' => $supplier]); + DB::rollback(); + return $pdf->stream('MockUpWhiteForm.pdf'); + } +} diff --git a/app/Http/Controllers/Transactions/DownloadMockUpWhiteFormPdfController.php b/app/Http/Controllers/Transactions/DownloadMockUpWhiteFormPdfController.php new file mode 100644 index 00000000..10267363 --- /dev/null +++ b/app/Http/Controllers/Transactions/DownloadMockUpWhiteFormPdfController.php @@ -0,0 +1,15 @@ +execute($request); + } +} diff --git a/resources/assets/vue/components/bookings/forms/SupplierPlaceOrderFormComponent.vue b/resources/assets/vue/components/bookings/forms/SupplierPlaceOrderFormComponent.vue index c0acd955..84a9caa8 100644 --- a/resources/assets/vue/components/bookings/forms/SupplierPlaceOrderFormComponent.vue +++ b/resources/assets/vue/components/bookings/forms/SupplierPlaceOrderFormComponent.vue @@ -48,6 +48,7 @@
    +
    @@ -138,6 +139,17 @@ payments: [], rate: 0 }; + }, + generateMockWhiteForm() { + var paymentsIds = []; + + this.payments.forEach(function(payment) { + paymentsIds.push(payment.id); + }); + + paymentsIds = paymentsIds.toString(); + + window.open(this.route('transactions.supplier.mockUpWhiteForm.download', this.supplier.id, this.parameters.rate, paymentsIds), '_blank'); } }, mixins: [FormHandler] diff --git a/routes/web.php b/routes/web.php index 03435aee..d3b4e432 100644 --- a/routes/web.php +++ b/routes/web.php @@ -170,4 +170,6 @@ Route::get('purchase/sensitive/', function(Request $request){ foreach ($items as $key => $item){ echo ($key+1).'. '.$item->product_name.' => '.$item->transaction->owner->marking.'

    '; } -}); \ No newline at end of file +}); + +Route::get('/transactions/supplier/{id}/mock-up-white-form/download/{rate}/{payment_ids}', 'Transactions\DownloadMockUpWhiteFormPdfController@download')->name('transactions.supplier.mockUpWhiteForm.download'); \ No newline at end of file From 481426bec99f753d34c08239622d7624a3473ea3 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sat, 12 Mar 2022 17:02:21 +0800 Subject: [PATCH 44/69] clean up development --- .../Services/GeneratesBookingQuotation.php | 2 +- .../CreateSupplierTransactionLogic.php | 104 ++----------- .../DownloadMockUpWhiteFormPdfLogic.php | 117 ++++---------- .../CreateSupplierTransactionProcessor.php | 143 ++++++++++++++++++ .../CalculatesTransactionServiceCharge.php | 2 +- .../CalculatesTransactionTransferFee.php | 4 +- .../Constants/BankAccountType.php | 2 + .../DownloadMockUpWhiteFormPdfController.php | 2 +- app/Http/Resources/CompanyResource.php | 15 +- app/Http/Resources/TransactionResource.php | 2 +- .../banks/forms/BankAccountFormComponent.vue | 6 +- .../elements/BookingConfirmationComponent.vue | 5 +- .../bookings/forms/BookingFormComponent.vue | 2 +- .../BookingPaymentQuotationComponent.vue | 13 +- .../forms/ConfirmQuotationFormComponent.vue | 5 - .../forms/CurrencyConverterComponent.vue | 2 +- .../forms/SupplierPlaceOrderFormComponent.vue | 10 +- .../SupplierPendingOrdersSectionComponent.vue | 11 +- .../companies/elements/SupplierComponent.vue | 4 +- .../SupplierServiceChargeFormComponent.vue | 37 +++-- .../general/forms/SelectableComponent.vue | 2 +- .../forms/AnnouncementFormComponent.vue | 13 +- .../assets/vue/general/mixins/formHandler.js | 1 + .../pdfs/currency_vendor_order.blade.php | 12 +- routes/web.php | 2 +- 25 files changed, 256 insertions(+), 262 deletions(-) create mode 100644 app/Classes/Modules/Transactions/Processors/CreateSupplierTransactionProcessor.php diff --git a/app/Classes/Modules/Bookings/Services/GeneratesBookingQuotation.php b/app/Classes/Modules/Bookings/Services/GeneratesBookingQuotation.php index 7d6c018e..34f58d3a 100644 --- a/app/Classes/Modules/Bookings/Services/GeneratesBookingQuotation.php +++ b/app/Classes/Modules/Bookings/Services/GeneratesBookingQuotation.php @@ -19,7 +19,7 @@ class GeneratesBookingQuotation $hours = $date->diffInHours($date->copy()->addMinutes($paymentAttemptLimit)->subDays($days)) ; $minutes = $date->diffInMinutes($date->copy()->addMinutes($paymentAttemptLimit)->subDays($days)->subHours($hours)); - $receive_date = $currencyConversionObject ? Carbon::now()->endOfDay()->addWeekdays($currencyConversionObject->getServiceId() === 1 ? 1 : 3)->timezone('Asia/Singapore')->format('4:00 \P\M, jS M, Y \G\M\T T') : null; + $receive_date = $currencyConversionObject ? Carbon::now()->endOfDay()->addWeekdays($currencyConversionObject->getServiceId() === 3 ? 4 : 2)->timezone('Asia/Singapore')->format('4:00 \P\M, jS M, Y \G\M\T T') : null; return [ 'bank' => new BankResource(Bank::find($calculationObject->getConfigurations()->getBankId())), diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php index 93caf8d1..1cf71643 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierTransactionLogic.php @@ -3,37 +3,19 @@ namespace App\Classes\Modules\Transactions\ControllersLogic; -use DB; -use Carbon\Carbon; +use App\Classes\Modules\Transactions\Processors\CreateSupplierTransactionProcessor; use App\Models\Document; -use Barryvdh\DomPDF\PDF; -use App\Models\Transaction; -use Illuminate\Support\Str; use Illuminate\Http\Request; -use App\Models\SegmentConstant; use Illuminate\Http\JsonResponse; -use Illuminate\Support\Facades\Storage; use Meneses\LaravelMpdf\Facades\LaravelMpdf; use App\Classes\ValueObjects\Constants\DocumentType; use App\Classes\ValueObjects\Constants\ApprovalStatus; -use App\Classes\ValueObjects\Constants\TransactionType; use App\Classes\Modules\Documents\Services\CreatesFiles; -use App\Classes\ValueObjects\Constants\SegmentConstants; -use App\Classes\ValueObjects\Constants\PaymentMethodType; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Companies\Services\FetchesCompany; -use App\Classes\Modules\Segments\Services\FetchesConstant; use Meneses\LaravelLaravelMpdf\Facades\LaravelLaravelMpdf; use App\Classes\Modules\Documents\Services\CreatesDocument; -use App\Classes\Modules\Transactions\Services\CreatesTransaction; - -use App\Classes\Modules\Transactions\Services\FetchesTransaction; use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject; -use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; -use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; -use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber; -use App\Classes\Modules\Transactions\Services\CalculatesTransactionTransferFee; -use App\Classes\Modules\Transactions\Services\CalculatesTransactionServiceCharge; class CreateSupplierTransactionLogic extends AbstractControllerLogic { @@ -52,14 +34,8 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic /** @var FetchesCompany */ private $fetchesCompany; - /** @var FetchesTransaction */ - private $fetchesTransaction; - - /** @var UpdatesTransactionStatus */ - private $updatesTransactionStatus; - - /** @var CreatesTransaction */ - private $createsTransaction; + /** @var CreateSupplierTransactionProcessor */ + private $createSupplierTransactionProcessor; /** @var CreatesDocument */ private $createsDocument; @@ -67,44 +43,19 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic /** @var CreatesFiles */ private $createsFile; - /** @var GeneratesTransactionBillNumber */ - private $generatesTransactionBillNumber; - - /** @var CalculatesTransactionServiceCharge */ - private $calculatesTransactionServiceCharge; - - /** @var CalculatesTransactionTransferFee */ - private $calculatesTransactionTransferFee; - - /** @var PDF */ - private $pdf; - /** * CreateSupplierTransactionLogic constructor. * @param FetchesCompany $fetchesCompany - * @param FetchesTransaction $fetchesTransaction - * @param FetchesConstant $fetchesConstant - * @param UpdatesTransactionStatus $updatesTransactionStatus - * @param CreatesTransaction $createsTransaction - * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber - * @param CalculatesTransactionServiceCharge $calculatesTransactionServiceCharge - * @param CalculatesTransactionTransferFee $calculatesTransactionTransferFee - * @param PDF $pdf + * @param CreateSupplierTransactionProcessor $createSupplierTransactionProcessor + * @param CreatesDocument $createsDocument + * @param CreatesFiles $createsFile */ - public function __construct(FetchesCompany $fetchesCompany, FetchesTransaction $fetchesTransaction, FetchesConstant $fetchesConstant, UpdatesTransactionStatus $updatesTransactionStatus, CreatesTransaction $createsTransaction, CreatesDocument $createsDocument, CreatesFiles $createsFile, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculatesTransactionServiceCharge $calculatesTransactionServiceCharge, CalculatesTransactionTransferFee $calculatesTransactionTransferFee, PDF $pdf) + public function __construct(FetchesCompany $fetchesCompany, CreateSupplierTransactionProcessor $createSupplierTransactionProcessor, CreatesDocument $createsDocument, CreatesFiles $createsFile) { - $this->fetchesCompany = $fetchesCompany; - $this->fetchesTransaction = $fetchesTransaction; - $this->fetchesConstant = $fetchesConstant; - $this->updatesTransactionStatus = $updatesTransactionStatus; - $this->createsTransaction = $createsTransaction; + $this->createSupplierTransactionProcessor = $createSupplierTransactionProcessor; $this->createsDocument = $createsDocument; $this->createsFile = $createsFile; - $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; - $this->calculatesTransactionServiceCharge = $calculatesTransactionServiceCharge; - $this->calculatesTransactionTransferFee = $calculatesTransactionTransferFee; - $this->pdf = $pdf; } public function logic(Request $request) : JsonResponse @@ -114,44 +65,13 @@ class CreateSupplierTransactionLogic extends AbstractControllerLogic $rate = $request->input('rate'); - $transactions = collect(); - $transferFeeTransactions = collect(); + $payments = $request->input('payments'); - foreach($request->input('payments') as $payment){ + $this->createSupplierTransactionProcessor->execute($supplier, $rate, $payments); - /** @var Transaction $payment */ - $payment = $this->fetchesTransaction->execute(['id' => $payment['id']]); - - if($payment->status !== ApprovalStatus::APPROVED) continue; + if(!count($this->createSupplierTransactionProcessor->getBills())) return $this->response([]); - $this->updatesTransactionStatus->execute($payment, ApprovalStatus::COMPLETED); - $billNumber = $this->generatesTransactionBillNumber->execute('SPLR-'); - // $constant = $this->fetchesConstant->execute(['service_charge' => $supplier->id]); - $constant = SegmentConstant::where('reference', SegmentConstants::SERVICE_CHARGE)->where('detail->id', $supplier->id)->first(); - $serviceCharge = $this->calculatesTransactionServiceCharge->execute($payment->original_amount, $rate, $constant ? $constant->detail->service_charge->amount : 0); - - $object = new TransactionObject($billNumber, TransactionType::BILL, $supplier->id, 1, - $supplier->banks()->where('default', true)->first()->id, PaymentMethodType::CASH, - $payment->original_amount * (1 / $rate), $payment->original_amount, 1, $payment->original_currency_id, - $rate, 0, $supplier->id == 2 ? 0 : $serviceCharge, null, ApprovalStatus::PENDING_VERIFICATION); - - $transactions[] = $billTransaction = $this->createsTransaction->execute($payment->booking, $object); - - $transferFeeNumber = $this->generatesTransactionBillNumber->execute('TRFR-'); - $trasferFee = $this->calculatesTransactionTransferFee->execute($payment->original_amount); - $object = new TransactionObject($transferFeeNumber, TransactionType::TRANSFER_FEE, 1, $supplier->id, - $supplier->banks()->where('default', true)->first()->id, PaymentMethodType::CASH, - $payment->original_amount, $payment->original_amount, $payment->original_currency_id, $payment->original_currency_id, - 1, 0, $trasferFee, null, ApprovalStatus::PENDING_VERIFICATION); - - $transferFeeTransactions[] = $this->createsTransaction->execute($billTransaction, $object); - } - - if(!count($transactions)) return $this->response([]); - - $pdf = LaravelMpdf::loadView('pages.pdfs.currency_vendor_order', ['transactions' => $transactions, 'transferFeeTransactions' => $transferFeeTransactions, 'supplier' => $supplier]); - - $path = Str::studly($supplier->name).'_'.Carbon::now()->format('Y_m_d_h_s_i').'.pdf'; + $pdf = LaravelMpdf::loadView('pages.pdfs.currency_vendor_order', ['transactions' => $this->createSupplierTransactionProcessor->getBills(), 'transferFeeTransactions' => $this->createSupplierTransactionProcessor->getTransferTransactions(), 'supplier' => $supplier]); $object = new DocumentObject( DocumentType::CURRENCY_VENDOR_ORDER, diff --git a/app/Classes/Modules/Transactions/ControllersLogic/DownloadMockUpWhiteFormPdfLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/DownloadMockUpWhiteFormPdfLogic.php index d3561244..e1875f0a 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/DownloadMockUpWhiteFormPdfLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/DownloadMockUpWhiteFormPdfLogic.php @@ -3,123 +3,60 @@ namespace App\Classes\Modules\Transactions\ControllersLogic; -// use DB; -use App\Models\Transaction; +use App\Classes\Modules\Transactions\Processors\CreateSupplierTransactionProcessor; use Illuminate\Http\Request; -use App\Models\SegmentConstant; -use Illuminate\Http\JsonResponse; -use Meneses\LaravelMpdf\Facades\LaravelMpdf; -use App\Classes\ValueObjects\Constants\ApprovalStatus; -use App\Classes\ValueObjects\Constants\TransactionType; -use App\Classes\ValueObjects\Constants\SegmentConstants; -use App\Classes\ValueObjects\Constants\PaymentMethodType; -use App\Classes\General\Abstracts\AbstractControllerLogic; -use App\Classes\Modules\Companies\Services\FetchesCompany; -use App\Classes\Modules\Segments\Services\FetchesConstant; -use App\Classes\Modules\Transactions\Services\CreatesTransaction; - -use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject; -use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber; -use App\Classes\Modules\Transactions\Services\CalculatesTransactionTransferFee; -use App\Classes\Modules\Transactions\Services\CalculatesTransactionServiceCharge; use Illuminate\Support\Facades\DB; +use Meneses\LaravelMpdf\Facades\LaravelMpdf; +use App\Classes\Modules\Companies\Services\FetchesCompany; +use Meneses\LaravelLaravelMpdf\Facades\LaravelLaravelMpdf; - -class DownloadMockUpWhiteFormPdfLogic extends AbstractControllerLogic +class DownloadMockUpWhiteFormPdfLogic { - - /** - * @return array - */ - protected function notification():array { - return [ - 'title' => 'Create Mock Up White Form', - 'message' => 'You have successfully created Mock Up White Form' - ]; - } - /** @var FetchesCompany */ private $fetchesCompany; - /** @var CreatesTransaction */ - private $createsTransaction; - - /** @var GeneratesTransactionBillNumber */ - private $generatesTransactionBillNumber; - - /** @var CalculatesTransactionServiceCharge */ - private $calculatesTransactionServiceCharge; - - /** @var CalculatesTransactionTransferFee */ - private $calculatesTransactionTransferFee; + /** @var CreateSupplierTransactionProcessor */ + private $createSupplierTransactionProcessor; /** - * CreateSupplierTransactionLogic constructor. + * DownloadMockUpWhiteFormPdfLogic constructor. * @param FetchesCompany $fetchesCompany - * @param FetchesConstant $fetchesConstant - * @param CreatesTransaction $createsTransaction - * @param GeneratesTransactionBillNumber $generatesTransactionBillNumber - * @param CalculatesTransactionServiceCharge $calculatesTransactionServiceCharge - * @param CalculatesTransactionTransferFee $calculatesTransactionTransferFee + * @param CreateSupplierTransactionProcessor $createSupplierTransactionProcessor */ - public function __construct(FetchesCompany $fetchesCompany, FetchesConstant $fetchesConstant, CreatesTransaction $createsTransaction, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CalculatesTransactionServiceCharge $calculatesTransactionServiceCharge, CalculatesTransactionTransferFee $calculatesTransactionTransferFee) + public function __construct(FetchesCompany $fetchesCompany, CreateSupplierTransactionProcessor $createSupplierTransactionProcessor) { - $this->fetchesCompany = $fetchesCompany; - $this->fetchesConstant = $fetchesConstant; - $this->createsTransaction = $createsTransaction; - $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; - $this->calculatesTransactionServiceCharge = $calculatesTransactionServiceCharge; - $this->calculatesTransactionTransferFee = $calculatesTransactionTransferFee; + $this->createSupplierTransactionProcessor = $createSupplierTransactionProcessor; } - public function logic(Request $request) : JsonResponse + + /** + * @param Request $request + * @return string|\Symfony\Component\HttpFoundation\Response + * @throws \App\Classes\Exceptions\MalformedRequestException + */ + public function execute(Request $request) { + $supplier = $this->fetchesCompany->execute(['id' => $request->route('id')]); - $rate = $request->route('rate'); + $rate = $request->input('rate'); - $transactions = collect(); - $transferFeeTransactions = collect(); - - $payment_ids = explode(",", $request->route('payment_ids')); + $payments = array_map(function($value){ + return ['id' => $value]; + }, json_decode($request->input('payments'))); DB::beginTransaction(); - foreach($payment_ids as $payment_id){ + $this->createSupplierTransactionProcessor->execute($supplier, $rate, $payments); - /** @var Transaction $payment */ - $payment = Transaction::find($payment_id); - - if($payment->status !== ApprovalStatus::APPROVED) continue; + if(!count($this->createSupplierTransactionProcessor->getBills())) return 'unexpected error'; - $billNumber = $this->generatesTransactionBillNumber->execute('SPLR-'); - $constant = SegmentConstant::where('reference', SegmentConstants::SERVICE_CHARGE)->where('detail->id', $supplier->id)->first(); - $serviceCharge = $this->calculatesTransactionServiceCharge->execute($payment->original_amount, $rate, $constant ? $constant->detail->service_charge->amount : 0); + $pdf = LaravelMpdf::loadView('pages.pdfs.currency_vendor_order', ['transactions' => $this->createSupplierTransactionProcessor->getBills(), 'transferFeeTransactions' => $this->createSupplierTransactionProcessor->getTransferTransactions(), 'supplier' => $supplier]); - $object = new TransactionObject($billNumber, TransactionType::BILL, $supplier->id, 1, - $supplier->banks()->where('default', true)->first()->id, PaymentMethodType::CASH, - $payment->original_amount * (1 / $rate), $payment->original_amount, 1, $payment->original_currency_id, - $rate, 0, $supplier->id == 2 ? 0 : $serviceCharge, null, ApprovalStatus::PENDING_VERIFICATION); + DB::rollBack(); - $transactions[] = $billTransaction = $this->createsTransaction->execute($payment->booking, $object); - - $transferFeeNumber = $this->generatesTransactionBillNumber->execute('TRFR-'); - $trasferFee = $this->calculatesTransactionTransferFee->execute($payment->original_amount); - $object = new TransactionObject($transferFeeNumber, TransactionType::TRANSFER_FEE, 1, $supplier->id, - $supplier->banks()->where('default', true)->first()->id, PaymentMethodType::CASH, - $payment->original_amount, $payment->original_amount, $payment->original_currency_id, $payment->original_currency_id, - 1, 0, $trasferFee, null, ApprovalStatus::PENDING_VERIFICATION); - - $transferFeeTransactions[] = $this->createsTransaction->execute($billTransaction, $object); - } - - - if(!count($transactions)) return $this->response([]); - - $pdf = LaravelMpdf::loadView('pages.pdfs.currency_vendor_order', ['transactions' => $transactions, 'transferFeeTransactions' => $transferFeeTransactions, 'supplier' => $supplier]); - DB::rollback(); return $pdf->stream('MockUpWhiteForm.pdf'); } } diff --git a/app/Classes/Modules/Transactions/Processors/CreateSupplierTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateSupplierTransactionProcessor.php new file mode 100644 index 00000000..3f052352 --- /dev/null +++ b/app/Classes/Modules/Transactions/Processors/CreateSupplierTransactionProcessor.php @@ -0,0 +1,143 @@ +fetchesTransaction = $fetchesTransaction; + $this->updatesTransactionStatus = $updatesTransactionStatus; + $this->createsTransaction = $createsTransaction; + $this->generatesTransactionBillNumber = $generatesTransactionBillNumber; + $this->calculatesTransactionServiceCharge = $calculatesTransactionServiceCharge; + $this->calculatesTransactionTransferFee = $calculatesTransactionTransferFee; + $this->bills = collect(); + $this->transferFee = collect(); + } + + /** + * @param Company $supplier + * @param String $rate + * @param array $payments + * @throws \App\Classes\Exceptions\MalformedRequestException + */ + public function execute(Company $supplier, String $rate, Array $payments) { + + foreach($payments as $payment){ + + /** @var Transaction $payment */ + $payment = $this->fetchesTransaction->execute(['id' => $payment['id']]); + + if($payment->status !== ApprovalStatus::APPROVED) continue; + + $this->updatesTransactionStatus->execute($payment, ApprovalStatus::COMPLETED); + $billNumber = $this->generatesTransactionBillNumber->execute('SPLR-'); + $constant = SegmentConstant::where('reference', SegmentConstants::SERVICE_CHARGE)->where('detail->id', $supplier->id)->first(); + + $serviceCharge = $this->calculatesTransactionServiceCharge->execute($payment->original_amount, $rate, $constant ? (float) $constant->detail->amount : 0); + + $object = new TransactionObject($billNumber, TransactionType::BILL, $supplier->id, 1, + $supplier->banks()->where('default', true)->first()->id, PaymentMethodType::CASH, + $payment->original_amount * (1 / $rate), $payment->original_amount, 1, $payment->original_currency_id, + $rate, 0, $serviceCharge, null, ApprovalStatus::PENDING_VERIFICATION); + + /** @var Transaction $billTransaction */ + $billTransaction = $this->createsTransaction->execute($payment, $object); + $this->pushBill($billTransaction); + + $transferFeeNumber = $this->generatesTransactionBillNumber->execute('TRFR-'); + $transferFee = $this->calculatesTransactionTransferFee->execute($payment->original_amount); + $object = new TransactionObject($transferFeeNumber, TransactionType::TRANSFER_FEE, 1, $supplier->id, + $supplier->banks()->where('default', true)->first()->id, PaymentMethodType::CASH, + $payment->original_amount, $payment->original_amount, $payment->original_currency_id, $payment->original_currency_id, + 1, 0, $transferFee, null, ApprovalStatus::PENDING_VERIFICATION); + + $this->pushTransferFee($this->createsTransaction->execute($billTransaction, $object)); + } + + } + + /** + * @return Collection + */ + public function getBills(): Collection + { + return $this->bills; + } + + /** + * @return Collection + */ + public function getTransferTransactions(): Collection + { + return $this->transferFee; + } + + /** + * @param $bill + */ + private function pushBill($bill): void + { + $this->bills->push($bill); + } + + /** + * @param $transferFee + */ + private function pushTransferFee($transferFee): void + { + $this->transferFee->push($transferFee); + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php b/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php index 641e3903..8ddb80c9 100644 --- a/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php +++ b/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php @@ -12,7 +12,7 @@ class CalculatesTransactionServiceCharge * @param float $transfer_fee * @return float */ - public function execute(float $amount, float $rate, ?float $service_charge = 0.75, ?float $transfer_fee = 0.00) { + public function execute(float $amount, float $rate, ?float $service_charge = 0, ?float $transfer_fee = 0.00) { return (($amount + $transfer_fee) * (1/$rate)) * $service_charge / 100; } diff --git a/app/Classes/Modules/Transactions/Services/CalculatesTransactionTransferFee.php b/app/Classes/Modules/Transactions/Services/CalculatesTransactionTransferFee.php index 14f77b84..b5feb245 100644 --- a/app/Classes/Modules/Transactions/Services/CalculatesTransactionTransferFee.php +++ b/app/Classes/Modules/Transactions/Services/CalculatesTransactionTransferFee.php @@ -10,8 +10,8 @@ class CalculatesTransactionTransferFee * @param float $transfer_fee * @return float */ - public function execute(float $amount, ?float $transfer_fee = 0.002) { - return $amount * $transfer_fee/100; + public function execute(float $amount, ?float $transfer_fee = 0) { + return $amount * ($transfer_fee / 100); } } \ No newline at end of file diff --git a/app/Classes/ValueObjects/Constants/BankAccountType.php b/app/Classes/ValueObjects/Constants/BankAccountType.php index 13a36fde..c1ae288e 100644 --- a/app/Classes/ValueObjects/Constants/BankAccountType.php +++ b/app/Classes/ValueObjects/Constants/BankAccountType.php @@ -8,4 +8,6 @@ final class BankAccountType { public const EXTERNAL = 2; + public const ALIPAY= 3; + } diff --git a/app/Http/Controllers/Transactions/DownloadMockUpWhiteFormPdfController.php b/app/Http/Controllers/Transactions/DownloadMockUpWhiteFormPdfController.php index 10267363..e94c9484 100644 --- a/app/Http/Controllers/Transactions/DownloadMockUpWhiteFormPdfController.php +++ b/app/Http/Controllers/Transactions/DownloadMockUpWhiteFormPdfController.php @@ -9,7 +9,7 @@ use Illuminate\Http\JsonResponse; class DownloadMockUpWhiteFormPdfController { - public function download(Request $request, DownloadMockUpWhiteFormPdfLogic $logic) : JsonResponse { + public function download(Request $request, DownloadMockUpWhiteFormPdfLogic $logic) { return $logic->execute($request); } } diff --git a/app/Http/Resources/CompanyResource.php b/app/Http/Resources/CompanyResource.php index 929432e3..fceab5bc 100644 --- a/app/Http/Resources/CompanyResource.php +++ b/app/Http/Resources/CompanyResource.php @@ -30,6 +30,9 @@ class CompanyResource extends JsonResource $lastPayment = $this->transactions()->where('transactions.type', TransactionType::PAYMENT)->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->orderBy('id', 'DESC')->first(); $totalPayments = $this->transactions()->where('transactions.type', TransactionType::PAYMENT)->whereIn('transactions.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount'); + $segment = SegmentConstant::where('reference', SegmentConstants::SUPPLIER_CURRENCIES)->where('detail->id', $this->id)->first(); + $serviceCharge = SegmentConstant::where('reference', SegmentConstants::SERVICE_CHARGE)->where('detail->id', $this->id)->first(); + return [ 'id' => $this->id, 'name' => $this->name, @@ -57,14 +60,14 @@ class CompanyResource extends JsonResource 'default' => new BankResource($this->banks->where('type', BankAccountType::EXTERNAL)->where('default', true)->first()) ], 'segments' => SegmentResource::collection($this->segments), - 'service_charges' => SegmentConstant::where('reference', SegmentConstants::SERVICE_CHARGE)->where('detail->id', $this->id)->first(), 'services' => (new FetchesCompanyServices())->getServices($this->servicesConfigurations()), - 'currencies' => $this->when($this->business_type === BusinessType::CURRENCY_VENDOR, function(){ - $segment = SegmentConstant::where('reference', SegmentConstants::SUPPLIER_CURRENCIES)->where('detail->id', $this->id)->first(); - return $segment ? CurrencyResource::collection(Currency::whereIn('id', $segment->detail->currencies)->get()) : []; - }), 'wallet' => new WalletResource($this->wallets()->first()), - 'created_at' => $this->created_at->format('d-m-Y') + 'created_at' => $this->created_at->format('d-m-Y'), + $this->mergeWhen($this->business_type === BusinessType::CURRENCY_VENDOR, [ + 'currencies' => $segment ? CurrencyResource::collection(Currency::whereIn('id', $segment->detail->currencies)->get()) : [], + 'service_charge' => $serviceCharge + ]) + ]; } } diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index 35c29908..b7ca2f72 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -18,7 +18,7 @@ class TransactionResource extends JsonResource { $booking = (int)$this->type === TransactionType::BILL ? $this->owner->owner : $this->booking; - $days = $this->updated_at->endOfDay()->addWeekdays($booking->service_id === 1 ? 1 : 3); + $days = $this->updated_at->endOfDay()->addWeekdays($booking->service_id === 3 ? 3 : 1); return [ 'id' => $this->id, diff --git a/resources/assets/vue/components/banks/forms/BankAccountFormComponent.vue b/resources/assets/vue/components/banks/forms/BankAccountFormComponent.vue index 7e529be8..4b4d0d6c 100644 --- a/resources/assets/vue/components/banks/forms/BankAccountFormComponent.vue +++ b/resources/assets/vue/components/banks/forms/BankAccountFormComponent.vue @@ -33,13 +33,13 @@
    - +
    -
    -
    +
    +
    diff --git a/resources/assets/vue/components/bookings/elements/BookingConfirmationComponent.vue b/resources/assets/vue/components/bookings/elements/BookingConfirmationComponent.vue index 6d98fa3c..9311c735 100644 --- a/resources/assets/vue/components/bookings/elements/BookingConfirmationComponent.vue +++ b/resources/assets/vue/components/bookings/elements/BookingConfirmationComponent.vue @@ -9,7 +9,7 @@
    -
    +
    {{this.data.serviceType.name}}
    @@ -20,7 +20,6 @@
    Service Type
    -
    @@ -79,7 +78,7 @@
    - +
    diff --git a/resources/assets/vue/components/bookings/forms/BookingFormComponent.vue b/resources/assets/vue/components/bookings/forms/BookingFormComponent.vue index 6b285afd..1fffd0a0 100644 --- a/resources/assets/vue/components/bookings/forms/BookingFormComponent.vue +++ b/resources/assets/vue/components/bookings/forms/BookingFormComponent.vue @@ -44,7 +44,7 @@
    {{service.name}} - +
    diff --git a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue index a0e13ff2..643cd29a 100644 --- a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue +++ b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue @@ -49,7 +49,8 @@
    -
    + +
    +
    +
    +
    The recipient will receive the transfer amount by
    {{ this.calculation.receive_date }}
    +
    +
    Outstanding
    @@ -399,11 +405,6 @@
    {{this.data.fixed_currency.short_code}} {{(Math.round(((this.data.outstanding_amount - parseFloat(amount.replace(',', '')))+ Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
    -
    -
    -
    The recipient will receive the transfer amount by
    {{ this.calculation.receive_date }}
    -
    -
    Recipient Gets
    diff --git a/resources/assets/vue/components/bookings/forms/ConfirmQuotationFormComponent.vue b/resources/assets/vue/components/bookings/forms/ConfirmQuotationFormComponent.vue index 9b168415..f8db5603 100644 --- a/resources/assets/vue/components/bookings/forms/ConfirmQuotationFormComponent.vue +++ b/resources/assets/vue/components/bookings/forms/ConfirmQuotationFormComponent.vue @@ -23,11 +23,6 @@
    You will be redirected to your bank to complete the payment of {{(Math.round((calculation.total + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}} MYR after clicking on the confirm button below. please follow your bank instruction to complete the payment
    -
    -
    -
    You will be redirected to your bank to complete the payment of {{(Math.round((calculation.total + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}} MYR after clicking on the confirm button below. please follow your bank instruction to complete the payment
    -
    -
    diff --git a/resources/assets/vue/components/bookings/forms/CurrencyConverterComponent.vue b/resources/assets/vue/components/bookings/forms/CurrencyConverterComponent.vue index df8d0ef2..65d5a243 100644 --- a/resources/assets/vue/components/bookings/forms/CurrencyConverterComponent.vue +++ b/resources/assets/vue/components/bookings/forms/CurrencyConverterComponent.vue @@ -6,7 +6,7 @@ {{error}}
    -
    +
    The recipient will receive the transfer amount by
    {{ this.calculation.receive_date }}
    diff --git a/resources/assets/vue/components/bookings/forms/SupplierPlaceOrderFormComponent.vue b/resources/assets/vue/components/bookings/forms/SupplierPlaceOrderFormComponent.vue index 84a9caa8..4ec71edd 100644 --- a/resources/assets/vue/components/bookings/forms/SupplierPlaceOrderFormComponent.vue +++ b/resources/assets/vue/components/bookings/forms/SupplierPlaceOrderFormComponent.vue @@ -141,15 +141,11 @@ }; }, generateMockWhiteForm() { - var paymentsIds = []; - - this.payments.forEach(function(payment) { - paymentsIds.push(payment.id); + let paymentIds = this.payments.map(function(payment) { + return payment.id }); - - paymentsIds = paymentsIds.toString(); - window.open(this.route('transactions.supplier.mockUpWhiteForm.download', this.supplier.id, this.parameters.rate, paymentsIds), '_blank'); + window.open(this.route('whiteForm.mockUp', this.supplier.id)+'?rate='+this.parameters.rate+'&payments='+JSON.stringify(paymentIds), '_blank'); } }, mixins: [FormHandler] diff --git a/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue b/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue index 07b1eda0..f5277a00 100644 --- a/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue +++ b/resources/assets/vue/components/bookings/sections/SupplierPendingOrdersSectionComponent.vue @@ -114,7 +114,7 @@
    - + @@ -126,7 +126,7 @@
    - + @@ -176,9 +176,10 @@ methods: { successHandler(response){ this.suppliers = response.payload.data; - this.updateSupplier(this.suppliers[0]); - this.updateCurrency(this.suppliers[0].currencies[0]); - this.updateService(this.suppliers[0].services[0]); + this.selectedSupplier= this.suppliers[0]; + this.selectedService = this.suppliers[0].services[0]; + this.selectedCurrency = this.suppliers[0].currencies[0]; + this.updateList(); }, updateSupplier(supplier){ if(supplier !== this.selectedSupplier){ diff --git a/resources/assets/vue/components/companies/elements/SupplierComponent.vue b/resources/assets/vue/components/companies/elements/SupplierComponent.vue index 8f0090fd..b25e9ae7 100644 --- a/resources/assets/vue/components/companies/elements/SupplierComponent.vue +++ b/resources/assets/vue/components/companies/elements/SupplierComponent.vue @@ -42,7 +42,7 @@
    -
    0.00
    +
    {{item.service_charge ? parseFloat(item.service_charge.detail.amount).toFixed(3) : '0.000'}}%
    @@ -59,7 +59,7 @@ - + diff --git a/resources/assets/vue/components/companies/forms/SupplierServiceChargeFormComponent.vue b/resources/assets/vue/components/companies/forms/SupplierServiceChargeFormComponent.vue index 4a4bea33..37301e23 100644 --- a/resources/assets/vue/components/companies/forms/SupplierServiceChargeFormComponent.vue +++ b/resources/assets/vue/components/companies/forms/SupplierServiceChargeFormComponent.vue @@ -17,8 +17,8 @@
    - - + +
    @@ -40,13 +40,9 @@ import { required, requiredIf } from "vuelidate/lib/validators"; export default { props: { - details: { - type: Object, - required: true - }, - defaultCharge: { + supplierId: { type: Number, - required: false + required: true } }, data(){ @@ -55,11 +51,9 @@ name: 'Service Charge', reference: 'SERVICE_CHARGE', detail: { - service_charge: { - id: this.details.id, - type: "percentage", - amount: this.defaultCharge, - }, + id: this.supplierId, + type: "percentage", + amount: 0, }, segment_id: 1 }, @@ -68,13 +62,26 @@ validations: { parameters: { amount: { - required: true + detail: { + amount: { + required: true + } + } + } + } + }, + created(){ + if(this.data){ + this.parameters.detail = { + id: this.supplierId, + type: "percentage", + amount: parseFloat(this.data.detail.amount).toFixed(3), } } }, methods: { submitForm(){ - this.submit(this.defaultCharge ? this.route('api.segment_constant.update', this.service_charges.id) : this.route('api.segment_constant.create'), 'post', this.section, true, true); + this.submit(this.data ? this.route('api.segment_constant.update', this.data.id) : this.route('api.segment_constant.create'), this.data ? 'put' : 'post', this.section, true, true); }, }, mixins: [ModalFormHandler] diff --git a/resources/assets/vue/components/general/forms/SelectableComponent.vue b/resources/assets/vue/components/general/forms/SelectableComponent.vue index 0e71e6a7..95db6af8 100644 --- a/resources/assets/vue/components/general/forms/SelectableComponent.vue +++ b/resources/assets/vue/components/general/forms/SelectableComponent.vue @@ -34,7 +34,7 @@ if(!success){return;} let vm = this; - let mappedList = response.payload.data.map(function(value){ + let mappedList = $.map(response.payload.data, function(value){ let preservedValue = value; return {'id': !isNaN(value[vm.valueColumn]) ? parseInt(value[vm.valueColumn]) : value[vm.valueColumn], 'text': vm.labelColumn.map(function(label){ diff --git a/resources/assets/vue/components/settings/forms/AnnouncementFormComponent.vue b/resources/assets/vue/components/settings/forms/AnnouncementFormComponent.vue index a29f7572..a2408fc3 100644 --- a/resources/assets/vue/components/settings/forms/AnnouncementFormComponent.vue +++ b/resources/assets/vue/components/settings/forms/AnnouncementFormComponent.vue @@ -77,7 +77,6 @@ parameters: { starting_on:'', ending_on:'', - // segment_id: '', title: '', description: '', } @@ -106,21 +105,11 @@ }, created(){ - console.log("lado form"); }, methods: { submitForm(){ - //this.submit(route('api.announcement.create'), 'post', this.section, true, false); this.submit((this.data ? this.route('api.announcement.update', this.data.id) : this.route('api.announcement.create')), (this.data ? 'put' : 'post'), this.section, true, false) - }, - // successHandler(response){ - // this.closeModal(); - // //this.formHandler(); - // this.resetForm(); - // }, - // errorHandler(error){ - // this.formHandler(error.message); - // } + } }, mixins: [ModalFormHandler], diff --git a/resources/assets/vue/general/mixins/formHandler.js b/resources/assets/vue/general/mixins/formHandler.js index 41713c17..3e7c0daa 100644 --- a/resources/assets/vue/general/mixins/formHandler.js +++ b/resources/assets/vue/general/mixins/formHandler.js @@ -31,6 +31,7 @@ export default { productPrice: {decimal: '.',thousands: ',', precision: 3}, exchangeRate: {decimal: '.', thousands: '', precision: 5}, percentage: {decimal: '.', thousands: '', precision: 2, suffix: '%'}, + threeDecimalPercentage: {decimal: '.', thousands: '', precision: 3, suffix: '%'}, integer: {decimal: '', thousands: '', precision: 0}, } diff --git a/resources/views/pages/pdfs/currency_vendor_order.blade.php b/resources/views/pages/pdfs/currency_vendor_order.blade.php index 922d7a7f..c19811bb 100644 --- a/resources/views/pages/pdfs/currency_vendor_order.blade.php +++ b/resources/views/pages/pdfs/currency_vendor_order.blade.php @@ -37,12 +37,12 @@ @foreach($transactions as $transaction) - {{$transaction->owner->marking}} - {{$transaction->owner->company->reference}} + {{$transaction->owner->owner->marking}} + {{$transaction->owner->owner->company->reference}} {{$transaction->currency_rate}} {{$transaction->currency->short_code}} {{number_format((float)$transaction->amount, 2, '.', '')}} - Account Holder Name: {{$transaction->owner->bank->holder_name}}
    {{$transaction->owner->bank->bank_name}}: {{$transaction->owner->bank->account_no}} -
    Branch: {{$transaction->owner->bank->bank_branch}}
    Bank in Amount: {{$transaction->original_currency->short_code}} {{$transaction->original_amount}} + Account Holder Name: {{$transaction->owner->owner->bank->holder_name}}
    {{$transaction->owner->owner->bank->bank_name}}: {{$transaction->owner->owner->bank->account_no}} +
    Branch: {{$transaction->owner->owner->bank->bank_branch}}
    Bank in Amount: {{$transaction->original_currency->short_code}} {{$transaction->original_amount}} @endforeach @@ -78,9 +78,9 @@ MYR {{$sub_total_amount}} - Service charge ({{ $supplier->id == 2 ? '0.00' : '0.75%' }}): + Service charge: @php - $service_charge = number_format((float)$sub_total_amount * 0.75 / 100, 2, '.', ''); + $service_charge = number_format((float)$transactions->sum('service_charge'), 2, '.', ''); @endphp MYR {{$service_charge}} diff --git a/routes/web.php b/routes/web.php index d3b4e432..5540a129 100644 --- a/routes/web.php +++ b/routes/web.php @@ -172,4 +172,4 @@ Route::get('purchase/sensitive/', function(Request $request){ } }); -Route::get('/transactions/supplier/{id}/mock-up-white-form/download/{rate}/{payment_ids}', 'Transactions\DownloadMockUpWhiteFormPdfController@download')->name('transactions.supplier.mockUpWhiteForm.download'); \ No newline at end of file +Route::get('/transactions/supplier/{id}/mock_up', 'Transactions\DownloadMockUpWhiteFormPdfController@download')->name('whiteForm.mockUp'); \ No newline at end of file From 708433aed0232b1e531e88ff15ae94c0aef1507f Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sat, 12 Mar 2022 17:31:59 +0800 Subject: [PATCH 45/69] clean up development --- app/Http/Resources/TransactionResource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index b7ca2f72..37971b36 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -17,7 +17,7 @@ class TransactionResource extends JsonResource public function toArray($request) { - $booking = (int)$this->type === TransactionType::BILL ? $this->owner->owner : $this->booking; + $booking = (int)$this->type === TransactionType::BILL ? $this->owner->owner : $this->owner; $days = $this->updated_at->endOfDay()->addWeekdays($booking->service_id === 3 ? 3 : 1); return [ From c98bf9752f45e6dbe2f5fdab9d5d8914f4e33509 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sat, 12 Mar 2022 17:47:05 +0800 Subject: [PATCH 46/69] clean up development --- database/seeds/UpdateTransactionBillOwnerSeeder.php | 1 + 1 file changed, 1 insertion(+) diff --git a/database/seeds/UpdateTransactionBillOwnerSeeder.php b/database/seeds/UpdateTransactionBillOwnerSeeder.php index cd8eebcf..7f04a0fc 100644 --- a/database/seeds/UpdateTransactionBillOwnerSeeder.php +++ b/database/seeds/UpdateTransactionBillOwnerSeeder.php @@ -27,6 +27,7 @@ class UpdateTransactionBillOwnerSeeder extends Seeder $row->owner_type = Transaction::class; $row->owner_id = $paymentTransaction->id; + $row->updated_at = $row->updated_at; $row->update(); } From 89069a8afe126470d63dbfb7095d369941e6ace7 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sat, 12 Mar 2022 19:32:45 +0800 Subject: [PATCH 47/69] clean up development --- .../CreateSupplierTransactionProcessor.php | 4 +- .../CalculatesTransactionServiceCharge.php | 28 ++++++- .../CalculatesTransactionTransferFee.php | 13 ++- .../UpdateTransactionBillOwnerSeeder.php | 25 +++--- .../companies/elements/SupplierComponent.vue | 16 +++- .../SupplierServiceChargeFormComponent.vue | 84 +++++++++++++++---- .../pdfs/currency_vendor_order.blade.php | 2 +- 7 files changed, 136 insertions(+), 36 deletions(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateSupplierTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateSupplierTransactionProcessor.php index 3f052352..75516fdf 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateSupplierTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateSupplierTransactionProcessor.php @@ -85,7 +85,7 @@ class CreateSupplierTransactionProcessor $billNumber = $this->generatesTransactionBillNumber->execute('SPLR-'); $constant = SegmentConstant::where('reference', SegmentConstants::SERVICE_CHARGE)->where('detail->id', $supplier->id)->first(); - $serviceCharge = $this->calculatesTransactionServiceCharge->execute($payment->original_amount, $rate, $constant ? (float) $constant->detail->amount : 0); + $serviceCharge = $this->calculatesTransactionServiceCharge->execute($payment->original_amount, $rate, $constant); $object = new TransactionObject($billNumber, TransactionType::BILL, $supplier->id, 1, $supplier->banks()->where('default', true)->first()->id, PaymentMethodType::CASH, @@ -97,7 +97,7 @@ class CreateSupplierTransactionProcessor $this->pushBill($billTransaction); $transferFeeNumber = $this->generatesTransactionBillNumber->execute('TRFR-'); - $transferFee = $this->calculatesTransactionTransferFee->execute($payment->original_amount); + $transferFee = $this->calculatesTransactionTransferFee->execute($payment->original_amount, $constant); $object = new TransactionObject($transferFeeNumber, TransactionType::TRANSFER_FEE, 1, $supplier->id, $supplier->banks()->where('default', true)->first()->id, PaymentMethodType::CASH, $payment->original_amount, $payment->original_amount, $payment->original_currency_id, $payment->original_currency_id, diff --git a/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php b/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php index 8ddb80c9..e04edee2 100644 --- a/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php +++ b/app/Classes/Modules/Transactions/Services/CalculatesTransactionServiceCharge.php @@ -2,18 +2,38 @@ namespace App\Classes\Modules\Transactions\Services; +use App\Models\SegmentConstant; + class CalculatesTransactionServiceCharge { + /** @var CalculatesTransactionTransferFee */ + private $calculatesTransactionTransferFee; + + /** + * CalculatesTransactionServiceCharge constructor. + * @param CalculatesTransactionTransferFee $calculatesTransactionTransferFee + */ + public function __construct(CalculatesTransactionTransferFee $calculatesTransactionTransferFee) + { + $this->calculatesTransactionTransferFee = $calculatesTransactionTransferFee; + } + /** * @param float $amount * @param float $rate - * @param float $service_charge - * @param float $transfer_fee + * @param SegmentConstant|null $service_charge * @return float */ - public function execute(float $amount, float $rate, ?float $service_charge = 0, ?float $transfer_fee = 0.00) { - return (($amount + $transfer_fee) * (1/$rate)) * $service_charge / 100; + public function execute(float $amount, float $rate, ?SegmentConstant $service_charge) { + + if(!$service_charge) { + return 0; + } + + $transfer_fee = $this->calculatesTransactionTransferFee->execute($amount, $service_charge); + return $service_charge->detail->amount->type === 'percentage' ? (($amount + $transfer_fee) * ( (float) $service_charge->detail->amount->value /100) * (1/$rate)) : (float) $service_charge->detail->amount->value; + } } \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/Services/CalculatesTransactionTransferFee.php b/app/Classes/Modules/Transactions/Services/CalculatesTransactionTransferFee.php index b5feb245..5a02a394 100644 --- a/app/Classes/Modules/Transactions/Services/CalculatesTransactionTransferFee.php +++ b/app/Classes/Modules/Transactions/Services/CalculatesTransactionTransferFee.php @@ -2,16 +2,23 @@ namespace App\Classes\Modules\Transactions\Services; +use App\Models\SegmentConstant; + class CalculatesTransactionTransferFee { /** * @param float $amount - * @param float $transfer_fee + * @param SegmentConstant|null $service_charge * @return float */ - public function execute(float $amount, ?float $transfer_fee = 0) { - return $amount * ($transfer_fee / 100); + public function execute(float $amount, ?SegmentConstant $service_charge) { + + if(!$service_charge) { + return 0; + } + + return $service_charge->detail->transferFee->type === 'percentage' ? $amount * ((float) $service_charge->detail->transferFee->value /100) : (float) $service_charge->detail->transferFee->value; } } \ No newline at end of file diff --git a/database/seeds/UpdateTransactionBillOwnerSeeder.php b/database/seeds/UpdateTransactionBillOwnerSeeder.php index 7f04a0fc..1ced925d 100644 --- a/database/seeds/UpdateTransactionBillOwnerSeeder.php +++ b/database/seeds/UpdateTransactionBillOwnerSeeder.php @@ -1,5 +1,6 @@ get(); + $bookings = Booking::all(); - foreach ($transaction as $key => $row) { - $key = 0; - $bills = $row->booking->transactions()->bills()->where('original_amount', '=', $row->original_amount)->get(); - if(count($bills) > 1){ $key = $bills->search(function($bill)use($row){ return $bill->id === $row->id; }); } - $paymentTransaction = $row->booking->transactions()->payments()->complete()->where('original_amount', '=', $row->original_amount)->skip($key)->first(); + foreach ($bookings as $booking) { - $row->owner_type = Transaction::class; - $row->owner_id = $paymentTransaction->id; - $row->updated_at = $row->updated_at; - $row->update(); + $transactions = $booking->transactions()->bills()->get(); + foreach ($transactions as $row) { + $key = 0; + $bills = $booking->transactions()->bills()->where('original_amount', '=', $row->original_amount)->get(); + if(count($bills) > 1){ $key = $bills->search(function($bill)use($row){ return $bill->id === $row->id; }); } + $paymentTransaction = $booking->transactions()->payments()->complete()->where('original_amount', '=', $row->original_amount)->skip($key)->first(); + + $row->owner_type = Transaction::class; + $row->owner_id = $paymentTransaction->id; + $row->updated_at = $row->updated_at; + $row->update(); + } } DB::commit(); diff --git a/resources/assets/vue/components/companies/elements/SupplierComponent.vue b/resources/assets/vue/components/companies/elements/SupplierComponent.vue index b25e9ae7..f6944c4c 100644 --- a/resources/assets/vue/components/companies/elements/SupplierComponent.vue +++ b/resources/assets/vue/components/companies/elements/SupplierComponent.vue @@ -22,7 +22,7 @@
    -
    +
    Currencies
    @@ -42,7 +42,19 @@
    -
    {{item.service_charge ? parseFloat(item.service_charge.detail.amount).toFixed(3) : '0.000'}}%
    +
    {{item.service_charge ? ((Math.round((parseFloat(item.service_charge.detail.amount.value) + Number.EPSILON) * 1000) / 1000).toFixed(3)+ '' +(item.service_charge.detail.amount.type === 'percentage' ? '%' : ' MYR')) : '0.000%'}}
    +
    +
    +
    +
    +
    +
    +
    Transfer Fee
    +
    +
    +
    +
    +
    {{item.service_charge ? ((Math.round((parseFloat(item.service_charge.detail.transferFee.value) + Number.EPSILON) * 1000) / 1000).toFixed(3)+ '' +(item.service_charge.detail.transferFee.type === 'percentage' ? '%' : ' FEC')) : '0.000%'}}
    diff --git a/resources/assets/vue/components/companies/forms/SupplierServiceChargeFormComponent.vue b/resources/assets/vue/components/companies/forms/SupplierServiceChargeFormComponent.vue index 37301e23..c6906d92 100644 --- a/resources/assets/vue/components/companies/forms/SupplierServiceChargeFormComponent.vue +++ b/resources/assets/vue/components/companies/forms/SupplierServiceChargeFormComponent.vue @@ -14,13 +14,49 @@ {{error}}
    -
    -
    - - - +
    +
    + + +
    +
    +
    +
    + MYR +
    +
    +
    +
    +
    +
    + % +
    +
    +
    +
    +
    +
    + + + + +
    +
    +
    +
    + FEC +
    +
    +
    +
    +
    +
    + % +
    +
    +
    @@ -52,20 +88,33 @@ reference: 'SERVICE_CHARGE', detail: { id: this.supplierId, - type: "percentage", - amount: 0, + amount: { + type: "percentage", + value: 0 + }, + transferFee: { + type: "percentage", + value: 0 + }, + transferCompanyId: this.supplierId }, segment_id: 1 }, + serviceChargeOptions: false, + transferFeeOptions: false, } }, validations: { parameters: { - amount: { - detail: { - amount: { - required: true - } + detail: { + amount: { + value: required + }, + transferFee: { + value: required + }, + transferCompanyId: { + required: true } } } @@ -74,8 +123,15 @@ if(this.data){ this.parameters.detail = { id: this.supplierId, - type: "percentage", - amount: parseFloat(this.data.detail.amount).toFixed(3), + amount: { + type: this.data.detail.amount.type, + value: parseFloat(this.data.detail.amount.value).toFixed(3) + }, + transferFee: { + type: this.data.detail.transferFee.type, + value: parseFloat(this.data.detail.transferFee.value).toFixed(3) + }, + transferCompanyId: this.data.detail.transferCompanyId } } }, diff --git a/resources/views/pages/pdfs/currency_vendor_order.blade.php b/resources/views/pages/pdfs/currency_vendor_order.blade.php index c19811bb..3f37cc08 100644 --- a/resources/views/pages/pdfs/currency_vendor_order.blade.php +++ b/resources/views/pages/pdfs/currency_vendor_order.blade.php @@ -57,7 +57,7 @@ RMB {{$sub_total_booking_amount}} - Transfer fee (0.002%): + Transfer fee: @php $transfer_fee = number_format((float)$transferFeeTransactions->sum('service_charge'), 2, '.', ''); @endphp From be0aa22607a5726ed079efac01b5233a24e862c9 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sat, 12 Mar 2022 20:21:01 +0800 Subject: [PATCH 48/69] clean up development --- .../CreateBookingRefundLogic.php | 14 +- .../UpdateRefundTransactionStatusLogic.php | 11 +- .../Processors/CreditWalletProcessor.php | 3 +- app/Http/Resources/TransactionResource.php | 5 +- .../elements/RefundConfirmationComponent.vue | 10 +- .../elements/RefundVerificationComponent.vue | 2 +- .../BookingPaymentQuotationComponent.vue | 12 ++ .../views/pages/dashboards/admin.blade.php | 169 ------------------ 8 files changed, 34 insertions(+), 192 deletions(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php index 75334583..74e92fa6 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php @@ -78,22 +78,18 @@ class CreateBookingRefundLogic extends AbstractControllerLogic public function logic(Request $request) : JsonResponse { - $booking = Booking::find($request->route('id')); - $transaction = $this->fetchesTransaction->execute(['id' => $request->route('payment_id')]); + $booking = $transaction->owner; + $billNumber = $this->generatesTransactionBillNumber->execute('RFD-'); - if((int) $transaction->type === TransactionType::BILL){ - $customerBooking = $booking->transactions()->payments()->complete()->where('original_amount', '=', $transaction->original_amount)->where('id', '<', $transaction->id)->orderByDesc('id')->first(); - } - $refund = $this->calculatesBookingRefundAmount->execute($booking, $booking->fix_currency_id, $transaction->bill_no); - // dd($refund); + $refund = $transaction->transactions()->refunds()->sum('amount'); if($refund + $request->input('amount') > $transaction->original_amount) throw new MalformedRequestException('Your refund must not be greater than '. $transaction->original_amount .'.'); - $transactionRefundCalculationObject = new TransactionRefundCalculationObject($booking, (int) $transaction->type === TransactionType::BILL ? $customerBooking : $transaction, $request->input('amount')); + $transactionRefundCalculationObject = new TransactionRefundCalculationObject($booking, $transaction, $request->input('amount')); $transactionRefundCalculationObject->init(); $object = new TransactionObject($billNumber, TransactionType::REFUND, 1, $booking->company->id, @@ -102,7 +98,7 @@ class CreateBookingRefundLogic extends AbstractControllerLogic $transactionRefundCalculationObject->getConversionObject()->getCurrencyId(), $transactionRefundCalculationObject->getTransaction()->currency_rate, $transactionRefundCalculationObject->getRefundTax(), $transactionRefundCalculationObject->getRefundServiceCharge(), null, ApprovalStatus::PENDING_VERIFICATION, [], $transaction->bill_no); - $transaction = $this->createsTransaction->execute($booking, $object); + $transaction = $this->createsTransaction->execute($transaction, $object); return $this->resourceResponse(new TransactionResource($transaction)); } diff --git a/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php index d760b05d..b86e4878 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php @@ -71,14 +71,15 @@ class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic $transaction = $this->updatesTransactionStatus->execute($transaction, $request->input('status')); - $company = $this->fetchesCompany->execute(['id' => $transaction->booking->company_id]); + $booking = $transaction->owner->owner; - $reference = 'Refund for booking reference '.$transaction->booking->marking; + $reference = 'Credit Voucher for Overpaid for Ref. '.$booking->marking; if ($transaction->status == ApprovalStatus::APPROVED) { - // add to credit wallet - $this->creditWalletProcessor->execute($company, $transaction->type, $transaction->amount, $reference); - } + $this->creditWalletProcessor->execute($booking->company, $transaction->type, $transaction->amount, $reference); + } + + return $this->response([]); } diff --git a/app/Classes/Modules/Wallets/Processors/CreditWalletProcessor.php b/app/Classes/Modules/Wallets/Processors/CreditWalletProcessor.php index 2b303938..d86a4465 100644 --- a/app/Classes/Modules/Wallets/Processors/CreditWalletProcessor.php +++ b/app/Classes/Modules/Wallets/Processors/CreditWalletProcessor.php @@ -68,9 +68,10 @@ class CreditWalletProcessor { if (!$company->wallets()->first()) { $object = new WalletObject($company->id, 1, $this->generatesWalletCode->execute()); - $wallet = $this->createsWallet->execute($object, $company); + $this->createsWallet->execute($object, $company); } + /** @var Wallet $wallet */ $wallet = $company->wallets()->first(); $billNumber = $this->generatesTransactionBillNumber->execute($transactionType === 2 ? 'DEBIT-NOTE-' : 'CREDIT-NOTE-'); diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index 37971b36..8bb30512 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -17,7 +17,7 @@ class TransactionResource extends JsonResource public function toArray($request) { - $booking = (int)$this->type === TransactionType::BILL ? $this->owner->owner : $this->owner; + $booking = in_array((int)$this->type, [TransactionType::BILL, TransactionType::REFUND])? $this->owner->owner : $this->owner; $days = $this->updated_at->endOfDay()->addWeekdays($booking->service_id === 3 ? 3 : 1); return [ @@ -39,7 +39,8 @@ class TransactionResource extends JsonResource 'status' => (int) $this->status, 'details' => TransactionDetailResource::collection($this->transactionDetails), 'documents' => new DocumentResource($this->documents()->first()), - 'transaction_bill' => new TransactionResource($this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->first())), + 'transaction_bill' => new TransactionResource($this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->bills()->first())), + 'transaction_refunds' => TransactionResource::collection($this->when((int) $this->type === TransactionType::PAYMENT, $this->transactions()->refunds()->get())), 'expires_on' => Carbon::parse($this->expires_on)->format('d-m-Y h:i:s A'), 'updated_at' => Carbon::parse($this->updated_at)->format('d-m-Y h:i:s A'), 'interval' => [ diff --git a/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue b/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue index c954a374..a2d3b277 100644 --- a/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue +++ b/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue @@ -24,16 +24,16 @@
    Refund Type:
    -
    - Partially Refund +
    + Full Refund
    -
    - Fully Refund +
    + Partial Refund
    -
    +
    diff --git a/resources/assets/vue/components/bookings/elements/RefundVerificationComponent.vue b/resources/assets/vue/components/bookings/elements/RefundVerificationComponent.vue index 914cb47a..e78a14f6 100644 --- a/resources/assets/vue/components/bookings/elements/RefundVerificationComponent.vue +++ b/resources/assets/vue/components/bookings/elements/RefundVerificationComponent.vue @@ -28,7 +28,7 @@
    Amount
    - {{(Math.round((data.booking.amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}} + {{(Math.round((data.amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
    diff --git a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue index 643cd29a..14947ef8 100644 --- a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue +++ b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue @@ -238,6 +238,18 @@

    Wallet Credit

    (Better Rate)

    + + + + + +
    diff --git a/resources/views/pages/dashboards/admin.blade.php b/resources/views/pages/dashboards/admin.blade.php index 40ffa8ff..d998c745 100644 --- a/resources/views/pages/dashboards/admin.blade.php +++ b/resources/views/pages/dashboards/admin.blade.php @@ -92,175 +92,6 @@
    -
    -
    -
    -
    -
    -
      -
    • -
    • -
    -
    -
    -
    -
    -

    webarch

    -

    Today's sales

    -
    -

    - MYR - 102,967 -

    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Purchase CODE #2345 - Qty 1 - - 27 RM -
    Purchase CODE #2345 - Qty 1 - - 27 RM -
    Purchase CODE #2345 - Qty 1 - - 27 RM -
    Purchase CODE #2345 - Qty 1 - - 27 RM -
    Purchase CODE #2345 - Qty 1 - - 27 RM -
    Purchase CODE #2345 - Qty 1 - - 27 RM -
    Purchase CODE #2345 - Qty 1 - - 27 RM -
    Purchase CODE #2345 - Qty 1 - - 27 RM -
    Purchase CODE #2345 - Qty 1 - - 27 RM -
    Purchase CODE #2345 - Qty 1 - - 27 RM -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - {{----}} - {{----}} - {{----}} -
    -
    -
    -
    -
    -
    From a39c84586ba58d94ad1a16c16228cb1ddf3b423c Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 13 Mar 2022 00:12:40 +0800 Subject: [PATCH 49/69] clean up development --- .../Bookings/ControllersLogic/CreateBookingRefundLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php index 74e92fa6..e6275dad 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php @@ -87,7 +87,7 @@ class CreateBookingRefundLogic extends AbstractControllerLogic $refund = $transaction->transactions()->refunds()->sum('amount'); - if($refund + $request->input('amount') > $transaction->original_amount) throw new MalformedRequestException('Your refund must not be greater than '. $transaction->original_amount .'.'); + if($refund + $request->input('amount') > $transaction->amount) throw new MalformedRequestException('Your refund must not be greater than '. $transaction->original_amount .'.'); $transactionRefundCalculationObject = new TransactionRefundCalculationObject($booking, $transaction, $request->input('amount')); $transactionRefundCalculationObject->init(); From ea83ba13d4f0b68656f957012c24e37987fae98a Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 13 Mar 2022 00:13:26 +0800 Subject: [PATCH 50/69] clean up development --- .../Bookings/ControllersLogic/CreateBookingRefundLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php index e6275dad..74e92fa6 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/CreateBookingRefundLogic.php @@ -87,7 +87,7 @@ class CreateBookingRefundLogic extends AbstractControllerLogic $refund = $transaction->transactions()->refunds()->sum('amount'); - if($refund + $request->input('amount') > $transaction->amount) throw new MalformedRequestException('Your refund must not be greater than '. $transaction->original_amount .'.'); + if($refund + $request->input('amount') > $transaction->original_amount) throw new MalformedRequestException('Your refund must not be greater than '. $transaction->original_amount .'.'); $transactionRefundCalculationObject = new TransactionRefundCalculationObject($booking, $transaction, $request->input('amount')); $transactionRefundCalculationObject->init(); From 99cdd6bf9dbbf9341286a28d9c842785ab0727eb Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 13 Mar 2022 00:19:08 +0800 Subject: [PATCH 51/69] debug transaction resource --- app/Http/Resources/TransactionResource.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index 8bb30512..cfc54c60 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -3,6 +3,7 @@ namespace App\Http\Resources; use App\Classes\ValueObjects\Constants\TransactionType; +use App\Models\Booking; use Carbon\Carbon; use Illuminate\Http\Resources\Json\JsonResource; @@ -18,6 +19,7 @@ class TransactionResource extends JsonResource { $booking = in_array((int)$this->type, [TransactionType::BILL, TransactionType::REFUND])? $this->owner->owner : $this->owner; + if(!$booking instanceof Booking) dd($booking); $days = $this->updated_at->endOfDay()->addWeekdays($booking->service_id === 3 ? 3 : 1); return [ From de5bb1d1f8f5883390ec64c66039dbf3b3693a63 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 13 Mar 2022 00:20:49 +0800 Subject: [PATCH 52/69] debug transaction resource --- app/Http/Resources/TransactionResource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index cfc54c60..25042510 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -19,7 +19,7 @@ class TransactionResource extends JsonResource { $booking = in_array((int)$this->type, [TransactionType::BILL, TransactionType::REFUND])? $this->owner->owner : $this->owner; - if(!$booking instanceof Booking) dd($booking); + if(!$booking instanceof Booking) dd($this->owner); $days = $this->updated_at->endOfDay()->addWeekdays($booking->service_id === 3 ? 3 : 1); return [ From 5b717a85020a252a45c3b3bcae7a1f1d1defce90 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 13 Mar 2022 00:21:21 +0800 Subject: [PATCH 53/69] debug transaction resource --- app/Http/Resources/TransactionResource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index 25042510..385b285c 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -19,7 +19,7 @@ class TransactionResource extends JsonResource { $booking = in_array((int)$this->type, [TransactionType::BILL, TransactionType::REFUND])? $this->owner->owner : $this->owner; - if(!$booking instanceof Booking) dd($this->owner); + if(!$booking instanceof Booking) dd($this); $days = $this->updated_at->endOfDay()->addWeekdays($booking->service_id === 3 ? 3 : 1); return [ From dbbeb10874c8ec4fba3d9fe4b153b1c6753f403f Mon Sep 17 00:00:00 2001 From: omair saleh Date: Sun, 13 Mar 2022 00:23:36 +0800 Subject: [PATCH 54/69] debug transaction resource --- app/Http/Resources/TransactionResource.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index 385b285c..7680e6e1 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -19,7 +19,6 @@ class TransactionResource extends JsonResource { $booking = in_array((int)$this->type, [TransactionType::BILL, TransactionType::REFUND])? $this->owner->owner : $this->owner; - if(!$booking instanceof Booking) dd($this); $days = $this->updated_at->endOfDay()->addWeekdays($booking->service_id === 3 ? 3 : 1); return [ From 33a2ebd3d74789238d2dc4e9f7efedd5293fbc71 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sun, 13 Mar 2022 00:23:45 +0800 Subject: [PATCH 55/69] tidy up and debug for refund --- .../elements/PaymentHistoryComponent.vue | 54 +++++++++++++++++-- .../elements/RefundConfirmationComponent.vue | 33 ++++++------ .../assets/vue/general/mixins/formHandler.js | 1 + 3 files changed, 67 insertions(+), 21 deletions(-) diff --git a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue index af43a8b7..5b43ce54 100644 --- a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue +++ b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue @@ -16,11 +16,17 @@
    -
    {{ item.type === 6 ? 'Refund' : 'Payment' }} Amount
    +
    Payment Amount
    {{item.currency.short_code}} {{(Math.round((item.amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
    +
    +
    Refunded Amount
    +
    + {{item.original_currency.short_code}} {{(Math.round((totalRefunds + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}} +
    +
    @@ -57,7 +63,15 @@
    Payment Amount
    - {{item.transaction_bill.original_currency.short_code}} {{(Math.round((item.transaction_bill.original_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}} + {{item.original_currency.short_code}} {{(Math.round((item.original_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}} +
    +
    +
    +
    +
    Refunded Amount
    +
    +
    +
    {{item.original_currency.short_code}} {{(Math.round((totalRefunds + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
    @@ -104,6 +118,22 @@
    {{item.original_currency.short_code}} {{(item.original_amount).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
    +
    +
    +
    Requested Refund Amount
    +
    +
    +
    {{item.original_currency.short_code}} {{(Math.round((totalRequestedRefund + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
    +
    +
    +
    +
    +
    Refunded Amount
    +
    +
    +
    {{item.original_currency.short_code}} {{(Math.round((totalRefunds + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
    +
    +
    Rate
    @@ -179,11 +209,11 @@
    -
    +
    - +
    @@ -207,6 +237,22 @@ section: 'bookingDetailSection', } }, + computed: { + totalRequestedRefund() { + var TotalRequestedRefund = 0; + this.data.transaction_refunds.forEach(function(refunds) { + TotalRequestedRefund += refunds.status === 1 ? refunds.original_amount : 0; + }); + return TotalRequestedRefund; + }, + totalRefunds() { + var TotalRequestedRefund = 0; + this.data.transaction_refunds.forEach(function(refunds) { + TotalRequestedRefund += refunds.status === 2 ? refunds.original_amount : 0; + }); + return TotalRequestedRefund; + } + }, methods: { clickExpand(){ this.expandPaymentDetails = !this.expandPaymentDetails; diff --git a/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue b/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue index a2d3b277..de2cd48f 100644 --- a/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue +++ b/resources/assets/vue/components/bookings/elements/RefundConfirmationComponent.vue @@ -1,5 +1,5 @@