From 2a6a980fc3d73c2b7ca1aa3e5db8fb6caf6df6f3 Mon Sep 17 00:00:00 2001 From: glovetleong Date: Sat, 30 Jul 2022 09:40:50 +0800 Subject: [PATCH 01/62] unit test --- tests/CreatesApplication.php | 22 ++++++++++++++++++++++ tests/Feature/ExampleTest.php | 20 ++++++++++++++++++++ tests/TestCase.php | 10 ++++++++++ tests/Unit/ExampleTest.php | 19 +++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 tests/CreatesApplication.php create mode 100644 tests/Feature/ExampleTest.php create mode 100644 tests/TestCase.php create mode 100644 tests/Unit/ExampleTest.php diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php new file mode 100644 index 00000000..547152f6 --- /dev/null +++ b/tests/CreatesApplication.php @@ -0,0 +1,22 @@ +make(Kernel::class)->bootstrap(); + + return $app; + } +} diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php new file mode 100644 index 00000000..8fbf3706 --- /dev/null +++ b/tests/Feature/ExampleTest.php @@ -0,0 +1,20 @@ +get('/'); + + $response->assertStatus(200); + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 00000000..2932d4a6 --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,10 @@ +assertTrue(true); + + } +} From 4db4f6094d4f4ef381dab1f074927555f61b1b4a Mon Sep 17 00:00:00 2001 From: glovetleong Date: Sat, 30 Jul 2022 09:56:30 +0800 Subject: [PATCH 02/62] unit test bug --- tests/Feature/ExampleTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php index 8fbf3706..6d9e8a75 100644 --- a/tests/Feature/ExampleTest.php +++ b/tests/Feature/ExampleTest.php @@ -13,7 +13,7 @@ class ExampleTest extends TestCase */ public function testBasicTest() { - $response = $this->get('/'); + $response = $this->get('/swagger'); $response->assertStatus(200); } From e77e82bac2132fa528c3c7e8698a1ef4d5cbf39b Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sun, 31 Jul 2022 15:58:20 +0800 Subject: [PATCH 03/62] move bill plz to shipping --- .../CreatePaymentTransactionLogic.php | 2 +- .../forms/PaymentFormComponent.vue | 91 ++++++++++++++++--- 2 files changed, 80 insertions(+), 13 deletions(-) diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentTransactionLogic.php index 04de4090..ff7c89ee 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentTransactionLogic.php @@ -83,7 +83,7 @@ class CreatePaymentTransactionLogic extends AbstractControllerLogic $payment_method = PaymentMethodType::PAYMENT_GATEWAY; $billPlzBill = $this->createsBillplzBill->execute( $company_module->name, - $company_module->employees()->first()->email, + $company_module->employees()->first()->email ?? '', 'This payment is for the invoice number . ' . $invoice_transaction->bill_no, $amount, $billNumber, diff --git a/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue b/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue index 72d56a03..a1848de5 100644 --- a/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue @@ -3,16 +3,67 @@
-

Outstanding: MYR {{ data.outstanding.toFixed(2) }}

- - - - - - -
+

Make Payment

+
- +
+
+
+
+ {{error}} +
+
+
+
+ + + + +
+
+
+
+
MYR
+
+
+
+
+
+
+
+
+
+
+
+ logo +
+

Online Banking

+
+
+
+
+
+
+
+ +
+

Manual Transfer

+
+
+
+
+
+
+
+
+
+
+
Cancel
+
+
+
Cancel
+
+
@@ -29,8 +80,15 @@ return { parameters : { amount: this.data.outstanding.toFixed(2), - transaction_id: this.data.id - } + transaction_id: this.data.id, + payment_method: '', + }, + paymentMethod: { + name: '', + id: '', + status: false + }, + error: '', } }, validations: { @@ -40,8 +98,17 @@ }, methods:{ submitForm(){ + this.parameters.payment_method = this.paymentMethod.id === 'payment_gateway' ? 5 : ''; this.submit(this.route('api.transaction.payment.create'), 'post', this.section, true, true); - } + }, + updatePaymentType(payment){ + this.paymentMethod = { + name: payment.name, + id: payment.id, + status: false, + } + this.error = ''; + }, }, mixins: [formHandler] } From db6412c5c08823aca9b4616eb9e833abe04410d6 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sun, 31 Jul 2022 16:06:35 +0800 Subject: [PATCH 04/62] when click on cancel will disminss the modal --- .../components/paymentsBilling/forms/PaymentFormComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue b/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue index a1848de5..b38d09c3 100644 --- a/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue @@ -58,7 +58,7 @@
-
Cancel
+
Cancel
Cancel
From 374cc7748a000072689e144efb95483528cef140 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sun, 31 Jul 2022 18:00:05 +0800 Subject: [PATCH 05/62] update billplz ui --- .../General/Eloquent/Filters/OwnerIdNotIn.php | 20 +++++++++++++++++++ .../CreatePaymentTransactionLogic.php | 2 +- .../forms/PaymentFormComponent.vue | 5 +++++ .../AdminPaymentsBillingSectionComponent.vue | 2 +- routes/web.php | 5 +++++ 5 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 app/Classes/General/Eloquent/Filters/OwnerIdNotIn.php diff --git a/app/Classes/General/Eloquent/Filters/OwnerIdNotIn.php b/app/Classes/General/Eloquent/Filters/OwnerIdNotIn.php new file mode 100644 index 00000000..97c7dcba --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/OwnerIdNotIn.php @@ -0,0 +1,20 @@ +whereNotIn('owner_id', $value); + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentTransactionLogic.php index ff7c89ee..9535c04f 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentTransactionLogic.php @@ -83,7 +83,7 @@ class CreatePaymentTransactionLogic extends AbstractControllerLogic $payment_method = PaymentMethodType::PAYMENT_GATEWAY; $billPlzBill = $this->createsBillplzBill->execute( $company_module->name, - $company_module->employees()->first()->email ?? '', + (app()->environment(['production'])) ? $company_module->employees()->first()->email : '', 'This payment is for the invoice number . ' . $invoice_transaction->bill_no, $amount, $billNumber, diff --git a/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue b/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue index b38d09c3..0dee1870 100644 --- a/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue @@ -109,6 +109,11 @@ } this.error = ''; }, + successHandler(response){ + if (response.payload.data.payment_method === 5) { + window.location.href = this.route('billplz.bill', response.payload.data.payment_reference) + '?auto_submit=true'; + } + } }, mixins: [formHandler] } diff --git a/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue index 8a759b4e..a822b542 100644 --- a/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue @@ -102,7 +102,7 @@
- + diff --git a/routes/web.php b/routes/web.php index 9407d990..e4a20254 100644 --- a/routes/web.php +++ b/routes/web.php @@ -420,3 +420,8 @@ 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'); + +Route::get('billplz/bills/{bill_no}', function($bill_no){ + return redirect(env('BILLPLZ_BASE_URL').'/bills/'.$bill_no); + })->name('billplz.bill'); + \ No newline at end of file From 37887de61d30404c9efc1b5909e7d850ce4f5359 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sun, 31 Jul 2022 20:15:38 +0800 Subject: [PATCH 06/62] add invoice in order resources --- app/Http/Resources/OrderResource.php | 1 + app/Models/Order.php | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/Http/Resources/OrderResource.php b/app/Http/Resources/OrderResource.php index d2c72930..bf8d8a41 100644 --- a/app/Http/Resources/OrderResource.php +++ b/app/Http/Resources/OrderResource.php @@ -46,6 +46,7 @@ class OrderResource extends JsonResource 'received_packages' => PackingListResource::collection($this->packingLists()->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('packages')->get()), ]; }), + 'invoices' => TransactionResource::collection($this->transactions), 'remarks' => RemarkResource::collection($this->remarks), 'created_at' => $this->created_at->format('d-m-Y') ]; diff --git a/app/Models/Order.php b/app/Models/Order.php index 352f46fb..312cd244 100644 --- a/app/Models/Order.php +++ b/app/Models/Order.php @@ -16,10 +16,13 @@ use Illuminate\Database\Eloquent\Relations\HasManyThrough; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\MorphMany; +use Staudenmeir\EloquentHasManyDeep\HasManyDeep; +use Staudenmeir\EloquentHasManyDeep\HasRelationships; class Order extends AbstractModel implements Addressable, Packable, Remarkable, Notifiable { use SoftDeletes; + use HasRelationships; protected $table = 'orders'; @@ -160,10 +163,10 @@ class Order extends AbstractModel implements Addressable, Packable, Remarkable, } /** - * @return morphMany + * @return hasManyDeep */ - // public function transactions(): morphMany - // { - // return $this->morphMany(Transaction::class, 'owner'); - // } + public function transactions(): hasManyDeep + { + return $this->hasManyDeep(Transaction::class, [PackingList::class], ['owner_id', 'owner_id'], ['id', 'id']); + } } From 436985db8f753a32440d6b80aff36a5f6531ade7 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sun, 31 Jul 2022 20:17:10 +0800 Subject: [PATCH 07/62] fix error section not showing --- .../components/addresses/elements/SelectAddressComponent.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/assets/vue/components/addresses/elements/SelectAddressComponent.vue b/resources/assets/vue/components/addresses/elements/SelectAddressComponent.vue index 492abb73..9b1e597e 100644 --- a/resources/assets/vue/components/addresses/elements/SelectAddressComponent.vue +++ b/resources/assets/vue/components/addresses/elements/SelectAddressComponent.vue @@ -52,8 +52,9 @@ value: { required: false }, - 'section': { + section: { type: String, + default: 'addressSection' } }, From 43491223abbec2f73f42b0c59771e656b3f5be31 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sun, 31 Jul 2022 21:38:15 +0800 Subject: [PATCH 08/62] customer payment ui inside orders --- .../sections/OrderProfileSectionComponent.vue | 17 ++ .../AdminPaymentsBillingComponent.vue | 1 + .../CustomerPaymentsBillingComponent.vue | 178 ++++++++++++++++++ .../forms/PaymentFormComponent.vue | 6 +- 4 files changed, 200 insertions(+), 2 deletions(-) create mode 100644 resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue diff --git a/resources/assets/vue/components/orders/sections/OrderProfileSectionComponent.vue b/resources/assets/vue/components/orders/sections/OrderProfileSectionComponent.vue index a0880e40..0b48c640 100644 --- a/resources/assets/vue/components/orders/sections/OrderProfileSectionComponent.vue +++ b/resources/assets/vue/components/orders/sections/OrderProfileSectionComponent.vue @@ -134,6 +134,23 @@
+ +
+
+
+
+

Invoices

+

You can view your invoices here and make payment.

+
+
+
+
+ +
+
+
+
+
diff --git a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue index 535ecfdc..8813d9ed 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue @@ -193,6 +193,7 @@
+
Make Payment
diff --git a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue new file mode 100644 index 00000000..6573fdca --- /dev/null +++ b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue @@ -0,0 +1,178 @@ + + diff --git a/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue b/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue index 0dee1870..79a67683 100644 --- a/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/forms/PaymentFormComponent.vue @@ -110,8 +110,10 @@ this.error = ''; }, successHandler(response){ - if (response.payload.data.payment_method === 5) { - window.location.href = this.route('billplz.bill', response.payload.data.payment_reference) + '?auto_submit=true'; + if (response.payload) { + if (response.payloaddata.payment_method === 5) { + window.location.href = this.route('billplz.bill', response.payload.data.payment_reference) + '?auto_submit=true'; + } } } }, From 2a0501ad99b18ef8506057389c7194affb1f4920 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sun, 31 Jul 2022 22:08:15 +0800 Subject: [PATCH 09/62] remove extra line of codes --- .../paymentsBilling/elements/AdminPaymentsBillingComponent.vue | 2 -- 1 file changed, 2 deletions(-) diff --git a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue index 8813d9ed..4e84177f 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue @@ -191,8 +191,6 @@
MYR {{(Math.round((item.shippng_transaction.outstanding + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
- -
Make Payment
From ff68ee76ab76148b92d4420d732199c41946a1d3 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sun, 31 Jul 2022 22:08:48 +0800 Subject: [PATCH 10/62] update base price according to packlinglist drop date --- .../CreateShippingInvoiceTransactionLogic.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateShippingInvoiceTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateShippingInvoiceTransactionLogic.php index 50b6165f..a8274aea 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateShippingInvoiceTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateShippingInvoiceTransactionLogic.php @@ -25,6 +25,7 @@ use App\Classes\ValueObjects\Constants\SegmentConstants; use App\Classes\ValueObjects\Constants\TransactionDetailType; use App\Models\Document; +use App\Models\PackingList; use App\Models\Transaction; use Carbon\Carbon; use Illuminate\Http\JsonResponse; @@ -114,7 +115,8 @@ class CreateShippingInvoiceTransactionLogic extends AbstractControllerLogic $state_rate = 0; $state_select = ''; - $base_price = $this->getConstantByKey($base_price_constant, date('Y-m-d')); + $packing_list_drop_date = Carbon::parse(PackingList::where('reference', $packing_list->reference)->where('type', 1)->first()->transports->first()->drop_date)->format('d/m/Y'); + $base_price = $this->getConstantByKey($base_price_constant, $packing_list_drop_date); $warehouseId = $order->orderRoles()->where('role_id', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->company_module_id; $selected_warehouse_rate = $this->getConstantByKey($warehouse_rate_constant, $warehouseId); From c24ddb4fa23f20b78dff004d2094c36b4501b54e Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sun, 31 Jul 2022 22:52:05 +0800 Subject: [PATCH 11/62] remove code error --- .../paymentsBilling/elements/AdminPaymentsBillingComponent.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue index 4e84177f..08894ee7 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue @@ -9,9 +9,8 @@
{{item.order.company_module.marking}}/{{item.order.reference}} -

{{item.receive_packing_list.transport.drop_date}}

-
Unclaimed Packing List
+
Unclaimed Packing List
From 0bad26e8ff7688bcab9388b602f6e6b6128176b6 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Mon, 1 Aug 2022 00:17:24 +0800 Subject: [PATCH 12/62] update segment - delete props --- .../settings/forms/BasePriceFormComponent.vue | 5 ----- .../forms/EditBasePriceFormComponent.vue | 9 --------- .../forms/EditSegmentPriceFormComponent.vue | 18 +++++------------- 3 files changed, 5 insertions(+), 27 deletions(-) diff --git a/resources/assets/vue/components/settings/forms/BasePriceFormComponent.vue b/resources/assets/vue/components/settings/forms/BasePriceFormComponent.vue index 62d8deda..c77d5ebc 100644 --- a/resources/assets/vue/components/settings/forms/BasePriceFormComponent.vue +++ b/resources/assets/vue/components/settings/forms/BasePriceFormComponent.vue @@ -48,11 +48,6 @@ import { required } from "vuelidate/lib/validators"; export default { - props: { - section: { - default: '' - }, - }, data() { return { parameters: { diff --git a/resources/assets/vue/components/settings/forms/EditBasePriceFormComponent.vue b/resources/assets/vue/components/settings/forms/EditBasePriceFormComponent.vue index 742e95dc..086a9ea0 100644 --- a/resources/assets/vue/components/settings/forms/EditBasePriceFormComponent.vue +++ b/resources/assets/vue/components/settings/forms/EditBasePriceFormComponent.vue @@ -29,15 +29,6 @@ import { required } from "vuelidate/lib/validators"; export default { - props: { - data: { - type: Object, - required: false - }, - section: { - default: '' - }, - }, data() { return { parameters: { diff --git a/resources/assets/vue/components/settings/forms/EditSegmentPriceFormComponent.vue b/resources/assets/vue/components/settings/forms/EditSegmentPriceFormComponent.vue index 910ba2fe..4d6b70b2 100644 --- a/resources/assets/vue/components/settings/forms/EditSegmentPriceFormComponent.vue +++ b/resources/assets/vue/components/settings/forms/EditSegmentPriceFormComponent.vue @@ -6,10 +6,10 @@

Edit {{data.name}} Price

- +
- +
@@ -28,20 +28,12 @@ import { required } from "vuelidate/lib/validators"; export default { - props: { - data: { - type: Object, - required: false - }, - section: { - default: '' - }, - }, data() { return { parameters: { reference: 'CUSTOM_PRICE', - value : { + id: this.data.id, + rate : { amount: 0 } } @@ -49,7 +41,7 @@ }, validations: { parameters: { - value: { + rate: { amount: { required } } } From 433d8e63b4d582e3239fc48c5c31378c20242d1e Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 5 Aug 2022 20:07:55 +0800 Subject: [PATCH 13/62] hide generate invoice for un-claimed packing list --- .../elements/AdminPaymentsBillingComponent.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue index 08894ee7..4d9d28a2 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue @@ -51,8 +51,10 @@
-
-
Generate Invoice
+
+
+
Generate Invoice
+
From 2b1fca6b2e6989f46a5865e2870f147653f738ca Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 5 Aug 2022 21:24:36 +0800 Subject: [PATCH 14/62] if company doesn't have billing address - hide generate invoice and show create billing address modal --- app/Http/Resources/AddressResource.php | 1 + .../AdminPaymentsBillingComponent.vue | 15 ++++- .../forms/BillingAddressFormComponent.vue | 66 +++++++++++++++++++ 3 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 resources/assets/vue/components/paymentsBilling/forms/BillingAddressFormComponent.vue diff --git a/app/Http/Resources/AddressResource.php b/app/Http/Resources/AddressResource.php index f86d5c29..a4df7e4f 100644 --- a/app/Http/Resources/AddressResource.php +++ b/app/Http/Resources/AddressResource.php @@ -41,6 +41,7 @@ class AddressResource extends JsonResource 'status' => (int) $this->status, 'contact' => new ContactResource($this->contacts->first()), 'remark' => new RemarkResource($this->remarks->first()), + 'type' => $this->type, $this->mergeWhen($this->relationLoaded('owner'), [ 'owner' => $this->when($this->owner instanceof Order, [ 'reference' => $this->owner->reference, diff --git a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue index 4d9d28a2..a56c9f2d 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue @@ -51,9 +51,18 @@
-
-
-
Generate Invoice
+
+
+ +
+
Add Delivery Address
+ + + +
+
+
Generate Invoice
+
diff --git a/resources/assets/vue/components/paymentsBilling/forms/BillingAddressFormComponent.vue b/resources/assets/vue/components/paymentsBilling/forms/BillingAddressFormComponent.vue new file mode 100644 index 00000000..c21a88b4 --- /dev/null +++ b/resources/assets/vue/components/paymentsBilling/forms/BillingAddressFormComponent.vue @@ -0,0 +1,66 @@ + + \ No newline at end of file From b984f931e13a3485d67b1d04f6dd6e37e7d44b43 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 5 Aug 2022 23:40:59 +0800 Subject: [PATCH 15/62] update admin payments and billings page - add address and postcode --- app/Http/Resources/AddressResource.php | 5 +++-- app/Http/Resources/CompanyModuleResource.php | 2 ++ .../AdminPaymentsBillingComponent.vue | 22 ++++++++++++------- .../AdminPaymentsBillingSectionComponent.vue | 2 +- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/app/Http/Resources/AddressResource.php b/app/Http/Resources/AddressResource.php index a4df7e4f..cfcd8389 100644 --- a/app/Http/Resources/AddressResource.php +++ b/app/Http/Resources/AddressResource.php @@ -21,11 +21,11 @@ class AddressResource extends JsonResource $centerPostcodeConstantObject = SegmentConstant::where('reference', SegmentConstants::CENTER_POSTCODE)->get(); $centerPostcodeConstant = $centerPostcodeConstantObject->isEmpty() ? [] : (array)$centerPostcodeConstantObject->first()->value; - $postcodeArea = in_array($this->postcode, $centerPostcodeConstant) ? 'CENTER_POSTCODE' : ''; + $postcodeArea = in_array($this->postcode, $centerPostcodeConstant) ? 'CENTER_POSTCODE' : null; $outstationPostcodeConstantObject = SegmentConstant::where('reference', SegmentConstants::OUTSTATION_POSTCODE)->get(); $outstationPostcodeConstant = $outstationPostcodeConstantObject->isEmpty() ? [] : (array)$outstationPostcodeConstantObject->first()->value; - in_array($this->postcode, $outstationPostcodeConstant) ? $postcodeArea = 'OUTSTATION_POSTCODE' : ''; + in_array($this->postcode, $outstationPostcodeConstant) ? $postcodeArea = 'OUTSTATION_POSTCODE' : null; return [ 'id' => $this->id, @@ -34,6 +34,7 @@ class AddressResource extends JsonResource 'street_two' => $this->street_two, 'district' => $this->district, 'state' => $this->state, + 'postcode' => $this->postcode, 'post_code' => $this->postcode, 'post_code_area' => $postcodeArea, 'country' => $this->country, diff --git a/app/Http/Resources/CompanyModuleResource.php b/app/Http/Resources/CompanyModuleResource.php index 51c651f7..13f4eb6a 100644 --- a/app/Http/Resources/CompanyModuleResource.php +++ b/app/Http/Resources/CompanyModuleResource.php @@ -3,6 +3,7 @@ namespace App\Http\Resources; use App\Classes\Modules\Companies\Services\FetchesCompanyServices; +use App\Classes\ValueObjects\Constants\AddressType; use App\Classes\ValueObjects\Constants\BankAccountType; use App\Classes\ValueObjects\Constants\BusinessType; use App\Classes\ValueObjects\Constants\DocumentType; @@ -41,6 +42,7 @@ class CompanyModuleResource extends JsonResource 'name' => $this->name, 'reference' => $this->reference, 'address' => new AddressResource($defaultAddress), + 'billingAddress' => new AddressResource($this->addresses()->where('type', AddressType::BILLING)->first()), 'company' => new CompanyResource($this->whenLoaded('company')), 'remarks' => RemarkResource::collection($this->remarks), 'marking' => $marking, diff --git a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue index a56c9f2d..806a8ff8 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue @@ -51,18 +51,24 @@
-
-
- -
-
Add Delivery Address
+
+
+
+
Add Billing Address
- +
-
-
Generate Invoice
+
+
Define Location
+ + +
+
Generate Invoice
+
+
+
diff --git a/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue index a822b542..840c2009 100644 --- a/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue @@ -102,7 +102,7 @@
- + From 845fdfd5cad1c4c0c5e1f2dd3db089f817414c90 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sat, 6 Aug 2022 00:41:28 +0800 Subject: [PATCH 16/62] debug all constant in settings --- .../Modules/Segments/ControllersLogic/UpdateConstantLogic.php | 2 +- .../Segments/ControllersLogic/UpdateConstantPostcodeLogic.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Classes/Modules/Segments/ControllersLogic/UpdateConstantLogic.php b/app/Classes/Modules/Segments/ControllersLogic/UpdateConstantLogic.php index 64c41820..99951553 100644 --- a/app/Classes/Modules/Segments/ControllersLogic/UpdateConstantLogic.php +++ b/app/Classes/Modules/Segments/ControllersLogic/UpdateConstantLogic.php @@ -102,7 +102,7 @@ class UpdateConstantLogic extends AbstractControllerLogic $constant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'reference' => $request->input('reference')]); - $constantValue = $this->updatesConstantValue->execute($constant->value, $request->input('id'), $request->input('value')); + $constantValue = $this->updatesConstantValue->execute($constant->value, $request->input('id'), $request->input('rate')); $object = new ConstantObject($request->input('reference'), $constantValue); diff --git a/app/Classes/Modules/Segments/ControllersLogic/UpdateConstantPostcodeLogic.php b/app/Classes/Modules/Segments/ControllersLogic/UpdateConstantPostcodeLogic.php index f39fdb29..ac6dc26e 100644 --- a/app/Classes/Modules/Segments/ControllersLogic/UpdateConstantPostcodeLogic.php +++ b/app/Classes/Modules/Segments/ControllersLogic/UpdateConstantPostcodeLogic.php @@ -25,8 +25,8 @@ class UpdateConstantPostcodeLogic extends AbstractControllerLogic */ protected function notification():array { return [ - 'title' => 'Updated Segment Constant', - 'message' => 'You have successfully updated the Segment Constant' + 'title' => 'Updated Postcode Constant', + 'message' => 'You have successfully updated the Postcode Constant' ]; } From f7a28610728edc353b3c58c8611572f5807af62f Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sat, 6 Aug 2022 00:42:20 +0800 Subject: [PATCH 17/62] update admin payments billing page - do extra validation checking on each data with vue conditions --- .../elements/AdminPaymentsBillingComponent.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue index 806a8ff8..6be09cd9 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue @@ -88,12 +88,16 @@

Container Reference

-
{{ item.packages.length ? item.packages[0].container.container_reference : 'n/a' }}
+
{{ item.packages[0].container ? item.packages[0].container.container_reference : 'n/a' }}
+
n/a

Due Date

-
{{ item.packages[0].container.transport.drop_date == null ? item.packages[0].container.transport.current_schedule.etd : item.packages[0].container.transport.drop_date }}
+
+
{{ item.packages[0].container.transport.drop_date == null ? item.packages[0].container.transport.current_schedule.etd : item.packages[0].container.transport.drop_date }}
+
n/a
+
n/a
n/a
From cd59debee4a929db4ff8d1524688a2598596f02e Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sat, 6 Aug 2022 01:46:06 +0800 Subject: [PATCH 18/62] update CUSTOM SEGMENTS price api --- .../ControllersLogic/UpdateSegmentLogic.php | 3 +- .../UpdateSegmentPriceLogic.php | 124 ++++++++++++++++++ .../Segments/UpdateSegmentPriceController.php | 20 +++ app/Http/Resources/SegmentResource.php | 2 +- .../CustomerPaymentsBillingComponent.vue | 5 +- .../settings/elements/SegmentComponent.vue | 2 +- .../forms/EditSegmentPriceFormComponent.vue | 12 +- routes/segment.php | 1 + 8 files changed, 158 insertions(+), 11 deletions(-) create mode 100644 app/Classes/Modules/Segments/ControllersLogic/UpdateSegmentPriceLogic.php create mode 100644 app/Http/Controllers/Segments/UpdateSegmentPriceController.php diff --git a/app/Classes/Modules/Segments/ControllersLogic/UpdateSegmentLogic.php b/app/Classes/Modules/Segments/ControllersLogic/UpdateSegmentLogic.php index 43eaa54e..f0378691 100644 --- a/app/Classes/Modules/Segments/ControllersLogic/UpdateSegmentLogic.php +++ b/app/Classes/Modules/Segments/ControllersLogic/UpdateSegmentLogic.php @@ -70,7 +70,8 @@ class UpdateSegmentLogic extends AbstractControllerLogic $segment_query = $this->fetchesSegment->execute(['id' => $request->route('id')]); $segment_object = new SegmentObject( - $request->input('name', $segment_query->name) + $request->input('name'), + $segment_query->company_module_id ); $this->canUpdateSegment->passes($segment_object); $segment_query = $this->updatesSegment->execute($segment_query, $segment_object); diff --git a/app/Classes/Modules/Segments/ControllersLogic/UpdateSegmentPriceLogic.php b/app/Classes/Modules/Segments/ControllersLogic/UpdateSegmentPriceLogic.php new file mode 100644 index 00000000..6f1567a8 --- /dev/null +++ b/app/Classes/Modules/Segments/ControllersLogic/UpdateSegmentPriceLogic.php @@ -0,0 +1,124 @@ + 'Updated Segment Price', + 'message' => 'You have successfully updated the Segment Price' + ]; + } + + /** @var CanUpdateConstant */ + private $canUpdateConstant; + + /** @var UpdatesConstant */ + private $updatesConstant; + + /** @var FetchesSegment */ + private $fetchesSegment; + + /** @var FetchesConstant */ + private $fetchesConstant; + + /** @var CanCreateConstant */ + private $canCreateConstant; + + /** @var CreatesConstant */ + private $createsConstant; + + /** @var CreatesSegment */ + private $createsSegment; + + /** @var UpdatesConstantValue */ + private $updatesConstantValue; + + /** + * UpdateConstantLogic constructor. + * @param CanUpdateConstant $canUpdateConstant + * @param UpdatesConstant $updatesConstant + * @param FetchesSegment $fetchesSegment + * @param FetchesConstant $fetchesConstant + * @param CanCreateConstant $canCreateConstant + * @param CreatesConstant $createsConstant + * @param UpdatesConstantValueByState $updatesConstantValueByState + * @param CreatesSegment $createsSegment + */ + public function __construct( + CanUpdateConstant $canUpdateConstant, + UpdatesConstant $updatesConstant, + FetchesSegment $fetchesSegment, + FetchesConstant $fetchesConstant, + CanCreateConstant $canCreateConstant, + CreatesConstant $createsConstant, + UpdatesConstantValue $updatesConstantValue, + CreatesSegment $createsSegment + ) + { + $this->canUpdateConstant = $canUpdateConstant; + $this->updatesConstant = $updatesConstant; + $this->fetchesSegment = $fetchesSegment; + $this->fetchesConstant = $fetchesConstant; + $this->canCreateConstant = $canCreateConstant; + $this->createsConstant = $createsConstant; + $this->updatesConstantValue = $updatesConstantValue; + $this->createsSegment = $createsSegment; + } + /** + * @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 + { + $segment = $this->fetchesSegment->execute(['id' => $request->route('id')]); + + try { + + $constant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'reference' => $request->input('reference')]); + + $object = new ConstantObject($request->input('reference'), [$request->input('value')]); + + $this->canUpdateConstant->passes($object); + + } catch (ResourceNotFoundException $exception){ + + $object = new ConstantObject( + $request->input('reference'), + [$request->input('value')] + ); + + $constant = $this->createsConstant->execute($segment, $object); + } + + $constant = $this->updatesConstant->execute($constant, $object); + + return $this->resourceResponse(new ConstantResource($constant)); + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/Segments/UpdateSegmentPriceController.php b/app/Http/Controllers/Segments/UpdateSegmentPriceController.php new file mode 100644 index 00000000..4e403348 --- /dev/null +++ b/app/Http/Controllers/Segments/UpdateSegmentPriceController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/app/Http/Resources/SegmentResource.php b/app/Http/Resources/SegmentResource.php index a587a7ff..2ec22145 100644 --- a/app/Http/Resources/SegmentResource.php +++ b/app/Http/Resources/SegmentResource.php @@ -19,7 +19,7 @@ class SegmentResource extends JsonResource return [ 'id' => $this->id, 'name' => $this->name, - 'price' => $constant ? $constant->value : 0 + 'price' => $constant ? $constant->value[0] : 0 ]; } } diff --git a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue index 6573fdca..b2c22979 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue @@ -17,7 +17,10 @@

Amount

MYR {{ item.amount.toFixed(2) }}
-
+
+
+ Billing Question? +
diff --git a/resources/assets/vue/components/settings/elements/SegmentComponent.vue b/resources/assets/vue/components/settings/elements/SegmentComponent.vue index 0c0e8866..bc698ea5 100644 --- a/resources/assets/vue/components/settings/elements/SegmentComponent.vue +++ b/resources/assets/vue/components/settings/elements/SegmentComponent.vue @@ -27,7 +27,7 @@
-
MYR {{item.price[data.id].amount}}
+
MYR {{item.price}}
diff --git a/resources/assets/vue/components/settings/forms/EditSegmentPriceFormComponent.vue b/resources/assets/vue/components/settings/forms/EditSegmentPriceFormComponent.vue index 73ab5c61..a6f613e3 100644 --- a/resources/assets/vue/components/settings/forms/EditSegmentPriceFormComponent.vue +++ b/resources/assets/vue/components/settings/forms/EditSegmentPriceFormComponent.vue @@ -6,10 +6,10 @@

Edit {{data.name}} Price

- +
- +
@@ -17,7 +17,7 @@
Cancel
-
Confirm
+
Confirm
@@ -34,16 +34,14 @@ reference: 'CUSTOM_PRICE', id: this.data.id, value : { - amount: this.data.price[this.data.id].amount + amount: this.data.price } } }; }, validations: { parameters: { - rate: { - amount: { required } - } + value: { required } } }, mixins: [modalFormHandler] diff --git a/routes/segment.php b/routes/segment.php index caf8ff82..c59f4ca9 100644 --- a/routes/segment.php +++ b/routes/segment.php @@ -7,6 +7,7 @@ Route::group(['prefix' => 'segment', 'as' => 'segment.', 'namespace' => 'Segment Route::delete('/delete/{id}', 'DeleteSegmentController@destroy')->name('delete'); Route::get('/{id}/show', 'FetchSegmentController@fetch')->name('show'); Route::put('/update/{id}', 'UpdateSegmentController@update')->name('update'); + Route::put('price/update/{id}', 'UpdateSegmentPriceController@update')->name('price.update'); Route::get('/list', 'ListSegmentsController@list')->name('list'); Route::get('/air-shipment/item-price/list', 'ListAirShipmentPriceController@list')->name('air_shipment.price.list'); From e7f8b62116e686c355a92d58d316c764f0b60a10 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sat, 6 Aug 2022 01:57:34 +0800 Subject: [PATCH 19/62] update seeder for segment constant --- database/seeders/SegmentConstantsTableSeeder.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/database/seeders/SegmentConstantsTableSeeder.php b/database/seeders/SegmentConstantsTableSeeder.php index ef47f580..159c8586 100644 --- a/database/seeders/SegmentConstantsTableSeeder.php +++ b/database/seeders/SegmentConstantsTableSeeder.php @@ -28,10 +28,7 @@ class SegmentConstantsTableSeeder extends Seeder $today = date("Y-m-d"); $prices = []; for($ii=0; $ii<$n_days;$ii++){ - $prices[] = [ - "date" => date('Y-m-d', strtotime($today. ' + '.$ii.' days')), - "price" => rand(10, 30) / 10 - ]; + $prices[date('Y-m-d', strtotime($today. ' + '.$ii.' days'))] = rand(10, 30) / 10; } $this->insertData(1, SegmentConstants::BASE_PRICE, $prices); @@ -127,9 +124,7 @@ class SegmentConstantsTableSeeder extends Seeder $this->insertData(1, SegmentConstants::OUTSTATION_POSTCODE, $prices); // insert customer prices - $prices = [ - ['id'=> 1, 'price' => 15 ] - ]; + $prices = [15]; $this->insertData(2, SegmentConstants::CUSTOMER_RATE, $prices); } From b52445f1062c9f6ddac276a47838aa5a71f6330d Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sat, 6 Aug 2022 23:33:09 +0800 Subject: [PATCH 20/62] migrate annoucment module from exchange --- .../elements/AnnouncementListComponent.vue | 135 ++++++++++++++++++ ...signAnnouncementToSegmentFormComponent.vue | 67 +++++++++ ...chAnnouncementFromSegmentFormComponent.vue | 51 +++++++ .../forms/ViewAnnouncementFormComponent.vue | 51 +++++++ .../AnnouncementQuickViewSectionComponent.vue | 55 +++++++ .../forms/AnnouncementFormComponent.vue | 32 ++--- 6 files changed, 370 insertions(+), 21 deletions(-) create mode 100644 resources/assets/vue/components/announcements/elements/AnnouncementListComponent.vue create mode 100644 resources/assets/vue/components/announcements/forms/AssignAnnouncementToSegmentFormComponent.vue create mode 100644 resources/assets/vue/components/announcements/forms/DetachAnnouncementFromSegmentFormComponent.vue create mode 100644 resources/assets/vue/components/announcements/forms/ViewAnnouncementFormComponent.vue create mode 100644 resources/assets/vue/components/announcements/sections/AnnouncementQuickViewSectionComponent.vue diff --git a/resources/assets/vue/components/announcements/elements/AnnouncementListComponent.vue b/resources/assets/vue/components/announcements/elements/AnnouncementListComponent.vue new file mode 100644 index 00000000..e0102b6d --- /dev/null +++ b/resources/assets/vue/components/announcements/elements/AnnouncementListComponent.vue @@ -0,0 +1,135 @@ + + + \ No newline at end of file diff --git a/resources/assets/vue/components/announcements/forms/AssignAnnouncementToSegmentFormComponent.vue b/resources/assets/vue/components/announcements/forms/AssignAnnouncementToSegmentFormComponent.vue new file mode 100644 index 00000000..e03fb36c --- /dev/null +++ b/resources/assets/vue/components/announcements/forms/AssignAnnouncementToSegmentFormComponent.vue @@ -0,0 +1,67 @@ + + \ No newline at end of file diff --git a/resources/assets/vue/components/announcements/forms/DetachAnnouncementFromSegmentFormComponent.vue b/resources/assets/vue/components/announcements/forms/DetachAnnouncementFromSegmentFormComponent.vue new file mode 100644 index 00000000..3903dcdc --- /dev/null +++ b/resources/assets/vue/components/announcements/forms/DetachAnnouncementFromSegmentFormComponent.vue @@ -0,0 +1,51 @@ + + \ No newline at end of file diff --git a/resources/assets/vue/components/announcements/forms/ViewAnnouncementFormComponent.vue b/resources/assets/vue/components/announcements/forms/ViewAnnouncementFormComponent.vue new file mode 100644 index 00000000..40a46cc8 --- /dev/null +++ b/resources/assets/vue/components/announcements/forms/ViewAnnouncementFormComponent.vue @@ -0,0 +1,51 @@ + + \ No newline at end of file diff --git a/resources/assets/vue/components/announcements/sections/AnnouncementQuickViewSectionComponent.vue b/resources/assets/vue/components/announcements/sections/AnnouncementQuickViewSectionComponent.vue new file mode 100644 index 00000000..a40ec4c8 --- /dev/null +++ b/resources/assets/vue/components/announcements/sections/AnnouncementQuickViewSectionComponent.vue @@ -0,0 +1,55 @@ + + + \ No newline at end of file diff --git a/resources/assets/vue/components/settings/forms/AnnouncementFormComponent.vue b/resources/assets/vue/components/settings/forms/AnnouncementFormComponent.vue index a29f7572..830ab23c 100644 --- a/resources/assets/vue/components/settings/forms/AnnouncementFormComponent.vue +++ b/resources/assets/vue/components/settings/forms/AnnouncementFormComponent.vue @@ -32,16 +32,16 @@
-
+
- +
-
+
- +
@@ -50,7 +50,7 @@
Cancel
-
{{this.data?"Update":"Create"}}
+
{{data ? "Update" : "Create"}}
@@ -91,9 +91,6 @@ description: { required }, - // segment_id: { - // required - // }, starting_on:{ required }, @@ -101,26 +98,19 @@ required }, } - }, - computed:{ - }, created(){ - console.log("lado form"); + if (this.data) { + this.parameters.starting_on = this.data.starting_on; + this.parameters.ending_on = this.data.ending_on; + this.parameters.title = this.data.title; + this.parameters.description = this.data.description; + } }, 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], From 6ed383c06cb3e2420351a017630f2c95c4124e1a Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sat, 6 Aug 2022 23:34:07 +0800 Subject: [PATCH 21/62] update create annoucment service to suit the date time format from datetime picker --- .../Announcements/Services/CreatesAnnouncement.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Classes/Modules/Announcements/Services/CreatesAnnouncement.php b/app/Classes/Modules/Announcements/Services/CreatesAnnouncement.php index 4a43bac8..dc2b271e 100644 --- a/app/Classes/Modules/Announcements/Services/CreatesAnnouncement.php +++ b/app/Classes/Modules/Announcements/Services/CreatesAnnouncement.php @@ -5,6 +5,7 @@ namespace App\Classes\Modules\Announcements\Services; use App\Classes\General\Eloquent\AbstractUpdateRecord; use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject; use App\Models\Announcement; +use DateTime; class CreatesAnnouncement extends AbstractUpdateRecord { @@ -18,9 +19,17 @@ class CreatesAnnouncement extends AbstractUpdateRecord $model = new Announcement(); $model->title = $object->getTitle(); $model->description = $object->getDescription(); - $model->starting_on = $object->getStartingOn(); - $model->ending_on = $object->getEndingOn(); + // $model->starting_on = $object->getStartingOn(); + $model->starting_on = $this->convertDateFormat($object->getStartingOn()); + // $model->ending_on = $object->getEndingOn(); + $model->ending_on = $this->convertDateFormat($object->getEndingOn()); return $this->handler($model); } + + public function convertDateFormat($value) { + $value = DateTime::createFromFormat('d-m-Y', $value)->format('Y-m-d H:i:s'); + + return $value; + } } From e84e39b8a1989152c3a8aa16ad4a347f52585fb1 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sat, 6 Aug 2022 23:46:37 +0800 Subject: [PATCH 22/62] debug annoucment segment --- .../forms/AssignAnnouncementToSegmentFormComponent.vue | 5 +++-- .../forms/DetachAnnouncementFromSegmentFormComponent.vue | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/resources/assets/vue/components/announcements/forms/AssignAnnouncementToSegmentFormComponent.vue b/resources/assets/vue/components/announcements/forms/AssignAnnouncementToSegmentFormComponent.vue index e03fb36c..2763f650 100644 --- a/resources/assets/vue/components/announcements/forms/AssignAnnouncementToSegmentFormComponent.vue +++ b/resources/assets/vue/components/announcements/forms/AssignAnnouncementToSegmentFormComponent.vue @@ -7,7 +7,8 @@

Assign Segment

-
Select a segment to view annoucment with title {{parameters.title | truncate(10) }}
+ +
Select a segment to view annoucment with title {{parameters.title }}
@@ -56,7 +57,7 @@ }, computed: { currentSegmentIds(){ - return this.parameters.segments.map(function (value){ + return this.data.segments.map(function (value){ return value.id; }) } diff --git a/resources/assets/vue/components/announcements/forms/DetachAnnouncementFromSegmentFormComponent.vue b/resources/assets/vue/components/announcements/forms/DetachAnnouncementFromSegmentFormComponent.vue index 3903dcdc..d59a6aea 100644 --- a/resources/assets/vue/components/announcements/forms/DetachAnnouncementFromSegmentFormComponent.vue +++ b/resources/assets/vue/components/announcements/forms/DetachAnnouncementFromSegmentFormComponent.vue @@ -12,7 +12,8 @@

Are you Sure?

-
Are you sure you want to remove {{this.item.name}}from viewing this annoucment with title {{ announcement_title | truncate(10)}}
+ +
Are you sure you want to remove {{this.item.name}}from viewing this annoucment with title {{ announcement_title }}
From 1706e2e1a3816f841520d6d2f8b9c37a7243a3a3 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sat, 6 Aug 2022 23:48:23 +0800 Subject: [PATCH 23/62] remove console.log --- .../forms/DetachAnnouncementFromSegmentFormComponent.vue | 4 ---- 1 file changed, 4 deletions(-) diff --git a/resources/assets/vue/components/announcements/forms/DetachAnnouncementFromSegmentFormComponent.vue b/resources/assets/vue/components/announcements/forms/DetachAnnouncementFromSegmentFormComponent.vue index d59a6aea..5ac5bd36 100644 --- a/resources/assets/vue/components/announcements/forms/DetachAnnouncementFromSegmentFormComponent.vue +++ b/resources/assets/vue/components/announcements/forms/DetachAnnouncementFromSegmentFormComponent.vue @@ -43,10 +43,6 @@ type: String } }, - created() { - console.log("created detach"); - }, - mixins: [componentHandler, ModalFormHandler] } \ No newline at end of file From 9e756132ca00f719b5d15e6ad7c3359a4b1dd93f Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sat, 6 Aug 2022 23:53:43 +0800 Subject: [PATCH 24/62] update annoucment css --- .../announcements/elements/AnnouncementListComponent.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/assets/vue/components/announcements/elements/AnnouncementListComponent.vue b/resources/assets/vue/components/announcements/elements/AnnouncementListComponent.vue index e0102b6d..84de4bfb 100644 --- a/resources/assets/vue/components/announcements/elements/AnnouncementListComponent.vue +++ b/resources/assets/vue/components/announcements/elements/AnnouncementListComponent.vue @@ -80,9 +80,9 @@
-
-
-
+
+ +
Targeted Segment
From a2c7eddf7bea7fb63a0cf78ee90d97705638dea7 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Sun, 7 Aug 2022 17:11:26 +0800 Subject: [PATCH 25/62] update payment and billing --- .../SuspendTransactionLogic.php | 6 +- .../UpdateTransactionStatusLogic.php | 66 ++++++++++++++++ .../UpdateTransactionStatusController.php | 21 +++++ app/Http/Resources/AddressResource.php | 4 +- app/Http/Resources/OrderResource.php | 2 +- app/Http/Resources/TransactionResource.php | 1 + app/Models/Transaction.php | 11 ++- .../elements/AnnouncementListComponent.vue | 8 +- .../AdminPaymentsBillingComponent.vue | 21 ++++- .../CustomerPaymentsBillingComponent.vue | 28 ++++++- .../CustomerInvoiceRemarkFormComponent.vue | 77 +++++++++++++++++++ .../forms/DeleteDisputeFormComponent.vue | 34 ++++++++ .../forms/InvoiceItemFormComponent.vue | 2 - .../views/pages/paymentAndBilling.blade.php | 49 ++++++++++-- resources/views/pages/settings.blade.php | 4 +- 15 files changed, 308 insertions(+), 26 deletions(-) create mode 100644 app/Classes/Modules/Transactions/ControllersLogic/UpdateTransactionStatusLogic.php create mode 100644 app/Http/Controllers/Transactions/UpdateTransactionStatusController.php create mode 100644 resources/assets/vue/components/paymentsBilling/forms/CustomerInvoiceRemarkFormComponent.vue create mode 100644 resources/assets/vue/components/paymentsBilling/forms/DeleteDisputeFormComponent.vue diff --git a/app/Classes/Modules/Transactions/ControllersLogic/SuspendTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/SuspendTransactionLogic.php index e824547e..94ec6433 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/SuspendTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/SuspendTransactionLogic.php @@ -50,10 +50,10 @@ class SuspendTransactionLogic extends AbstractControllerLogic $transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]); - $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::SUSPENDED); - - return $this->response([]); + $transaction = $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::SUSPENDED); + return $this->resourceResponse(new TransactionResource($transaction)); + } diff --git a/app/Classes/Modules/Transactions/ControllersLogic/UpdateTransactionStatusLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/UpdateTransactionStatusLogic.php new file mode 100644 index 00000000..1f6085e4 --- /dev/null +++ b/app/Classes/Modules/Transactions/ControllersLogic/UpdateTransactionStatusLogic.php @@ -0,0 +1,66 @@ + 'Update Transaction Status', + 'message' => 'You have successfully updated the Transaction Status' + ]; + } + + /** @var FetchesTransaction */ + private $fetchesTransaction; + + /** @var UpdatesTransactionStatus */ + private $updatesTransactionStatus; + + + /** + * SuspendTransactionLogic constructor. + * @param FetchesTransaction $fetchesTransaction + * @param UpdatesTransactionStatus $updatesTransactionStatus + */ + public function __construct(FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus) + { + $this->fetchesTransaction = $fetchesTransaction; + $this->updatesTransactionStatus = $updatesTransactionStatus; + } + + + public function logic(Request $request) : JsonResponse + { + $approvalArray = [ + 'approve' => ApprovalStatus::APPROVED, + 'expire' => ApprovalStatus::EXPIRED, + ]; + + $approvalStatus = $approvalArray[$request->route('status')]; + + $transaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]); + + $transaction = $this->updatesTransactionStatus->execute($transaction, $approvalStatus); + + return $this->resourceResponse(new TransactionResource($transaction)); + } + + + +} diff --git a/app/Http/Controllers/Transactions/UpdateTransactionStatusController.php b/app/Http/Controllers/Transactions/UpdateTransactionStatusController.php new file mode 100644 index 00000000..56ed9868 --- /dev/null +++ b/app/Http/Controllers/Transactions/UpdateTransactionStatusController.php @@ -0,0 +1,21 @@ +execute($request); + } +} diff --git a/app/Http/Resources/AddressResource.php b/app/Http/Resources/AddressResource.php index cfcd8389..70461cd6 100644 --- a/app/Http/Resources/AddressResource.php +++ b/app/Http/Resources/AddressResource.php @@ -21,11 +21,11 @@ class AddressResource extends JsonResource $centerPostcodeConstantObject = SegmentConstant::where('reference', SegmentConstants::CENTER_POSTCODE)->get(); $centerPostcodeConstant = $centerPostcodeConstantObject->isEmpty() ? [] : (array)$centerPostcodeConstantObject->first()->value; - $postcodeArea = in_array($this->postcode, $centerPostcodeConstant) ? 'CENTER_POSTCODE' : null; + $postcodeArea = in_array((String)$this->postcode, $centerPostcodeConstant) ? 'CENTER_POSTCODE' : null; $outstationPostcodeConstantObject = SegmentConstant::where('reference', SegmentConstants::OUTSTATION_POSTCODE)->get(); $outstationPostcodeConstant = $outstationPostcodeConstantObject->isEmpty() ? [] : (array)$outstationPostcodeConstantObject->first()->value; - in_array($this->postcode, $outstationPostcodeConstant) ? $postcodeArea = 'OUTSTATION_POSTCODE' : null; + in_array((String)$this->postcode, $outstationPostcodeConstant) ? $postcodeArea = 'OUTSTATION_POSTCODE' : null; return [ 'id' => $this->id, diff --git a/app/Http/Resources/OrderResource.php b/app/Http/Resources/OrderResource.php index bf8d8a41..cbdaeccb 100644 --- a/app/Http/Resources/OrderResource.php +++ b/app/Http/Resources/OrderResource.php @@ -46,7 +46,7 @@ class OrderResource extends JsonResource 'received_packages' => PackingListResource::collection($this->packingLists()->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('packages')->get()), ]; }), - 'invoices' => TransactionResource::collection($this->transactions), + 'invoices' => TransactionResource::collection($this->transactions()->whereNotIn('transactions.status', [0, 1])->get()), 'remarks' => RemarkResource::collection($this->remarks), 'created_at' => $this->created_at->format('d-m-Y') ]; diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index 27840ad8..70f3c7dd 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -47,6 +47,7 @@ class TransactionResource extends JsonResource ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::COMPLETED, ApprovalStatus::REJECTED]) ->get() ), + 'remarks' => RemarkResource::collection($this->remarks), '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') ]; diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index d2432941..a0055fb1 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\Remarkable; use App\Classes\General\Interfaces\Transactionable; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\TransactionType; @@ -13,7 +14,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\MorphMany; use Illuminate\Database\Eloquent\Relations\MorphTo; -class Transaction extends AbstractModel implements Documentable, Transactionable +class Transaction extends AbstractModel implements Documentable, Transactionable, Remarkable { protected $table = 'transactions'; @@ -122,4 +123,12 @@ class Transaction extends AbstractModel implements Documentable, Transactionable { return $query->whereIn('status', [ApprovalStatus::COMPLETED]); } + + /** + * @return MorphMany + */ + public function remarks(): morphMany + { + return $this->morphMany(Remark::class, 'owner'); + } } diff --git a/resources/assets/vue/components/announcements/elements/AnnouncementListComponent.vue b/resources/assets/vue/components/announcements/elements/AnnouncementListComponent.vue index 84de4bfb..0e935c50 100644 --- a/resources/assets/vue/components/announcements/elements/AnnouncementListComponent.vue +++ b/resources/assets/vue/components/announcements/elements/AnnouncementListComponent.vue @@ -22,12 +22,11 @@
- -
{{item.title}}
+
{{item.title}}
-
+
Message
@@ -35,8 +34,7 @@
- -
{{item.description}}
+
{{item.description}}
diff --git a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue index 6be09cd9..d39b1de6 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingComponent.vue @@ -27,7 +27,24 @@
n/a
MYR {{ item.shippng_transaction.amount.toFixed(2) }}
-
+
+

Billing Question

+
{{ item.shippng_transaction.remarks[0].content }}
+
+
+
+ +
+ + + +
+
+
+ +
+
+
@@ -81,7 +98,7 @@
-
+
diff --git a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue index b2c22979..1cc2c81a 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/CustomerPaymentsBillingComponent.vue @@ -1,7 +1,7 @@