accounting-engine 0.1.3 → 0.1.5
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.
package/package.json
CHANGED
@@ -47,12 +47,16 @@ const applyRules = async (rules, data, upperCondition = null) => {
|
|
47
47
|
for await (const line of invoice.accounting_lines) {
|
48
48
|
if (eval(evalCondition)) {
|
49
49
|
willPull.push(_.findIndex(invoice.accounting_lines, line));
|
50
|
-
returnData.forEach((item) => {
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
returnData.forEach(async (item) => {
|
51
|
+
const r = {};
|
52
|
+
_.forEach(Object.keys(item), (key) => {
|
53
|
+
try {
|
54
|
+
r[key] = eval(item[key]);
|
55
|
+
} catch (error) {
|
56
|
+
r[key] = item[key];
|
57
|
+
}
|
55
58
|
});
|
59
|
+
resultLines.push(r);
|
56
60
|
});
|
57
61
|
}
|
58
62
|
}
|
@@ -143,7 +147,7 @@ const normalizeInvoiceForAccounting = async (invoice, direction) => {
|
|
143
147
|
type: 'taxable',
|
144
148
|
code: item.code,
|
145
149
|
percent: item.percent,
|
146
|
-
amount: item.taxable,
|
150
|
+
amount: item.code === '0015' ? Number(item.amount) / (Number(item.percent) / 100).toFixed(2) : item.taxable,
|
147
151
|
withholding,
|
148
152
|
});
|
149
153
|
}
|
@@ -178,7 +182,7 @@ const normalizeInvoiceForAccounting = async (invoice, direction) => {
|
|
178
182
|
type: 'taxable',
|
179
183
|
code: item.code,
|
180
184
|
percent: item.percent,
|
181
|
-
amount: item.taxable,
|
185
|
+
amount: item.code === '0015' ? Number(item.amount) / (Number(item.percent) / 100).toFixed(2) : item.taxable,
|
182
186
|
withholding: {
|
183
187
|
type: null,
|
184
188
|
code: null,
|