@tomei/finance 0.6.93 → 0.6.94

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomei/finance",
3
- "version": "0.6.93",
3
+ "version": "0.6.94",
4
4
  "description": "NestJS package for finance module",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -106,7 +106,7 @@ export default class Account extends AccountSystemEntity {
106
106
  }
107
107
  }
108
108
 
109
- private init(accountData: any) {
109
+ public init(accountData: any) {
110
110
  this.IsNewRecord = false;
111
111
  this.CompanyId = accountData.CompanyId;
112
112
  this.ParentAccountNo = accountData.ParentAccountNo;
@@ -342,6 +342,50 @@ export default class FinanceCompany extends ObjectBase {
342
342
  return FinanceCompany._htFinanceCompanies.get(companyId);
343
343
  }
344
344
 
345
+ static async findAccount(
346
+ loginUser: LoginUserBase,
347
+ dbTransaction: any,
348
+ accountNo: string,
349
+ ): Promise<Account> {
350
+ try {
351
+ //Part 1: Privilege Check
352
+ //Check if the user has the privilege to view the account
353
+ const systemCode =
354
+ ApplicationConfig.getComponentConfigValue('system-code');
355
+ const isPrivileged = await loginUser.checkPrivileges(
356
+ systemCode,
357
+ 'FINANCECOMPANY_VIEW_ACCOUNT',
358
+ );
359
+
360
+ //If the user is not privileged, throw an error
361
+ if (!isPrivileged) {
362
+ throw new ClassError(
363
+ 'FinanceCompany',
364
+ 'findAccountErrMsg0X',
365
+ 'User not privileged to view finance company account',
366
+ );
367
+ }
368
+
369
+ //Part 2: Find Account
370
+ //Find the account using the accountNo
371
+ const record = await FinanceCompany._AccountRepository.findOne({
372
+ where: {
373
+ AccountNo: accountNo,
374
+ },
375
+ transaction: dbTransaction,
376
+ });
377
+
378
+ if (record) {
379
+ const account = new Account(dbTransaction);
380
+ account.init(record.get({ plain: true }));
381
+ return account;
382
+ }
383
+ return undefined;
384
+ } catch (error) {
385
+ throw error;
386
+ }
387
+ }
388
+
345
389
  async createCustomer<T extends FinanceCustomerBase>(
346
390
  dbTransaction: any,
347
391
  custSystemCode: string,