@things-factory/sales-ui 4.3.107 → 4.3.108

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -772,7 +772,7 @@ class PurchaseOrderApprovalDetail extends connect(store)(localize(i18next)(PageV
772
772
 
773
773
  if (!response.errors) {
774
774
  this._clearView()
775
- this._showToast({ message: i18next.t('purchase_order_updated') })
775
+ this._showToast({ message: i18next.t('text.purchase_order_updated') })
776
776
  this._navigateToList()
777
777
  }
778
778
  } catch (e) {
@@ -839,6 +839,10 @@ class PurchaseOrderApprovalDetail extends connect(store)(localize(i18next)(PageV
839
839
  brand
840
840
  description
841
841
  }
842
+ productDetail {
843
+ id
844
+ name
845
+ }
842
846
  adjustedBatchId
843
847
  remark
844
848
  status
@@ -2,6 +2,7 @@ import '@things-factory/grist-ui'
2
2
  import '@things-factory/biz-ui'
3
3
  import '@things-factory/warehouse-ui'
4
4
  import '@things-factory/import-ui/client/components/import-pop-up'
5
+ import '@things-factory/operato-wms/client/pages/components/select-product-popup'
5
6
 
6
7
  import gql from 'graphql-tag'
7
8
  import { css, html } from 'lit-element'
@@ -522,29 +523,13 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
522
523
  width: 150
523
524
  },
524
525
  {
525
- type: 'object',
526
- name: 'product',
526
+ type: 'string',
527
+ name: 'productName',
527
528
  header: i18next.t('field.product'),
528
- record: {
529
- editable: this._editable,
530
- options: {
531
- queryName: 'products',
532
- basicArgs: {
533
- filters: [{ name: 'bizplace_id', operator: 'eq', value: this._purchaseOrderData?.bizplace?.id }]
534
- },
535
- nameField: 'name',
536
- descriptionField: 'description',
537
- select: [
538
- { name: 'id', hidden: true },
539
- { name: 'sku', header: i18next.t('field.sku') },
540
- { name: 'name', header: i18next.t('field.name') },
541
- { name: 'brand', header: i18next.t('field.brand') },
542
- { name: 'description', header: i18next.t('field.description') },
543
- { name: 'packingType', header: i18next.t('field.packing_type') },
544
- { name: 'primaryUnit', header: i18next.t('field.uom') },
545
- { name: 'primaryValue', header: i18next.t('field.uom_value') }
546
- ],
547
- list: { fields: ['sku', 'name', 'brand', 'description', 'packingType'] }
529
+ imex: { header: i18next.t('field.product'), key: 'productName', width: 50, type: 'string' },
530
+ handlers: {
531
+ click: (columns, data, column, record, rowIndex) => {
532
+ this._openProductSelection(rowIndex)
548
533
  }
549
534
  },
550
535
  width: 350
@@ -1038,6 +1023,10 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1038
1023
  brand
1039
1024
  description
1040
1025
  }
1026
+ productDetail {
1027
+ id
1028
+ name
1029
+ }
1041
1030
  adjustedBatchId
1042
1031
  remark
1043
1032
  status
@@ -1165,11 +1154,19 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1165
1154
  throw new Error(i18next.t('text.container_no_is_empty'))
1166
1155
  }
1167
1156
 
1168
- _validateProducts() {
1157
+ _validateProducts(records = []) {
1169
1158
  // no records
1170
- const records = this.productGrist.dirtyData.records
1159
+ if (!records?.length) {
1160
+ records = this.productGrist.dirtyData.records
1161
+ }
1162
+
1171
1163
  if (!records?.length) throw new Error(i18next.t('text.no_products'))
1172
1164
 
1165
+ const duplicatedProducts = records.filter((item, index) => records.indexOf(item) != index)
1166
+
1167
+ if (duplicatedProducts?.length > 0)
1168
+ throw new Error(i18next.t('text.there_is_duplicated_products_with_same_batch_no'))
1169
+
1173
1170
  const checkRequiredFields = ({ batchId, packingType, uomValue, uom }) =>
1174
1171
  !batchId || !packingType || !uomValue || !uom
1175
1172
 
@@ -1210,6 +1207,7 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1210
1207
  id: record.id || null,
1211
1208
  batchId: record.batchId,
1212
1209
  product: { id: record.product.id },
1210
+ productDetail: record.productDetailId ? { id: record.productDetailId } : { id: record.productDetail.id },
1213
1211
  packingType: record.packingType,
1214
1212
  uomValue: record?.uomValue ? record.uomValue : 0,
1215
1213
  uom: record.uom,
@@ -1218,7 +1216,7 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1218
1216
  remark: record?.remark || null,
1219
1217
  discountAmt: record.discountAmt,
1220
1218
  unitPrice:
1221
- status == PURCHASE_ORDER_STATUS.DRAFT ? record.unitPrice : record.unitPrice > 1 ? record.unitPrice : 1,
1219
+ status == PURCHASE_ORDER_STATUS.DRAFT ? record.unitPrice : record.unitPrice > 0 ? record.unitPrice : 1,
1222
1220
  miscAmt: record.miscAmt,
1223
1221
  taxRate: record.taxRate
1224
1222
  }
@@ -1429,6 +1427,20 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1429
1427
  imex: { header: i18next.t('field.packing_type'), key: 'packingType', width: 25, type: 'string' },
1430
1428
  width: 100
1431
1429
  },
1430
+ {
1431
+ type: 'string',
1432
+ name: 'uom',
1433
+ header: i18next.t('field.uom'),
1434
+ imex: { header: i18next.t('field.uom'), key: 'uom', width: 25, type: 'string' },
1435
+ width: 100
1436
+ },
1437
+ {
1438
+ type: 'float',
1439
+ name: 'uomValue',
1440
+ header: i18next.t('field.uom_value'),
1441
+ imex: { header: i18next.t('field.uom_value'), key: 'uomValue', width: 25, type: 'float' },
1442
+ width: 100
1443
+ },
1432
1444
  {
1433
1445
  type: 'string',
1434
1446
  name: 'remark',
@@ -1476,6 +1488,59 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1476
1488
  return productGrist
1477
1489
  }
1478
1490
 
1491
+ _openProductSelection(rowIndex) {
1492
+ if (this._purchaseOrderData?.bizplace?.id) {
1493
+ openPopup(
1494
+ html`
1495
+ <select-product-popup
1496
+ .bizplaceId="${this._purchaseOrderData?.bizplace?.id}"
1497
+ @selected="${e => {
1498
+ // let newRecord = []
1499
+ // newRecord.push(e.detail)
1500
+
1501
+ if (this.productGrist.dirtyData.records.length !== rowIndex) {
1502
+ // update existing product data records
1503
+ this.productGrist.dirtyData.records.splice(rowIndex, 1, {
1504
+ ...this.productGrist.dirtyData.records[rowIndex],
1505
+ ...e.detail
1506
+ })
1507
+
1508
+ this.productGrist.dirtyData.records = this.productGrist.dirtyData.records.map(item => {
1509
+ return {
1510
+ ...item,
1511
+ totalUomValue:
1512
+ item?.packQty > 0
1513
+ ? item?.totalUomValue
1514
+ ? item.totalUomValue
1515
+ : `${parseFloat(item.packQty * e.detail.uomValue).toFixed(2)} ${e.detail.uom}`
1516
+ : null
1517
+ }
1518
+ })
1519
+
1520
+ this.productData = {
1521
+ ...this.productData,
1522
+ records: [...this.productGrist.dirtyData.records]
1523
+ }
1524
+ } else {
1525
+ this.productData = {
1526
+ ...this.productData,
1527
+ records: [...this.productGrist.dirtyData.records, e.detail]
1528
+ }
1529
+ }
1530
+ }}"
1531
+ ></select-product-popup>
1532
+ `,
1533
+ {
1534
+ backdrop: true,
1535
+ size: 'large',
1536
+ title: i18next.t('title.select_item')
1537
+ }
1538
+ )
1539
+ } else {
1540
+ this._showToast({ message: i18next.t('text.company_selection_is_empty') })
1541
+ }
1542
+ }
1543
+
1479
1544
  async _exportableData() {
1480
1545
  try {
1481
1546
  var headerSetting = [
@@ -1526,6 +1591,10 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1526
1591
  primaryUnit
1527
1592
  primaryValue
1528
1593
  }
1594
+ productDetail {
1595
+ id
1596
+ name
1597
+ }
1529
1598
  }
1530
1599
  }
1531
1600
  `,
@@ -1560,21 +1629,25 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1560
1629
  }
1561
1630
 
1562
1631
  async importHandler(records) {
1563
- this.productData = { records }
1564
-
1565
- const orderProducts = records.map(record => {
1566
- delete record.cuFlag
1567
- delete record.id
1568
- return {
1569
- ...record,
1570
- unitPrice: record?.unitPrice > 0 ? parseFloat(record?.unitPrice?.toFixed(2)) : 0,
1571
- packQty: parseInt(record?.packQty) || 0,
1572
- miscAmt: record?.miscAmt > 0 ? parseFloat(record?.miscAmt?.toFixed(2)) : 0,
1573
- discountAmt: record?.discountAmt > 0 ? parseFloat(record?.discountAmt?.toFixed(2)) : 0,
1574
- taxRate: record?.taxRate > 0 ? parseFloat(record?.taxRate?.toFixed(2)) : 0
1575
- }
1576
- })
1577
- await this.bulkUploadValidatePoOrderProducts(orderProducts)
1632
+ try {
1633
+ this._validateProducts(records)
1634
+
1635
+ const orderProducts = records.map(record => {
1636
+ delete record.cuFlag
1637
+ delete record.id
1638
+ return {
1639
+ ...record,
1640
+ unitPrice: record?.unitPrice > 0 ? parseFloat(record?.unitPrice) : 0,
1641
+ packQty: parseInt(record?.packQty) || 0,
1642
+ miscAmt: record?.miscAmt > 0 ? parseFloat(record?.miscAmt) : 0,
1643
+ discountAmt: record?.discountAmt > 0 ? parseFloat(record?.discountAmt) : 0,
1644
+ taxRate: record?.taxRate > 0 ? parseFloat(record?.taxRate) : 0
1645
+ }
1646
+ })
1647
+ await this.bulkUploadValidatePoOrderProducts(orderProducts)
1648
+ } catch (e) {
1649
+ this._showToast(e)
1650
+ }
1578
1651
  history.back()
1579
1652
  }
1580
1653
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/sales-ui",
3
- "version": "4.3.107",
3
+ "version": "4.3.108",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -24,15 +24,15 @@
24
24
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
25
25
  },
26
26
  "dependencies": {
27
- "@things-factory/code-base": "^4.3.107",
28
- "@things-factory/form-ui": "^4.3.107",
29
- "@things-factory/grist-ui": "^4.3.107",
30
- "@things-factory/i18n-base": "^4.3.107",
31
- "@things-factory/import-ui": "^4.3.107",
32
- "@things-factory/sales-base": "^4.3.107",
33
- "@things-factory/setting-ui": "^4.3.107",
34
- "@things-factory/shell": "^4.3.107",
35
- "@things-factory/warehouse-ui": "^4.3.107"
27
+ "@things-factory/code-base": "^4.3.108",
28
+ "@things-factory/form-ui": "^4.3.108",
29
+ "@things-factory/grist-ui": "^4.3.108",
30
+ "@things-factory/i18n-base": "^4.3.108",
31
+ "@things-factory/import-ui": "^4.3.108",
32
+ "@things-factory/sales-base": "^4.3.108",
33
+ "@things-factory/setting-ui": "^4.3.108",
34
+ "@things-factory/shell": "^4.3.108",
35
+ "@things-factory/warehouse-ui": "^4.3.108"
36
36
  },
37
- "gitHead": "6f972d110c7b502f370d3887062bb6b38d1ddbc9"
37
+ "gitHead": "8aa8811dd0ebb1f4c1d9bc50fc221766d855c553"
38
38
  }
@@ -30,6 +30,7 @@
30
30
  "text.please_select_a_valid_draft_order_to_generate_release_order": "please select a valid draft order to generate release order",
31
31
  "text.purchase_order_form_invalid": "purchase order form invalid",
32
32
  "text.purchase_order_saved": "purchase order saved",
33
+ "text.purchase_order_updated": "purchase order updated",
33
34
  "text.release_order(s)_has_been_generated": "release order(s) has been generated",
34
35
  "text.update_draft_release_order": "update draft release order",
35
36
  "text.update_purchase_order": "update purchase order",
@@ -41,5 +42,6 @@
41
42
  "title.purchase_order_detail": "purchase order detail",
42
43
  "title.purchase_order": "purchase order",
43
44
  "title.purchase_orders_approval": "purchase orders approval",
44
- "title.purchase_orders": "purchase orders"
45
+ "title.purchase_orders": "purchase orders",
46
+ "text.there_is_duplicated_products_with_same_batch_no": "there is duplicated products with same batch no"
45
47
  }
@@ -41,5 +41,7 @@
41
41
  "label.unit_price": "[ko] unit price",
42
42
  "label.misc_amt": "[ko] misc amt",
43
43
  "label.total_disc_amt": "[ko] total disc amt",
44
- "label.tax_rate": "[ko] tax rate"
44
+ "label.tax_rate": "[ko] tax rate",
45
+ "text.purchase_order_updated": "[ko] purchase order updated",
46
+ "text.there_is_duplicated_products_with_same_batch_no": "[ko] there is duplicated products with same batch no"
45
47
  }
@@ -41,5 +41,7 @@
41
41
  "label.unit_price": "[ms] unit price",
42
42
  "label.misc_amt": "[ms] misc amt",
43
43
  "label.total_disc_amt": "[ms] total disc amt",
44
- "label.tax_rate": "[ms] tax rate"
44
+ "label.tax_rate": "[ms] tax rate",
45
+ "text.purchase_order_updated": "[ms] purchase order updated",
46
+ "text.there_is_duplicated_products_with_same_batch_no": "[ms] there is duplicated products with same batch no"
45
47
  }
@@ -41,5 +41,7 @@
41
41
  "label.unit_price": "[zh] unit price",
42
42
  "label.misc_amt": "[zh] misc amt",
43
43
  "label.total_disc_amt": "[zh] total disc amt",
44
- "label.tax_rate": "[zh] tax rate"
44
+ "label.tax_rate": "[zh] tax rate",
45
+ "text.purchase_order_updated": "[zh] purchase order updated",
46
+ "text.there_is_duplicated_products_with_same_batch_no": "[zh] there is duplicated products with same batch no"
45
47
  }