From 2a959e98073303b07c47d66960bf13a1a94c1e88 Mon Sep 17 00:00:00 2001 From: TemuulenBM Date: Wed, 6 Dec 2023 17:58:40 +0800 Subject: [PATCH] completed Product,Sales and Purchases page --- addon/components/inventory-form-panel.hbs | 5 ++- addon/components/inventory-form-panel.js | 11 +++-- addon/components/inventory-panel/details.hbs | 8 ++++ addon/components/product-panel.js | 10 ++++- .../components/purchase-order-form-panel.hbs | 25 +++++++++-- addon/components/purchase-order-form-panel.js | 12 +++--- .../purchase-order-panel/details.hbs | 28 +------------ addon/components/sales-order-form-panel.hbs | 8 ++-- addon/components/sales-order-form-panel.js | 8 ++++ addon/components/supplier-form-panel.hbs | 2 +- addon/controllers/products/index.js | 12 ++---- addon/controllers/purchase-orders/index.js | 2 +- .../controllers/purchase-orders/index/new.js | 2 +- addon/controllers/sales-orders/index.js | 5 +-- addon/controllers/sales-orders/index/new.js | 2 +- addon/models/inventory.js | 30 ++++++++++++++ addon/models/purchase-order.js | 34 ++++++++++++--- addon/models/sales-order.js | 30 ++++++++++++++ addon/routes/inventory/index.js | 2 +- addon/routes/products/index/details.js | 2 +- addon/routes/sales-orders/index.js | 1 - addon/serializers/pallet-product.js | 11 +++++ addon/serializers/purchase-order.js | 13 +++++- ..._manufactured_date_column_on_inventory.php | 30 ++++++++++++++ .../Http/Controllers/InventoryController.php | 8 ++-- .../Controllers/PurchaseOrderController.php | 41 +++++++++++++++++++ .../Http/Controllers/SalesOrderController.php | 41 +++++++++++++++++++ server/src/Http/Resources/IndexInventory.php | 2 + server/src/Http/Resources/Inventory.php | 33 ++++++++------- server/src/Http/Resources/PurchaseOrder.php | 37 +++++++++++++++++ server/src/Http/Resources/SalesOrder.php | 2 +- server/src/Models/Inventory.php | 26 ++++++++++++ server/src/Models/PurchaseOrder.php | 21 ++++++++-- server/src/Models/SalesOrder.php | 24 ++++++++++- 34 files changed, 435 insertions(+), 93 deletions(-) create mode 100644 server/migrations/2023_12_06_090936_add_manufactured_date_column_on_inventory.php create mode 100644 server/src/Http/Resources/PurchaseOrder.php diff --git a/addon/components/inventory-form-panel.hbs b/addon/components/inventory-form-panel.hbs index d00f7a8d..a30bc745 100644 --- a/addon/components/inventory-form-panel.hbs +++ b/addon/components/inventory-form-panel.hbs @@ -95,8 +95,9 @@ - - + + + diff --git a/addon/components/inventory-form-panel.js b/addon/components/inventory-form-panel.js index 4db412a3..ea8c63b3 100644 --- a/addon/components/inventory-form-panel.js +++ b/addon/components/inventory-form-panel.js @@ -152,13 +152,18 @@ export default class InventoryFormPanelComponent extends Component { @action setDefaultBatchValues() { const currentDate = new Date().toISOString().split('T')[0]; - // unlikely to need but incase batch isn't initialized, do it here if (!this.inventory.batch) { this.inventory.batch = this.store.createRecord('batch'); } this.inventory.batch.set('batch_number', currentDate); - this.inventory.batch.set('expiry_date_at', currentDate); - this.inventory.batch.set('manufacture_date_at', currentDate); + } + + @action setExpiryDate(event) { + const { + target: { value }, + } = event; + + this.inventory.set('expiry_date_at', new Date(value)); } } diff --git a/addon/components/inventory-panel/details.hbs b/addon/components/inventory-panel/details.hbs index afa9998c..b01fc142 100644 --- a/addon/components/inventory-panel/details.hbs +++ b/addon/components/inventory-panel/details.hbs @@ -17,6 +17,14 @@
Batch
{{n-a @inventory.batch.batch_number}}
+
+
Expiry Date
+
{{n-a @inventory.expiry_date_at}}
+
+
+
Manufactured Date
+
{{n-a @inventory.created_at}}
+
\ No newline at end of file diff --git a/addon/components/product-panel.js b/addon/components/product-panel.js index a18642b0..d6e47057 100644 --- a/addon/components/product-panel.js +++ b/addon/components/product-panel.js @@ -89,11 +89,19 @@ export default class ProductPanelComponent extends Component { constructor() { super(...arguments); this.product = this.args.product; - console.log('[this.product]', this.product); + this.getProductSupplier(); this.tab = this.getTabUsingSlug(this.args.tab); applyContextComponentArguments(this); } + getProductSupplier() { + if (this.product.supplier_uuid) { + this.store.findRecord('vendor', this.product.supplier_uuid).then((vendor) => { + this.product.set('supplier', vendor); + }); + } + } + /** * Sets the overlay context. * diff --git a/addon/components/purchase-order-form-panel.hbs b/addon/components/purchase-order-form-panel.hbs index ae236dbc..93535239 100644 --- a/addon/components/purchase-order-form-panel.hbs +++ b/addon/components/purchase-order-form-panel.hbs @@ -30,6 +30,21 @@
+ + + {{model.name}} + +
- + + +