@things-factory/sales-ui 4.3.127 → 4.3.131

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.
@@ -24,6 +24,8 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
24
24
  _purchaseOrderData: Object,
25
25
  _enableTransportationServiceSetting: Boolean,
26
26
  _enableTransportForCustomClearanceSetting: Boolean,
27
+ _enableToleranceLimit: Boolean,
28
+ _toleranceLimit: Object,
27
29
  _disableTransport: Boolean,
28
30
  _editable: Boolean,
29
31
  _files: Array,
@@ -776,6 +778,12 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
776
778
  }
777
779
 
778
780
  event.detail.after = { ...changeRecord }
781
+
782
+ if (this._enableToleranceLimit) {
783
+ if (this._checkToleranceLimitExceed()) {
784
+ this._showToast({ message: 'Tolerance limit exceeded' })
785
+ }
786
+ }
779
787
  } catch (e) {
780
788
  const beforeValue = event.detail.before && event.detail.before[event.detail.column.name]
781
789
  if (beforeValue) {
@@ -788,6 +796,35 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
788
796
  }
789
797
  }
790
798
 
799
+ _checkToleranceLimitExceed() {
800
+ if (this._toleranceLimit?.value) {
801
+ let originalTotalPrice =
802
+ this.productData.records.reduce((init, item) => {
803
+ return (init += item.unitPrice)
804
+ }, 0) || 0
805
+
806
+ let changedTotalPrice =
807
+ this.productGrist.dirtyData.records.reduce((init, item) => {
808
+ return (init += item.unitPrice)
809
+ }, 0) || 0
810
+
811
+ if (changedTotalPrice > originalTotalPrice) {
812
+ if (this._toleranceLimit.type == 'AMOUNT') {
813
+ if (changedTotalPrice - originalTotalPrice > this._toleranceLimit.value) {
814
+ return true
815
+ }
816
+ } else if (this._toleranceLimit.type == 'PERCENTAGE') {
817
+ const percentChange = ((changedTotalPrice - originalTotalPrice) / originalTotalPrice) * 100
818
+ if (percentChange > this._toleranceLimit.value) {
819
+ return true
820
+ }
821
+ }
822
+ }
823
+ }
824
+
825
+ return false
826
+ }
827
+
791
828
  _onMiscChargesChangeHandler(event) {
792
829
  let changeRecord = event.detail.after
793
830
  this._calcMiscCharges(event, changeRecord, false)
@@ -922,6 +959,25 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
922
959
 
923
960
  if (!result.value) return
924
961
 
962
+ if (this._enableToleranceLimit) {
963
+ if (this._checkToleranceLimitExceed) {
964
+ const toleranceLimitResult = await CustomAlert({
965
+ title: i18next.t('title.tolerance_limit'),
966
+ text:
967
+ status == PURCHASE_ORDER_STATUS.DRAFT
968
+ ? ''
969
+ : i18next.t('text.total_price_exceed_x_y', {
970
+ x: this._toleranceLimit.value,
971
+ y: this._toleranceLimit.type == 'PERCENTAGE' ? '%' : ''
972
+ }),
973
+ confirmButton: { text: i18next.t('button.submit') },
974
+ cancelButton: { text: i18next.t('button.cancel') }
975
+ })
976
+
977
+ if (!toleranceLimitResult.value) return
978
+ }
979
+ }
980
+
925
981
  //comment start
926
982
  //detailed review needed 19 May 2022 by @ChrisLim-git
927
983
  let purchaseOrder = {
@@ -1100,14 +1156,16 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1100
1156
  if (!response.errors) {
1101
1157
  this._purchaseOrderData = {
1102
1158
  ...response.data.purchaseOrder,
1103
- bufferLocation: {
1104
- ...response.data.purchaseOrder.bufferLocation,
1105
- name: `${response.data.purchaseOrder.bufferLocation.name} ${
1106
- response.data.purchaseOrder.bufferLocation.description
1107
- ? `(${response.data.purchaseOrder.bufferLocation.description})`
1108
- : ''
1109
- }`
1110
- }
1159
+ bufferLocation: response.data.purchaseOrder?.bufferLocation
1160
+ ? {
1161
+ ...response.data.purchaseOrder.bufferLocation,
1162
+ name: `${response.data.purchaseOrder.bufferLocation.name} ${
1163
+ response.data.purchaseOrder.bufferLocation.description
1164
+ ? `(${response.data.purchaseOrder.bufferLocation.description})`
1165
+ : ''
1166
+ }`
1167
+ }
1168
+ : null
1111
1169
  }
1112
1170
 
1113
1171
  this.productData = {
@@ -1395,6 +1453,17 @@ class PurchaseOrderDetail extends connect(store)(localize(i18next)(PageView)) {
1395
1453
  if (!this._enableTransportForCustomClearanceSetting)
1396
1454
  this._enableTransportForCustomClearanceSetting = await fetchSettingRule('enable-custom-clearance-transportation')
1397
1455
 
1456
+ if (!this._enableToleranceLimit) {
1457
+ this._enableToleranceLimit = await fetchSettingRule('enable-tolerance-limit')
1458
+
1459
+ if (this._enableToleranceLimit) {
1460
+ this._toleranceLimit = await fetchSettingRule('tolerance-limit')
1461
+ if (this._toleranceLimit) {
1462
+ this._toleranceLimit = JSON.parse(this._toleranceLimit)
1463
+ }
1464
+ }
1465
+ }
1466
+
1398
1467
  if (!this._containerSizes) this._containerSizes = await getCodeByName('CONTAINER_SIZES')
1399
1468
 
1400
1469
  if (!this._currency) this._currency = await getCodeByName('CURRENCY')
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "@things-factory/sales-ui",
3
- "version": "4.3.127",
3
+ "version": "4.3.131",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
7
- "license": "MIT",
8
7
  "author": "",
9
8
  "description": "UI module that handles sales order",
10
9
  "publishConfig": {
@@ -24,15 +23,15 @@
24
23
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
25
24
  },
26
25
  "dependencies": {
27
- "@things-factory/code-base": "^4.3.122",
28
- "@things-factory/form-ui": "^4.3.122",
29
- "@things-factory/grist-ui": "^4.3.123",
30
- "@things-factory/i18n-base": "^4.3.122",
31
- "@things-factory/import-ui": "^4.3.123",
32
- "@things-factory/sales-base": "^4.3.127",
33
- "@things-factory/setting-ui": "^4.3.123",
34
- "@things-factory/shell": "^4.3.122",
35
- "@things-factory/warehouse-ui": "^4.3.127"
26
+ "@things-factory/code-base": "^4.3.131",
27
+ "@things-factory/form-ui": "^4.3.131",
28
+ "@things-factory/grist-ui": "^4.3.131",
29
+ "@things-factory/i18n-base": "^4.3.131",
30
+ "@things-factory/import-ui": "^4.3.131",
31
+ "@things-factory/sales-base": "^4.3.131",
32
+ "@things-factory/setting-ui": "^4.3.131",
33
+ "@things-factory/shell": "^4.3.131",
34
+ "@things-factory/warehouse-ui": "^4.3.131"
36
35
  },
37
- "gitHead": "ed6406fce1541dd5ca6a7508047934e8fa5698b1"
36
+ "gitHead": "3ae054257c32ac18b023913a313f784459581ea3"
38
37
  }
@@ -31,6 +31,7 @@
31
31
  "text.purchase_order_form_invalid": "purchase order form invalid",
32
32
  "text.purchase_order_saved": "purchase order saved",
33
33
  "text.release_order(s)_has_been_generated": "release order(s) has been generated",
34
+ "text.total_price_exceed_x_y": "total price exceed {x}{y}",
34
35
  "text.update_draft_release_order": "update draft release order",
35
36
  "text.update_purchase_order": "update purchase order",
36
37
  "title.create_purchase_order": "create 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
+ "title.tolerance_limit": "tolerance limit"
45
47
  }
@@ -26,6 +26,7 @@
26
26
  "text.draft_order_saved": "[ko]draft order saved",
27
27
  "text.purchase_order_form_invalid": "[ko]purchase order form invalid",
28
28
  "text.purchase_order_saved": "[ko]purchase order saved",
29
+ "text.total_price_exceed_x_y": "[ko]total price exceed {x}{y}",
29
30
  "text.update_draft_release_order": "update draft release order",
30
31
  "text.update_purchase_order": "[ko]update purchase order",
31
32
  "title.create_purchase_order": "[ko]create purchase order",
@@ -37,6 +38,7 @@
37
38
  "title.purchase_order": "[ko]purchase order",
38
39
  "title.purchase_orders_approval": "[ko]purchase orders approval",
39
40
  "title.purchase_orders": "[ko]purchase orders",
41
+ "title.tolerance_limit": "[ko]tolerance limit",
40
42
  "label.pack_qty": "[ko] pack qty",
41
43
  "label.unit_price": "[ko] unit price",
42
44
  "label.misc_amt": "[ko] misc amt",
@@ -26,6 +26,7 @@
26
26
  "text.draft_order_saved": "[ms]draft order saved",
27
27
  "text.purchase_order_form_invalid": "[ms]purchase order form invalid",
28
28
  "text.purchase_order_saved": "[ms]purchase order saved",
29
+ "text.total_price_exceed_x_y": "[ms]total price exceed {x}{y}",
29
30
  "text.update_draft_release_order": "update draft release order",
30
31
  "text.update_purchase_order": "[ms]update purchase order",
31
32
  "title.create_purchase_order": "[ms]create purchase order",
@@ -37,6 +38,7 @@
37
38
  "title.purchase_order": "[ms]purchase order",
38
39
  "title.purchase_orders_approval": "[ms]purchase orders approval",
39
40
  "title.purchase_orders": "[ms]purchase orders",
41
+ "title.tolerance_limit": "[ms]tolerance limit",
40
42
  "label.pack_qty": "[ms] pack qty",
41
43
  "label.unit_price": "[ms] unit price",
42
44
  "label.misc_amt": "[ms] misc amt",
@@ -26,6 +26,7 @@
26
26
  "text.draft_order_saved": "[zh]draft order saved",
27
27
  "text.purchase_order_form_invalid": "[zh]purchase order form invalid",
28
28
  "text.purchase_order_saved": "[zh]purchase order saved",
29
+ "text.total_price_exceed_x_y": "[zh]total price exceed {x}{y}",
29
30
  "text.update_draft_release_order": "update draft release order",
30
31
  "text.update_purchase_order": "[zh]update purchase order",
31
32
  "title.create_purchase_order": "[zh]create purchase order",
@@ -37,6 +38,7 @@
37
38
  "title.purchase_order": "[zh]purchase order",
38
39
  "title.purchase_orders_approval": "[zh]purchase orders approval",
39
40
  "title.purchase_orders": "[zh]purchase orders",
41
+ "title.tolerance_limit": "[zh]tolerance limit",
40
42
  "label.pack_qty": "[zh] pack qty",
41
43
  "label.unit_price": "[zh] unit price",
42
44
  "label.misc_amt": "[zh] misc amt",
package/LICENSE.md DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) Hatiolab
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.