@tomei/finance 0.3.62 → 0.3.64
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/dist/account/account.d.ts +2 -0
- package/dist/account/account.js +46 -0
- package/dist/account/account.js.map +1 -1
- package/dist/finance-company/finance-company.js +14 -6
- package/dist/finance-company/finance-company.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/account/account.ts +47 -0
- package/src/finance-company/finance-company.ts +23 -6
package/package.json
CHANGED
package/src/account/account.ts
CHANGED
|
@@ -98,6 +98,53 @@ export default class Account extends AccountSystemEntity {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
private init(accountData: any) {
|
|
102
|
+
this.IsNewRecord = false;
|
|
103
|
+
this.CompanyId = accountData.CompanyId;
|
|
104
|
+
this.ParentAccountNo = accountData.ParentAccountNo;
|
|
105
|
+
this.Name = accountData.Name;
|
|
106
|
+
this.Description = accountData.Description;
|
|
107
|
+
this.AccountType = accountData.AccountType;
|
|
108
|
+
this.AccountSubtype = accountData.AccountSubType;
|
|
109
|
+
this.OwnerId = accountData.OwnerId;
|
|
110
|
+
this.OwnerType = accountData.OwnerType;
|
|
111
|
+
this.RelatedObjectId = accountData.RelatedObjectId;
|
|
112
|
+
this.RelatedObjectType = accountData.RelatedObjectType;
|
|
113
|
+
this.CreatedById = accountData.CreatedById;
|
|
114
|
+
this.CreatedAt = accountData.CreatedAt;
|
|
115
|
+
this.UpdatedById = accountData.UpdatedById;
|
|
116
|
+
this.UpdatedAt = accountData.UpdatedAt;
|
|
117
|
+
this.AccSystemRefId = accountData.AccSystemRefId;
|
|
118
|
+
this.PostedToAccSystemYN = accountData.PostedToAccSystemYN;
|
|
119
|
+
this.PostedById = accountData.PostedById;
|
|
120
|
+
this.PostedDateTime = accountData.PostedDateTime;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
static async initAccount(
|
|
124
|
+
dbTransaction: any,
|
|
125
|
+
accountNo: string,
|
|
126
|
+
): Promise<Account> {
|
|
127
|
+
try {
|
|
128
|
+
const accountData = await Account._RepositoryBase.findOne({
|
|
129
|
+
where: {
|
|
130
|
+
AccountNo: accountNo,
|
|
131
|
+
},
|
|
132
|
+
transaction: dbTransaction,
|
|
133
|
+
});
|
|
134
|
+
if (accountData) {
|
|
135
|
+
const account = new Account(dbTransaction);
|
|
136
|
+
account.init(accountData.get({ plain: true }));
|
|
137
|
+
return account;
|
|
138
|
+
} else {
|
|
139
|
+
const notFoundError = new RecordNotFoundError('No Record Found.');
|
|
140
|
+
throw notFoundError;
|
|
141
|
+
}
|
|
142
|
+
} catch (error) {
|
|
143
|
+
console.log('Account Class constructor err: ', error);
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
101
148
|
/**
|
|
102
149
|
* Account static constructor
|
|
103
150
|
*
|
|
@@ -603,9 +603,12 @@ export default class FinanceCompany extends ObjectBase {
|
|
|
603
603
|
|
|
604
604
|
for (let i = 0; i < savedItems.length; i++) {
|
|
605
605
|
const journalEntry = new JournalEntry(dbTransaction);
|
|
606
|
-
const account =
|
|
607
|
-
|
|
608
|
-
|
|
606
|
+
const account = await Account.initAccount(
|
|
607
|
+
dbTransaction,
|
|
608
|
+
savedItems[i].value[0],
|
|
609
|
+
);
|
|
610
|
+
const creditAmount = savedItems[i].value[1];
|
|
611
|
+
const currency = htCreditAccountCurrency.get(savedItems[i].value[0]);
|
|
609
612
|
|
|
610
613
|
const dt = await journalEntry.newLedgerTransaction(
|
|
611
614
|
TransactionTypeOptions.DEBIT,
|
|
@@ -803,9 +806,17 @@ export default class FinanceCompany extends ObjectBase {
|
|
|
803
806
|
|
|
804
807
|
for (let i = 0; i < savedItems.length; i++) {
|
|
805
808
|
const journalEntry = new JournalEntry(dbTransaction);
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
+
//Temporary fix to successfully save journal entry in PostJournal
|
|
810
|
+
journalEntry.init({
|
|
811
|
+
CompanyId: this.CompanyId,
|
|
812
|
+
Name: 'issue Invoice ' + invoice.DocNo,
|
|
813
|
+
});
|
|
814
|
+
const account = await Account.initAccount(
|
|
815
|
+
dbTransaction,
|
|
816
|
+
savedItems[i].value[0],
|
|
817
|
+
);
|
|
818
|
+
const creditAmount = savedItems[i].value[1];
|
|
819
|
+
const currency = htCreditAccountCurrency.get(savedItems[i].value[0]);
|
|
809
820
|
|
|
810
821
|
const dt = await journalEntry.newLedgerTransaction(
|
|
811
822
|
TransactionTypeOptions.DEBIT,
|
|
@@ -972,6 +983,12 @@ export default class FinanceCompany extends ObjectBase {
|
|
|
972
983
|
}
|
|
973
984
|
|
|
974
985
|
const journalEntry = new JournalEntry(dbTransaction);
|
|
986
|
+
//Temporary fix to successfully save journal entry in PostJournal
|
|
987
|
+
journalEntry.init({
|
|
988
|
+
CompanyId: this.CompanyId,
|
|
989
|
+
Name: 'Issue Debit Note ' + creditNote.DocNo,
|
|
990
|
+
});
|
|
991
|
+
|
|
975
992
|
const transactionDate = new Date();
|
|
976
993
|
|
|
977
994
|
const creditTransaction = await journalEntry.newLedgerTransaction(
|