@tomei/finance 0.3.7 → 0.3.9

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.3.7",
3
+ "version": "0.3.9",
4
4
  "description": "NestJS package for finance module",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -46,33 +46,35 @@ export default abstract class FinanceCustomerBase
46
46
  RepositoryBase: IRepositoryBase<any>;
47
47
 
48
48
  constructor(
49
- custSystemRefId: string,
50
- custSystemCode: string,
51
- sFinanceCompanyId: string,
49
+ custSystemRefId?: string,
50
+ custSystemCode?: string,
51
+ sFinanceCompanyId?: string,
52
52
  ) {
53
53
  super();
54
- const financeCustomerData =
55
- FinanceCustomerBase._FinanceCustomerRepository.findOne({
56
- where: {
57
- CompanyId: sFinanceCompanyId,
58
- CustSystemCode: custSystemCode,
59
- CustSystemRefId: custSystemRefId,
60
- },
61
- });
62
- if (financeCustomerData) {
63
- this.CompanyId = sFinanceCompanyId;
64
- this.CustSystemCode = custSystemCode;
65
- this.CustSystemRefId = custSystemRefId;
66
- } else {
67
- const notFoundError = new RecordNotFoundError('No Record Found');
68
- throw notFoundError;
54
+ if (custSystemRefId && custSystemCode && sFinanceCompanyId) {
55
+ const financeCustomerData =
56
+ FinanceCustomerBase._FinanceCustomerRepository.findOne({
57
+ where: {
58
+ CompanyId: sFinanceCompanyId,
59
+ CustSystemCode: custSystemCode,
60
+ CustSystemRefId: custSystemRefId,
61
+ },
62
+ });
63
+ if (financeCustomerData) {
64
+ this.CompanyId = sFinanceCompanyId;
65
+ this.CustSystemCode = custSystemCode;
66
+ this.CustSystemRefId = custSystemRefId;
67
+ } else {
68
+ const notFoundError = new RecordNotFoundError('No Record Found');
69
+ throw notFoundError;
70
+ }
69
71
  }
70
72
  }
71
73
 
72
74
  /*
73
75
  * Get the billing address for a person.
74
76
  **/
75
- abstract getBillingAddress(): Promise<IAddress>;
77
+ abstract getBillingAddress(params: any): Promise<IAddress>;
76
78
 
77
79
  init(person: LoginUserBase) {
78
80
  this.FullName = person.FullName;
@@ -85,8 +87,12 @@ export default abstract class FinanceCustomerBase
85
87
 
86
88
  async save(
87
89
  customerId: string,
90
+ custSystemCode: string,
91
+ custSystemRefId: string,
88
92
  dbTransaction?: any,
89
93
  ): Promise<FinanceCustomerModel> {
94
+ this.CustSystemCode = custSystemCode;
95
+ this.CustSystemRefId = custSystemRefId;
90
96
  const data = await FinanceCustomerBase._FinanceCustomerRepository.create(
91
97
  {
92
98
  CustomerId: customerId,
@@ -39,7 +39,7 @@ export default class FinanceCompany extends ObjectBase {
39
39
  private static _FinanceCustomerRepository = new FinanceCustomerRepository();
40
40
  private static _LedgerTransactionRepository =
41
41
  new LedgerTransactionRepository();
42
- AccountingSystem: IAccountSystem;
42
+ private _AccountingSystem: IAccountSystem;
43
43
 
44
44
  get CompSystemCode(): string {
45
45
  return this._CompSystemCode;
@@ -85,6 +85,14 @@ export default class FinanceCompany extends ObjectBase {
85
85
  return 'finance_Company';
86
86
  }
87
87
 
88
+ get AccountingSystem(): IAccountSystem {
89
+ return this._AccountingSystem;
90
+ }
91
+
92
+ set AccountingSystem(system: IAccountSystem) {
93
+ this._AccountingSystem = system;
94
+ }
95
+
88
96
  constructor(
89
97
  compSystemCode: string,
90
98
  compSystemRefId: string,
@@ -165,6 +173,7 @@ export default class FinanceCompany extends ObjectBase {
165
173
 
166
174
  /*Retrieve and store the CompanyId from the result*/
167
175
  financeCompany.ObjectId = company.CompanyId;
176
+ financeCompany._CompanyId = company.CompanyId;
168
177
 
169
178
  /*Add the details into the hashtable*/
170
179
  const sKey = `${compSystemCode}-${compSystemRefId}-${accSystemCode}`;
@@ -249,11 +258,9 @@ export default class FinanceCompany extends ObjectBase {
249
258
  const financeCustomerData =
250
259
  await FinanceCompany._FinanceCustomerRepository.findOne({
251
260
  where: {
252
- /*todo:verify SystemCode*/
253
- // SystemCode: this.SystemCode,
254
- AccSystemCode: this.AccSystemCode,
255
- AccSystemCustomerId: custSystemCode,
256
- CustomerRefId: custSystemRefId,
261
+ CompanyId: this._CompanyId,
262
+ CustSystemCode: custSystemCode,
263
+ CustSystemRefId: custSystemRefId,
257
264
  },
258
265
  });
259
266
 
@@ -266,7 +273,12 @@ export default class FinanceCompany extends ObjectBase {
266
273
  customer,
267
274
  });
268
275
 
269
- const newCustomer = await customer.save(customerId, dbTransaction);
276
+ const newCustomer = await customer.save(
277
+ customerId,
278
+ custSystemCode,
279
+ custSystemRefId,
280
+ dbTransaction,
281
+ );
270
282
 
271
283
  const payload = {
272
284
  Action: 'Create',