@tomei/finance 0.6.8 → 0.6.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.6.8",
3
+ "version": "0.6.9",
4
4
  "description": "NestJS package for finance module",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -131,57 +131,36 @@ export default class Document extends AccountSystemEntity {
131
131
  return 'finance_Document';
132
132
  }
133
133
 
134
- constructor(dbTransaction?: any, docNo?: string) {
134
+ constructor(dbTransaction?: any, documentData?: any) {
135
135
  super();
136
136
  if (dbTransaction) {
137
137
  this._DbTransaction = dbTransaction;
138
138
  }
139
- if (docNo) {
140
- this.DocNo = docNo;
141
- this.RepositoryBase.findOne({
142
- where: {
143
- DocNo: this.DocNo,
144
- },
145
- transaction: dbTransaction,
146
- })
147
- .then((documentData) => {
148
- if (documentData) {
149
- this.DocType = documentData.DocType;
150
- this.DocDate = documentData.DocDate;
151
- this.CompanyId = documentData.CompanyId;
152
- this.Currency = documentData.Currency;
153
- this.Amount = documentData.Amount;
154
- this.Description = documentData.Description;
155
- this.Status = documentData.Status;
156
- this.IssuedById = documentData.IssuedById;
157
- this.IssuedToId = documentData.IssuedToId;
158
- this.IssuedToType = documentData.IssuedToType;
159
- this.RelatedObjectId = documentData.RelatedObjectId;
160
- this.RelatedObjectType = documentData.RelatedObjectType;
161
- this.CreatedById = documentData.CreatedById;
162
- this.CreatedAt = documentData.CreatedAt;
163
- this.UpdatedById = documentData.UpdatedById;
164
- this.UpdatedAt = documentData.UpdatedAt;
165
- this.DocPDFFileMediaId = documentData.DocPDFFileMediaId;
166
- this.DocHTMLFileMediaId = documentData.DocHTMLFileMediaId;
167
- this.AccSystemRefId = documentData.AccSystemRefId;
168
- this.PostedToAccSystemYN = documentData.PostedToAccSystemYN;
169
- this.PostedById = documentData.PostedById;
170
- this.PostedDateTime = documentData.PostedDateTime;
171
- this.UseAccSystemDocYN = documentData.UseAccSystemDocYN;
172
- this.IsNewRecord = false;
173
- } else {
174
- const notFoundError = new RecordNotFoundError(
175
- 'FinanceDocumentErrMsg',
176
- 'No Record Found.',
177
- );
178
- throw notFoundError;
179
- }
180
- })
181
- .catch((err) => {
182
- // tslint:disable-next-line:no-console
183
- console.log('Document Class constructor err: ', err);
184
- });
139
+ if (documentData) {
140
+ this.DocType = documentData.DocType;
141
+ this.DocDate = documentData.DocDate;
142
+ this.CompanyId = documentData.CompanyId;
143
+ this.Currency = documentData.Currency;
144
+ this.Amount = documentData.Amount;
145
+ this.Description = documentData.Description;
146
+ this.Status = documentData.Status;
147
+ this.IssuedById = documentData.IssuedById;
148
+ this.IssuedToId = documentData.IssuedToId;
149
+ this.IssuedToType = documentData.IssuedToType;
150
+ this.RelatedObjectId = documentData.RelatedObjectId;
151
+ this.RelatedObjectType = documentData.RelatedObjectType;
152
+ this.CreatedById = documentData.CreatedById;
153
+ this.CreatedAt = documentData.CreatedAt;
154
+ this.UpdatedById = documentData.UpdatedById;
155
+ this.UpdatedAt = documentData.UpdatedAt;
156
+ this.DocPDFFileMediaId = documentData.DocPDFFileMediaId;
157
+ this.DocHTMLFileMediaId = documentData.DocHTMLFileMediaId;
158
+ this.AccSystemRefId = documentData.AccSystemRefId;
159
+ this.PostedToAccSystemYN = documentData.PostedToAccSystemYN;
160
+ this.PostedById = documentData.PostedById;
161
+ this.PostedDateTime = documentData.PostedDateTime;
162
+ this.UseAccSystemDocYN = documentData.UseAccSystemDocYN;
163
+ this.IsNewRecord = false;
185
164
  }
186
165
  }
187
166
 
@@ -214,7 +193,6 @@ export default class Document extends AccountSystemEntity {
214
193
 
215
194
  public static async initDocument(dbTransaction: any, docNo: string) {
216
195
  try {
217
- const document = new Document(dbTransaction);
218
196
  const documentData = await this._RepositoryBase.findOne({
219
197
  where: {
220
198
  DocNo: docNo,
@@ -226,31 +204,34 @@ export default class Document extends AccountSystemEntity {
226
204
  ],
227
205
  });
228
206
  if (documentData) {
229
- document.DocNo = documentData.DocNo;
230
- document.DocType = documentData.DocType;
231
- document.DocDate = documentData.DocDate;
232
- document.CompanyId = documentData.CompanyId;
233
- document.Currency = documentData.Currency;
234
- document.Amount = documentData.Amount;
235
- document.Description = documentData.Description;
236
- document.Status = documentData.Status;
237
- document.IssuedById = documentData.IssuedById;
238
- document.IssuedToId = documentData.IssuedToId;
239
- document.IssuedToType = documentData.IssuedToType;
240
- document.RelatedObjectId = documentData.RelatedObjectId;
241
- document.RelatedObjectType = documentData.RelatedObjectType;
242
- document.CreatedById = documentData.CreatedById;
243
- document.CreatedAt = documentData.CreatedAt;
244
- document.UpdatedById = documentData.UpdatedById;
245
- document.UpdatedAt = documentData.UpdatedAt;
246
- document.DocPDFFileMediaId = documentData.DocPDFFileMediaId;
247
- document.DocHTMLFileMediaId = documentData.DocHTMLFileMediaId;
248
- document.AccSystemRefId = documentData.AccSystemRefId;
249
- document.PostedToAccSystemYN = documentData.PostedToAccSystemYN;
250
- document.PostedById = documentData.PostedById;
251
- document.PostedDateTime = documentData.PostedDateTime;
252
- document.UseAccSystemDocYN = documentData.UseAccSystemDocYN;
253
- document.IsNewRecord = false;
207
+ const document = new Document(dbTransaction, {
208
+ DocNo: documentData.DocNo,
209
+ DocType: documentData.DocType,
210
+ CompanyId: documentData.CompanyId,
211
+ DocDate: documentData.DocDate,
212
+ Currency: documentData.Currency,
213
+ Amount: documentData.Amount,
214
+ Description: documentData.Description,
215
+ Status: documentData.Status,
216
+ IssuedById: documentData.IssuedById,
217
+ IssuedToId: documentData.IssuedToId,
218
+ IssuedToType: documentData.IssuedToType,
219
+ RelatedObjectId: documentData.RelatedObjectId,
220
+ RelatedObjectType: documentData.RelatedObjectType,
221
+ CreatedById: documentData.CreatedById,
222
+ CreatedAt: documentData.CreatedAt,
223
+ UpdatedById: documentData.UpdatedById,
224
+ UpdatedAt: documentData.UpdatedAt,
225
+ DocPDFFileMediaId: documentData.DocPDFFileMediaId,
226
+ DocHTMLFileMediaId: documentData.DocHTMLFileMediaId,
227
+ AccSystemRefId: documentData.AccSystemRefId,
228
+ PostedToAccSystemYN: documentData.PostedToAccSystemYN,
229
+ PostedById: documentData.PostedById,
230
+ PostedDateTime: documentData.PostedDateTime,
231
+ UseAccSystemDocYN: documentData.UseAccSystemDocYN,
232
+ });
233
+
234
+ return document;
254
235
  } else {
255
236
  const notFoundError = new ClassError(
256
237
  'Document',
@@ -260,7 +241,6 @@ export default class Document extends AccountSystemEntity {
260
241
 
261
242
  throw notFoundError;
262
243
  }
263
- return documentData;
264
244
  } catch (error) {
265
245
  throw error;
266
246
  }