accounting-engine 0.1.10 → 0.1.12

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "accounting-engine",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "Bu paket, verilen faturanın, belirtilen kurallar çerçevesinde muhasebeleştirilmesini kolaylaştırmak adına oluşturulmuştur.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -48,7 +48,17 @@ 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 = { type: line.type };
51
+ const r = {
52
+ type: line.type,
53
+ name: line.name,
54
+ quantity: line.quantity,
55
+ unit: line.quantity_unit,
56
+ price: line.price,
57
+ extension_amount: line.extension_amount,
58
+ additional: line.additional,
59
+ taxCode: line.code,
60
+ taxPercent: line.percent,
61
+ };
52
62
  _.forEach(Object.keys(item), (key) => {
53
63
  try {
54
64
  r[key] = eval(item[key]);
@@ -236,6 +246,7 @@ const normalizeInvoiceForAccounting = async (invoice, direction) => {
236
246
  receiver_object: invoice.receiver_object,
237
247
  accounting_lines: accountingLines,
238
248
  additional_document_reference: invoice.additional_document_reference,
249
+ payable_amount: invoice.payable_amount,
239
250
  };
240
251
  return data;
241
252
  };
@@ -259,8 +270,33 @@ const normalizeJSON = async (opts, data, dir) => {
259
270
  if (index !== -1) {
260
271
  acc[index].borc += item.borc;
261
272
  acc[index].alacak += item.alacak;
273
+ if (item.type === 'taxable') {
274
+ acc[index].stocks.push({
275
+ code: dir === 'in' ? item.additional?.buyers_item_id : item.additional?.seller_item_id || null,
276
+ name: item.name,
277
+ quantity: item.quantity,
278
+ quantityPrice: item.price,
279
+ taxCode: item.taxCode,
280
+ taxPercent: item.taxPercent,
281
+ });
282
+ }
262
283
  } else {
263
- acc.push(item);
284
+ acc.push({
285
+ ...item,
286
+ stocks:
287
+ item.type === 'taxable'
288
+ ? [
289
+ {
290
+ code: dir === 'in' ? item.additional?.buyers_item_id : item.additional?.seller_item_id || null,
291
+ name: item.name,
292
+ quantity: item.quantity,
293
+ quantityPrice: item.price,
294
+ taxCode: item.taxCode,
295
+ taxPercent: item.taxPercent,
296
+ },
297
+ ]
298
+ : [],
299
+ });
264
300
  }
265
301
  return acc;
266
302
  },