@tomei/finance 0.5.0 → 0.5.1

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.
Files changed (167) hide show
  1. package/dist/account/account.d.ts +35 -35
  2. package/dist/account/account.js +231 -231
  3. package/dist/account/account.repository.d.ts +5 -5
  4. package/dist/account/account.repository.js +11 -11
  5. package/dist/account/interfaces/account-attr.interface.d.ts +29 -29
  6. package/dist/account/interfaces/account-attr.interface.js +2 -2
  7. package/dist/account-system-entity/account-system-entity.d.ts +11 -11
  8. package/dist/account-system-entity/account-system-entity.js +66 -66
  9. package/dist/account-system-entity/post-history.repository.d.ts +5 -5
  10. package/dist/account-system-entity/post-history.repository.js +11 -11
  11. package/dist/config.d.ts +1888 -1888
  12. package/dist/config.js +331 -331
  13. package/dist/customer/customer.d.ts +43 -41
  14. package/dist/customer/customer.js +236 -214
  15. package/dist/customer/customer.js.map +1 -1
  16. package/dist/customer/finance-customer.repository.d.ts +5 -5
  17. package/dist/customer/finance-customer.repository.js +25 -25
  18. package/dist/customer/interfaces/customer.repository.interface.d.ts +3 -3
  19. package/dist/customer/interfaces/customer.repository.interface.js +2 -2
  20. package/dist/customer/interfaces/finance-customer-attr.interface.d.ts +10 -10
  21. package/dist/customer/interfaces/finance-customer-attr.interface.js +2 -2
  22. package/dist/customer/interfaces/finance-customer.repository.interface.d.ts +3 -3
  23. package/dist/customer/interfaces/finance-customer.repository.interface.js +2 -2
  24. package/dist/database.d.ts +4 -4
  25. package/dist/database.js +14 -14
  26. package/dist/document/document-item.d.ts +38 -38
  27. package/dist/document/document-item.js +83 -83
  28. package/dist/document/document-item.repository.d.ts +5 -5
  29. package/dist/document/document-item.repository.js +11 -11
  30. package/dist/document/document.d.ts +76 -76
  31. package/dist/document/document.js +566 -566
  32. package/dist/document/document.repository.d.ts +5 -5
  33. package/dist/document/document.repository.js +11 -11
  34. package/dist/document/interfaces/document-attr.interface.d.ts +27 -27
  35. package/dist/document/interfaces/document-attr.interface.js +6 -6
  36. package/dist/document/interfaces/document-item-attr.interface.d.ts +22 -22
  37. package/dist/document/interfaces/document-item-attr.interface.js +6 -6
  38. package/dist/document/interfaces/document-item.repository.interface.d.ts +3 -3
  39. package/dist/document/interfaces/document-item.repository.interface.js +2 -2
  40. package/dist/enum/doc-type.enum.d.ts +8 -8
  41. package/dist/enum/doc-type.enum.js +12 -12
  42. package/dist/enum/document-status.enum.d.ts +6 -6
  43. package/dist/enum/document-status.enum.js +10 -10
  44. package/dist/enum/index.d.ts +8 -8
  45. package/dist/enum/index.js +17 -17
  46. package/dist/enum/payment-method.enum.d.ts +3 -3
  47. package/dist/enum/payment-method.enum.js +7 -7
  48. package/dist/enum/payment-status.enum.d.ts +4 -4
  49. package/dist/enum/payment-status.enum.js +8 -8
  50. package/dist/enum/payment-type.enum.d.ts +4 -4
  51. package/dist/enum/payment-type.enum.js +8 -8
  52. package/dist/enum/quick-book-client-scopes.enum.d.ts +13 -13
  53. package/dist/enum/quick-book-client-scopes.enum.js +18 -18
  54. package/dist/enum/transaction-type.enum.d.ts +4 -4
  55. package/dist/enum/transaction-type.enum.js +8 -8
  56. package/dist/finance-company/finance-company.d.ts +57 -57
  57. package/dist/finance-company/finance-company.js +1192 -1192
  58. package/dist/finance-company/finance-company.repository.d.ts +5 -5
  59. package/dist/finance-company/finance-company.repository.js +11 -11
  60. package/dist/helpers/typeof.d.ts +1 -1
  61. package/dist/helpers/typeof.js +26 -26
  62. package/dist/index.d.ts +17 -17
  63. package/dist/index.js +32 -32
  64. package/dist/interfaces/account-system.interface.d.ts +13 -13
  65. package/dist/interfaces/account-system.interface.js +2 -2
  66. package/dist/interfaces/index.d.ts +2 -2
  67. package/dist/interfaces/index.js +2 -2
  68. package/dist/journal-entry/interfaces/journal-entry-attr.interface.d.ts +11 -11
  69. package/dist/journal-entry/interfaces/journal-entry-attr.interface.js +2 -2
  70. package/dist/journal-entry/journal-entry.d.ts +39 -39
  71. package/dist/journal-entry/journal-entry.js +215 -215
  72. package/dist/journal-entry/journal-entry.repository.d.ts +5 -5
  73. package/dist/journal-entry/journal-entry.repository.js +11 -11
  74. package/dist/ledger-transaction/interfaces/ledger-transaction-attr.interface.d.ts +17 -17
  75. package/dist/ledger-transaction/interfaces/ledger-transaction-attr.interface.js +2 -2
  76. package/dist/ledger-transaction/interfaces/ledger-transaction.repository.interface.d.ts +5 -5
  77. package/dist/ledger-transaction/interfaces/ledger-transaction.repository.interface.js +2 -2
  78. package/dist/ledger-transaction/ledger-transaction.d.ts +48 -48
  79. package/dist/ledger-transaction/ledger-transaction.js +155 -155
  80. package/dist/ledger-transaction/ledger-transaction.repository.d.ts +5 -5
  81. package/dist/ledger-transaction/ledger-transaction.repository.js +11 -11
  82. package/dist/models/account.entity.d.ts +30 -30
  83. package/dist/models/account.entity.js +232 -232
  84. package/dist/models/customer.entity.d.ts +13 -13
  85. package/dist/models/customer.entity.js +109 -109
  86. package/dist/models/document-item.entity.d.ts +27 -27
  87. package/dist/models/document-item.entity.js +172 -172
  88. package/dist/models/document.entity.d.ts +36 -36
  89. package/dist/models/document.entity.js +242 -242
  90. package/dist/models/finance-company.entity.d.ts +9 -9
  91. package/dist/models/finance-company.entity.js +44 -44
  92. package/dist/models/journal-entry.entity.d.ts +16 -16
  93. package/dist/models/journal-entry.entity.js +127 -127
  94. package/dist/models/ledger-transaction.entity.d.ts +24 -24
  95. package/dist/models/ledger-transaction.entity.js +172 -172
  96. package/dist/models/payment-item.entity.d.ts +12 -12
  97. package/dist/models/payment-item.entity.js +75 -75
  98. package/dist/models/payment-method-type.entity.d.ts +13 -13
  99. package/dist/models/payment-method-type.entity.js +85 -85
  100. package/dist/models/payment-method.entity.d.ts +10 -10
  101. package/dist/models/payment-method.entity.js +62 -62
  102. package/dist/models/payment-paid-with.entity.d.ts +24 -24
  103. package/dist/models/payment-paid-with.entity.js +158 -158
  104. package/dist/models/payment.entity.d.ts +27 -27
  105. package/dist/models/payment.entity.js +188 -188
  106. package/dist/models/post-history.entity.d.ts +11 -11
  107. package/dist/models/post-history.entity.js +63 -63
  108. package/dist/payment/interfaces/payment-attr.interface.d.ts +22 -22
  109. package/dist/payment/interfaces/payment-attr.interface.js +6 -6
  110. package/dist/payment/interfaces/payment-params.interface.d.ts +7 -7
  111. package/dist/payment/interfaces/payment-params.interface.js +2 -2
  112. package/dist/payment/payment.d.ts +51 -51
  113. package/dist/payment/payment.js +179 -179
  114. package/dist/payment/payment.repository.d.ts +5 -5
  115. package/dist/payment/payment.repository.js +11 -11
  116. package/dist/payment-item/interfaces/payment-item-attr.interface.d.ts +10 -10
  117. package/dist/payment-item/interfaces/payment-item-attr.interface.js +6 -6
  118. package/dist/payment-item/payment-item.d.ts +23 -23
  119. package/dist/payment-item/payment-item.js +115 -115
  120. package/dist/payment-item/payment-item.repository.d.ts +5 -5
  121. package/dist/payment-item/payment-item.repository.js +11 -11
  122. package/dist/payment-method/interfaces/payment-method-attr.interface.d.ts +5 -5
  123. package/dist/payment-method/interfaces/payment-method-attr.interface.js +2 -2
  124. package/dist/payment-method/payment-method.d.ts +18 -18
  125. package/dist/payment-method/payment-method.js +98 -98
  126. package/dist/payment-method/payment-method.repository.d.ts +5 -5
  127. package/dist/payment-method/payment-method.repository.js +11 -11
  128. package/dist/payment-method-type/interfaces/payment-method-type-attr.interface.d.ts +8 -8
  129. package/dist/payment-method-type/interfaces/payment-method-type-attr.interface.js +2 -2
  130. package/dist/payment-method-type/payment-method-type.d.ts +16 -16
  131. package/dist/payment-method-type/payment-method-type.js +70 -70
  132. package/dist/payment-method-type/payment-method-type.repository.d.ts +5 -5
  133. package/dist/payment-method-type/payment-method-type.repository.js +11 -11
  134. package/dist/payment-paid-with/interfaces/payment-paid-with.interface.d.ts +19 -19
  135. package/dist/payment-paid-with/interfaces/payment-paid-with.interface.js +6 -6
  136. package/dist/payment-paid-with/payment-paid-with.d.ts +31 -31
  137. package/dist/payment-paid-with/payment-paid-with.js +52 -52
  138. package/dist/payment-paid-with/payment-paid-with.repository.d.ts +5 -5
  139. package/dist/payment-paid-with/payment-paid-with.repository.js +11 -11
  140. package/dist/test-document.d.ts +3 -3
  141. package/dist/test-document.js +18 -18
  142. package/dist/test.d.ts +1 -1
  143. package/dist/test.js +7 -7
  144. package/dist/tsconfig.tsbuildinfo +1 -1
  145. package/package.json +1 -1
  146. package/src/customer/customer.ts +40 -0
  147. package/dist/account/interfaces/account.repository.interface.d.ts +0 -3
  148. package/dist/account/interfaces/account.repository.interface.js +0 -3
  149. package/dist/account/interfaces/account.repository.interface.js.map +0 -1
  150. package/dist/document/interfaces/document.repository.interface.d.ts +0 -3
  151. package/dist/document/interfaces/document.repository.interface.js +0 -3
  152. package/dist/document/interfaces/document.repository.interface.js.map +0 -1
  153. package/dist/journal-entry/interfaces/journal-entry.repository.interface.d.ts +0 -10
  154. package/dist/journal-entry/interfaces/journal-entry.repository.interface.js +0 -3
  155. package/dist/journal-entry/interfaces/journal-entry.repository.interface.js.map +0 -1
  156. package/dist/payment/interfaces/payment-item-attr.interface.d.ts +0 -7
  157. package/dist/payment/interfaces/payment-item-attr.interface.js +0 -7
  158. package/dist/payment/interfaces/payment-item-attr.interface.js.map +0 -1
  159. package/dist/payment/interfaces/payment-item.repository.interface.d.ts +0 -3
  160. package/dist/payment/interfaces/payment-item.repository.interface.js +0 -3
  161. package/dist/payment/interfaces/payment-item.repository.interface.js.map +0 -1
  162. package/dist/payment/interfaces/payment.repository.interface.d.ts +0 -3
  163. package/dist/payment/interfaces/payment.repository.interface.js +0 -3
  164. package/dist/payment/interfaces/payment.repository.interface.js.map +0 -1
  165. package/dist/payment/payment-item.repository.d.ts +0 -17
  166. package/dist/payment/payment-item.repository.js +0 -51
  167. package/dist/payment/payment-item.repository.js.map +0 -1
@@ -1,216 +1,216 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const cuid = require("cuid");
13
- const enum_1 = require("../enum");
14
- const account_system_entity_1 = require("../account-system-entity/account-system-entity");
15
- const ledger_transaction_repository_1 = require("../ledger-transaction/ledger-transaction.repository");
16
- const ledger_transaction_1 = require("../ledger-transaction/ledger-transaction");
17
- const journal_entry_repository_1 = require("./journal-entry.repository");
18
- const general_1 = require("@tomei/general");
19
- class JournalEntry extends account_system_entity_1.AccountSystemEntity {
20
- get JournalEntryId() {
21
- return this._JournalEntryId;
22
- }
23
- set JournalEntryId(id) {
24
- this._JournalEntryId = id;
25
- }
26
- get RepositoryBase() {
27
- return JournalEntry._RepositoryBase;
28
- }
29
- get TableName() {
30
- return 'finance_JournalEntry';
31
- }
32
- get ObjectName() {
33
- return this.Name;
34
- }
35
- get ObjectId() {
36
- return this._JournalEntryId;
37
- }
38
- constructor(dbTransaction, journalEntryId) {
39
- super();
40
- this._JournalEntryId = 'New';
41
- this.Date = new Date();
42
- this.Name = '';
43
- this.Description = '';
44
- this._DebitTransactions = [];
45
- this._CreditTransactions = [];
46
- if (dbTransaction) {
47
- this._DbTransaction = dbTransaction;
48
- }
49
- if (journalEntryId) {
50
- this.RepositoryBase.findOne({
51
- where: {
52
- JournalEntryId: journalEntryId,
53
- },
54
- transaction: dbTransaction,
55
- })
56
- .then((journalEntryData) => {
57
- if (journalEntryData) {
58
- this.CompanyId = journalEntryData.CompanyId;
59
- this.Date = journalEntryData.Date;
60
- this.Name = journalEntryData.Name;
61
- this.Description = journalEntryData.Description;
62
- this.AccSystemRefId = journalEntryData.AccSystemRefId;
63
- this.PostedToAccSystemYN = journalEntryData.PostedToAccSystemYN;
64
- this.PostedById = journalEntryData.PostedById;
65
- this.PostedDateTime = journalEntryData.PostedDateTime;
66
- }
67
- else {
68
- const notFoundError = new general_1.RecordNotFoundError('No Record Found.');
69
- throw notFoundError;
70
- }
71
- })
72
- .catch((err) => {
73
- console.log('Journal entry constructor err: ', err);
74
- });
75
- }
76
- else {
77
- this.init({
78
- JournalEntryId: 'New',
79
- CompanyId: '',
80
- Date: new Date(),
81
- Name: '',
82
- Description: '',
83
- AccSystemRefId: '',
84
- PostedToAccSystemYN: 'N',
85
- PostedById: '',
86
- PostedDateTime: null,
87
- });
88
- }
89
- }
90
- get DebitTransactions() {
91
- return new Promise((resolve, reject) => {
92
- if (this.JournalEntryId !== 'New') {
93
- JournalEntry._LedgerTransactionRepository
94
- .findAll({
95
- where: {
96
- TransactionType: enum_1.TransactionTypeOptions.DEBIT,
97
- },
98
- transaction: this._DbTransaction,
99
- })
100
- .then((debitTransactions) => {
101
- const debitTransactionObjects = debitTransactions.map((debitTransactionData) => new ledger_transaction_1.default(this._DbTransaction, debitTransactionData.TransactionId));
102
- return Promise.all(debitTransactionObjects);
103
- })
104
- .then((debitTransactionObjects) => {
105
- this._DebitTransactions = debitTransactionObjects;
106
- resolve(this._DebitTransactions);
107
- })
108
- .catch((err) => {
109
- reject(err);
110
- });
111
- }
112
- else {
113
- resolve(this._DebitTransactions);
114
- }
115
- });
116
- }
117
- get CreditTransactions() {
118
- return new Promise((resolve, reject) => {
119
- if (this.JournalEntryId !== 'New') {
120
- JournalEntry._LedgerTransactionRepository
121
- .findAll({
122
- where: {
123
- TransactionType: enum_1.TransactionTypeOptions.CREDIT,
124
- },
125
- transaction: this._DbTransaction,
126
- })
127
- .then((creditTransaction) => {
128
- const creditTransactionObjects = creditTransaction.map((creditTransactionData) => new ledger_transaction_1.default(this._DbTransaction, creditTransactionData.TransactionId));
129
- return Promise.all(creditTransactionObjects);
130
- })
131
- .then((creditTransactionObjects) => {
132
- this._CreditTransactions = creditTransactionObjects;
133
- resolve(this._CreditTransactions);
134
- })
135
- .catch((err) => {
136
- reject(err);
137
- });
138
- }
139
- else {
140
- resolve(this._CreditTransactions);
141
- }
142
- });
143
- }
144
- init(params) {
145
- if (params.JournalEntryId)
146
- this.JournalEntryId = params.JournalEntryId;
147
- if (params.CompanyId)
148
- this.CompanyId = params.CompanyId;
149
- if (params.Date)
150
- this.Date = params.Date;
151
- if (params.Name)
152
- this.Name = params.Name;
153
- if (params.Description)
154
- this.Description = params.Description;
155
- if (params.PostedById)
156
- this.PostedById = params.PostedById;
157
- if (params.PostedToAccSystemYN)
158
- this.PostedToAccSystemYN = params.PostedToAccSystemYN;
159
- if (params.PostedDateTime)
160
- this.PostedDateTime = params.PostedDateTime;
161
- }
162
- getData() {
163
- return {
164
- JournalEntryId: this.JournalEntryId,
165
- Date: this.Date,
166
- Name: this.Name,
167
- Description: this.Description,
168
- PostedById: this.PostedById,
169
- PostedToAccSystemYN: this.PostedToAccSystemYN,
170
- PostedDateTime: this.PostedDateTime,
171
- };
172
- }
173
- create() {
174
- return __awaiter(this, void 0, void 0, function* () {
175
- return yield this.RepositoryBase.create(this.getData);
176
- });
177
- }
178
- save(userId, dbTransaction) {
179
- return __awaiter(this, void 0, void 0, function* () {
180
- try {
181
- this.JournalEntryId = cuid();
182
- const data = yield this.RepositoryBase.create({
183
- JournalEntryId: this.JournalEntryId,
184
- CompanyId: this.CompanyId,
185
- Date: this.Date,
186
- Name: this.Name,
187
- Description: this.Description,
188
- PostedById: userId,
189
- PostedToAccSystemYN: this.PostedToAccSystemYN,
190
- PostedDateTime: this.PostedDateTime,
191
- }, { transaction: dbTransaction });
192
- return data;
193
- }
194
- catch (error) {
195
- throw error;
196
- }
197
- });
198
- }
199
- newLedgerTransaction(transactionType) {
200
- return __awaiter(this, void 0, void 0, function* () {
201
- const ledgerTransaction = new ledger_transaction_1.default(transactionType, this._DbTransaction);
202
- ledgerTransaction.JournalEntryId = this.JournalEntryId;
203
- if (transactionType === enum_1.TransactionTypeOptions.DEBIT) {
204
- this._DebitTransactions.push(ledgerTransaction);
205
- }
206
- else if (transactionType === enum_1.TransactionTypeOptions.CREDIT) {
207
- this._CreditTransactions.push(ledgerTransaction);
208
- }
209
- return ledgerTransaction;
210
- });
211
- }
212
- }
213
- exports.default = JournalEntry;
214
- JournalEntry._RepositoryBase = new journal_entry_repository_1.JournalEntryRepository();
215
- JournalEntry._LedgerTransactionRepository = new ledger_transaction_repository_1.LedgerTransactionRepository();
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const cuid = require("cuid");
13
+ const enum_1 = require("../enum");
14
+ const account_system_entity_1 = require("../account-system-entity/account-system-entity");
15
+ const ledger_transaction_repository_1 = require("../ledger-transaction/ledger-transaction.repository");
16
+ const ledger_transaction_1 = require("../ledger-transaction/ledger-transaction");
17
+ const journal_entry_repository_1 = require("./journal-entry.repository");
18
+ const general_1 = require("@tomei/general");
19
+ class JournalEntry extends account_system_entity_1.AccountSystemEntity {
20
+ get JournalEntryId() {
21
+ return this._JournalEntryId;
22
+ }
23
+ set JournalEntryId(id) {
24
+ this._JournalEntryId = id;
25
+ }
26
+ get RepositoryBase() {
27
+ return JournalEntry._RepositoryBase;
28
+ }
29
+ get TableName() {
30
+ return 'finance_JournalEntry';
31
+ }
32
+ get ObjectName() {
33
+ return this.Name;
34
+ }
35
+ get ObjectId() {
36
+ return this._JournalEntryId;
37
+ }
38
+ constructor(dbTransaction, journalEntryId) {
39
+ super();
40
+ this._JournalEntryId = 'New';
41
+ this.Date = new Date();
42
+ this.Name = '';
43
+ this.Description = '';
44
+ this._DebitTransactions = [];
45
+ this._CreditTransactions = [];
46
+ if (dbTransaction) {
47
+ this._DbTransaction = dbTransaction;
48
+ }
49
+ if (journalEntryId) {
50
+ this.RepositoryBase.findOne({
51
+ where: {
52
+ JournalEntryId: journalEntryId,
53
+ },
54
+ transaction: dbTransaction,
55
+ })
56
+ .then((journalEntryData) => {
57
+ if (journalEntryData) {
58
+ this.CompanyId = journalEntryData.CompanyId;
59
+ this.Date = journalEntryData.Date;
60
+ this.Name = journalEntryData.Name;
61
+ this.Description = journalEntryData.Description;
62
+ this.AccSystemRefId = journalEntryData.AccSystemRefId;
63
+ this.PostedToAccSystemYN = journalEntryData.PostedToAccSystemYN;
64
+ this.PostedById = journalEntryData.PostedById;
65
+ this.PostedDateTime = journalEntryData.PostedDateTime;
66
+ }
67
+ else {
68
+ const notFoundError = new general_1.RecordNotFoundError('No Record Found.');
69
+ throw notFoundError;
70
+ }
71
+ })
72
+ .catch((err) => {
73
+ console.log('Journal entry constructor err: ', err);
74
+ });
75
+ }
76
+ else {
77
+ this.init({
78
+ JournalEntryId: 'New',
79
+ CompanyId: '',
80
+ Date: new Date(),
81
+ Name: '',
82
+ Description: '',
83
+ AccSystemRefId: '',
84
+ PostedToAccSystemYN: 'N',
85
+ PostedById: '',
86
+ PostedDateTime: null,
87
+ });
88
+ }
89
+ }
90
+ get DebitTransactions() {
91
+ return new Promise((resolve, reject) => {
92
+ if (this.JournalEntryId !== 'New') {
93
+ JournalEntry._LedgerTransactionRepository
94
+ .findAll({
95
+ where: {
96
+ TransactionType: enum_1.TransactionTypeOptions.DEBIT,
97
+ },
98
+ transaction: this._DbTransaction,
99
+ })
100
+ .then((debitTransactions) => {
101
+ const debitTransactionObjects = debitTransactions.map((debitTransactionData) => new ledger_transaction_1.default(this._DbTransaction, debitTransactionData.TransactionId));
102
+ return Promise.all(debitTransactionObjects);
103
+ })
104
+ .then((debitTransactionObjects) => {
105
+ this._DebitTransactions = debitTransactionObjects;
106
+ resolve(this._DebitTransactions);
107
+ })
108
+ .catch((err) => {
109
+ reject(err);
110
+ });
111
+ }
112
+ else {
113
+ resolve(this._DebitTransactions);
114
+ }
115
+ });
116
+ }
117
+ get CreditTransactions() {
118
+ return new Promise((resolve, reject) => {
119
+ if (this.JournalEntryId !== 'New') {
120
+ JournalEntry._LedgerTransactionRepository
121
+ .findAll({
122
+ where: {
123
+ TransactionType: enum_1.TransactionTypeOptions.CREDIT,
124
+ },
125
+ transaction: this._DbTransaction,
126
+ })
127
+ .then((creditTransaction) => {
128
+ const creditTransactionObjects = creditTransaction.map((creditTransactionData) => new ledger_transaction_1.default(this._DbTransaction, creditTransactionData.TransactionId));
129
+ return Promise.all(creditTransactionObjects);
130
+ })
131
+ .then((creditTransactionObjects) => {
132
+ this._CreditTransactions = creditTransactionObjects;
133
+ resolve(this._CreditTransactions);
134
+ })
135
+ .catch((err) => {
136
+ reject(err);
137
+ });
138
+ }
139
+ else {
140
+ resolve(this._CreditTransactions);
141
+ }
142
+ });
143
+ }
144
+ init(params) {
145
+ if (params.JournalEntryId)
146
+ this.JournalEntryId = params.JournalEntryId;
147
+ if (params.CompanyId)
148
+ this.CompanyId = params.CompanyId;
149
+ if (params.Date)
150
+ this.Date = params.Date;
151
+ if (params.Name)
152
+ this.Name = params.Name;
153
+ if (params.Description)
154
+ this.Description = params.Description;
155
+ if (params.PostedById)
156
+ this.PostedById = params.PostedById;
157
+ if (params.PostedToAccSystemYN)
158
+ this.PostedToAccSystemYN = params.PostedToAccSystemYN;
159
+ if (params.PostedDateTime)
160
+ this.PostedDateTime = params.PostedDateTime;
161
+ }
162
+ getData() {
163
+ return {
164
+ JournalEntryId: this.JournalEntryId,
165
+ Date: this.Date,
166
+ Name: this.Name,
167
+ Description: this.Description,
168
+ PostedById: this.PostedById,
169
+ PostedToAccSystemYN: this.PostedToAccSystemYN,
170
+ PostedDateTime: this.PostedDateTime,
171
+ };
172
+ }
173
+ create() {
174
+ return __awaiter(this, void 0, void 0, function* () {
175
+ return yield this.RepositoryBase.create(this.getData);
176
+ });
177
+ }
178
+ save(userId, dbTransaction) {
179
+ return __awaiter(this, void 0, void 0, function* () {
180
+ try {
181
+ this.JournalEntryId = cuid();
182
+ const data = yield this.RepositoryBase.create({
183
+ JournalEntryId: this.JournalEntryId,
184
+ CompanyId: this.CompanyId,
185
+ Date: this.Date,
186
+ Name: this.Name,
187
+ Description: this.Description,
188
+ PostedById: userId,
189
+ PostedToAccSystemYN: this.PostedToAccSystemYN,
190
+ PostedDateTime: this.PostedDateTime,
191
+ }, { transaction: dbTransaction });
192
+ return data;
193
+ }
194
+ catch (error) {
195
+ throw error;
196
+ }
197
+ });
198
+ }
199
+ newLedgerTransaction(transactionType) {
200
+ return __awaiter(this, void 0, void 0, function* () {
201
+ const ledgerTransaction = new ledger_transaction_1.default(transactionType, this._DbTransaction);
202
+ ledgerTransaction.JournalEntryId = this.JournalEntryId;
203
+ if (transactionType === enum_1.TransactionTypeOptions.DEBIT) {
204
+ this._DebitTransactions.push(ledgerTransaction);
205
+ }
206
+ else if (transactionType === enum_1.TransactionTypeOptions.CREDIT) {
207
+ this._CreditTransactions.push(ledgerTransaction);
208
+ }
209
+ return ledgerTransaction;
210
+ });
211
+ }
212
+ }
213
+ exports.default = JournalEntry;
214
+ JournalEntry._RepositoryBase = new journal_entry_repository_1.JournalEntryRepository();
215
+ JournalEntry._LedgerTransactionRepository = new ledger_transaction_repository_1.LedgerTransactionRepository();
216
216
  //# sourceMappingURL=journal-entry.js.map
@@ -1,5 +1,5 @@
1
- import { RepositoryBase, IRepositoryBase } from '@tomei/general';
2
- import JournalEntryModel from '../models/journal-entry.entity';
3
- export declare class JournalEntryRepository extends RepositoryBase<JournalEntryModel> implements IRepositoryBase<JournalEntryModel> {
4
- constructor();
5
- }
1
+ import { RepositoryBase, IRepositoryBase } from '@tomei/general';
2
+ import JournalEntryModel from '../models/journal-entry.entity';
3
+ export declare class JournalEntryRepository extends RepositoryBase<JournalEntryModel> implements IRepositoryBase<JournalEntryModel> {
4
+ constructor();
5
+ }
@@ -1,12 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JournalEntryRepository = void 0;
4
- const general_1 = require("@tomei/general");
5
- const journal_entry_entity_1 = require("../models/journal-entry.entity");
6
- class JournalEntryRepository extends general_1.RepositoryBase {
7
- constructor() {
8
- super(journal_entry_entity_1.default);
9
- }
10
- }
11
- exports.JournalEntryRepository = JournalEntryRepository;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JournalEntryRepository = void 0;
4
+ const general_1 = require("@tomei/general");
5
+ const journal_entry_entity_1 = require("../models/journal-entry.entity");
6
+ class JournalEntryRepository extends general_1.RepositoryBase {
7
+ constructor() {
8
+ super(journal_entry_entity_1.default);
9
+ }
10
+ }
11
+ exports.JournalEntryRepository = JournalEntryRepository;
12
12
  //# sourceMappingURL=journal-entry.repository.js.map
@@ -1,17 +1,17 @@
1
- import { TransactionTypeOptions } from '../../enum';
2
- export interface ILedgerTransactionAttr {
3
- TransactionId?: string;
4
- TransactionType?: TransactionTypeOptions;
5
- JournalEntryId?: string;
6
- AccountNo?: string;
7
- Date?: Date;
8
- Name?: string;
9
- Description?: string;
10
- Currency?: string;
11
- DebitAmount?: number;
12
- CreditAmount?: number;
13
- RelatedObjectId?: string;
14
- RelatedObjectType?: string;
15
- RelatedDocNo?: string;
16
- RelatedPaymentId?: string;
17
- }
1
+ import { TransactionTypeOptions } from '../../enum';
2
+ export interface ILedgerTransactionAttr {
3
+ TransactionId?: string;
4
+ TransactionType?: TransactionTypeOptions;
5
+ JournalEntryId?: string;
6
+ AccountNo?: string;
7
+ Date?: Date;
8
+ Name?: string;
9
+ Description?: string;
10
+ Currency?: string;
11
+ DebitAmount?: number;
12
+ CreditAmount?: number;
13
+ RelatedObjectId?: string;
14
+ RelatedObjectType?: string;
15
+ RelatedDocNo?: string;
16
+ RelatedPaymentId?: string;
17
+ }
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=ledger-transaction-attr.interface.js.map
@@ -1,5 +1,5 @@
1
- export interface ILedgerTransactionRepository<T> {
2
- create?(data: T | any, options?: any): Promise<T> | any;
3
- findAll?(options?: any): Promise<T[]>;
4
- findOne?(options: any): Promise<T>;
5
- }
1
+ export interface ILedgerTransactionRepository<T> {
2
+ create?(data: T | any, options?: any): Promise<T> | any;
3
+ findAll?(options?: any): Promise<T[]>;
4
+ findOne?(options: any): Promise<T>;
5
+ }
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=ledger-transaction.repository.interface.js.map
@@ -1,48 +1,48 @@
1
- import { ILedgerTransactionAttr } from './interfaces/ledger-transaction-attr.interface';
2
- import { TransactionTypeOptions } from '../enum/transaction-type.enum';
3
- import LedgerTransactionModel from '../models/ledger-transaction.entity';
4
- export default class LedgerTransaction {
5
- TransactionId: string;
6
- TransactionType: TransactionTypeOptions;
7
- JournalEntryId: string;
8
- AccountNo: string;
9
- Date: Date;
10
- Name: string;
11
- Description: string;
12
- Currency: string;
13
- DebitAmount: number;
14
- CreditAmount: number;
15
- RelatedObjectId: string;
16
- RelatedObjectType: string;
17
- RelatedDocNo: string;
18
- RelatedPaymentId: string;
19
- private _DbTransaction;
20
- private static _LedgerTransactionRepository;
21
- constructor(transactionType: TransactionTypeOptions, dbTransaction?: any, transactionId?: string);
22
- init(params?: ILedgerTransactionAttr): void;
23
- getData(): {
24
- TransactionId: string;
25
- TransactionType: TransactionTypeOptions;
26
- JournalEntryId: string;
27
- AccountNo: string;
28
- Date: Date;
29
- Name: string;
30
- Description: string;
31
- Currency: string;
32
- DebitAmount: number;
33
- CreditAmount: number;
34
- RelatedObjectId: string;
35
- RelatedObjectType: string;
36
- RelatedDocNo: string;
37
- RelatedPaymentId: string;
38
- };
39
- save(dbTransaction?: any): Promise<LedgerTransactionModel>;
40
- create(): Promise<LedgerTransactionModel>;
41
- findAll(options: any): Promise<LedgerTransactionModel[]>;
42
- findAllWithPagination(options: any): Promise<{
43
- count: number;
44
- rows: LedgerTransactionModel[];
45
- }>;
46
- accountTransactionHistory(accountNo: string): Promise<LedgerTransactionModel[]>;
47
- newLedgerTransaction(transactionType: TransactionTypeOptions, journalEntryId?: string): Promise<any>;
48
- }
1
+ import { ILedgerTransactionAttr } from './interfaces/ledger-transaction-attr.interface';
2
+ import { TransactionTypeOptions } from '../enum/transaction-type.enum';
3
+ import LedgerTransactionModel from '../models/ledger-transaction.entity';
4
+ export default class LedgerTransaction {
5
+ TransactionId: string;
6
+ TransactionType: TransactionTypeOptions;
7
+ JournalEntryId: string;
8
+ AccountNo: string;
9
+ Date: Date;
10
+ Name: string;
11
+ Description: string;
12
+ Currency: string;
13
+ DebitAmount: number;
14
+ CreditAmount: number;
15
+ RelatedObjectId: string;
16
+ RelatedObjectType: string;
17
+ RelatedDocNo: string;
18
+ RelatedPaymentId: string;
19
+ private _DbTransaction;
20
+ private static _LedgerTransactionRepository;
21
+ constructor(transactionType: TransactionTypeOptions, dbTransaction?: any, transactionId?: string);
22
+ init(params?: ILedgerTransactionAttr): void;
23
+ getData(): {
24
+ TransactionId: string;
25
+ TransactionType: TransactionTypeOptions;
26
+ JournalEntryId: string;
27
+ AccountNo: string;
28
+ Date: Date;
29
+ Name: string;
30
+ Description: string;
31
+ Currency: string;
32
+ DebitAmount: number;
33
+ CreditAmount: number;
34
+ RelatedObjectId: string;
35
+ RelatedObjectType: string;
36
+ RelatedDocNo: string;
37
+ RelatedPaymentId: string;
38
+ };
39
+ save(dbTransaction?: any): Promise<LedgerTransactionModel>;
40
+ create(): Promise<LedgerTransactionModel>;
41
+ findAll(options: any): Promise<LedgerTransactionModel[]>;
42
+ findAllWithPagination(options: any): Promise<{
43
+ count: number;
44
+ rows: LedgerTransactionModel[];
45
+ }>;
46
+ accountTransactionHistory(accountNo: string): Promise<LedgerTransactionModel[]>;
47
+ newLedgerTransaction(transactionType: TransactionTypeOptions, journalEntryId?: string): Promise<any>;
48
+ }