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 @@
+
+ Marking {{item.receive_packing_list.transport.drop_date}} Invoice Date Status Amount Container Reference Due Date Total CBM Subtotal Service Charges Tax Total Name {{product.name}} Unit Price {{product.price}} Quantity {{product.quantity}} Total {{currency}} {{(Math.round((productTotal + Number.EPSILON) * 100) / 100).toFixed(2)}} {{ data }} Total Outstanding: MYR {{ data.outstanding.toFixed(2) }}Invoice Details
+ Reject Document
+ Approve Payment
+ Approve Invoice
+ Are you Sure?
+ {{currency}} {{productTotal.toFixed(3)}}
+