gemcap-be-common 1.3.146 → 1.3.147

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/db/new-summary.js CHANGED
@@ -222,19 +222,19 @@ class NewSummaryExcel {
222
222
  if (product.deactivationDate) {
223
223
  continue;
224
224
  }
225
- if ((0, dayjs_1.default)(product.payoffDate).isBefore((0, dayjs_1.default)(periodEnd))) {
225
+ if ((0, dayjs_1.default)(product.payoffDate).utc().isBefore((0, dayjs_1.default)(periodEnd).utc())) {
226
226
  periodEnd = product.payoffDate;
227
227
  }
228
- const daysHeld = (0, dayjs_1.default)(periodEnd).diff((0, dayjs_1.default)(product.startDate), 'day');
228
+ const daysHeld = (0, dayjs_1.default)(periodEnd).utc().diff((0, dayjs_1.default)(product.startDate).utc(), 'day');
229
229
  const lastTransaction = await (0, loan_transactions_db_1.getLastTransactionForDate)(product._id.toString(), periodEnd);
230
230
  const endingBalance = lastTransaction ? lastTransaction.balance : 0;
231
231
  const endingParticipationBalance = await this.loanChargesService.getParticipationBalance(product.code, end);
232
232
  const netExposure = new decimal_js_1.default(endingBalance).sub(endingParticipationBalance).toNumber();
233
233
  const lastSignedBBC = await this.signsService.getLatestSignedBBCDate(borrowerId, periodEnd);
234
- const lastSignedBBCDate = lastSignedBBC ? (0, dayjs_1.default)(lastSignedBBC.bbcDate).format(dateFormat) : '';
234
+ const lastSignedBBCDate = lastSignedBBC ? (0, dayjs_1.default)(lastSignedBBC.bbcDate).utc().format(dateFormat) : '';
235
235
  const averageBalanceSinceInception = new decimal_js_1.default(await (0, loan_products_db_1.getAverageActualBalance)(product._id.toString(), {
236
- start: (0, dayjs_1.default)(product.startDate),
237
- end: (0, dayjs_1.default)(periodEnd),
236
+ start: (0, dayjs_1.default)(product.startDate).utc(),
237
+ end: (0, dayjs_1.default)(periodEnd).utc(),
238
238
  })).toDP(2).toNumber();
239
239
  const totalIncomeReceived = await this.getPaidAmount(product._id.toString());
240
240
  const MOIC = averageBalanceSinceInception ? new decimal_js_1.default(totalIncomeReceived).add(Math.abs(averageBalanceSinceInception)).div(Math.abs(averageBalanceSinceInception)).toDP(2).toNumber() : 0;
@@ -243,8 +243,8 @@ class NewSummaryExcel {
243
243
  const newDataRow = {
244
244
  borrowerName: borrower.name,
245
245
  productName: product.name,
246
- maturityDate: product.maturityDate ? (0, dayjs_1.default)(product.maturityDate).format(dateFormat) : '',
247
- payOffDate: product.payoffDate ? (0, dayjs_1.default)(product.payoffDate).format(dateFormat) : '',
246
+ maturityDate: product.maturityDate ? (0, dayjs_1.default)(product.maturityDate).utc().format(dateFormat) : '',
247
+ payOffDate: product.payoffDate ? (0, dayjs_1.default)(product.payoffDate).utc().format(dateFormat) : '',
248
248
  commitmentAmount: product.commitment,
249
249
  endingBalance,
250
250
  endingParticipationBalance,
@@ -277,8 +277,8 @@ class NewSummaryExcel {
277
277
  });
278
278
  const reportPeriod = [
279
279
  [{ v: 'Report period', t: 's' }],
280
- [{ v: 'From', t: 's' }, { v: (0, dayjs_1.default)(start).utcOffset(0).format(dateFormat), t: 's' }],
281
- [{ v: 'To', t: 's' }, { v: (0, dayjs_1.default)(end).utcOffset(0).format(dateFormat), t: 's' }],
280
+ [{ v: 'From', t: 's' }, { v: (0, dayjs_1.default)(start).utc().format(dateFormat), t: 's' }],
281
+ [{ v: 'To', t: 's' }, { v: (0, dayjs_1.default)(end).utc().format(dateFormat), t: 's' }],
282
282
  ];
283
283
  return { report: [...reportPeriod, emptyRow, headerWithStyles, ...dataWithStyles] };
284
284
  }
@@ -338,7 +338,7 @@ class NewSummaryExcel {
338
338
  t: 's',
339
339
  s: rightAlign,
340
340
  }], []);
341
- const lastBBC = await (0, bbcDates_db_1.getLatestSignedBBCDateDoc)(borrowerId, (0, dayjs_1.default)(end).endOf('day').toDate());
341
+ const lastBBC = await (0, bbcDates_db_1.getLatestSignedBBCDateDoc)(borrowerId, (0, dayjs_1.default)(end).utc().endOf('day').toDate());
342
342
  if (!lastBBC) {
343
343
  return null;
344
344
  }
@@ -515,8 +515,8 @@ class NewSummaryExcel {
515
515
  .filter((product) => product.borrowerId.toString() === borrowerId)
516
516
  .sort((a, b) => (a.type > b.type ? 1 : -1));
517
517
  for (const product of borrowerProducts) {
518
- const month = (0, dayjs_1.default)(end).month() + 1;
519
- const year = (0, dayjs_1.default)(end).year();
518
+ const month = (0, dayjs_1.default)(end).utc().month() + 1;
519
+ const year = (0, dayjs_1.default)(end).utc().year();
520
520
  const monthEndData = await this.monthEndDataService.getMonthEndData(product._id.toString(), year, month);
521
521
  const productType = product.type[0].toUpperCase() + product.type.slice(1).toLowerCase();
522
522
  const dataToShow = {
@@ -648,7 +648,7 @@ class NewSummaryExcel {
648
648
  }]);
649
649
  }
650
650
  const dataDeep = 5;
651
- const periodEnd = { month: (0, dayjs_1.default)(start).month() + 1, year: (0, dayjs_1.default)(start).year() };
651
+ const periodEnd = { month: (0, dayjs_1.default)(start).utc().month() + 1, year: (0, dayjs_1.default)(start).utc().year() };
652
652
  const periodStart = (0, financial_spreading_service_1.getShiftedMonth)(periodEnd, -dataDeep);
653
653
  const monthHeader = [];
654
654
  const months = [];
@@ -659,17 +659,17 @@ class NewSummaryExcel {
659
659
  t: 's',
660
660
  s: { alignment: { horizontal: 'right' } },
661
661
  });
662
- months.push((0, dayjs_1.default)(`${currentMonth.year}-${currentMonth.month}-01`).format('YYYY-MM'));
662
+ months.push((0, dayjs_1.default)(`${currentMonth.year}-${currentMonth.month}-01`).utc().format('YYYY-MM'));
663
663
  }
664
664
  loanEconomicsData.push(emptyRow);
665
665
  loanEconomicsData.push([{ v: '' }, ...monthHeader]);
666
666
  const transactions = await this.loanTransactionsService.getLoanTransactions({
667
667
  borrowerId,
668
668
  productId: product._id.toString(),
669
- periodStart: (0, dayjs_1.default)(`${periodStart.year}-${periodStart.month}-01`).utcOffset(0).toDate(),
669
+ periodStart: (0, dayjs_1.default)(`${periodStart.year}-${periodStart.month}-01`).utc().toDate(),
670
670
  periodEnd: end,
671
671
  }, null, false);
672
- const grouped = lodash_1.default.groupBy(transactions, (tx) => (0, dayjs_1.default)(tx.date).format('YYYY-MM'));
672
+ const grouped = lodash_1.default.groupBy(transactions, (tx) => (0, dayjs_1.default)(tx.date).utc().format('YYYY-MM'));
673
673
  const yieldData = await this.yieldService.getCalculatedYieldTotalsForPeriod(product._id.toString(), periodStart, periodEnd);
674
674
  const yieldDataSorted = yieldData.slice().sort((a, b) => {
675
675
  if (a.year !== b.year) {
@@ -722,7 +722,7 @@ class NewSummaryExcel {
722
722
  });
723
723
  if (totalType === yield_service_1.ETotalType.AVERAGE_BALANCE) {
724
724
  const loanTurn = totalYieldData.reduce((acc, yieldDataDoc) => {
725
- const monthStart = (0, dayjs_1.default)(`${yieldDataDoc.year}-${yieldDataDoc.month}-01`).utcOffset(0);
725
+ const monthStart = (0, dayjs_1.default)(`${yieldDataDoc.year}-${yieldDataDoc.month}-01`).utc();
726
726
  const daysInMonth = monthStart.daysInMonth();
727
727
  const txs = grouped[monthStart.format('YYYY-MM')] ?? [];
728
728
  const collections = txs.filter((t) => t.transactionType === LoanTransaction_model_1.ELoanTransactionTypes.COLLECTION);
@@ -762,31 +762,29 @@ class NewSummaryExcel {
762
762
  const loanEconomicsData = await getLoanEconomics();
763
763
  // FINANCIAL
764
764
  const getFinancialDate = async (endDate) => {
765
- const month = (0, dayjs_1.default)(endDate).utcOffset(0).month();
766
- const year = (0, dayjs_1.default)(endDate).utcOffset(0).year();
765
+ const month = (0, dayjs_1.default)(endDate).utc().month();
766
+ const year = (0, dayjs_1.default)(endDate).utc().year();
767
767
  const monthDeep = 11;
768
- const currentMonth = (0, dayjs_1.default)(endDate).utcOffset(0).month() + 1;
769
- const currentYear = (0, dayjs_1.default)(endDate).utcOffset(0).year();
770
768
  const { data: ytdDataPL } = await this.financialSpreadingService.getFinancialSpreadingData({
771
769
  borrowerId,
772
770
  financialSpreadingType: FinancialSpreadingSheet_model_1.EFinancialSpreadingType.PROFIT_LOSS,
773
- selectedMonth: { year: currentYear, month },
774
- }, currentMonth - 2); // jan to current
771
+ selectedMonth: { year: year, month },
772
+ }, month);
775
773
  const { data: ytdDataBS } = await this.financialSpreadingService.getFinancialSpreadingData({
776
774
  borrowerId,
777
775
  financialSpreadingType: FinancialSpreadingSheet_model_1.EFinancialSpreadingType.BALANCE_SHEET,
778
- selectedMonth: { year: currentYear, month },
779
- }, currentMonth - 2); // jan to current
776
+ selectedMonth: { year: year, month },
777
+ }, month);
780
778
  const { data: lyYtdDataPL } = await this.financialSpreadingService.getFinancialSpreadingData({
781
779
  borrowerId,
782
780
  financialSpreadingType: FinancialSpreadingSheet_model_1.EFinancialSpreadingType.PROFIT_LOSS,
783
- selectedMonth: { year: currentYear - 1, month },
784
- }, currentMonth - 2);
781
+ selectedMonth: { year: year - 1, month },
782
+ }, month);
785
783
  const { data: lyYtdDataBS } = await this.financialSpreadingService.getFinancialSpreadingData({
786
784
  borrowerId,
787
785
  financialSpreadingType: FinancialSpreadingSheet_model_1.EFinancialSpreadingType.BALANCE_SHEET,
788
- selectedMonth: { year: currentYear - 1, month },
789
- }, currentMonth - 2);
786
+ selectedMonth: { year: year - 1, month },
787
+ }, month);
790
788
  const ytdData = [...ytdDataPL, ...ytdDataBS];
791
789
  const lyYtdData = [...lyYtdDataPL, ...lyYtdDataBS];
792
790
  const { data: dataPL, sheets: sheetsPL } = await this.financialSpreadingService.getFinancialSpreadingData({
@@ -802,12 +800,12 @@ class NewSummaryExcel {
802
800
  const { data: sameMonthLastYearPL, sheets: sameMonthLastYearSheetsPL, } = await this.financialSpreadingService.getFinancialSpreadingData({
803
801
  borrowerId,
804
802
  financialSpreadingType: FinancialSpreadingSheet_model_1.EFinancialSpreadingType.PROFIT_LOSS,
805
- selectedMonth: { year: currentYear - 1, month },
803
+ selectedMonth: { year: year - 1, month },
806
804
  }, 0);
807
805
  const { data: sameMonthLastYearBS, sheets: sameMonthLastYearSheetsBS, } = await this.financialSpreadingService.getFinancialSpreadingData({
808
806
  borrowerId,
809
807
  financialSpreadingType: FinancialSpreadingSheet_model_1.EFinancialSpreadingType.BALANCE_SHEET,
810
- selectedMonth: { year: currentYear - 1, month },
808
+ selectedMonth: { year: year - 1, month },
811
809
  }, 0);
812
810
  const data = [
813
811
  ...dataPL,
@@ -822,8 +820,10 @@ class NewSummaryExcel {
822
820
  ...sameMonthLastYearSheetsBS,
823
821
  ];
824
822
  const generateMonthCells = () => {
825
- const current = (0, dayjs_1.default)(`${year}-${String(month).padStart(2, '0')}-01`);
823
+ const current = (0, dayjs_1.default)(`${year}-${String(month + 1).padStart(2, '0')}-01`).utc();
826
824
  const sameMonthLastYear = current.subtract(1, 'year');
825
+ const currentLabel = `Current Month (${current.format('MMMM YYYY')})`;
826
+ const currentLastYearLabel = `Same Month Last Year (${sameMonthLastYear.format('MMMM YYYY')})`;
827
827
  const ytdLabel = `YTD ${current.format('MMMM YYYY')}`;
828
828
  const lyYtdLabel = `YTD ${sameMonthLastYear.format('MMMM YYYY')}`;
829
829
  const historicalMonths = [];
@@ -838,8 +838,8 @@ class NewSummaryExcel {
838
838
  return [
839
839
  [
840
840
  { v: '', t: 's' },
841
- { v: 'Current Month', t: 's' },
842
- { v: 'Same Month Last Year', t: 's' },
841
+ { v: currentLabel, t: 's' },
842
+ { v: currentLastYearLabel, t: 's' },
843
843
  { v: ytdLabel, t: 's' },
844
844
  { v: lyYtdLabel, t: 's' },
845
845
  ...historicalMonths,
@@ -1172,7 +1172,7 @@ class NewSummaryExcel {
1172
1172
  const financialRatiosBaseLY = financialRatiosBaseKeys.reduce((acc, key) => {
1173
1173
  const sheet = sheets.find((s) => s.rowType === key && s.isTotal);
1174
1174
  const dataEntry = data.find((d) => {
1175
- return d.sheetId.toString() === sheet._id.toString() && d.year === currentYear - 1 && d.month === currentMonth;
1175
+ return d.sheetId.toString() === sheet._id.toString() && d.year === year - 1 && d.month === month + 1;
1176
1176
  });
1177
1177
  if (!dataEntry) {
1178
1178
  return acc;
@@ -1327,19 +1327,19 @@ class NewSummaryExcel {
1327
1327
  const fullComplianceBorrower = await this.complianceBorrowersService.getFullComplianceBorrowerById(complianceBorrower._id.toString());
1328
1328
  const dueItems = [];
1329
1329
  const acceptedItems = [];
1330
- const previousMonthStart = (0, dayjs_1.default)(start).utcOffset(0).subtract(1, 'months').startOf('month');
1330
+ const previousMonthStart = (0, dayjs_1.default)(start).utc().subtract(1, 'months').startOf('month');
1331
1331
  if (fullComplianceBorrower) {
1332
1332
  fullComplianceBorrower.items.forEach((item) => {
1333
1333
  item.instances.forEach((instance) => {
1334
1334
  const row = {
1335
- name: `${item.item?.name} (${(0, dayjs_1.default)(instance.nextDate).format('MMM.D, YYYY')})`,
1336
- dueDate: instance.nextDate ? (0, dayjs_1.default)(instance.nextDate).format('YYYY/MM/DD') : '-',
1335
+ name: `${item.item?.name} (${(0, dayjs_1.default)(instance.nextDate).utc().format('MMM.D, YYYY')})`,
1336
+ dueDate: instance.nextDate ? (0, dayjs_1.default)(instance.nextDate).utc().format('YYYY/MM/DD') : '-',
1337
1337
  progress: instance.progress?.text ?? '-',
1338
- submittedDate: instance.submittedDate ? (0, dayjs_1.default)(instance.submittedDate).format('YYYY/MM/DD') : '-',
1338
+ submittedDate: instance.submittedDate ? (0, dayjs_1.default)(instance.submittedDate).utc().format('YYYY/MM/DD') : '-',
1339
1339
  status: instance.status,
1340
1340
  };
1341
1341
  if (instance.status === ComplianceItem_model_1.EComplianceItemStatus.ACCEPTED) {
1342
- if (previousMonthStart.isBefore((0, dayjs_1.default)(instance.submittedDate))) {
1342
+ if (previousMonthStart.isBefore((0, dayjs_1.default)(instance.submittedDate).utc())) {
1343
1343
  acceptedItems.push(row);
1344
1344
  }
1345
1345
  }
@@ -1362,7 +1362,7 @@ class NewSummaryExcel {
1362
1362
  borrowerSubTitle,
1363
1363
  [{ v: 'ALL VALUES $\'000' }],
1364
1364
  emptyRow,
1365
- getSegment(`REVOLVER LOAN BALANCE & COLLATERAL - AS AT ${(0, dayjs_1.default)(lastBBC.bbcDate).utcOffset(0).format(dateFormat)} (LAST SIGNED BBC)`),
1365
+ getSegment(`REVOLVER LOAN BALANCE & COLLATERAL - AS AT ${(0, dayjs_1.default)(lastBBC.bbcDate).utc().format(dateFormat)} (LAST SIGNED BBC)`),
1366
1366
  headerWithStyles,
1367
1367
  ...inventoryDataWithStyles,
1368
1368
  emptyRow,
package/db/new-summary.ts CHANGED
@@ -292,19 +292,19 @@ export class NewSummaryExcel {
292
292
  if (product.deactivationDate) {
293
293
  continue;
294
294
  }
295
- if (dayjs(product.payoffDate).isBefore(dayjs(periodEnd))) {
295
+ if (dayjs(product.payoffDate).utc().isBefore(dayjs(periodEnd).utc())) {
296
296
  periodEnd = product.payoffDate;
297
297
  }
298
- const daysHeld = dayjs(periodEnd).diff(dayjs(product.startDate), 'day');
298
+ const daysHeld = dayjs(periodEnd).utc().diff(dayjs(product.startDate).utc(), 'day');
299
299
  const lastTransaction = await getLastTransactionForDate(product._id.toString(), periodEnd);
300
300
  const endingBalance = lastTransaction ? lastTransaction.balance : 0;
301
301
  const endingParticipationBalance = await this.loanChargesService.getParticipationBalance(product.code, end);
302
302
  const netExposure = new Decimal(endingBalance).sub(endingParticipationBalance).toNumber();
303
303
  const lastSignedBBC = await this.signsService.getLatestSignedBBCDate(borrowerId, periodEnd);
304
- const lastSignedBBCDate = lastSignedBBC ? dayjs(lastSignedBBC.bbcDate).format(dateFormat) : '';
304
+ const lastSignedBBCDate = lastSignedBBC ? dayjs(lastSignedBBC.bbcDate).utc().format(dateFormat) : '';
305
305
  const averageBalanceSinceInception = new Decimal(await getAverageActualBalance(product._id.toString(), {
306
- start: dayjs(product.startDate),
307
- end: dayjs(periodEnd),
306
+ start: dayjs(product.startDate).utc(),
307
+ end: dayjs(periodEnd).utc(),
308
308
  })).toDP(2).toNumber();
309
309
 
310
310
  const totalIncomeReceived = await this.getPaidAmount(product._id.toString());
@@ -315,8 +315,8 @@ export class NewSummaryExcel {
315
315
  const newDataRow: ReportRow = {
316
316
  borrowerName: borrower.name,
317
317
  productName: product.name,
318
- maturityDate: product.maturityDate ? dayjs(product.maturityDate).format(dateFormat) : '',
319
- payOffDate: product.payoffDate ? dayjs(product.payoffDate).format(dateFormat) : '',
318
+ maturityDate: product.maturityDate ? dayjs(product.maturityDate).utc().format(dateFormat) : '',
319
+ payOffDate: product.payoffDate ? dayjs(product.payoffDate).utc().format(dateFormat) : '',
320
320
  commitmentAmount: product.commitment,
321
321
  endingBalance,
322
322
  endingParticipationBalance,
@@ -349,8 +349,8 @@ export class NewSummaryExcel {
349
349
  });
350
350
  const reportPeriod = [
351
351
  [{ v: 'Report period', t: 's' }],
352
- [{ v: 'From', t: 's' }, { v: dayjs(start).utcOffset(0).format(dateFormat), t: 's' }],
353
- [{ v: 'To', t: 's' }, { v: dayjs(end).utcOffset(0).format(dateFormat), t: 's' }],
352
+ [{ v: 'From', t: 's' }, { v: dayjs(start).utc().format(dateFormat), t: 's' }],
353
+ [{ v: 'To', t: 's' }, { v: dayjs(end).utc().format(dateFormat), t: 's' }],
354
354
  ];
355
355
  return { report: [...reportPeriod, emptyRow, headerWithStyles, ...dataWithStyles] };
356
356
  };
@@ -416,7 +416,7 @@ export class NewSummaryExcel {
416
416
  s: rightAlign,
417
417
  }], []);
418
418
 
419
- const lastBBC = await getLatestSignedBBCDateDoc(borrowerId, dayjs(end).endOf('day').toDate());
419
+ const lastBBC = await getLatestSignedBBCDateDoc(borrowerId, dayjs(end).utc().endOf('day').toDate());
420
420
  if (!lastBBC) {
421
421
  return null;
422
422
  }
@@ -612,8 +612,8 @@ export class NewSummaryExcel {
612
612
  .filter((product) => product.borrowerId.toString() === borrowerId)
613
613
  .sort((a, b) => (a.type > b.type ? 1 : -1));
614
614
  for (const product of borrowerProducts) {
615
- const month = dayjs(end).month() + 1;
616
- const year = dayjs(end).year();
615
+ const month = dayjs(end).utc().month() + 1;
616
+ const year = dayjs(end).utc().year();
617
617
  const monthEndData = await this.monthEndDataService.getMonthEndData(product._id.toString(), year, month);
618
618
  const productType = product.type[0].toUpperCase() + product.type.slice(1).toLowerCase();
619
619
  const dataToShow = {
@@ -756,7 +756,7 @@ export class NewSummaryExcel {
756
756
  }
757
757
 
758
758
  const dataDeep = 5;
759
- const periodEnd = { month: dayjs(start).month() + 1, year: dayjs(start).year() };
759
+ const periodEnd = { month: dayjs(start).utc().month() + 1, year: dayjs(start).utc().year() };
760
760
  const periodStart = getShiftedMonth(periodEnd, -dataDeep);
761
761
  const monthHeader: IExcelJsCell[] = [];
762
762
  const months = [];
@@ -767,7 +767,7 @@ export class NewSummaryExcel {
767
767
  t: 's',
768
768
  s: { alignment: { horizontal: 'right' } },
769
769
  });
770
- months.push(dayjs(`${currentMonth.year}-${currentMonth.month}-01`).format('YYYY-MM'));
770
+ months.push(dayjs(`${currentMonth.year}-${currentMonth.month}-01`).utc().format('YYYY-MM'));
771
771
  }
772
772
  loanEconomicsData.push(emptyRow);
773
773
  loanEconomicsData.push([{ v: '' }, ...monthHeader]);
@@ -776,14 +776,14 @@ export class NewSummaryExcel {
776
776
  {
777
777
  borrowerId,
778
778
  productId: product._id.toString(),
779
- periodStart: dayjs(`${periodStart.year}-${periodStart.month}-01`).utcOffset(0).toDate(),
779
+ periodStart: dayjs(`${periodStart.year}-${periodStart.month}-01`).utc().toDate(),
780
780
  periodEnd: end,
781
781
  },
782
782
  null,
783
783
  false,
784
784
  );
785
785
 
786
- const grouped = _.groupBy(transactions, (tx) => dayjs(tx.date).format('YYYY-MM'));
786
+ const grouped = _.groupBy(transactions, (tx) => dayjs(tx.date).utc().format('YYYY-MM'));
787
787
  const yieldData = await this.yieldService.getCalculatedYieldTotalsForPeriod(product._id.toString(), periodStart, periodEnd);
788
788
  const yieldDataSorted = yieldData.slice().sort((a, b) => {
789
789
  if (a.year !== b.year) {
@@ -843,7 +843,7 @@ export class NewSummaryExcel {
843
843
  if (totalType === ETotalType.AVERAGE_BALANCE) {
844
844
  const loanTurn = totalYieldData.reduce((acc, yieldDataDoc) => {
845
845
 
846
- const monthStart = dayjs(`${yieldDataDoc.year}-${yieldDataDoc.month}-01`).utcOffset(0);
846
+ const monthStart = dayjs(`${yieldDataDoc.year}-${yieldDataDoc.month}-01`).utc();
847
847
  const daysInMonth = monthStart.daysInMonth();
848
848
  const txs = grouped[monthStart.format('YYYY-MM')] ?? [];
849
849
  const collections = txs.filter((t) => t.transactionType === ELoanTransactionTypes.COLLECTION);
@@ -890,36 +890,33 @@ export class NewSummaryExcel {
890
890
 
891
891
  // FINANCIAL
892
892
  const getFinancialDate = async (endDate: Date): Promise<IExcelJsCell[][]> => {
893
- const month = dayjs(endDate).utcOffset(0).month();
894
- const year = dayjs(endDate).utcOffset(0).year();
893
+ const month = dayjs(endDate).utc().month();
894
+ const year = dayjs(endDate).utc().year();
895
895
  const monthDeep = 11;
896
896
 
897
- const currentMonth = dayjs(endDate).utcOffset(0).month() + 1;
898
- const currentYear = dayjs(endDate).utcOffset(0).year();
899
-
900
897
  const { data: ytdDataPL } = await this.financialSpreadingService.getFinancialSpreadingData({
901
898
  borrowerId,
902
899
  financialSpreadingType: EFinancialSpreadingType.PROFIT_LOSS,
903
- selectedMonth: { year: currentYear, month },
904
- }, currentMonth - 2); // jan to current
900
+ selectedMonth: { year: year, month },
901
+ }, month);
905
902
 
906
903
  const { data: ytdDataBS } = await this.financialSpreadingService.getFinancialSpreadingData({
907
904
  borrowerId,
908
905
  financialSpreadingType: EFinancialSpreadingType.BALANCE_SHEET,
909
- selectedMonth: { year: currentYear, month },
910
- }, currentMonth - 2); // jan to current
906
+ selectedMonth: { year: year, month },
907
+ }, month);
911
908
 
912
909
  const { data: lyYtdDataPL } = await this.financialSpreadingService.getFinancialSpreadingData({
913
910
  borrowerId,
914
911
  financialSpreadingType: EFinancialSpreadingType.PROFIT_LOSS,
915
- selectedMonth: { year: currentYear - 1, month },
916
- }, currentMonth - 2);
912
+ selectedMonth: { year: year - 1, month },
913
+ }, month);
917
914
 
918
915
  const { data: lyYtdDataBS } = await this.financialSpreadingService.getFinancialSpreadingData({
919
916
  borrowerId,
920
917
  financialSpreadingType: EFinancialSpreadingType.BALANCE_SHEET,
921
- selectedMonth: { year: currentYear - 1, month },
922
- }, currentMonth - 2);
918
+ selectedMonth: { year: year - 1, month },
919
+ }, month);
923
920
 
924
921
  const ytdData = [...ytdDataPL, ...ytdDataBS];
925
922
  const lyYtdData = [...lyYtdDataPL, ...lyYtdDataBS];
@@ -942,7 +939,7 @@ export class NewSummaryExcel {
942
939
  } = await this.financialSpreadingService.getFinancialSpreadingData({
943
940
  borrowerId,
944
941
  financialSpreadingType: EFinancialSpreadingType.PROFIT_LOSS,
945
- selectedMonth: { year: currentYear - 1, month },
942
+ selectedMonth: { year: year - 1, month },
946
943
  }, 0);
947
944
 
948
945
  const {
@@ -951,7 +948,7 @@ export class NewSummaryExcel {
951
948
  } = await this.financialSpreadingService.getFinancialSpreadingData({
952
949
  borrowerId,
953
950
  financialSpreadingType: EFinancialSpreadingType.BALANCE_SHEET,
954
- selectedMonth: { year: currentYear - 1, month },
951
+ selectedMonth: { year: year - 1, month },
955
952
  }, 0);
956
953
 
957
954
  const data = [
@@ -968,8 +965,10 @@ export class NewSummaryExcel {
968
965
  ];
969
966
 
970
967
  const generateMonthCells = (): IExcelJsCell[][] => {
971
- const current = dayjs(`${year}-${String(month).padStart(2, '0')}-01`);
968
+ const current = dayjs(`${year}-${String(month + 1).padStart(2, '0')}-01`).utc();
972
969
  const sameMonthLastYear = current.subtract(1, 'year');
970
+ const currentLabel = `Current Month (${current.format('MMMM YYYY')})`;
971
+ const currentLastYearLabel = `Same Month Last Year (${sameMonthLastYear.format('MMMM YYYY')})`;
973
972
  const ytdLabel = `YTD ${current.format('MMMM YYYY')}`;
974
973
  const lyYtdLabel = `YTD ${sameMonthLastYear.format('MMMM YYYY')}`;
975
974
 
@@ -986,8 +985,8 @@ export class NewSummaryExcel {
986
985
  return [
987
986
  [
988
987
  { v: '', t: 's' },
989
- { v: 'Current Month', t: 's' },
990
- { v: 'Same Month Last Year', t: 's' },
988
+ { v: currentLabel, t: 's' },
989
+ { v: currentLastYearLabel, t: 's' },
991
990
  { v: ytdLabel, t: 's' },
992
991
  { v: lyYtdLabel, t: 's' },
993
992
  ...historicalMonths,
@@ -1360,7 +1359,7 @@ export class NewSummaryExcel {
1360
1359
  const financialRatiosBaseLY = financialRatiosBaseKeys.reduce((acc, key) => {
1361
1360
  const sheet = sheets.find((s) => s.rowType === key && s.isTotal);
1362
1361
  const dataEntry = data.find((d) => {
1363
- return d.sheetId.toString() === sheet._id.toString() && d.year === currentYear - 1 && d.month === currentMonth;
1362
+ return d.sheetId.toString() === sheet._id.toString() && d.year === year - 1 && d.month === month + 1;
1364
1363
  });
1365
1364
  if (!dataEntry) {
1366
1365
  return acc;
@@ -1557,20 +1556,20 @@ export class NewSummaryExcel {
1557
1556
  const fullComplianceBorrower = await this.complianceBorrowersService.getFullComplianceBorrowerById(complianceBorrower._id.toString());
1558
1557
  const dueItems = [];
1559
1558
  const acceptedItems = [];
1560
- const previousMonthStart = dayjs(start).utcOffset(0).subtract(1, 'months').startOf('month');
1559
+ const previousMonthStart = dayjs(start).utc().subtract(1, 'months').startOf('month');
1561
1560
 
1562
1561
  if (fullComplianceBorrower) {
1563
1562
  fullComplianceBorrower.items.forEach((item) => {
1564
1563
  item.instances.forEach((instance) => {
1565
1564
  const row: ComplianceItemRow = {
1566
- name: `${item.item?.name} (${dayjs(instance.nextDate).format('MMM.D, YYYY')})`,
1567
- dueDate: instance.nextDate ? dayjs(instance.nextDate).format('YYYY/MM/DD') : '-',
1565
+ name: `${item.item?.name} (${dayjs(instance.nextDate).utc().format('MMM.D, YYYY')})`,
1566
+ dueDate: instance.nextDate ? dayjs(instance.nextDate).utc().format('YYYY/MM/DD') : '-',
1568
1567
  progress: instance.progress?.text ?? '-',
1569
- submittedDate: instance.submittedDate ? dayjs(instance.submittedDate).format('YYYY/MM/DD') : '-',
1568
+ submittedDate: instance.submittedDate ? dayjs(instance.submittedDate).utc().format('YYYY/MM/DD') : '-',
1570
1569
  status: instance.status,
1571
1570
  };
1572
1571
  if (instance.status === EComplianceItemStatus.ACCEPTED) {
1573
- if (previousMonthStart.isBefore(dayjs(instance.submittedDate))) {
1572
+ if (previousMonthStart.isBefore(dayjs(instance.submittedDate).utc())) {
1574
1573
  acceptedItems.push(row);
1575
1574
  }
1576
1575
  } else {
@@ -1594,7 +1593,7 @@ export class NewSummaryExcel {
1594
1593
  [{ v: 'ALL VALUES $\'000' }],
1595
1594
  emptyRow,
1596
1595
 
1597
- getSegment(`REVOLVER LOAN BALANCE & COLLATERAL - AS AT ${dayjs(lastBBC.bbcDate).utcOffset(0).format(dateFormat)} (LAST SIGNED BBC)`),
1596
+ getSegment(`REVOLVER LOAN BALANCE & COLLATERAL - AS AT ${dayjs(lastBBC.bbcDate).utc().format(dateFormat)} (LAST SIGNED BBC)`),
1598
1597
  headerWithStyles,
1599
1598
  ...inventoryDataWithStyles,
1600
1599
  emptyRow,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemcap-be-common",
3
- "version": "1.3.146",
3
+ "version": "1.3.147",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {