@tomei/finance 0.4.3 → 0.4.5

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.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "NestJS package for finance module",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -303,13 +303,21 @@ export default class Document extends AccountSystemEntity {
303
303
 
304
304
  /* todo: needs to generate HTML first before converting to PDF */
305
305
  const templateLocation = path.resolve('./invoice-template/index.html');
306
+ const cssLocation = path.resolve('./invoice-template/assets/css/style.css');
306
307
  const readFileContent = util.promisify(fs.readFile);
307
- const htmlString = await readFileContent(templateLocation, 'utf8');
308
+ // const htmlString = await readFileContent(templateLocation, 'utf8');
309
+ const [htmlString, cssString] = await Promise.all([
310
+ readFileContent(templateLocation, 'utf8'),
311
+ readFileContent(cssLocation, 'utf8'),
312
+ ]);
308
313
 
309
314
  /* converting HTML to PDF */
310
315
  const browser = await puppeteer.launch();
311
316
  const page = await browser.newPage();
312
317
 
318
+ /* include the CSS from the HTML directory */
319
+ await page.addStyleTag({ content: cssString });
320
+
313
321
  if (htmlString) {
314
322
  await page.setContent(htmlString);
315
323
  } else if (templateLocation) {
@@ -1322,6 +1322,7 @@ export default class FinanceCompany extends ObjectBase {
1322
1322
  payment.PaymentId = cuid();
1323
1323
  payment.PaymentType = PaymentType.PAYOUT;
1324
1324
  payment.ReceivedBy = loginUser.ObjectId;
1325
+ payment.IssuedBy = loginUser.ObjectId;
1325
1326
 
1326
1327
  await FinanceCompany._PaymentRepository.create(
1327
1328
  {
@@ -1408,6 +1409,8 @@ export default class FinanceCompany extends ObjectBase {
1408
1409
  creditLT.Date = transactionDate;
1409
1410
  creditLT.Description = customer.FullName;
1410
1411
  creditLT.Name = customer.FullName;
1412
+ creditLT.RelatedObjectId = payment.RelatedObjectId;
1413
+ creditLT.RelatedObjectType = payment.RelatedObjectType;
1411
1414
 
1412
1415
  const debitLT = await journalEntry.newLedgerTransaction(
1413
1416
  TransactionTypeOptions.DEBIT,
@@ -1422,6 +1425,8 @@ export default class FinanceCompany extends ObjectBase {
1422
1425
  debitLT.Date = transactionDate;
1423
1426
  debitLT.Description = paymentMethodType.Name;
1424
1427
  debitLT.Name = paymentMethodType.Name;
1428
+ debitLT.RelatedObjectId = payment.RelatedObjectId;
1429
+ debitLT.RelatedObjectType = payment.RelatedObjectType;
1425
1430
 
1426
1431
  await this.postJournal(dbTransaction, journalEntry, loginUser);
1427
1432
  } catch (error) {