@tomei/finance 0.6.89 → 0.6.90

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 (112) hide show
  1. package/.commitlintrc.json +22 -22
  2. package/.eslintrc.js +72 -72
  3. package/.gitlab-ci.yml +16 -16
  4. package/.husky/commit-msg +4 -4
  5. package/.husky/pre-commit +4 -4
  6. package/.prettierrc +4 -4
  7. package/CONTRIBUTING.md +30 -30
  8. package/LICENSE +21 -21
  9. package/README.md +13 -13
  10. package/configs/config.js +348 -348
  11. package/dist/customer/customer.js +7 -1
  12. package/dist/customer/customer.js.map +1 -1
  13. package/dist/document/document.d.ts +1 -0
  14. package/dist/document/document.js +14 -0
  15. package/dist/document/document.js.map +1 -1
  16. package/dist/finance-company/finance-company.d.ts +1 -1
  17. package/dist/finance-company/finance-company.js +29 -8
  18. package/dist/finance-company/finance-company.js.map +1 -1
  19. package/dist/interfaces/account-system.interface.d.ts +15 -10
  20. package/dist/payment-item/payment-item.js +4 -4
  21. package/dist/tsconfig.tsbuildinfo +1 -1
  22. package/invoice-template/assets/css/style.css.map +12 -12
  23. package/invoice-template/assets/css/style.min.css +1 -1
  24. package/invoice-template/assets/img/arrow_bg.svg +11 -11
  25. package/invoice-template/assets/img/coffy_shop_img.svg +18 -18
  26. package/invoice-template/assets/img/logo_accent.svg +3 -3
  27. package/invoice-template/assets/img/logo_white.svg +4 -4
  28. package/invoice-template/assets/img/sign.svg +12 -12
  29. package/invoice-template/assets/img/tomei-logo.svg +9 -9
  30. package/invoice-template/assets/js/html2canvas.min.js +10379 -10379
  31. package/invoice-template/assets/js/jquery.min.js +1 -1
  32. package/invoice-template/assets/sass/common/_color_variable.scss +12 -12
  33. package/invoice-template/assets/sass/common/_typography.scss +178 -178
  34. package/invoice-template/assets/sass/style.scss +12 -12
  35. package/migrations/finance-account-migration.js +97 -97
  36. package/migrations/finance-company-migration.js +29 -29
  37. package/migrations/finance-customer-migration.js +51 -51
  38. package/migrations/finance-document-item-migration.js +111 -111
  39. package/migrations/finance-document-migration.js +122 -122
  40. package/migrations/finance-journal-entry-migration.js +59 -59
  41. package/migrations/finance-ledger-transaction-migration.js +89 -89
  42. package/migrations/finance-payment-item-migration.js +52 -52
  43. package/migrations/finance-payment-method-migration.js +31 -31
  44. package/migrations/finance-payment-method-type-migration.js +55 -55
  45. package/migrations/finance-payment-migration.js +96 -96
  46. package/migrations/finance-post-history-migration.js +45 -45
  47. package/migrations/finance-tax-migration.js +52 -52
  48. package/migrations/refactor-finance-document-migration.js +71 -71
  49. package/nest-cli.json +19 -19
  50. package/package.json +82 -82
  51. package/sonar-project.properties +12 -12
  52. package/src/account/account.repository.ts +11 -11
  53. package/src/account/account.ts +278 -278
  54. package/src/account/interfaces/account-attr.interface.ts +31 -31
  55. package/src/account-system-entity/account-system-entity.ts +66 -66
  56. package/src/account-system-entity/post-history.repository.ts +11 -11
  57. package/src/config.ts +382 -382
  58. package/src/customer/customer.ts +309 -305
  59. package/src/customer/finance-customer.repository.ts +13 -13
  60. package/src/customer/interfaces/customer.repository.interface.ts +3 -3
  61. package/src/customer/interfaces/finance-customer-attr.interface.ts +10 -10
  62. package/src/customer/interfaces/finance-customer.repository.interface.ts +4 -4
  63. package/src/database.ts +48 -48
  64. package/src/document/document-item.repository.ts +11 -11
  65. package/src/document/document.repository.ts +11 -11
  66. package/src/document/document.ts +15 -0
  67. package/src/document/interfaces/document-attr.interface.ts +28 -28
  68. package/src/document/interfaces/document-item-attr.interface.ts +22 -22
  69. package/src/document/interfaces/document-item.repository.interface.ts +4 -4
  70. package/src/enum/collect-payment-type.ts +3 -3
  71. package/src/enum/doc-type.enum.ts +8 -8
  72. package/src/enum/index.ts +19 -19
  73. package/src/enum/payment-method.enum.ts +3 -3
  74. package/src/enum/payment-type.enum.ts +4 -4
  75. package/src/enum/quick-book-client-scopes.enum.ts +14 -14
  76. package/src/finance-company/finance-company.repository.ts +11 -11
  77. package/src/finance-company/finance-company.ts +2331 -2310
  78. package/src/helpers/login-user.ts +38 -38
  79. package/src/helpers/typeof.ts +35 -35
  80. package/src/index.ts +32 -32
  81. package/src/interfaces/account-system.interface.ts +30 -23
  82. package/src/interfaces/index.ts +3 -3
  83. package/src/models/account.entity.ts +206 -206
  84. package/src/models/customer.entity.ts +93 -93
  85. package/src/models/document-item.entity.ts +143 -143
  86. package/src/models/document.entity.ts +211 -211
  87. package/src/models/finance-company.entity.ts +69 -69
  88. package/src/models/journal-entry.entity.ts +110 -110
  89. package/src/models/ledger-transaction.entity.ts +148 -148
  90. package/src/models/payment-item.entity.ts +60 -60
  91. package/src/models/payment-method-type.entity.ts +70 -70
  92. package/src/models/payment-method.entity.ts +51 -51
  93. package/src/models/payment.entity.ts +165 -165
  94. package/src/models/post-history.entity.ts +41 -41
  95. package/src/models/tax.entity.ts +75 -75
  96. package/src/payment/interfaces/payment-attr.interface.ts +23 -23
  97. package/src/payment/interfaces/payment-params.interface.ts +8 -8
  98. package/src/payment/payment.repository.ts +11 -11
  99. package/src/payment/payment.ts +236 -236
  100. package/src/payment-item/interfaces/payment-item-attr.interface.ts +10 -10
  101. package/src/payment-item/payment-item.repository.ts +11 -11
  102. package/src/payment-item/payment-item.ts +134 -134
  103. package/src/payment-method/payment-method.repository.ts +11 -11
  104. package/src/payment-method-type/payment-method-type.repository.ts +11 -11
  105. package/src/tax/interfaces/tax-attr.interface.ts +10 -10
  106. package/src/tax/tax.repository.ts +11 -11
  107. package/src/tax/tax.ts +69 -69
  108. package/src/test-document.ts +25 -25
  109. package/src/test.ts +3 -3
  110. package/tsconfig.build.json +4 -4
  111. package/tsconfig.json +22 -22
  112. package/tslint.json +18 -18
@@ -1,278 +1,278 @@
1
- import { RecordNotFoundError } from '@tomei/general/dist/class/exceptions/record-not-found.error';
2
- import { AccountSystemEntity } from '../account-system-entity/account-system-entity';
3
- import AccountModel from '../models/account.entity';
4
- import { AccountRepository } from './account.repository';
5
-
6
- // eslint-disable-next-line @typescript-eslint/no-var-requires
7
- // const getConfig = require('../config');
8
-
9
- export default class Account extends AccountSystemEntity {
10
- AccountNo = 'New';
11
- ParentAccountNo? = '';
12
- Name = '';
13
- Description = '';
14
- AccountType = '';
15
- AccountSubtype = '';
16
- OwnerId = '';
17
- OwnerType = '';
18
- RelatedObjectId = '';
19
- RelatedObjectType = '';
20
- CreatedById = '';
21
- CreatedAt: Date;
22
- UpdatedById = '';
23
- UpdatedAt: Date;
24
- protected _ObjectType = 'Account';
25
-
26
- private static _RepositoryBase = new AccountRepository();
27
-
28
- private _DbTransaction: any;
29
- private _IsNewRecord = true;
30
-
31
- private get IsNewRecord() {
32
- return this._IsNewRecord;
33
- }
34
-
35
- private set IsNewRecord(record: boolean) {
36
- this._IsNewRecord = record;
37
- }
38
-
39
- get ObjectType() {
40
- return this._ObjectType;
41
- }
42
-
43
- /* AccountSystemEntity Implementation */
44
- get RepositoryBase() {
45
- return Account._RepositoryBase;
46
- }
47
-
48
- /* ObjectBase Implementation */
49
- get ObjectId() {
50
- return this.AccountNo;
51
- }
52
-
53
- get ObjectName() {
54
- return this.Name;
55
- }
56
-
57
- get TableName() {
58
- return 'finance_Account';
59
- }
60
-
61
- constructor(dbTransaction?: any, accountNo?: string) {
62
- super();
63
- if (dbTransaction) {
64
- this._DbTransaction = dbTransaction;
65
- }
66
- if (accountNo) {
67
- this.RepositoryBase.findOne({
68
- where: {
69
- AccountNo: accountNo,
70
- },
71
- transaction: dbTransaction,
72
- })
73
- .then((accountData) => {
74
- if (accountData) {
75
- this.IsNewRecord = false;
76
- this.CompanyId = accountData.CompanyId;
77
- this.ParentAccountNo = accountData.ParentAccountNo;
78
- this.Name = accountData.Name;
79
- this.Description = accountData.Description;
80
- this.AccountType = accountData.AccountType;
81
- this.AccountSubtype = accountData.AccountSubType;
82
- this.OwnerId = accountData.OwnerId;
83
- this.OwnerType = accountData.OwnerType;
84
- this.RelatedObjectId = accountData.RelatedObjectId;
85
- this.RelatedObjectType = accountData.RelatedObjectType;
86
- this.CreatedById = accountData.CreatedById;
87
- this.CreatedAt = accountData.CreatedAt;
88
- this.UpdatedById = accountData.UpdatedById;
89
- this.UpdatedAt = accountData.UpdatedAt;
90
- this.AccSystemRefId = accountData.AccSystemRefId;
91
- this.PostedToAccSystemYN = accountData.PostedToAccSystemYN;
92
- this.PostedById = accountData.PostedById;
93
- this.PostedDateTime = accountData.PostedDateTime;
94
- } else {
95
- const notFoundError = new RecordNotFoundError(
96
- 'AccountErrMsg',
97
- 'No Record Found.',
98
- );
99
- throw notFoundError;
100
- }
101
- })
102
- .catch((err) => {
103
- // tslint:disable-next-line:no-console
104
- console.log('Account Class constructor err: ', err);
105
- });
106
- }
107
- }
108
-
109
- private init(accountData: any) {
110
- this.IsNewRecord = false;
111
- this.CompanyId = accountData.CompanyId;
112
- this.ParentAccountNo = accountData.ParentAccountNo;
113
- this.Name = accountData.Name;
114
- this.Description = accountData.Description;
115
- this.AccountType = accountData.AccountType;
116
- this.AccountSubtype = accountData.AccountSubType;
117
- this.OwnerId = accountData.OwnerId;
118
- this.OwnerType = accountData.OwnerType;
119
- this.RelatedObjectId = accountData.RelatedObjectId;
120
- this.RelatedObjectType = accountData.RelatedObjectType;
121
- this.CreatedById = accountData.CreatedById;
122
- this.CreatedAt = accountData.CreatedAt;
123
- this.UpdatedById = accountData.UpdatedById;
124
- this.UpdatedAt = accountData.UpdatedAt;
125
- this.AccSystemRefId = accountData.AccSystemRefId;
126
- this.PostedToAccSystemYN = accountData.PostedToAccSystemYN;
127
- this.PostedById = accountData.PostedById;
128
- this.PostedDateTime = accountData.PostedDateTime;
129
- }
130
-
131
- static async initAccount(
132
- dbTransaction: any,
133
- accountNo: string,
134
- ): Promise<Account> {
135
- try {
136
- const accountData = await Account._RepositoryBase.findOne({
137
- where: {
138
- AccountNo: accountNo,
139
- },
140
- transaction: dbTransaction,
141
- });
142
- if (accountData) {
143
- const account = new Account(dbTransaction);
144
- account.init(accountData.get({ plain: true }));
145
- return account;
146
- } else {
147
- const notFoundError = new RecordNotFoundError(
148
- 'AccountErrMsg',
149
- 'No Record Found.',
150
- );
151
- throw notFoundError;
152
- }
153
- } catch (error) {
154
- console.log('Account Class constructor err: ', error);
155
- throw error;
156
- }
157
- }
158
-
159
- /**
160
- * Account static constructor
161
- *
162
- * Create the Customer Account Receivable (AR) and Customer Account Payable (AP) default accounts.
163
- * The static constructor is to run once each time the program loads and check if the default accounts have been created.
164
- * If it has not, it will create the accounts.
165
- */
166
- static initialize(): void {
167
- const dbTransaction = null;
168
- let defaultAccountReceivable: Account;
169
- let defaultAccountPayable: Account;
170
-
171
- // const config = getConfig();
172
- // config.systemConfig['EZC']
173
-
174
- try {
175
- defaultAccountReceivable = new Account(dbTransaction, 'EZC-AR');
176
- } catch (err) {
177
- defaultAccountReceivable = new Account(dbTransaction);
178
- defaultAccountReceivable.AccountNo = null;
179
- defaultAccountReceivable.AccountType = 'Account Receivable';
180
- defaultAccountReceivable.OwnerId = 'System';
181
- defaultAccountReceivable.OwnerType = '';
182
- }
183
-
184
- try {
185
- defaultAccountPayable = new Account(dbTransaction, 'EZC-AP');
186
- } catch (err) {
187
- defaultAccountPayable = new Account(dbTransaction);
188
- defaultAccountPayable.AccountNo = null;
189
- defaultAccountPayable.AccountType = 'Account Payable';
190
- defaultAccountPayable.OwnerId = 'System';
191
- }
192
- }
193
-
194
- validateAccountValue() {
195
- if (!this.AccSystemRefId) {
196
- throw new Error('AccSystemAccountId is required.');
197
- }
198
- if (!this.AccountType) {
199
- throw new Error('AccountType is required.');
200
- }
201
- }
202
-
203
- isParentAccountExists() {
204
- if (this.ParentAccountNo) return true;
205
- return false;
206
- }
207
-
208
- async save(
209
- CompanyId: string,
210
- AccSystemRefId: string,
211
- userId: string,
212
- dbTransaction?: any,
213
- ): Promise<AccountModel> {
214
- this.AccSystemRefId = AccSystemRefId;
215
- console.log('Account Save: Before AccountNo FindOne');
216
-
217
- let data = await this.RepositoryBase.findOne({
218
- where: {
219
- AccountNo: this.AccountNo,
220
- },
221
- transaction: dbTransaction,
222
- });
223
- console.log('Account Save: After AccountNo FindOne');
224
- console.log(data, '<><><><><> Account Data Result <><><><><><>');
225
-
226
- if (data) {
227
- console.log('Account Save: THERE IS DATA FOUND');
228
-
229
- this.AccountNo = data.AccountNo;
230
- this.AccSystemRefId = data.AccSystemRefId;
231
- this.Name = data.Name;
232
- this.Description = data.Description;
233
- this.AccountType = data.AccountType;
234
- this.AccountSubtype = data.AccountSubType;
235
- this.CompanyId = data.CompanyId;
236
- this.OwnerId = data.OwnerId;
237
- this.OwnerType = data.OwnerType;
238
- this.RelatedObjectId = data.RelatedObjectId;
239
- this.RelatedObjectType = data.RelatedObjectType;
240
- this.PostedToAccSystemYN = data.PostedToAccSystemYN;
241
- this.ParentAccountNo = data.ParentAccountNo;
242
- this.CreatedAt = data.CreatedAt;
243
- this.CreatedById = data.CreatedById;
244
- this.UpdatedAt = new Date();
245
- } else {
246
- console.log('Account Save: THERE IS NO DATA FOUND');
247
-
248
- data = await this.RepositoryBase.create(
249
- {
250
- AccountNo: this.AccountNo,
251
- AccSystemRefId: this.AccSystemRefId,
252
- Name: this.Name,
253
- Description: this.Description,
254
- AccountType: this.AccountType,
255
- AccountSubtype: this.AccountSubtype,
256
- CompanyId: CompanyId,
257
- OwnerId: this.OwnerId,
258
- OwnerType: this.OwnerType,
259
- RelatedObjectId: this.RelatedObjectId,
260
- RelatedObjectType: this.RelatedObjectType,
261
- PostedToAccSystemYN: this.PostedToAccSystemYN,
262
- ParentAccountNo: this.ParentAccountNo,
263
- CreatedAt: new Date(),
264
- UpdatedAt: new Date(),
265
- CreatedById: userId,
266
- },
267
- {
268
- transaction: dbTransaction,
269
- },
270
- );
271
- console.log(data, '<><><><><><><> DATA THAT GETS CREATED <><><><><><><>');
272
- }
273
-
274
- console.log(data, 'Account Save: Account details returned');
275
-
276
- return data;
277
- }
278
- }
1
+ import { RecordNotFoundError } from '@tomei/general/dist/class/exceptions/record-not-found.error';
2
+ import { AccountSystemEntity } from '../account-system-entity/account-system-entity';
3
+ import AccountModel from '../models/account.entity';
4
+ import { AccountRepository } from './account.repository';
5
+
6
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
7
+ // const getConfig = require('../config');
8
+
9
+ export default class Account extends AccountSystemEntity {
10
+ AccountNo = 'New';
11
+ ParentAccountNo? = '';
12
+ Name = '';
13
+ Description = '';
14
+ AccountType = '';
15
+ AccountSubtype = '';
16
+ OwnerId = '';
17
+ OwnerType = '';
18
+ RelatedObjectId = '';
19
+ RelatedObjectType = '';
20
+ CreatedById = '';
21
+ CreatedAt: Date;
22
+ UpdatedById = '';
23
+ UpdatedAt: Date;
24
+ protected _ObjectType = 'Account';
25
+
26
+ private static _RepositoryBase = new AccountRepository();
27
+
28
+ private _DbTransaction: any;
29
+ private _IsNewRecord = true;
30
+
31
+ private get IsNewRecord() {
32
+ return this._IsNewRecord;
33
+ }
34
+
35
+ private set IsNewRecord(record: boolean) {
36
+ this._IsNewRecord = record;
37
+ }
38
+
39
+ get ObjectType() {
40
+ return this._ObjectType;
41
+ }
42
+
43
+ /* AccountSystemEntity Implementation */
44
+ get RepositoryBase() {
45
+ return Account._RepositoryBase;
46
+ }
47
+
48
+ /* ObjectBase Implementation */
49
+ get ObjectId() {
50
+ return this.AccountNo;
51
+ }
52
+
53
+ get ObjectName() {
54
+ return this.Name;
55
+ }
56
+
57
+ get TableName() {
58
+ return 'finance_Account';
59
+ }
60
+
61
+ constructor(dbTransaction?: any, accountNo?: string) {
62
+ super();
63
+ if (dbTransaction) {
64
+ this._DbTransaction = dbTransaction;
65
+ }
66
+ if (accountNo) {
67
+ this.RepositoryBase.findOne({
68
+ where: {
69
+ AccountNo: accountNo,
70
+ },
71
+ transaction: dbTransaction,
72
+ })
73
+ .then((accountData) => {
74
+ if (accountData) {
75
+ this.IsNewRecord = false;
76
+ this.CompanyId = accountData.CompanyId;
77
+ this.ParentAccountNo = accountData.ParentAccountNo;
78
+ this.Name = accountData.Name;
79
+ this.Description = accountData.Description;
80
+ this.AccountType = accountData.AccountType;
81
+ this.AccountSubtype = accountData.AccountSubType;
82
+ this.OwnerId = accountData.OwnerId;
83
+ this.OwnerType = accountData.OwnerType;
84
+ this.RelatedObjectId = accountData.RelatedObjectId;
85
+ this.RelatedObjectType = accountData.RelatedObjectType;
86
+ this.CreatedById = accountData.CreatedById;
87
+ this.CreatedAt = accountData.CreatedAt;
88
+ this.UpdatedById = accountData.UpdatedById;
89
+ this.UpdatedAt = accountData.UpdatedAt;
90
+ this.AccSystemRefId = accountData.AccSystemRefId;
91
+ this.PostedToAccSystemYN = accountData.PostedToAccSystemYN;
92
+ this.PostedById = accountData.PostedById;
93
+ this.PostedDateTime = accountData.PostedDateTime;
94
+ } else {
95
+ const notFoundError = new RecordNotFoundError(
96
+ 'AccountErrMsg',
97
+ 'No Record Found.',
98
+ );
99
+ throw notFoundError;
100
+ }
101
+ })
102
+ .catch((err) => {
103
+ // tslint:disable-next-line:no-console
104
+ console.log('Account Class constructor err: ', err);
105
+ });
106
+ }
107
+ }
108
+
109
+ private init(accountData: any) {
110
+ this.IsNewRecord = false;
111
+ this.CompanyId = accountData.CompanyId;
112
+ this.ParentAccountNo = accountData.ParentAccountNo;
113
+ this.Name = accountData.Name;
114
+ this.Description = accountData.Description;
115
+ this.AccountType = accountData.AccountType;
116
+ this.AccountSubtype = accountData.AccountSubType;
117
+ this.OwnerId = accountData.OwnerId;
118
+ this.OwnerType = accountData.OwnerType;
119
+ this.RelatedObjectId = accountData.RelatedObjectId;
120
+ this.RelatedObjectType = accountData.RelatedObjectType;
121
+ this.CreatedById = accountData.CreatedById;
122
+ this.CreatedAt = accountData.CreatedAt;
123
+ this.UpdatedById = accountData.UpdatedById;
124
+ this.UpdatedAt = accountData.UpdatedAt;
125
+ this.AccSystemRefId = accountData.AccSystemRefId;
126
+ this.PostedToAccSystemYN = accountData.PostedToAccSystemYN;
127
+ this.PostedById = accountData.PostedById;
128
+ this.PostedDateTime = accountData.PostedDateTime;
129
+ }
130
+
131
+ static async initAccount(
132
+ dbTransaction: any,
133
+ accountNo: string,
134
+ ): Promise<Account> {
135
+ try {
136
+ const accountData = await Account._RepositoryBase.findOne({
137
+ where: {
138
+ AccountNo: accountNo,
139
+ },
140
+ transaction: dbTransaction,
141
+ });
142
+ if (accountData) {
143
+ const account = new Account(dbTransaction);
144
+ account.init(accountData.get({ plain: true }));
145
+ return account;
146
+ } else {
147
+ const notFoundError = new RecordNotFoundError(
148
+ 'AccountErrMsg',
149
+ 'No Record Found.',
150
+ );
151
+ throw notFoundError;
152
+ }
153
+ } catch (error) {
154
+ console.log('Account Class constructor err: ', error);
155
+ throw error;
156
+ }
157
+ }
158
+
159
+ /**
160
+ * Account static constructor
161
+ *
162
+ * Create the Customer Account Receivable (AR) and Customer Account Payable (AP) default accounts.
163
+ * The static constructor is to run once each time the program loads and check if the default accounts have been created.
164
+ * If it has not, it will create the accounts.
165
+ */
166
+ static initialize(): void {
167
+ const dbTransaction = null;
168
+ let defaultAccountReceivable: Account;
169
+ let defaultAccountPayable: Account;
170
+
171
+ // const config = getConfig();
172
+ // config.systemConfig['EZC']
173
+
174
+ try {
175
+ defaultAccountReceivable = new Account(dbTransaction, 'EZC-AR');
176
+ } catch (err) {
177
+ defaultAccountReceivable = new Account(dbTransaction);
178
+ defaultAccountReceivable.AccountNo = null;
179
+ defaultAccountReceivable.AccountType = 'Account Receivable';
180
+ defaultAccountReceivable.OwnerId = 'System';
181
+ defaultAccountReceivable.OwnerType = '';
182
+ }
183
+
184
+ try {
185
+ defaultAccountPayable = new Account(dbTransaction, 'EZC-AP');
186
+ } catch (err) {
187
+ defaultAccountPayable = new Account(dbTransaction);
188
+ defaultAccountPayable.AccountNo = null;
189
+ defaultAccountPayable.AccountType = 'Account Payable';
190
+ defaultAccountPayable.OwnerId = 'System';
191
+ }
192
+ }
193
+
194
+ validateAccountValue() {
195
+ if (!this.AccSystemRefId) {
196
+ throw new Error('AccSystemAccountId is required.');
197
+ }
198
+ if (!this.AccountType) {
199
+ throw new Error('AccountType is required.');
200
+ }
201
+ }
202
+
203
+ isParentAccountExists() {
204
+ if (this.ParentAccountNo) return true;
205
+ return false;
206
+ }
207
+
208
+ async save(
209
+ CompanyId: string,
210
+ AccSystemRefId: string,
211
+ userId: string,
212
+ dbTransaction?: any,
213
+ ): Promise<AccountModel> {
214
+ this.AccSystemRefId = AccSystemRefId;
215
+ console.log('Account Save: Before AccountNo FindOne');
216
+
217
+ let data = await this.RepositoryBase.findOne({
218
+ where: {
219
+ AccountNo: this.AccountNo,
220
+ },
221
+ transaction: dbTransaction,
222
+ });
223
+ console.log('Account Save: After AccountNo FindOne');
224
+ console.log(data, '<><><><><> Account Data Result <><><><><><>');
225
+
226
+ if (data) {
227
+ console.log('Account Save: THERE IS DATA FOUND');
228
+
229
+ this.AccountNo = data.AccountNo;
230
+ this.AccSystemRefId = data.AccSystemRefId;
231
+ this.Name = data.Name;
232
+ this.Description = data.Description;
233
+ this.AccountType = data.AccountType;
234
+ this.AccountSubtype = data.AccountSubType;
235
+ this.CompanyId = data.CompanyId;
236
+ this.OwnerId = data.OwnerId;
237
+ this.OwnerType = data.OwnerType;
238
+ this.RelatedObjectId = data.RelatedObjectId;
239
+ this.RelatedObjectType = data.RelatedObjectType;
240
+ this.PostedToAccSystemYN = data.PostedToAccSystemYN;
241
+ this.ParentAccountNo = data.ParentAccountNo;
242
+ this.CreatedAt = data.CreatedAt;
243
+ this.CreatedById = data.CreatedById;
244
+ this.UpdatedAt = new Date();
245
+ } else {
246
+ console.log('Account Save: THERE IS NO DATA FOUND');
247
+
248
+ data = await this.RepositoryBase.create(
249
+ {
250
+ AccountNo: this.AccountNo,
251
+ AccSystemRefId: this.AccSystemRefId,
252
+ Name: this.Name,
253
+ Description: this.Description,
254
+ AccountType: this.AccountType,
255
+ AccountSubtype: this.AccountSubtype,
256
+ CompanyId: CompanyId,
257
+ OwnerId: this.OwnerId,
258
+ OwnerType: this.OwnerType,
259
+ RelatedObjectId: this.RelatedObjectId,
260
+ RelatedObjectType: this.RelatedObjectType,
261
+ PostedToAccSystemYN: this.PostedToAccSystemYN,
262
+ ParentAccountNo: this.ParentAccountNo,
263
+ CreatedAt: new Date(),
264
+ UpdatedAt: new Date(),
265
+ CreatedById: userId,
266
+ },
267
+ {
268
+ transaction: dbTransaction,
269
+ },
270
+ );
271
+ console.log(data, '<><><><><><><> DATA THAT GETS CREATED <><><><><><><>');
272
+ }
273
+
274
+ console.log(data, 'Account Save: Account details returned');
275
+
276
+ return data;
277
+ }
278
+ }
@@ -1,31 +1,31 @@
1
- import { ObjectBase, LoginUserBase } from '@tomei/general';
2
-
3
- export interface IAccountAttr {
4
- AccountNo: string;
5
- CompanyId: 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
- CreatedAt: Date;
16
- CreatedById: string;
17
- UpdatedAt?: Date;
18
- UpdatedById?: string;
19
- AccSystemRefId: string;
20
- PostedToAccSystemYN: string;
21
- PostedById?: string;
22
- PostedDateTime?: Date;
23
- }
24
-
25
- export interface ICreateAccountAttr {
26
- Owner: LoginUserBase;
27
- RelatedObject?: ObjectBase;
28
- AccountType?: string;
29
- AccountSubType?: string;
30
- ParentAccountNo?: string;
31
- }
1
+ import { ObjectBase, LoginUserBase } from '@tomei/general';
2
+
3
+ export interface IAccountAttr {
4
+ AccountNo: string;
5
+ CompanyId: 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
+ CreatedAt: Date;
16
+ CreatedById: string;
17
+ UpdatedAt?: Date;
18
+ UpdatedById?: string;
19
+ AccSystemRefId: string;
20
+ PostedToAccSystemYN: string;
21
+ PostedById?: string;
22
+ PostedDateTime?: Date;
23
+ }
24
+
25
+ export interface ICreateAccountAttr {
26
+ Owner: LoginUserBase;
27
+ RelatedObject?: ObjectBase;
28
+ AccountType?: string;
29
+ AccountSubType?: string;
30
+ ParentAccountNo?: string;
31
+ }