@darkpos/pricing 1.0.121 → 1.0.124

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.
@@ -0,0 +1,10 @@
1
+ module.exports = ({ actions }) =>
2
+ function getSerialStatus({ item }) {
3
+ if (actions.isSerialRequired({ item }) && !item.serial) {
4
+ return 'required';
5
+ }
6
+ if (item.serial && !actions.isSerialLengthValid({ serial: item.serial })) {
7
+ return 'invalidLength';
8
+ }
9
+ return 'ok';
10
+ };
package/lib/item/index.js CHANGED
@@ -71,6 +71,9 @@ const applyNotesOverridesToItem = require('./applyNotesOverridesToItem');
71
71
  const getModifiersToNotCompute = require('./getModifiersToNotCompute');
72
72
  const getSplitDepartment = require('./getSplitDepartment');
73
73
  const isPriceChanged = require('./isPriceChanged');
74
+ const isSerialRequired = require('./isSerialRequired');
75
+ const isSerialLengthValid = require('./isSerialLengthValid');
76
+ const getSerialStatus = require('./getSerialStatus');
74
77
 
75
78
  const itemActions = (deps = {}) => {
76
79
  const actions = {};
@@ -155,6 +158,9 @@ const itemActions = (deps = {}) => {
155
158
  getModifiersToNotCompute: getModifiersToNotCompute(innerDeps),
156
159
  getSplitDepartment: getSplitDepartment(innerDeps),
157
160
  isPriceChanged: isPriceChanged(innerDeps),
161
+ isSerialRequired: isSerialRequired(innerDeps),
162
+ isSerialLengthValid: isSerialLengthValid(innerDeps),
163
+ getSerialStatus: getSerialStatus(innerDeps),
158
164
  });
159
165
 
160
166
  Object.keys(freezedActions).forEach(actionName => {
@@ -0,0 +1,22 @@
1
+ module.exports = ({ settings, _ }) =>
2
+ function isSerialLengthValid({ serial }) {
3
+ const minSerialLength = _.get(
4
+ settings,
5
+ 'types.inventory.minimumSerialLength',
6
+ null
7
+ );
8
+ const maxSerialLength = _.get(
9
+ settings,
10
+ 'types.inventory.maximumSerialLength',
11
+ null
12
+ );
13
+
14
+ const serialLenght = serial ? serial.length : 0;
15
+
16
+ const minLen = typeof minSerialLength === 'number' ? minSerialLength : null;
17
+ const maxLen = typeof maxSerialLength === 'number' ? maxSerialLength : null;
18
+
19
+ if (minLen != null && serialLenght < minLen) return false;
20
+ if (maxLen != null && serialLenght > maxLen) return false;
21
+ return true;
22
+ };
@@ -0,0 +1,4 @@
1
+ module.exports = () =>
2
+ function isSerialRequired({ item }) {
3
+ return !!(item && item.serialRequired);
4
+ };
@@ -20,8 +20,8 @@ module.exports = ({
20
20
 
21
21
  return { ...order, ...actions.getTotals(order.orders) };
22
22
  }
23
- const startRequestDate = order.start ? order.start.requestDate : null;
24
- const endRequestDate = order.end ? order.end.requestDate : null;
23
+ const startRequestDate = actions.getStartDate({ order });
24
+ const endRequestDate = actions.getEndDate({ order });
25
25
 
26
26
  const options = {
27
27
  ...opts,
@@ -1,4 +1,4 @@
1
1
  module.exports = ({ _ }) =>
2
2
  function getStartDate({ order }) {
3
- return _.get(order, 'start.actualDate', '');
3
+ return _.get(order, 'start.requestDate', '');
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darkpos/pricing",
3
- "version": "1.0.121",
3
+ "version": "1.0.124",
4
4
  "description": "Pricing calculator",
5
5
  "author": "Dark POS",
6
6
  "license": "ISC",
@@ -55,5 +55,5 @@
55
55
  "supertest": "^6.2.3",
56
56
  "supervisor": "^0.12.0"
57
57
  },
58
- "gitHead": "01eaaf2b2c151777c248a5368665265c52f31e8b"
58
+ "gitHead": "22154961d7818dd8d93ec38b9a03fd516bf592c0"
59
59
  }