accounting-engine 0.1.6 → 0.1.8
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 +1 -1
- package/src/services/engine.service.js +17 -15
package/package.json
CHANGED
@@ -48,7 +48,7 @@ const applyRules = async (rules, data, upperCondition = null) => {
|
|
48
48
|
if (eval(evalCondition)) {
|
49
49
|
willPull.push(_.findIndex(invoice.accounting_lines, line));
|
50
50
|
returnData.forEach(async (item) => {
|
51
|
-
const r = {};
|
51
|
+
const r = { type: line.type };
|
52
52
|
_.forEach(Object.keys(item), (key) => {
|
53
53
|
try {
|
54
54
|
r[key] = eval(item[key]);
|
@@ -136,6 +136,13 @@ const normalizeInvoiceForAccounting = async (invoice, direction) => {
|
|
136
136
|
amount: line.withholding_tax_subtotals[0].amount,
|
137
137
|
};
|
138
138
|
}
|
139
|
+
let amount = item.taxable;
|
140
|
+
if (item.code === '0015' && Number(item.percent) !== 0 && Number(item.amount) !== 0) {
|
141
|
+
const calculatedAmount = Number(item.amount) / (Number(item.percent) / 100).toFixed(2);
|
142
|
+
if (Math.abs(calculatedAmount - item.taxable) > 1) {
|
143
|
+
amount = calculatedAmount;
|
144
|
+
}
|
145
|
+
}
|
139
146
|
taxables.push({
|
140
147
|
id: line.id,
|
141
148
|
name: line.name,
|
@@ -147,13 +154,7 @@ const normalizeInvoiceForAccounting = async (invoice, direction) => {
|
|
147
154
|
type: 'taxable',
|
148
155
|
code: item.code,
|
149
156
|
percent: item.percent,
|
150
|
-
amount
|
151
|
-
// eslint-disable-next-line no-nested-ternary
|
152
|
-
item.code === '0015'
|
153
|
-
? Number(item.amount) === 0
|
154
|
-
? item.taxable
|
155
|
-
: Number(item.amount) / (Number(item.percent) / 100).toFixed(2)
|
156
|
-
: item.taxable,
|
157
|
+
amount,
|
157
158
|
withholding,
|
158
159
|
});
|
159
160
|
}
|
@@ -184,17 +185,18 @@ const normalizeInvoiceForAccounting = async (invoice, direction) => {
|
|
184
185
|
const index = _.findIndex(taxables, { type: 'taxable', code: item.code, percent: item.percent });
|
185
186
|
taxables[index].amount += item.taxable;
|
186
187
|
} else {
|
188
|
+
let amount = item.taxable;
|
189
|
+
if (item.code === '0015' && Number(item.percent) !== 0 && Number(item.amount) !== 0) {
|
190
|
+
const calculatedAmount = Number(item.amount) / (Number(item.percent) / 100).toFixed(2);
|
191
|
+
if (Math.abs(calculatedAmount - item.taxable) > 1) {
|
192
|
+
amount = calculatedAmount;
|
193
|
+
}
|
194
|
+
}
|
187
195
|
taxables.push({
|
188
196
|
type: 'taxable',
|
189
197
|
code: item.code,
|
190
198
|
percent: item.percent,
|
191
|
-
amount
|
192
|
-
// eslint-disable-next-line no-nested-ternary
|
193
|
-
item.code === '0015'
|
194
|
-
? Number(item.amount) === 0
|
195
|
-
? item.taxable
|
196
|
-
: Number(item.amount) / (Number(item.percent) / 100).toFixed(2)
|
197
|
-
: item.taxable,
|
199
|
+
amount,
|
198
200
|
withholding: {
|
199
201
|
type: null,
|
200
202
|
code: null,
|