@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,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