@tomei/finance 0.6.43 → 0.6.44
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/journal-entry/journal-entry.d.ts +2 -1
- package/dist/journal-entry/journal-entry.js +47 -32
- package/dist/journal-entry/journal-entry.js.map +1 -1
- package/dist/journal-entry/journal-entry.repository.d.ts +1 -0
- package/dist/journal-entry/journal-entry.repository.js +16 -0
- package/dist/journal-entry/journal-entry.repository.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/journal-entry/journal-entry.repository.ts +6 -0
- package/src/journal-entry/journal-entry.ts +53 -32
package/package.json
CHANGED
|
@@ -56,35 +56,7 @@ export default class JournalEntry extends AccountSystemEntity {
|
|
|
56
56
|
if (dbTransaction) {
|
|
57
57
|
this._DbTransaction = dbTransaction;
|
|
58
58
|
}
|
|
59
|
-
if (journalEntryId) {
|
|
60
|
-
this.RepositoryBase.findOne({
|
|
61
|
-
where: {
|
|
62
|
-
JournalEntryId: journalEntryId,
|
|
63
|
-
},
|
|
64
|
-
transaction: dbTransaction,
|
|
65
|
-
})
|
|
66
|
-
.then((journalEntryData) => {
|
|
67
|
-
if (journalEntryData) {
|
|
68
|
-
this.CompanyId = journalEntryData.CompanyId;
|
|
69
|
-
this.Date = journalEntryData.Date;
|
|
70
|
-
this.Name = journalEntryData.Name;
|
|
71
|
-
this.Description = journalEntryData.Description;
|
|
72
|
-
this.AccSystemRefId = journalEntryData.AccSystemRefId;
|
|
73
|
-
this.PostedToAccSystemYN = journalEntryData.PostedToAccSystemYN;
|
|
74
|
-
this.PostedById = journalEntryData.PostedById;
|
|
75
|
-
this.PostedDateTime = journalEntryData.PostedDateTime;
|
|
76
|
-
} else {
|
|
77
|
-
const notFoundError = new RecordNotFoundError(
|
|
78
|
-
'JournalEntryErrMsg',
|
|
79
|
-
'No Record Found.',
|
|
80
|
-
);
|
|
81
|
-
throw notFoundError;
|
|
82
|
-
}
|
|
83
|
-
})
|
|
84
|
-
.catch((err) => {
|
|
85
|
-
console.log('Journal entry constructor err: ', err);
|
|
86
|
-
});
|
|
87
|
-
} else {
|
|
59
|
+
if (!journalEntryId) {
|
|
88
60
|
this.init({
|
|
89
61
|
JournalEntryId: 'New',
|
|
90
62
|
CompanyId: '',
|
|
@@ -99,6 +71,51 @@ export default class JournalEntry extends AccountSystemEntity {
|
|
|
99
71
|
}
|
|
100
72
|
}
|
|
101
73
|
|
|
74
|
+
public static async initJournalEntry(
|
|
75
|
+
dbTransaction?: any,
|
|
76
|
+
journalEntryId?: string,
|
|
77
|
+
): Promise<JournalEntry> {
|
|
78
|
+
try {
|
|
79
|
+
if (journalEntryId) {
|
|
80
|
+
const journalEntryData = await JournalEntry._RepositoryBase.findOne({
|
|
81
|
+
where: {
|
|
82
|
+
JournalEntryId: journalEntryId,
|
|
83
|
+
},
|
|
84
|
+
transaction: dbTransaction,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
if (journalEntryData) {
|
|
88
|
+
const journalEntry = new JournalEntry();
|
|
89
|
+
journalEntry.init({
|
|
90
|
+
JournalEntryId: journalEntryData.JournalEntryId,
|
|
91
|
+
CompanyId: journalEntryData.CompanyId,
|
|
92
|
+
Date: new Date(),
|
|
93
|
+
Name: journalEntryData.Name,
|
|
94
|
+
Description: journalEntryData.Description,
|
|
95
|
+
AccSystemRefId: journalEntryData.AccSystemRefId,
|
|
96
|
+
PostedToAccSystemYN: journalEntryData.PostedToAccSystemYN,
|
|
97
|
+
PostedById: journalEntryData.PostedById,
|
|
98
|
+
PostedDateTime: journalEntryData.PostedDateTime,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
return journalEntry;
|
|
102
|
+
} else {
|
|
103
|
+
const notFoundError = new RecordNotFoundError(
|
|
104
|
+
'JournalEntryErrMsg',
|
|
105
|
+
'No Record Found.',
|
|
106
|
+
);
|
|
107
|
+
throw notFoundError;
|
|
108
|
+
}
|
|
109
|
+
} else {
|
|
110
|
+
const journalEntry = new JournalEntry(dbTransaction);
|
|
111
|
+
|
|
112
|
+
return journalEntry;
|
|
113
|
+
}
|
|
114
|
+
} catch (error) {
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
102
119
|
get DebitTransactions(): Promise<LedgerTransaction[]> {
|
|
103
120
|
return new Promise((resolve, reject) => {
|
|
104
121
|
if (this.JournalEntryId !== 'New') {
|
|
@@ -189,13 +206,17 @@ export default class JournalEntry extends AccountSystemEntity {
|
|
|
189
206
|
};
|
|
190
207
|
}
|
|
191
208
|
|
|
192
|
-
async create() {
|
|
193
|
-
return await this.RepositoryBase.create(this.getData
|
|
209
|
+
async create(dbTransaction?: any) {
|
|
210
|
+
return await this.RepositoryBase.create(this.getData, {
|
|
211
|
+
transaction: dbTransaction,
|
|
212
|
+
});
|
|
194
213
|
}
|
|
195
214
|
|
|
196
215
|
async save(userId: string, dbTransaction?: any): Promise<JournalEntryModel> {
|
|
197
216
|
try {
|
|
198
|
-
|
|
217
|
+
const count = await this.RepositoryBase.count(dbTransaction);
|
|
218
|
+
this.JournalEntryId = `${count + 1}`;
|
|
219
|
+
|
|
199
220
|
const data = await this.RepositoryBase.create(
|
|
200
221
|
{
|
|
201
222
|
JournalEntryId: this.JournalEntryId,
|