@tomei/finance 0.4.25 → 0.5.0

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 (171) 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/interfaces/account.repository.interface.d.ts +3 -0
  8. package/dist/account/interfaces/account.repository.interface.js +3 -0
  9. package/dist/account/interfaces/account.repository.interface.js.map +1 -0
  10. package/dist/account-system-entity/account-system-entity.d.ts +11 -11
  11. package/dist/account-system-entity/account-system-entity.js +66 -66
  12. package/dist/account-system-entity/post-history.repository.d.ts +5 -5
  13. package/dist/account-system-entity/post-history.repository.js +11 -11
  14. package/dist/config.d.ts +1888 -1888
  15. package/dist/config.js +331 -331
  16. package/dist/customer/customer.d.ts +41 -41
  17. package/dist/customer/customer.js +214 -214
  18. package/dist/customer/finance-customer.repository.d.ts +5 -5
  19. package/dist/customer/finance-customer.repository.js +25 -25
  20. package/dist/customer/interfaces/customer.repository.interface.d.ts +3 -3
  21. package/dist/customer/interfaces/customer.repository.interface.js +2 -2
  22. package/dist/customer/interfaces/finance-customer-attr.interface.d.ts +10 -10
  23. package/dist/customer/interfaces/finance-customer-attr.interface.js +2 -2
  24. package/dist/customer/interfaces/finance-customer.repository.interface.d.ts +3 -3
  25. package/dist/customer/interfaces/finance-customer.repository.interface.js +2 -2
  26. package/dist/database.d.ts +4 -4
  27. package/dist/database.js +14 -14
  28. package/dist/document/document-item.d.ts +38 -38
  29. package/dist/document/document-item.js +83 -83
  30. package/dist/document/document-item.repository.d.ts +5 -5
  31. package/dist/document/document-item.repository.js +11 -11
  32. package/dist/document/document.d.ts +76 -76
  33. package/dist/document/document.js +566 -566
  34. package/dist/document/document.repository.d.ts +5 -5
  35. package/dist/document/document.repository.js +11 -11
  36. package/dist/document/interfaces/document-attr.interface.d.ts +27 -27
  37. package/dist/document/interfaces/document-attr.interface.js +6 -6
  38. package/dist/document/interfaces/document-item-attr.interface.d.ts +22 -22
  39. package/dist/document/interfaces/document-item-attr.interface.js +6 -6
  40. package/dist/document/interfaces/document-item.repository.interface.d.ts +3 -3
  41. package/dist/document/interfaces/document-item.repository.interface.js +2 -2
  42. package/dist/document/interfaces/document.repository.interface.d.ts +3 -0
  43. package/dist/document/interfaces/document.repository.interface.js +3 -0
  44. package/dist/document/interfaces/document.repository.interface.js.map +1 -0
  45. package/dist/enum/doc-type.enum.d.ts +8 -8
  46. package/dist/enum/doc-type.enum.js +12 -12
  47. package/dist/enum/document-status.enum.d.ts +6 -6
  48. package/dist/enum/document-status.enum.js +10 -10
  49. package/dist/enum/index.d.ts +8 -8
  50. package/dist/enum/index.js +17 -17
  51. package/dist/enum/payment-method.enum.d.ts +3 -3
  52. package/dist/enum/payment-method.enum.js +7 -7
  53. package/dist/enum/payment-status.enum.d.ts +4 -4
  54. package/dist/enum/payment-status.enum.js +8 -8
  55. package/dist/enum/payment-type.enum.d.ts +4 -4
  56. package/dist/enum/payment-type.enum.js +8 -8
  57. package/dist/enum/quick-book-client-scopes.enum.d.ts +13 -13
  58. package/dist/enum/quick-book-client-scopes.enum.js +18 -18
  59. package/dist/enum/transaction-type.enum.d.ts +4 -4
  60. package/dist/enum/transaction-type.enum.js +8 -8
  61. package/dist/finance-company/finance-company.d.ts +57 -57
  62. package/dist/finance-company/finance-company.js +1192 -1192
  63. package/dist/finance-company/finance-company.repository.d.ts +5 -5
  64. package/dist/finance-company/finance-company.repository.js +11 -11
  65. package/dist/helpers/typeof.d.ts +1 -1
  66. package/dist/helpers/typeof.js +26 -26
  67. package/dist/index.d.ts +17 -16
  68. package/dist/index.js +32 -30
  69. package/dist/index.js.map +1 -1
  70. package/dist/interfaces/account-system.interface.d.ts +13 -13
  71. package/dist/interfaces/account-system.interface.js +2 -2
  72. package/dist/interfaces/index.d.ts +2 -2
  73. package/dist/interfaces/index.js +2 -2
  74. package/dist/journal-entry/interfaces/journal-entry-attr.interface.d.ts +11 -11
  75. package/dist/journal-entry/interfaces/journal-entry-attr.interface.js +2 -2
  76. package/dist/journal-entry/interfaces/journal-entry.repository.interface.d.ts +10 -0
  77. package/dist/journal-entry/interfaces/journal-entry.repository.interface.js +3 -0
  78. package/dist/journal-entry/interfaces/journal-entry.repository.interface.js.map +1 -0
  79. package/dist/journal-entry/journal-entry.d.ts +39 -39
  80. package/dist/journal-entry/journal-entry.js +215 -215
  81. package/dist/journal-entry/journal-entry.repository.d.ts +5 -5
  82. package/dist/journal-entry/journal-entry.repository.js +11 -11
  83. package/dist/ledger-transaction/interfaces/ledger-transaction-attr.interface.d.ts +17 -17
  84. package/dist/ledger-transaction/interfaces/ledger-transaction-attr.interface.js +2 -2
  85. package/dist/ledger-transaction/interfaces/ledger-transaction.repository.interface.d.ts +5 -5
  86. package/dist/ledger-transaction/interfaces/ledger-transaction.repository.interface.js +2 -2
  87. package/dist/ledger-transaction/ledger-transaction.d.ts +48 -48
  88. package/dist/ledger-transaction/ledger-transaction.js +155 -155
  89. package/dist/ledger-transaction/ledger-transaction.repository.d.ts +5 -5
  90. package/dist/ledger-transaction/ledger-transaction.repository.js +11 -11
  91. package/dist/models/account.entity.d.ts +30 -30
  92. package/dist/models/account.entity.js +232 -232
  93. package/dist/models/customer.entity.d.ts +13 -13
  94. package/dist/models/customer.entity.js +109 -109
  95. package/dist/models/document-item.entity.d.ts +27 -27
  96. package/dist/models/document-item.entity.js +172 -172
  97. package/dist/models/document.entity.d.ts +36 -36
  98. package/dist/models/document.entity.js +242 -242
  99. package/dist/models/finance-company.entity.d.ts +9 -9
  100. package/dist/models/finance-company.entity.js +44 -44
  101. package/dist/models/journal-entry.entity.d.ts +16 -16
  102. package/dist/models/journal-entry.entity.js +127 -127
  103. package/dist/models/ledger-transaction.entity.d.ts +24 -24
  104. package/dist/models/ledger-transaction.entity.js +172 -172
  105. package/dist/models/payment-item.entity.d.ts +12 -12
  106. package/dist/models/payment-item.entity.js +75 -75
  107. package/dist/models/payment-method-type.entity.d.ts +13 -13
  108. package/dist/models/payment-method-type.entity.js +85 -85
  109. package/dist/models/payment-method.entity.d.ts +10 -10
  110. package/dist/models/payment-method.entity.js +62 -62
  111. package/dist/models/payment-paid-with.entity.d.ts +24 -24
  112. package/dist/models/payment-paid-with.entity.js +158 -158
  113. package/dist/models/payment.entity.d.ts +27 -27
  114. package/dist/models/payment.entity.js +188 -188
  115. package/dist/models/post-history.entity.d.ts +11 -11
  116. package/dist/models/post-history.entity.js +63 -63
  117. package/dist/payment/interfaces/payment-attr.interface.d.ts +22 -22
  118. package/dist/payment/interfaces/payment-attr.interface.js +6 -6
  119. package/dist/payment/interfaces/payment-item-attr.interface.d.ts +7 -0
  120. package/dist/payment/interfaces/payment-item-attr.interface.js +7 -0
  121. package/dist/payment/interfaces/payment-item-attr.interface.js.map +1 -0
  122. package/dist/payment/interfaces/payment-item.repository.interface.d.ts +3 -0
  123. package/dist/payment/interfaces/payment-item.repository.interface.js +3 -0
  124. package/dist/payment/interfaces/payment-item.repository.interface.js.map +1 -0
  125. package/dist/payment/interfaces/payment-params.interface.d.ts +7 -7
  126. package/dist/payment/interfaces/payment-params.interface.js +2 -2
  127. package/dist/payment/interfaces/payment.repository.interface.d.ts +3 -0
  128. package/dist/payment/interfaces/payment.repository.interface.js +3 -0
  129. package/dist/payment/interfaces/payment.repository.interface.js.map +1 -0
  130. package/dist/payment/payment-item.repository.d.ts +17 -0
  131. package/dist/payment/payment-item.repository.js +51 -0
  132. package/dist/payment/payment-item.repository.js.map +1 -0
  133. package/dist/payment/payment.d.ts +51 -51
  134. package/dist/payment/payment.js +179 -179
  135. package/dist/payment/payment.repository.d.ts +5 -5
  136. package/dist/payment/payment.repository.js +11 -11
  137. package/dist/payment-item/interfaces/payment-item-attr.interface.d.ts +10 -10
  138. package/dist/payment-item/interfaces/payment-item-attr.interface.js +6 -6
  139. package/dist/payment-item/payment-item.d.ts +23 -23
  140. package/dist/payment-item/payment-item.js +115 -97
  141. package/dist/payment-item/payment-item.js.map +1 -1
  142. package/dist/payment-item/payment-item.repository.d.ts +5 -5
  143. package/dist/payment-item/payment-item.repository.js +11 -11
  144. package/dist/payment-method/interfaces/payment-method-attr.interface.d.ts +5 -5
  145. package/dist/payment-method/interfaces/payment-method-attr.interface.js +2 -2
  146. package/dist/payment-method/payment-method.d.ts +18 -18
  147. package/dist/payment-method/payment-method.js +98 -98
  148. package/dist/payment-method/payment-method.repository.d.ts +5 -5
  149. package/dist/payment-method/payment-method.repository.js +11 -11
  150. package/dist/payment-method-type/interfaces/payment-method-type-attr.interface.d.ts +8 -8
  151. package/dist/payment-method-type/interfaces/payment-method-type-attr.interface.js +2 -2
  152. package/dist/payment-method-type/payment-method-type.d.ts +16 -16
  153. package/dist/payment-method-type/payment-method-type.js +70 -70
  154. package/dist/payment-method-type/payment-method-type.repository.d.ts +5 -5
  155. package/dist/payment-method-type/payment-method-type.repository.js +11 -11
  156. package/dist/payment-paid-with/interfaces/payment-paid-with.interface.d.ts +19 -19
  157. package/dist/payment-paid-with/interfaces/payment-paid-with.interface.js +6 -6
  158. package/dist/payment-paid-with/payment-paid-with.d.ts +31 -31
  159. package/dist/payment-paid-with/payment-paid-with.js +52 -52
  160. package/dist/payment-paid-with/payment-paid-with.repository.d.ts +5 -5
  161. package/dist/payment-paid-with/payment-paid-with.repository.js +11 -11
  162. package/dist/test-document.d.ts +3 -0
  163. package/dist/test-document.js +19 -0
  164. package/dist/test-document.js.map +1 -0
  165. package/dist/test.d.ts +1 -1
  166. package/dist/test.js +7 -7
  167. package/dist/tsconfig.tsbuildinfo +1 -1
  168. package/package.json +1 -1
  169. package/src/index.ts +2 -0
  170. package/src/payment-item/payment-item.ts +22 -1
  171. package/src/test-document.ts +25 -0
@@ -1,35 +1,35 @@
1
- import { AccountSystemEntity } from '../account-system-entity/account-system-entity';
2
- import AccountModel from '../models/account.entity';
3
- import { AccountRepository } from './account.repository';
4
- export default class Account extends AccountSystemEntity {
5
- AccountNo: string;
6
- ParentAccountNo?: string;
7
- Name: string;
8
- Description: string;
9
- AccountType: string;
10
- AccountSubtype: string;
11
- OwnerId: string;
12
- OwnerType: string;
13
- RelatedObjectId: string;
14
- RelatedObjectType: string;
15
- CreatedById: string;
16
- CreatedAt: Date;
17
- UpdatedById: string;
18
- UpdatedAt: Date;
19
- private static _RepositoryBase;
20
- private _DbTransaction;
21
- private _IsNewRecord;
22
- private get IsNewRecord();
23
- private set IsNewRecord(value);
24
- get RepositoryBase(): AccountRepository;
25
- get ObjectId(): string;
26
- get ObjectName(): string;
27
- get TableName(): string;
28
- constructor(dbTransaction?: any, accountNo?: string);
29
- private init;
30
- static initAccount(dbTransaction: any, accountNo: string): Promise<Account>;
31
- static initialize(): void;
32
- validateAccountValue(): void;
33
- isParentAccountExists(): boolean;
34
- save(CompanyId: string, AccSystemRefId: string, userId: string, dbTransaction?: any): Promise<AccountModel>;
35
- }
1
+ import { AccountSystemEntity } from '../account-system-entity/account-system-entity';
2
+ import AccountModel from '../models/account.entity';
3
+ import { AccountRepository } from './account.repository';
4
+ export default class Account extends AccountSystemEntity {
5
+ AccountNo: string;
6
+ ParentAccountNo?: string;
7
+ Name: string;
8
+ Description: string;
9
+ AccountType: string;
10
+ AccountSubtype: string;
11
+ OwnerId: string;
12
+ OwnerType: string;
13
+ RelatedObjectId: string;
14
+ RelatedObjectType: string;
15
+ CreatedById: string;
16
+ CreatedAt: Date;
17
+ UpdatedById: string;
18
+ UpdatedAt: Date;
19
+ private static _RepositoryBase;
20
+ private _DbTransaction;
21
+ private _IsNewRecord;
22
+ private get IsNewRecord();
23
+ private set IsNewRecord(value);
24
+ get RepositoryBase(): AccountRepository;
25
+ get ObjectId(): string;
26
+ get ObjectName(): string;
27
+ get TableName(): string;
28
+ constructor(dbTransaction?: any, accountNo?: string);
29
+ private init;
30
+ static initAccount(dbTransaction: any, accountNo: string): Promise<Account>;
31
+ static initialize(): void;
32
+ validateAccountValue(): void;
33
+ isParentAccountExists(): boolean;
34
+ save(CompanyId: string, AccSystemRefId: string, userId: string, dbTransaction?: any): Promise<AccountModel>;
35
+ }
@@ -1,232 +1,232 @@
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 general_1 = require("@tomei/general");
13
- const account_system_entity_1 = require("../account-system-entity/account-system-entity");
14
- const account_repository_1 = require("./account.repository");
15
- class Account extends account_system_entity_1.AccountSystemEntity {
16
- get IsNewRecord() {
17
- return this._IsNewRecord;
18
- }
19
- set IsNewRecord(record) {
20
- this._IsNewRecord = record;
21
- }
22
- get RepositoryBase() {
23
- return Account._RepositoryBase;
24
- }
25
- get ObjectId() {
26
- return this.AccountNo;
27
- }
28
- get ObjectName() {
29
- return this.Name;
30
- }
31
- get TableName() {
32
- return 'finance_Account';
33
- }
34
- constructor(dbTransaction, accountNo) {
35
- super();
36
- this.AccountNo = 'New';
37
- this.ParentAccountNo = '';
38
- this.Name = '';
39
- this.Description = '';
40
- this.AccountType = '';
41
- this.AccountSubtype = '';
42
- this.OwnerId = '';
43
- this.OwnerType = '';
44
- this.RelatedObjectId = '';
45
- this.RelatedObjectType = '';
46
- this.CreatedById = '';
47
- this.UpdatedById = '';
48
- this._IsNewRecord = true;
49
- if (dbTransaction) {
50
- this._DbTransaction = dbTransaction;
51
- }
52
- if (accountNo) {
53
- this.RepositoryBase.findOne({
54
- where: {
55
- AccountNo: accountNo,
56
- },
57
- transaction: dbTransaction,
58
- })
59
- .then((accountData) => {
60
- if (accountData) {
61
- this.IsNewRecord = false;
62
- this.CompanyId = accountData.CompanyId;
63
- this.ParentAccountNo = accountData.ParentAccountNo;
64
- this.Name = accountData.Name;
65
- this.Description = accountData.Description;
66
- this.AccountType = accountData.AccountType;
67
- this.AccountSubtype = accountData.AccountSubType;
68
- this.OwnerId = accountData.OwnerId;
69
- this.OwnerType = accountData.OwnerType;
70
- this.RelatedObjectId = accountData.RelatedObjectId;
71
- this.RelatedObjectType = accountData.RelatedObjectType;
72
- this.CreatedById = accountData.CreatedById;
73
- this.CreatedAt = accountData.CreatedAt;
74
- this.UpdatedById = accountData.UpdatedById;
75
- this.UpdatedAt = accountData.UpdatedAt;
76
- this.AccSystemRefId = accountData.AccSystemRefId;
77
- this.PostedToAccSystemYN = accountData.PostedToAccSystemYN;
78
- this.PostedById = accountData.PostedById;
79
- this.PostedDateTime = accountData.PostedDateTime;
80
- }
81
- else {
82
- const notFoundError = new general_1.RecordNotFoundError('No Record Found.');
83
- throw notFoundError;
84
- }
85
- })
86
- .catch((err) => {
87
- console.log('Account Class constructor err: ', err);
88
- });
89
- }
90
- }
91
- init(accountData) {
92
- this.IsNewRecord = false;
93
- this.CompanyId = accountData.CompanyId;
94
- this.ParentAccountNo = accountData.ParentAccountNo;
95
- this.Name = accountData.Name;
96
- this.Description = accountData.Description;
97
- this.AccountType = accountData.AccountType;
98
- this.AccountSubtype = accountData.AccountSubType;
99
- this.OwnerId = accountData.OwnerId;
100
- this.OwnerType = accountData.OwnerType;
101
- this.RelatedObjectId = accountData.RelatedObjectId;
102
- this.RelatedObjectType = accountData.RelatedObjectType;
103
- this.CreatedById = accountData.CreatedById;
104
- this.CreatedAt = accountData.CreatedAt;
105
- this.UpdatedById = accountData.UpdatedById;
106
- this.UpdatedAt = accountData.UpdatedAt;
107
- this.AccSystemRefId = accountData.AccSystemRefId;
108
- this.PostedToAccSystemYN = accountData.PostedToAccSystemYN;
109
- this.PostedById = accountData.PostedById;
110
- this.PostedDateTime = accountData.PostedDateTime;
111
- }
112
- static initAccount(dbTransaction, accountNo) {
113
- return __awaiter(this, void 0, void 0, function* () {
114
- try {
115
- const accountData = yield Account._RepositoryBase.findOne({
116
- where: {
117
- AccountNo: accountNo,
118
- },
119
- transaction: dbTransaction,
120
- });
121
- if (accountData) {
122
- const account = new Account(dbTransaction);
123
- account.init(accountData.get({ plain: true }));
124
- return account;
125
- }
126
- else {
127
- const notFoundError = new general_1.RecordNotFoundError('No Record Found.');
128
- throw notFoundError;
129
- }
130
- }
131
- catch (error) {
132
- console.log('Account Class constructor err: ', error);
133
- throw error;
134
- }
135
- });
136
- }
137
- static initialize() {
138
- const dbTransaction = null;
139
- let defaultAccountReceivable;
140
- let defaultAccountPayable;
141
- try {
142
- defaultAccountReceivable = new Account(dbTransaction, 'EZC-AR');
143
- }
144
- catch (err) {
145
- defaultAccountReceivable = new Account(dbTransaction);
146
- defaultAccountReceivable.AccountNo = null;
147
- defaultAccountReceivable.AccountType = 'Account Receivable';
148
- defaultAccountReceivable.OwnerId = 'System';
149
- defaultAccountReceivable.OwnerType = '';
150
- }
151
- try {
152
- defaultAccountPayable = new Account(dbTransaction, 'EZC-AP');
153
- }
154
- catch (err) {
155
- defaultAccountPayable = new Account(dbTransaction);
156
- defaultAccountPayable.AccountNo = null;
157
- defaultAccountPayable.AccountType = 'Account Payable';
158
- defaultAccountPayable.OwnerId = 'System';
159
- }
160
- }
161
- validateAccountValue() {
162
- if (!this.AccSystemRefId) {
163
- throw new Error('AccSystemAccountId is required.');
164
- }
165
- if (!this.AccountType) {
166
- throw new Error('AccountType is required.');
167
- }
168
- }
169
- isParentAccountExists() {
170
- if (this.ParentAccountNo)
171
- return true;
172
- return false;
173
- }
174
- save(CompanyId, AccSystemRefId, userId, dbTransaction) {
175
- return __awaiter(this, void 0, void 0, function* () {
176
- this.AccSystemRefId = AccSystemRefId;
177
- console.log('Account Save: Before AccountNo FindOne');
178
- let data = yield this.RepositoryBase.findOne({
179
- where: {
180
- AccountNo: this.AccountNo,
181
- },
182
- transaction: dbTransaction,
183
- });
184
- console.log('Account Save: After AccountNo FindOne');
185
- console.log(data, '<><><><><> Account Data Result <><><><><><>');
186
- if (data) {
187
- console.log('Account Save: THERE IS DATA FOUND');
188
- this.AccountNo = data.AccountNo;
189
- this.AccSystemRefId = data.AccSystemRefId;
190
- this.Name = data.Name;
191
- this.Description = data.Description;
192
- this.AccountType = data.AccountType;
193
- this.AccountSubtype = data.AccountSubType;
194
- this.CompanyId = data.CompanyId;
195
- this.OwnerId = data.OwnerId;
196
- this.OwnerType = data.OwnerType;
197
- this.RelatedObjectId = data.RelatedObjectId;
198
- this.RelatedObjectType = data.RelatedObjectType;
199
- this.PostedToAccSystemYN = data.PostedToAccSystemYN;
200
- this.CreatedAt = data.CreatedAt;
201
- this.CreatedById = data.CreatedById;
202
- }
203
- else {
204
- console.log('Account Save: THERE IS NO DATA FOUND');
205
- data = yield this.RepositoryBase.create({
206
- AccountNo: this.AccountNo,
207
- AccSystemRefId: this.AccSystemRefId,
208
- Name: this.Name,
209
- Description: this.Description,
210
- AccountType: this.AccountType,
211
- AccountSubtype: this.AccountSubtype,
212
- CompanyId: CompanyId,
213
- OwnerId: this.OwnerId,
214
- OwnerType: this.OwnerType,
215
- RelatedObjectId: this.RelatedObjectId,
216
- RelatedObjectType: this.RelatedObjectType,
217
- PostedToAccSystemYN: this.PostedToAccSystemYN,
218
- CreatedAt: new Date(),
219
- CreatedById: userId,
220
- }, {
221
- transaction: dbTransaction,
222
- });
223
- console.log(data, '<><><><><><><> DATA THAT GETS CREATED <><><><><><><>');
224
- }
225
- console.log(data, 'Account Save: Account details returned');
226
- return data;
227
- });
228
- }
229
- }
230
- exports.default = Account;
231
- Account._RepositoryBase = new account_repository_1.AccountRepository();
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 general_1 = require("@tomei/general");
13
+ const account_system_entity_1 = require("../account-system-entity/account-system-entity");
14
+ const account_repository_1 = require("./account.repository");
15
+ class Account extends account_system_entity_1.AccountSystemEntity {
16
+ get IsNewRecord() {
17
+ return this._IsNewRecord;
18
+ }
19
+ set IsNewRecord(record) {
20
+ this._IsNewRecord = record;
21
+ }
22
+ get RepositoryBase() {
23
+ return Account._RepositoryBase;
24
+ }
25
+ get ObjectId() {
26
+ return this.AccountNo;
27
+ }
28
+ get ObjectName() {
29
+ return this.Name;
30
+ }
31
+ get TableName() {
32
+ return 'finance_Account';
33
+ }
34
+ constructor(dbTransaction, accountNo) {
35
+ super();
36
+ this.AccountNo = 'New';
37
+ this.ParentAccountNo = '';
38
+ this.Name = '';
39
+ this.Description = '';
40
+ this.AccountType = '';
41
+ this.AccountSubtype = '';
42
+ this.OwnerId = '';
43
+ this.OwnerType = '';
44
+ this.RelatedObjectId = '';
45
+ this.RelatedObjectType = '';
46
+ this.CreatedById = '';
47
+ this.UpdatedById = '';
48
+ this._IsNewRecord = true;
49
+ if (dbTransaction) {
50
+ this._DbTransaction = dbTransaction;
51
+ }
52
+ if (accountNo) {
53
+ this.RepositoryBase.findOne({
54
+ where: {
55
+ AccountNo: accountNo,
56
+ },
57
+ transaction: dbTransaction,
58
+ })
59
+ .then((accountData) => {
60
+ if (accountData) {
61
+ this.IsNewRecord = false;
62
+ this.CompanyId = accountData.CompanyId;
63
+ this.ParentAccountNo = accountData.ParentAccountNo;
64
+ this.Name = accountData.Name;
65
+ this.Description = accountData.Description;
66
+ this.AccountType = accountData.AccountType;
67
+ this.AccountSubtype = accountData.AccountSubType;
68
+ this.OwnerId = accountData.OwnerId;
69
+ this.OwnerType = accountData.OwnerType;
70
+ this.RelatedObjectId = accountData.RelatedObjectId;
71
+ this.RelatedObjectType = accountData.RelatedObjectType;
72
+ this.CreatedById = accountData.CreatedById;
73
+ this.CreatedAt = accountData.CreatedAt;
74
+ this.UpdatedById = accountData.UpdatedById;
75
+ this.UpdatedAt = accountData.UpdatedAt;
76
+ this.AccSystemRefId = accountData.AccSystemRefId;
77
+ this.PostedToAccSystemYN = accountData.PostedToAccSystemYN;
78
+ this.PostedById = accountData.PostedById;
79
+ this.PostedDateTime = accountData.PostedDateTime;
80
+ }
81
+ else {
82
+ const notFoundError = new general_1.RecordNotFoundError('No Record Found.');
83
+ throw notFoundError;
84
+ }
85
+ })
86
+ .catch((err) => {
87
+ console.log('Account Class constructor err: ', err);
88
+ });
89
+ }
90
+ }
91
+ init(accountData) {
92
+ this.IsNewRecord = false;
93
+ this.CompanyId = accountData.CompanyId;
94
+ this.ParentAccountNo = accountData.ParentAccountNo;
95
+ this.Name = accountData.Name;
96
+ this.Description = accountData.Description;
97
+ this.AccountType = accountData.AccountType;
98
+ this.AccountSubtype = accountData.AccountSubType;
99
+ this.OwnerId = accountData.OwnerId;
100
+ this.OwnerType = accountData.OwnerType;
101
+ this.RelatedObjectId = accountData.RelatedObjectId;
102
+ this.RelatedObjectType = accountData.RelatedObjectType;
103
+ this.CreatedById = accountData.CreatedById;
104
+ this.CreatedAt = accountData.CreatedAt;
105
+ this.UpdatedById = accountData.UpdatedById;
106
+ this.UpdatedAt = accountData.UpdatedAt;
107
+ this.AccSystemRefId = accountData.AccSystemRefId;
108
+ this.PostedToAccSystemYN = accountData.PostedToAccSystemYN;
109
+ this.PostedById = accountData.PostedById;
110
+ this.PostedDateTime = accountData.PostedDateTime;
111
+ }
112
+ static initAccount(dbTransaction, accountNo) {
113
+ return __awaiter(this, void 0, void 0, function* () {
114
+ try {
115
+ const accountData = yield Account._RepositoryBase.findOne({
116
+ where: {
117
+ AccountNo: accountNo,
118
+ },
119
+ transaction: dbTransaction,
120
+ });
121
+ if (accountData) {
122
+ const account = new Account(dbTransaction);
123
+ account.init(accountData.get({ plain: true }));
124
+ return account;
125
+ }
126
+ else {
127
+ const notFoundError = new general_1.RecordNotFoundError('No Record Found.');
128
+ throw notFoundError;
129
+ }
130
+ }
131
+ catch (error) {
132
+ console.log('Account Class constructor err: ', error);
133
+ throw error;
134
+ }
135
+ });
136
+ }
137
+ static initialize() {
138
+ const dbTransaction = null;
139
+ let defaultAccountReceivable;
140
+ let defaultAccountPayable;
141
+ try {
142
+ defaultAccountReceivable = new Account(dbTransaction, 'EZC-AR');
143
+ }
144
+ catch (err) {
145
+ defaultAccountReceivable = new Account(dbTransaction);
146
+ defaultAccountReceivable.AccountNo = null;
147
+ defaultAccountReceivable.AccountType = 'Account Receivable';
148
+ defaultAccountReceivable.OwnerId = 'System';
149
+ defaultAccountReceivable.OwnerType = '';
150
+ }
151
+ try {
152
+ defaultAccountPayable = new Account(dbTransaction, 'EZC-AP');
153
+ }
154
+ catch (err) {
155
+ defaultAccountPayable = new Account(dbTransaction);
156
+ defaultAccountPayable.AccountNo = null;
157
+ defaultAccountPayable.AccountType = 'Account Payable';
158
+ defaultAccountPayable.OwnerId = 'System';
159
+ }
160
+ }
161
+ validateAccountValue() {
162
+ if (!this.AccSystemRefId) {
163
+ throw new Error('AccSystemAccountId is required.');
164
+ }
165
+ if (!this.AccountType) {
166
+ throw new Error('AccountType is required.');
167
+ }
168
+ }
169
+ isParentAccountExists() {
170
+ if (this.ParentAccountNo)
171
+ return true;
172
+ return false;
173
+ }
174
+ save(CompanyId, AccSystemRefId, userId, dbTransaction) {
175
+ return __awaiter(this, void 0, void 0, function* () {
176
+ this.AccSystemRefId = AccSystemRefId;
177
+ console.log('Account Save: Before AccountNo FindOne');
178
+ let data = yield this.RepositoryBase.findOne({
179
+ where: {
180
+ AccountNo: this.AccountNo,
181
+ },
182
+ transaction: dbTransaction,
183
+ });
184
+ console.log('Account Save: After AccountNo FindOne');
185
+ console.log(data, '<><><><><> Account Data Result <><><><><><>');
186
+ if (data) {
187
+ console.log('Account Save: THERE IS DATA FOUND');
188
+ this.AccountNo = data.AccountNo;
189
+ this.AccSystemRefId = data.AccSystemRefId;
190
+ this.Name = data.Name;
191
+ this.Description = data.Description;
192
+ this.AccountType = data.AccountType;
193
+ this.AccountSubtype = data.AccountSubType;
194
+ this.CompanyId = data.CompanyId;
195
+ this.OwnerId = data.OwnerId;
196
+ this.OwnerType = data.OwnerType;
197
+ this.RelatedObjectId = data.RelatedObjectId;
198
+ this.RelatedObjectType = data.RelatedObjectType;
199
+ this.PostedToAccSystemYN = data.PostedToAccSystemYN;
200
+ this.CreatedAt = data.CreatedAt;
201
+ this.CreatedById = data.CreatedById;
202
+ }
203
+ else {
204
+ console.log('Account Save: THERE IS NO DATA FOUND');
205
+ data = yield this.RepositoryBase.create({
206
+ AccountNo: this.AccountNo,
207
+ AccSystemRefId: this.AccSystemRefId,
208
+ Name: this.Name,
209
+ Description: this.Description,
210
+ AccountType: this.AccountType,
211
+ AccountSubtype: this.AccountSubtype,
212
+ CompanyId: CompanyId,
213
+ OwnerId: this.OwnerId,
214
+ OwnerType: this.OwnerType,
215
+ RelatedObjectId: this.RelatedObjectId,
216
+ RelatedObjectType: this.RelatedObjectType,
217
+ PostedToAccSystemYN: this.PostedToAccSystemYN,
218
+ CreatedAt: new Date(),
219
+ CreatedById: userId,
220
+ }, {
221
+ transaction: dbTransaction,
222
+ });
223
+ console.log(data, '<><><><><><><> DATA THAT GETS CREATED <><><><><><><>');
224
+ }
225
+ console.log(data, 'Account Save: Account details returned');
226
+ return data;
227
+ });
228
+ }
229
+ }
230
+ exports.default = Account;
231
+ Account._RepositoryBase = new account_repository_1.AccountRepository();
232
232
  //# sourceMappingURL=account.js.map
@@ -1,5 +1,5 @@
1
- import { RepositoryBase, IRepositoryBase } from '@tomei/general';
2
- import AccountModel from '../models/account.entity';
3
- export declare class AccountRepository extends RepositoryBase<AccountModel> implements IRepositoryBase<AccountModel> {
4
- constructor();
5
- }
1
+ import { RepositoryBase, IRepositoryBase } from '@tomei/general';
2
+ import AccountModel from '../models/account.entity';
3
+ export declare class AccountRepository extends RepositoryBase<AccountModel> implements IRepositoryBase<AccountModel> {
4
+ constructor();
5
+ }
@@ -1,12 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AccountRepository = void 0;
4
- const general_1 = require("@tomei/general");
5
- const account_entity_1 = require("../models/account.entity");
6
- class AccountRepository extends general_1.RepositoryBase {
7
- constructor() {
8
- super(account_entity_1.default);
9
- }
10
- }
11
- exports.AccountRepository = AccountRepository;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccountRepository = void 0;
4
+ const general_1 = require("@tomei/general");
5
+ const account_entity_1 = require("../models/account.entity");
6
+ class AccountRepository extends general_1.RepositoryBase {
7
+ constructor() {
8
+ super(account_entity_1.default);
9
+ }
10
+ }
11
+ exports.AccountRepository = AccountRepository;
12
12
  //# sourceMappingURL=account.repository.js.map
@@ -1,29 +1,29 @@
1
- import { ObjectBase, LoginUserBase } from '@tomei/general';
2
- export interface IAccountAttr {
3
- AccountNo: string;
4
- CompanyId: string;
5
- ParentAccountNo?: string;
6
- Name: string;
7
- Description?: string;
8
- AccountType: string;
9
- AccountSubType?: string;
10
- OwnerId?: string;
11
- OwnerType?: string;
12
- RelatedObjectId?: string;
13
- RelatedObjectType?: string;
14
- CreatedAt: Date;
15
- CreatedById: string;
16
- UpdatedAt?: Date;
17
- UpdatedById?: string;
18
- AccSystemRefId: string;
19
- PostedToAccSystemYN: string;
20
- PostedById?: string;
21
- PostedDateTime?: Date;
22
- }
23
- export interface ICreateAccountAttr {
24
- Owner: LoginUserBase;
25
- RelatedObject?: ObjectBase;
26
- AccountType?: string;
27
- AccountSubType?: string;
28
- ParentAccountNo?: string;
29
- }
1
+ import { ObjectBase, LoginUserBase } from '@tomei/general';
2
+ export interface IAccountAttr {
3
+ AccountNo: string;
4
+ CompanyId: string;
5
+ ParentAccountNo?: string;
6
+ Name: string;
7
+ Description?: string;
8
+ AccountType: string;
9
+ AccountSubType?: string;
10
+ OwnerId?: string;
11
+ OwnerType?: string;
12
+ RelatedObjectId?: string;
13
+ RelatedObjectType?: string;
14
+ CreatedAt: Date;
15
+ CreatedById: string;
16
+ UpdatedAt?: Date;
17
+ UpdatedById?: string;
18
+ AccSystemRefId: string;
19
+ PostedToAccSystemYN: string;
20
+ PostedById?: string;
21
+ PostedDateTime?: Date;
22
+ }
23
+ export interface ICreateAccountAttr {
24
+ Owner: LoginUserBase;
25
+ RelatedObject?: ObjectBase;
26
+ AccountType?: string;
27
+ AccountSubType?: string;
28
+ ParentAccountNo?: string;
29
+ }
@@ -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=account-attr.interface.js.map
@@ -0,0 +1,3 @@
1
+ import { IRepositoryBase } from '@tomei/general';
2
+ import AccountModel from '../../models/account.entity';
3
+ export type IAccountRepository = IRepositoryBase<AccountModel>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=account.repository.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.repository.interface.js","sourceRoot":"","sources":["../../../src/account/interfaces/account.repository.interface.ts"],"names":[],"mappings":""}