@tomei/finance 0.3.82 → 0.3.83

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": "@tomei/finance",
3
- "version": "0.3.82",
3
+ "version": "0.3.83",
4
4
  "description": "NestJS package for finance module",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -361,19 +361,27 @@ export default class FinanceCompany extends ObjectBase {
361
361
  const newJournalEntry = await journalEntry.save('test', dbTransaction);
362
362
 
363
363
  for (const ledgerTransaction of debitTransactions) {
364
- const dt = await ledgerTransaction.newLedgerTransaction(
365
- TransactionTypeOptions.DEBIT,
366
- newJournalEntry.JournalEntryId,
367
- );
368
- await dt.save();
364
+ ledgerTransaction.TransactionId = cuid();
365
+ ledgerTransaction.JournalEntryId = newJournalEntry.JournalEntryId;
366
+
367
+ await ledgerTransaction.save(dbTransaction);
368
+ // const dt = await ledgerTransaction.newLedgerTransaction(
369
+ // TransactionTypeOptions.DEBIT,
370
+ // newJournalEntry.JournalEntryId,
371
+ // );
372
+ // await dt.save();
369
373
  }
370
374
 
371
375
  for (const ledgerTransaction of creditTransactions) {
372
- const ct = await ledgerTransaction.newLedgerTransaction(
373
- TransactionTypeOptions.CREDIT,
374
- newJournalEntry.JournalEntryId,
375
- );
376
- await ct.save();
376
+ ledgerTransaction.TransactionId = cuid();
377
+ ledgerTransaction.JournalEntryId = newJournalEntry.JournalEntryId;
378
+
379
+ await ledgerTransaction.save(dbTransaction);
380
+ // const ct = await ledgerTransaction.newLedgerTransaction(
381
+ // TransactionTypeOptions.CREDIT,
382
+ // newJournalEntry.JournalEntryId,
383
+ // );
384
+ // await ct.save();
377
385
  }
378
386
 
379
387
  await this.AccountingSystem.postJournalEntry(newJournalEntry);
@@ -2,7 +2,7 @@ import * as cuid from 'cuid';
2
2
  import { ILedgerTransactionAttr } from './interfaces/ledger-transaction-attr.interface';
3
3
  import { TransactionTypeOptions } from '../enum/transaction-type.enum';
4
4
  import { LedgerTransactionRepository } from './ledger-transaction.repository';
5
- import JournalEntryModel from '../models/journal-entry.entity';
5
+ import LedgerTransactionModel from '../models/ledger-transaction.entity';
6
6
 
7
7
  export default class LedgerTransaction {
8
8
  TransactionId = 'New';
@@ -69,6 +69,34 @@ export default class LedgerTransaction {
69
69
  };
70
70
  }
71
71
 
72
+ async save(dbTransaction?: any): Promise<LedgerTransactionModel> {
73
+ try {
74
+ this.TransactionId = cuid();
75
+
76
+ return await LedgerTransaction._LedgerTransactionRepository.create(
77
+ {
78
+ TransactionId: this.TransactionId,
79
+ TransactionType: this.TransactionType,
80
+ JournalEntryId: this.JournalEntryId,
81
+ AccountNo: this.AccountNo,
82
+ Date: this.Date,
83
+ Name: this.Name,
84
+ Description: this.Description,
85
+ Currency: this.Currency,
86
+ DebitAmount: this.DebitAmount,
87
+ CreditAmount: this.CreditAmount,
88
+ RelatedObjectId: this.RelatedObjectId,
89
+ RelatedObjectType: this.RelatedObjectType,
90
+ RelatedDocNo: this.RelatedDocNo,
91
+ RelatedPaymentId: this.RelatedPaymentId,
92
+ },
93
+ { transaction: dbTransaction },
94
+ );
95
+ } catch (error) {
96
+ throw error;
97
+ }
98
+ }
99
+
72
100
  async create() {
73
101
  return await LedgerTransaction._LedgerTransactionRepository.create(
74
102
  this.getData,