diff --git a/app/Classes/General/Eloquent/Filters/DoesNotHaveTransactionType.php b/app/Classes/General/Eloquent/Filters/DoesNotHaveTransactionType.php new file mode 100644 index 00000000..3568ac3b --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/DoesNotHaveTransactionType.php @@ -0,0 +1,20 @@ +whereDoesntHave('transactions', function (Builder $query) use($value) { + $query->where('type', $value); + }); + } +} \ No newline at end of file diff --git a/app/Classes/General/Eloquent/Filters/HasInvoiceStatusIn.php b/app/Classes/General/Eloquent/Filters/HasInvoiceStatusIn.php new file mode 100644 index 00000000..e02c5791 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/HasInvoiceStatusIn.php @@ -0,0 +1,20 @@ +whereHas('transactions', function (Builder $query) use($value) { + $query->where('type', 1)->whereIn('status', $value); + }); + } +} \ No newline at end of file diff --git a/app/Classes/General/Eloquent/Filters/HasTransactionType.php b/app/Classes/General/Eloquent/Filters/HasTransactionType.php new file mode 100644 index 00000000..f2d20c2f --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/HasTransactionType.php @@ -0,0 +1,20 @@ +whereHas('transactions', function (Builder $query) use($value) { + $query->where('type', $value); + }); + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/ControllersLogic/ApproveShippingInvoiceTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/ApproveShippingInvoiceTransactionLogic.php index 14b5008e..5bcb33ce 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/ApproveShippingInvoiceTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/ApproveShippingInvoiceTransactionLogic.php @@ -17,6 +17,7 @@ use App\Classes\Modules\Documents\Services\CreatesDocument; use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject; use App\Classes\Modules\PackingLists\Services\FetchesPackingList; use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; +use App\Classes\Modules\Transactions\ControllersLogic\Document; class ApproveShippingInvoiceTransactionLogic extends AbstractControllerLogic { @@ -66,7 +67,7 @@ class ApproveShippingInvoiceTransactionLogic extends AbstractControllerLogic */ public function logic(Request $request) : JsonResponse { - $packing_list = $this->fetchesPackingList->execute(['id' => $request->input('packing_list_id')]); + $packing_list = $this->fetchesPackingList->execute(['id' => $request->route('id')]); $invoice_transaction = $packing_list->transactions->where('type', TransactionType::SHIPPING_INVOICE)->first(); diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentTransactionLogic.php index bd99d86d..04de4090 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentTransactionLogic.php @@ -84,8 +84,11 @@ class CreatePaymentTransactionLogic extends AbstractControllerLogic $billPlzBill = $this->createsBillplzBill->execute( $company_module->name, $company_module->employees()->first()->email, - 'This payment is credit topup for company ref. ' . $company_module->reference, $amount, $billNumber, - $request->input('bank_code'), true + 'This payment is for the invoice number . ' . $invoice_transaction->bill_no, + $amount, + $billNumber, + $request->input('bank_code'), + true ); $payment_reference = $billPlzBill->id; diff --git a/app/Classes/Modules/Transactions/ControllersLogic/UpdateShippingInvoiceTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/UpdateShippingInvoiceTransactionLogic.php index 32d51bf6..f60130ac 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/UpdateShippingInvoiceTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/UpdateShippingInvoiceTransactionLogic.php @@ -83,9 +83,7 @@ class UpdateShippingInvoiceTransactionLogic extends AbstractControllerLogic public function logic(Request $request) : JsonResponse { - $packing_list = $this->fetchesPackingList->execute(['id' => $request->input('packing_list_id')]); - - $invoice_transaction = $packing_list->transactions->where('type', TransactionType::SHIPPING_INVOICE)->first(); + $invoice_transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]); $old_transaction_details = $invoice_transaction->transactionDetails->whereNotIn('reference', ['SHIPPING_FEE', 'OVER_WEIGHT_CHARGES'])->pluck('id')->toArray(); @@ -110,17 +108,17 @@ class UpdateShippingInvoiceTransactionLogic extends AbstractControllerLogic $object_detail = new TransactionDetailObject( 'CUSTOM_CHARGES', isset($transaction_detail->name) ? $transaction_detail->name : TransactionDetailType::CUSTOM_CHARGES, - 1, + $transaction_detail->quantity, $transaction_detail->price ); - if($transaction_detail->id){ + if(isset($transaction_detail->id)){ $new_transaction_detail = $this->updatesTransactionDetail->execute($this->fetchesTransactionDetail->execute(['id' => $transaction_detail->id]), $object_detail); }else{ $new_transaction_detail = $this->createsTransactionDetail->execute($invoice_transaction, $object_detail); } - $total_cbm += $new_transaction_detail->price; + $total_cbm += $new_transaction_detail->amount; } } @@ -139,7 +137,7 @@ class UpdateShippingInvoiceTransactionLogic extends AbstractControllerLogic 0, 0, null, - ApprovalStatus::PENDING_SUBMISSION + ApprovalStatus::PENDING_VERIFICATION ); /** @var Transaction $invoice_transaction */ diff --git a/app/Http/Resources/TransactionDetailResource.php b/app/Http/Resources/TransactionDetailResource.php index 1b60cfce..69a00c42 100644 --- a/app/Http/Resources/TransactionDetailResource.php +++ b/app/Http/Resources/TransactionDetailResource.php @@ -16,11 +16,11 @@ class TransactionDetailResource extends JsonResource { return [ - 'stockCode' => $this->product_code, - 'description' => $this->product_name, + 'reference' => $this->reference, 'quantity' => $this->quantity, - 'unit_price' => (double) $this->price, - 'total' => (double) $this->amount + 'price' => (double) $this->price, + 'name' => $this->name, + 'amount' => (double) $this->amount ]; } } diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index 05c35038..27840ad8 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -2,6 +2,9 @@ namespace App\Http\Resources; +use App\Classes\ValueObjects\Constants\ApprovalStatus; +use App\Classes\ValueObjects\Constants\DocumentType; +use App\Classes\ValueObjects\Constants\TransactionType; use Carbon\Carbon; use Illuminate\Http\Resources\Json\JsonResource; @@ -19,18 +22,33 @@ class TransactionResource extends JsonResource return [ 'id' => $this->id, // 'booking' => new BookingResource($this->booking), + 'documents' => DocumentResource::collection($this->documents), 'type' => (int) $this->type, 'bill_no' => $this->bill_no, 'amount' => (double) $this->amount, + 'outstanding' => (double) $this->amount - ($this->transactions()->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount')), + 'service_charge' => (double) $this->service_charge, + 'tax' => (double) $this->tax, 'original_amount' => (double) $this->original_amount, 'currency' => new CurrencyResource($this->currency), 'original_currency' => new CurrencyResource($this->original_currency), 'currency_rate' => (double) $this->currency_rate, 'status' => (int) $this->status, 'details' => TransactionDetailResource::collection($this->transactionDetails), - 'documents' => new DocumentResource($this->documents()->first()), + 'transactions' => TransactionResource::collection($this->transactions), + 'payment_attempts' => TransactionResource::collection( + $this->transactions() + ->payments()->where('status', ApprovalStatus::PENDING_SUBMISSION) + ->get() + ), + 'payment_history' => TransactionResource::collection( + $this->transactions() + ->payments() + ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::COMPLETED, ApprovalStatus::REJECTED]) + ->get() + ), 'expires_on' => Carbon::parse($this->expires_on)->format('d-m-Y h:s:i'), - 'updated_at' => Carbon::parse($this->update_at)->format('d-m-Y h:s:i') + 'updated_at' => Carbon::parse($this->update_at)->format('d-m-Y') ]; } } diff --git a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue new file mode 100644 index 00000000..ec6c0b46 --- /dev/null +++ b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue @@ -0,0 +1,257 @@ + + diff --git a/resources/assets/vue/components/paymentsBilling/elements/PaymentHistoryComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/PaymentHistoryComponent.vue new file mode 100644 index 00000000..c76c9a07 --- /dev/null +++ b/resources/assets/vue/components/paymentsBilling/elements/PaymentHistoryComponent.vue @@ -0,0 +1,137 @@ + + + diff --git a/resources/assets/vue/components/paymentsBilling/elements/PaymentVerificationComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/PaymentVerificationComponent.vue new file mode 100644 index 00000000..4c499bcd --- /dev/null +++ b/resources/assets/vue/components/paymentsBilling/elements/PaymentVerificationComponent.vue @@ -0,0 +1,159 @@ + + + diff --git a/resources/assets/vue/components/paymentsBilling/elements/ShippingTransactionComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/ShippingTransactionComponent.vue new file mode 100644 index 00000000..0d7d29f0 --- /dev/null +++ b/resources/assets/vue/components/paymentsBilling/elements/ShippingTransactionComponent.vue @@ -0,0 +1,70 @@ + + + diff --git a/resources/assets/vue/components/paymentsBilling/forms/ApproveShippingInvoiceFormComponent.vue b/resources/assets/vue/components/paymentsBilling/forms/ApproveShippingInvoiceFormComponent.vue new file mode 100644 index 00000000..07d9f1cf --- /dev/null +++ b/resources/assets/vue/components/paymentsBilling/forms/ApproveShippingInvoiceFormComponent.vue @@ -0,0 +1,31 @@ + + \ No newline at end of file diff --git a/resources/assets/vue/components/paymentsBilling/forms/DeletePaymentAttemptFormComponent.vue b/resources/assets/vue/components/paymentsBilling/forms/DeletePaymentAttemptFormComponent.vue new file mode 100644 index 00000000..ba371bd4 --- /dev/null +++ b/resources/assets/vue/components/paymentsBilling/forms/DeletePaymentAttemptFormComponent.vue @@ -0,0 +1,33 @@ + + \ No newline at end of file diff --git a/resources/assets/vue/components/paymentsBilling/forms/InvoiceItemFormComponent.vue b/resources/assets/vue/components/paymentsBilling/forms/InvoiceItemFormComponent.vue new file mode 100644 index 00000000..6243f19c --- /dev/null +++ b/resources/assets/vue/components/paymentsBilling/forms/InvoiceItemFormComponent.vue @@ -0,0 +1,171 @@ + + diff --git a/resources/assets/vue/components/paymentsBilling/forms/InvoiceItemsFormComponent.vue b/resources/assets/vue/components/paymentsBilling/forms/InvoiceItemsFormComponent.vue new file mode 100644 index 00000000..e7e8f93d --- /dev/null +++ b/resources/assets/vue/components/paymentsBilling/forms/InvoiceItemsFormComponent.vue @@ -0,0 +1,79 @@ + + diff --git a/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue b/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue new file mode 100644 index 00000000..ec70e31f --- /dev/null +++ b/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue @@ -0,0 +1,49 @@ + + \ No newline at end of file diff --git a/resources/assets/vue/components/paymentsBilling/forms/PaymentVerificationFormComponent.vue b/resources/assets/vue/components/paymentsBilling/forms/PaymentVerificationFormComponent.vue new file mode 100644 index 00000000..bb1df036 --- /dev/null +++ b/resources/assets/vue/components/paymentsBilling/forms/PaymentVerificationFormComponent.vue @@ -0,0 +1,84 @@ + + + \ No newline at end of file diff --git a/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue new file mode 100644 index 00000000..8a759b4e --- /dev/null +++ b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue @@ -0,0 +1,149 @@ + + \ No newline at end of file diff --git a/resources/views/pages/paymentAndBilling.blade.php b/resources/views/pages/paymentAndBilling.blade.php new file mode 100644 index 00000000..59acb35b --- /dev/null +++ b/resources/views/pages/paymentAndBilling.blade.php @@ -0,0 +1,100 @@ +@extends('layouts.base_portal') +@section('inner_content') +
+
+ +
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
Payments
+
+
+
+
+
+ {{--
+
+
+
+
+ +
+
+
+
+
Refunds
+
+
+
+
+
--}} + {{--
+
+
+
+
+ +
+
+
+
+
Supplier Bills
+
+
+
+
+
--}} +
+
+
+
+
+
+
+ + + +
+
+
+
+ {{--
+
+
+
+ + + +
+
+
+
--}} +
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/partials/menu.blade.php b/resources/views/partials/menu.blade.php index 837a7586..952060c7 100644 --- a/resources/views/partials/menu.blade.php +++ b/resources/views/partials/menu.blade.php @@ -147,6 +147,17 @@
Shipping Queue
+
+
+ +
+
+
Payment And Billing
+
+
diff --git a/routes/transaction.php b/routes/transaction.php index 8ed481f0..89545b7c 100644 --- a/routes/transaction.php +++ b/routes/transaction.php @@ -5,18 +5,19 @@ use Illuminate\Support\Facades\Route; Route::group(['prefix' => 'transactions', 'namespace' => 'Transactions', 'as' => 'transaction.'], function () { Route::get('/list', 'ListTransactionsController@list')->name('list'); - // Route::delete('/suspend/{id}', 'SuspendTransactionController@suspend')->name('suspend'); + Route::delete('/suspend/{id}', 'SuspendTransactionController@suspend')->name('suspend'); - Route::post('/payment/create', 'CreatePaymentTransactionController@create')->name('payment.create'); - Route::post('/payment/upload-verification-document/{transaction_id}', 'UploadPaymentVerificationDocumentController@upload')->name('verification.create'); - Route::put('/payment/approve/{transaction_id}/{status}', 'ApprovePaymentTransactionController@approve')->where('status', 'approve|reject')->name('approval'); - - - route::post('/shipping-invoice/create', 'CreateShippingInvoiceTransactionController@create')->name('supplier.create'); - - route::put('/shipping-invoice/update', 'UpdateShippingInvoiceTransactionController@update')->name('supplier.update'); - - route::put('/shipping-invoice/approve', 'ApproveShippingInvoiceTransactionController@approve')->name('supplier.approve'); + Route::group(['prefix' => 'payment', 'as' => 'payment.'], function () { + Route::post('/create', 'CreatePaymentTransactionController@create')->name('create'); + Route::post('/upload-verification-document/{transaction_id}', 'UploadPaymentVerificationDocumentController@upload')->name('verification.create'); + Route::put('/approve/{transaction_id}/{status}', 'ApprovePaymentTransactionController@approve')->where('status', 'approve|reject')->name('approval'); + }); + + Route::group(['prefix' => 'invoice', 'as' => 'invoice.'], function () { + route::post('/shipping-invoice/create', 'CreateShippingInvoiceTransactionController@create')->name('create'); + route::put('/shipping-invoice/{id}/update', 'UpdateShippingInvoiceTransactionController@update')->name('update'); + route::put('/shipping-invoice/{id}/approve', 'ApproveShippingInvoiceTransactionController@approve')->name('approve'); + }); route::post('/shipping-invoice/calculator', 'ShippingEstimationCalculatorController@calculate')->name('shipping.estimation.calculator'); diff --git a/routes/web.php b/routes/web.php index 084d94da..9407d990 100644 --- a/routes/web.php +++ b/routes/web.php @@ -412,4 +412,11 @@ Route::get('/customers/active/{active_start}/{active_end}/{inactive_start?}/{ina Route::get('/online_payment/redirect', 'Billplz\CallbackBillplzController@callback')->name('online_payment.redirect'); +Route::get('/order/{id}', function ($id) { + return view('pages.orders.profile', ['id' => $id]); +})->name('order.details'); + +Route::get('/payment-and-billing', function () { + return view('pages.paymentAndBilling'); +})->name('admin.payment-and-billing'); Route::get('/notifications/list', 'Notifications\ListNotificationsController@list')->name('notifications.list');