@tomei/finance 0.6.52 → 0.6.54

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 (108) hide show
  1. package/.commitlintrc.json +22 -22
  2. package/.eslintrc.js +72 -72
  3. package/.husky/commit-msg +4 -4
  4. package/.husky/pre-commit +4 -4
  5. package/.prettierrc +4 -4
  6. package/CONTRIBUTING.md +30 -30
  7. package/LICENSE +21 -21
  8. package/README.md +13 -13
  9. package/configs/config.js +348 -348
  10. package/dist/enum/payment-status.enum.d.ts +3 -1
  11. package/dist/enum/payment-status.enum.js +3 -1
  12. package/dist/enum/payment-status.enum.js.map +1 -1
  13. package/dist/finance-company/finance-company.d.ts +3 -1
  14. package/dist/finance-company/finance-company.js +178 -177
  15. package/dist/finance-company/finance-company.js.map +1 -1
  16. package/dist/payment/payment.d.ts +2 -2
  17. package/dist/payment/payment.js +4 -4
  18. package/dist/payment/payment.js.map +1 -1
  19. package/dist/payment-item/payment-item.js +4 -4
  20. package/dist/tsconfig.tsbuildinfo +1 -1
  21. package/invoice-template/assets/css/style.css.map +12 -12
  22. package/invoice-template/assets/css/style.min.css +1 -1
  23. package/invoice-template/assets/img/arrow_bg.svg +11 -11
  24. package/invoice-template/assets/img/coffy_shop_img.svg +18 -18
  25. package/invoice-template/assets/img/logo_accent.svg +3 -3
  26. package/invoice-template/assets/img/logo_white.svg +4 -4
  27. package/invoice-template/assets/img/sign.svg +12 -12
  28. package/invoice-template/assets/img/tomei-logo.svg +9 -9
  29. package/invoice-template/assets/js/html2canvas.min.js +10379 -10379
  30. package/invoice-template/assets/js/jquery.min.js +1 -1
  31. package/invoice-template/assets/sass/common/_color_variable.scss +12 -12
  32. package/invoice-template/assets/sass/common/_typography.scss +178 -178
  33. package/invoice-template/assets/sass/style.scss +12 -12
  34. package/migrations/finance-account-migration.js +97 -97
  35. package/migrations/finance-company-migration.js +29 -29
  36. package/migrations/finance-customer-migration.js +51 -51
  37. package/migrations/finance-document-item-migration.js +111 -111
  38. package/migrations/finance-document-migration.js +122 -122
  39. package/migrations/finance-journal-entry-migration.js +59 -59
  40. package/migrations/finance-ledger-transaction-migration.js +89 -89
  41. package/migrations/finance-payment-item-migration.js +52 -52
  42. package/migrations/finance-payment-method-migration.js +31 -31
  43. package/migrations/finance-payment-method-type-migration.js +55 -55
  44. package/migrations/finance-payment-migration.js +96 -96
  45. package/migrations/finance-post-history-migration.js +45 -45
  46. package/migrations/finance-tax-migration.js +52 -52
  47. package/nest-cli.json +19 -19
  48. package/package.json +82 -82
  49. package/src/account/account.repository.ts +11 -11
  50. package/src/account/account.ts +276 -276
  51. package/src/account/interfaces/account-attr.interface.ts +31 -31
  52. package/src/account-system-entity/account-system-entity.ts +66 -66
  53. package/src/account-system-entity/post-history.repository.ts +11 -11
  54. package/src/config.ts +382 -382
  55. package/src/customer/customer.ts +300 -300
  56. package/src/customer/finance-customer.repository.ts +13 -13
  57. package/src/customer/interfaces/customer.repository.interface.ts +3 -3
  58. package/src/customer/interfaces/finance-customer-attr.interface.ts +10 -10
  59. package/src/customer/interfaces/finance-customer.repository.interface.ts +4 -4
  60. package/src/database.ts +48 -48
  61. package/src/document/document-item.repository.ts +11 -11
  62. package/src/document/document.repository.ts +11 -11
  63. package/src/document/interfaces/document-attr.interface.ts +28 -28
  64. package/src/document/interfaces/document-item-attr.interface.ts +22 -22
  65. package/src/document/interfaces/document-item.repository.interface.ts +4 -4
  66. package/src/enum/doc-type.enum.ts +8 -8
  67. package/src/enum/index.ts +17 -17
  68. package/src/enum/payment-method.enum.ts +3 -3
  69. package/src/enum/payment-status.enum.ts +3 -1
  70. package/src/enum/payment-type.enum.ts +4 -4
  71. package/src/enum/quick-book-client-scopes.enum.ts +14 -14
  72. package/src/finance-company/finance-company.repository.ts +11 -11
  73. package/src/finance-company/finance-company.ts +2176 -2094
  74. package/src/helpers/login-user.ts +38 -38
  75. package/src/helpers/typeof.ts +35 -35
  76. package/src/index.ts +32 -32
  77. package/src/interfaces/account-system.interface.ts +20 -20
  78. package/src/interfaces/index.ts +3 -3
  79. package/src/models/account.entity.ts +206 -206
  80. package/src/models/customer.entity.ts +93 -93
  81. package/src/models/document-item.entity.ts +143 -143
  82. package/src/models/document.entity.ts +211 -211
  83. package/src/models/finance-company.entity.ts +29 -29
  84. package/src/models/journal-entry.entity.ts +110 -110
  85. package/src/models/ledger-transaction.entity.ts +148 -148
  86. package/src/models/payment-item.entity.ts +60 -60
  87. package/src/models/payment-method-type.entity.ts +70 -70
  88. package/src/models/payment-method.entity.ts +51 -51
  89. package/src/models/payment.entity.ts +165 -165
  90. package/src/models/post-history.entity.ts +41 -41
  91. package/src/models/tax.entity.ts +75 -75
  92. package/src/payment/interfaces/payment-attr.interface.ts +23 -23
  93. package/src/payment/interfaces/payment-params.interface.ts +8 -8
  94. package/src/payment/payment.repository.ts +11 -11
  95. package/src/payment/payment.ts +240 -236
  96. package/src/payment-item/interfaces/payment-item-attr.interface.ts +10 -10
  97. package/src/payment-item/payment-item.repository.ts +11 -11
  98. package/src/payment-item/payment-item.ts +133 -133
  99. package/src/payment-method/payment-method.repository.ts +11 -11
  100. package/src/payment-method-type/payment-method-type.repository.ts +11 -11
  101. package/src/tax/interfaces/tax-attr.interface.ts +10 -10
  102. package/src/tax/tax.repository.ts +11 -11
  103. package/src/tax/tax.ts +61 -61
  104. package/src/test-document.ts +25 -25
  105. package/src/test.ts +3 -3
  106. package/tsconfig.build.json +4 -4
  107. package/tsconfig.json +22 -22
  108. package/tslint.json +18 -18
@@ -1,276 +1,276 @@
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.CreatedAt = data.CreatedAt;
242
- this.CreatedById = data.CreatedById;
243
- this.UpdatedAt = new Date();
244
- } else {
245
- console.log('Account Save: THERE IS NO DATA FOUND');
246
-
247
- data = await this.RepositoryBase.create(
248
- {
249
- AccountNo: this.AccountNo,
250
- AccSystemRefId: this.AccSystemRefId,
251
- Name: this.Name,
252
- Description: this.Description,
253
- AccountType: this.AccountType,
254
- AccountSubtype: this.AccountSubtype,
255
- CompanyId: CompanyId,
256
- OwnerId: this.OwnerId,
257
- OwnerType: this.OwnerType,
258
- RelatedObjectId: this.RelatedObjectId,
259
- RelatedObjectType: this.RelatedObjectType,
260
- PostedToAccSystemYN: this.PostedToAccSystemYN,
261
- CreatedAt: new Date(),
262
- UpdatedAt: new Date(),
263
- CreatedById: userId,
264
- },
265
- {
266
- transaction: dbTransaction,
267
- },
268
- );
269
- console.log(data, '<><><><><><><> DATA THAT GETS CREATED <><><><><><><>');
270
- }
271
-
272
- console.log(data, 'Account Save: Account details returned');
273
-
274
- return data;
275
- }
276
- }
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.CreatedAt = data.CreatedAt;
242
+ this.CreatedById = data.CreatedById;
243
+ this.UpdatedAt = new Date();
244
+ } else {
245
+ console.log('Account Save: THERE IS NO DATA FOUND');
246
+
247
+ data = await this.RepositoryBase.create(
248
+ {
249
+ AccountNo: this.AccountNo,
250
+ AccSystemRefId: this.AccSystemRefId,
251
+ Name: this.Name,
252
+ Description: this.Description,
253
+ AccountType: this.AccountType,
254
+ AccountSubtype: this.AccountSubtype,
255
+ CompanyId: CompanyId,
256
+ OwnerId: this.OwnerId,
257
+ OwnerType: this.OwnerType,
258
+ RelatedObjectId: this.RelatedObjectId,
259
+ RelatedObjectType: this.RelatedObjectType,
260
+ PostedToAccSystemYN: this.PostedToAccSystemYN,
261
+ CreatedAt: new Date(),
262
+ UpdatedAt: new Date(),
263
+ CreatedById: userId,
264
+ },
265
+ {
266
+ transaction: dbTransaction,
267
+ },
268
+ );
269
+ console.log(data, '<><><><><><><> DATA THAT GETS CREATED <><><><><><><>');
270
+ }
271
+
272
+ console.log(data, 'Account Save: Account details returned');
273
+
274
+ return data;
275
+ }
276
+ }
@@ -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
+ }