@things-factory/sales-ui 4.3.159 → 4.3.161
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.
|
@@ -5,17 +5,32 @@ import '@things-factory/import-ui/client/components/import-pop-up'
|
|
|
5
5
|
import '@things-factory/operato-wms/client/pages/components/select-product-popup'
|
|
6
6
|
|
|
7
7
|
import gql from 'graphql-tag'
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
css,
|
|
10
|
+
html
|
|
11
|
+
} from 'lit-element'
|
|
9
12
|
import { connect } from 'pwa-helpers/connect-mixin'
|
|
10
13
|
|
|
11
14
|
import { getCodeByName } from '@things-factory/code-base'
|
|
12
15
|
import { MultiColumnFormStyles } from '@things-factory/form-ui'
|
|
13
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
i18next,
|
|
18
|
+
localize
|
|
19
|
+
} from '@things-factory/i18n-base'
|
|
14
20
|
import { openPopup } from '@things-factory/layout-base'
|
|
15
21
|
import { fetchSettingRule } from '@things-factory/setting-ui'
|
|
16
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
client,
|
|
24
|
+
CustomAlert,
|
|
25
|
+
navigate,
|
|
26
|
+
PageView,
|
|
27
|
+
store
|
|
28
|
+
} from '@things-factory/shell'
|
|
17
29
|
import { CommonButtonStyles } from '@things-factory/styles'
|
|
18
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
flattenObject,
|
|
32
|
+
isMobileDevice
|
|
33
|
+
} from '@things-factory/utils'
|
|
19
34
|
|
|
20
35
|
import { PURCHASE_ORDER_STATUS } from '../../constants'
|
|
21
36
|
|
|
@@ -483,7 +498,6 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
|
|
|
483
498
|
await this._fetchPO()
|
|
484
499
|
|
|
485
500
|
this._editable = this._purchaseOrderData?.status == PURCHASE_ORDER_STATUS.DRAFT
|
|
486
|
-
|
|
487
501
|
this._configureProductGrist()
|
|
488
502
|
} catch (e) {
|
|
489
503
|
this._showToast(e)
|
|
@@ -735,6 +749,10 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
|
|
|
735
749
|
changeRecord.brand = brand ? changeRecord.product.brand : ''
|
|
736
750
|
}
|
|
737
751
|
|
|
752
|
+
if(changedColumn == 'unitPrice' && isNaN(changeRecord.unitPrice )){
|
|
753
|
+
throw new Error(i18next.t('text.invalid_input_in_unit_price'))
|
|
754
|
+
}
|
|
755
|
+
|
|
738
756
|
const priceAmtChangeColumn = ['packQty', 'unitPrice', 'miscAmt', 'discountAmt', 'taxRate']
|
|
739
757
|
if (priceAmtChangeColumn.indexOf(changedColumn) >= 0) {
|
|
740
758
|
if (changedColumn != 'miscAmt') {
|
|
@@ -754,7 +772,7 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
|
|
|
754
772
|
}
|
|
755
773
|
}
|
|
756
774
|
|
|
757
|
-
const amountRelatedColumns = ['uomValue', 'uom', 'packQty', 'releaseQty', 'releaseUomValue']
|
|
775
|
+
const amountRelatedColumns = ['uomValue', 'uom', 'packQty', 'releaseQty', 'releaseUomValue', 'unitPrice']
|
|
758
776
|
if (amountRelatedColumns.indexOf(changedColumn) >= 0) {
|
|
759
777
|
const calcedAmount = this._calcAmount(changedColumn, changeRecord)
|
|
760
778
|
for (let key in calcedAmount) {
|
|
@@ -891,14 +909,14 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
|
|
|
891
909
|
let { packQty, totalAmt, taxAmt, taxRate, discountAmt, unitPrice, miscAmt } = changeRecord
|
|
892
910
|
|
|
893
911
|
packQty = packQty || 0
|
|
894
|
-
unitPrice = parseFloat(
|
|
912
|
+
unitPrice = parseFloat(unitPrice || 0).toFixed(2)
|
|
895
913
|
miscAmt = parseFloat((miscAmt || 0).toFixed(2))
|
|
896
914
|
taxRate = parseFloat((taxRate || 0).toFixed(2))
|
|
897
915
|
discountAmt = parseFloat((discountAmt || 0).toFixed(2))
|
|
898
916
|
|
|
899
|
-
let totalAmtBeforeTax = packQty * unitPrice + miscAmt - discountAmt
|
|
917
|
+
let totalAmtBeforeTax = parseFloat(packQty * unitPrice + miscAmt - discountAmt).toFixed(2)
|
|
900
918
|
taxAmt = parseFloat(((totalAmtBeforeTax * taxRate) / 100).toFixed(2))
|
|
901
|
-
totalAmt = parseFloat(
|
|
919
|
+
totalAmt = parseFloat(totalAmtBeforeTax + taxAmt).toFixed(2)
|
|
902
920
|
|
|
903
921
|
return { totalAmt, taxAmt, taxRate, discountAmt, unitPrice, miscAmt }
|
|
904
922
|
}
|
|
@@ -1079,6 +1097,7 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
|
|
|
1079
1097
|
name
|
|
1080
1098
|
brand
|
|
1081
1099
|
description
|
|
1100
|
+
costPrice
|
|
1082
1101
|
}
|
|
1083
1102
|
productDetail {
|
|
1084
1103
|
id
|
|
@@ -1163,6 +1182,7 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
|
|
|
1163
1182
|
return {
|
|
1164
1183
|
...itm,
|
|
1165
1184
|
brand: itm.product.brand,
|
|
1185
|
+
unitPrice: itm.product.costPrice,
|
|
1166
1186
|
productName: `${itm.product.name}(${itm.product.description}(${itm.product.sku}))`,
|
|
1167
1187
|
...this._calcPrice(itm)
|
|
1168
1188
|
}
|
|
@@ -1242,10 +1262,14 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
|
|
|
1242
1262
|
throw new Error(i18next.t('text.x_should_be_positive', { state: { x: i18next.t('label.pack_qty') } }))
|
|
1243
1263
|
}
|
|
1244
1264
|
|
|
1245
|
-
if (records.some(({ unitPrice }) => unitPrice
|
|
1246
|
-
|
|
1265
|
+
if (records.some(({ unitPrice }) => isNaN(unitPrice) && unitPrice !==undefined))
|
|
1266
|
+
{ throw new Error(i18next.t('text.invalid_input_in_unit_price'))
|
|
1247
1267
|
}
|
|
1248
1268
|
|
|
1269
|
+
if (records.some(({ unitPrice }) => unitPrice < 0)) {
|
|
1270
|
+
throw new Error(i18next.t('text.x_should_be_positive', { state: { x: i18next.t('label.unit_price') } }))
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1249
1273
|
if (records.some(({ miscAmt }) => miscAmt < 0)) {
|
|
1250
1274
|
throw new Error(i18next.t('text.x_should_be_positive', { state: { x: i18next.t('label.misc_amt') } }))
|
|
1251
1275
|
}
|
|
@@ -1279,8 +1303,7 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
|
|
|
1279
1303
|
totalUomValue: record?.uomValue ? `${(record.uomValue * record.packQty).toFixed(2)} ${record.uom}` : ``,
|
|
1280
1304
|
remark: record?.remark || null,
|
|
1281
1305
|
discountAmt: record.discountAmt,
|
|
1282
|
-
unitPrice:
|
|
1283
|
-
status == PURCHASE_ORDER_STATUS.DRAFT ? record.unitPrice : record.unitPrice > 0 ? record.unitPrice : 1,
|
|
1306
|
+
unitPrice: parseFloat(PURCHASE_ORDER_STATUS.DRAFT ? record.unitPrice : record.unitPrice > 0 ? record.unitPrice : 0),
|
|
1284
1307
|
miscAmt: record.miscAmt,
|
|
1285
1308
|
taxRate: record.taxRate
|
|
1286
1309
|
}
|
|
@@ -1534,7 +1557,7 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
|
|
|
1534
1557
|
type: 'float',
|
|
1535
1558
|
name: 'unitPrice',
|
|
1536
1559
|
header: i18next.t('field.unit_price'),
|
|
1537
|
-
imex: { header: i18next.t('field.unit_price'), key: 'unitPrice', width: 25, type: '
|
|
1560
|
+
imex: { header: i18next.t('field.unit_price'), key: 'unitPrice', width: 25, type: 'string' },
|
|
1538
1561
|
width: 100
|
|
1539
1562
|
},
|
|
1540
1563
|
{
|
|
@@ -1650,7 +1673,6 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
|
|
|
1650
1673
|
taxRate
|
|
1651
1674
|
batchId
|
|
1652
1675
|
batchIdRef
|
|
1653
|
-
unitPrice
|
|
1654
1676
|
remark
|
|
1655
1677
|
productSKU
|
|
1656
1678
|
productName
|
|
@@ -1665,10 +1687,12 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
|
|
|
1665
1687
|
brand
|
|
1666
1688
|
primaryUnit
|
|
1667
1689
|
primaryValue
|
|
1690
|
+
costPrice
|
|
1668
1691
|
}
|
|
1669
1692
|
productDetail {
|
|
1670
1693
|
id
|
|
1671
1694
|
name
|
|
1695
|
+
costPrice
|
|
1672
1696
|
}
|
|
1673
1697
|
}
|
|
1674
1698
|
}
|
|
@@ -1678,14 +1702,22 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
|
|
|
1678
1702
|
|
|
1679
1703
|
if (!response.errors) {
|
|
1680
1704
|
const data = response.data.bulkUploadValidatePoOrderProducts.map(item => {
|
|
1705
|
+
if (item.unitPrice == null) {
|
|
1706
|
+
item.unitPrice = item.productDetail.costPrice
|
|
1707
|
+
}
|
|
1708
|
+
let totalAmtBeforeTax = parseFloat(item.packQty * item.unitPrice + item.miscAmt - item.discountAmt).toFixed(2)
|
|
1709
|
+
let taxAmt = parseFloat(((totalAmtBeforeTax * item.taxRate) / 100).toFixed(2))
|
|
1710
|
+
let totalAmt = parseFloat(totalAmtBeforeTax + item.taxAmt).toFixed(2)
|
|
1681
1711
|
return {
|
|
1682
1712
|
...item,
|
|
1683
1713
|
productName: item?.productName,
|
|
1684
|
-
unitPrice: parseFloat(item.unitPrice
|
|
1714
|
+
unitPrice: parseFloat(item.unitPrice || 0).toFixed(2),
|
|
1685
1715
|
packQty: parseInt(item.packQty) || 0,
|
|
1686
1716
|
miscAmt: parseFloat(item.miscAmt) || 0,
|
|
1687
1717
|
discountAmt: parseFloat(item.discountAmt) || 0,
|
|
1688
|
-
taxRate: parseFloat(item.taxRate) || 0
|
|
1718
|
+
taxRate: parseFloat(item.taxRate) || 0,
|
|
1719
|
+
taxAmt,
|
|
1720
|
+
totalAmt
|
|
1689
1721
|
}
|
|
1690
1722
|
})
|
|
1691
1723
|
this.productData = {
|
|
@@ -1708,11 +1740,29 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
|
|
|
1708
1740
|
this._validateProducts(records)
|
|
1709
1741
|
|
|
1710
1742
|
const orderProducts = records.map(record => {
|
|
1743
|
+
if (record.unitPrice) {
|
|
1744
|
+
record.unitPrice = parseFloat(record.unitPrice)
|
|
1745
|
+
}
|
|
1746
|
+
if (!record.unitPrice) {
|
|
1747
|
+
if (record.unitPrice == 0) {
|
|
1748
|
+
record.unitPrice == 0
|
|
1749
|
+
} else {
|
|
1750
|
+
record.unitPrice = null
|
|
1751
|
+
}
|
|
1752
|
+
if (record.unitCost != null) {
|
|
1753
|
+
record.unitCost = parseFloat(record.unitCost)
|
|
1754
|
+
if(isNaN(record.unitCost)){
|
|
1755
|
+
throw new Error(i18next.t('text.invalid_unit_price'))
|
|
1756
|
+
|
|
1757
|
+
}
|
|
1758
|
+
//itm.unitCost= itm.unitCost.toFixed(2)
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1711
1761
|
delete record.cuFlag
|
|
1712
1762
|
delete record.id
|
|
1713
1763
|
return {
|
|
1714
1764
|
...record,
|
|
1715
|
-
unitPrice: record
|
|
1765
|
+
unitPrice: record.unitPrice,
|
|
1716
1766
|
packQty: parseInt(record?.packQty) || 0,
|
|
1717
1767
|
miscAmt: record?.miscAmt > 0 ? parseFloat(record?.miscAmt) : 0,
|
|
1718
1768
|
discountAmt: record?.discountAmt > 0 ? parseFloat(record?.discountAmt) : 0,
|
|
@@ -1733,6 +1783,9 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
|
|
|
1733
1783
|
records = records
|
|
1734
1784
|
.filter(record => record.productSKU)
|
|
1735
1785
|
.map(record => {
|
|
1786
|
+
if (typeof record.unitPrice === 'object') {
|
|
1787
|
+
record.unitPrice = 0
|
|
1788
|
+
}
|
|
1736
1789
|
return {
|
|
1737
1790
|
...record
|
|
1738
1791
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/sales-ui",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.161",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"@things-factory/grist-ui": "^4.3.159",
|
|
29
29
|
"@things-factory/i18n-base": "^4.3.159",
|
|
30
30
|
"@things-factory/import-ui": "^4.3.159",
|
|
31
|
-
"@things-factory/sales-base": "^4.3.
|
|
31
|
+
"@things-factory/sales-base": "^4.3.161",
|
|
32
32
|
"@things-factory/setting-ui": "^4.3.159",
|
|
33
33
|
"@things-factory/shell": "^4.3.159",
|
|
34
|
-
"@things-factory/warehouse-ui": "^4.3.
|
|
34
|
+
"@things-factory/warehouse-ui": "^4.3.161"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "7fe9232a64285ebaa04382258806889c47924157"
|
|
37
37
|
}
|
package/translations/en.json
CHANGED
|
@@ -45,5 +45,6 @@
|
|
|
45
45
|
"title.purchase_orders_approval": "purchase orders approval",
|
|
46
46
|
"title.purchase_orders": "purchase orders",
|
|
47
47
|
"text.there_is_duplicated_products_with_same_batch_no": "there is duplicated products with same batch no",
|
|
48
|
+
"text.invalid_input_in_unit_price": "invalid input in unit price",
|
|
48
49
|
"title.tolerance_limit": "tolerance limit"
|
|
49
50
|
}
|
package/translations/ko.json
CHANGED
|
@@ -45,5 +45,6 @@
|
|
|
45
45
|
"label.total_disc_amt": "[ko] total disc amt",
|
|
46
46
|
"label.tax_rate": "[ko] tax rate",
|
|
47
47
|
"text.purchase_order_updated": "[ko] purchase order updated",
|
|
48
|
-
"text.there_is_duplicated_products_with_same_batch_no": "[ko] there is duplicated products with same batch no"
|
|
48
|
+
"text.there_is_duplicated_products_with_same_batch_no": "[ko] there is duplicated products with same batch no",
|
|
49
|
+
"text.invalid_input_in_unit_price": "[ko] invalid input in unit price"
|
|
49
50
|
}
|
package/translations/ms.json
CHANGED
|
@@ -45,5 +45,6 @@
|
|
|
45
45
|
"label.total_disc_amt": "[ms] total disc amt",
|
|
46
46
|
"label.tax_rate": "[ms] tax rate",
|
|
47
47
|
"text.purchase_order_updated": "[ms] purchase order updated",
|
|
48
|
-
"text.there_is_duplicated_products_with_same_batch_no": "[ms] there is duplicated products with same batch no"
|
|
48
|
+
"text.there_is_duplicated_products_with_same_batch_no": "[ms] there is duplicated products with same batch no",
|
|
49
|
+
"text.invalid_input_in_unit_price": "[ms] invalid input in unit price"
|
|
49
50
|
}
|
package/translations/zh.json
CHANGED
|
@@ -45,5 +45,6 @@
|
|
|
45
45
|
"label.total_disc_amt": "[zh] total disc amt",
|
|
46
46
|
"label.tax_rate": "[zh] tax rate",
|
|
47
47
|
"text.purchase_order_updated": "[zh] purchase order updated",
|
|
48
|
-
"text.there_is_duplicated_products_with_same_batch_no": "[zh] there is duplicated products with same batch no"
|
|
48
|
+
"text.there_is_duplicated_products_with_same_batch_no": "[zh] there is duplicated products with same batch no",
|
|
49
|
+
"text.invalid_input_in_unit_price": "[zh] invalid input in unit price"
|
|
49
50
|
}
|