fix: transaction type in customer/vendor transactions report.

This commit is contained in:
a.bouhuolia
2021-05-09 03:10:36 +02:00
parent 8566ce126e
commit bd7c9db5f6
10 changed files with 40 additions and 19 deletions

View File

@@ -14,7 +14,7 @@ export default class Ledger implements ILedger {
* @param {ILedgerEntry[]} entries
*/
constructor(entries: ILedgerEntry[]) {
this.entries = Ledger.mappingEntries(entries);
this.entries = entries;
}
/**
@@ -75,11 +75,11 @@ export default class Ledger implements ILedger {
return closingBalance;
}
static mappingEntries(entries): ILedgerEntry[] {
return entries.map(this.mapEntry);
static mappingTransactions(entries): ILedgerEntry[] {
return entries.map(this.mapTransaction);
}
static mapEntry(entry): ILedgerEntry {
static mapTransaction(entry): ILedgerEntry {
return {
credit: defaultTo(entry.credit, 0),
debit: defaultTo(entry.debit, 0),
@@ -88,7 +88,14 @@ export default class Ledger implements ILedger {
contactId: entry.contactId,
date: entry.date,
transactionNumber: entry.transactionNumber,
transactionType: entry.referenceTypeFormatted,
referenceNumber: entry.referenceNumber,
referenceType: entry.referenceType,
}
}
static fromTransactions(transactions) {
const entries = Ledger.mappingTransactions(transactions);
return new Ledger(entries);
}
}