tango-app-api-payment-subscription 3.5.25 → 3.5.27
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
|
@@ -815,14 +815,16 @@ export async function invoiceDownload( req, res ) {
|
|
|
815
815
|
|
|
816
816
|
invoiceInfo.totalAmount = roundAmount( invoiceInfo.totalAmount, invoiceInfo.currency );
|
|
817
817
|
let AmountinWords = amountToWords( invoiceInfo.totalAmount, invoiceInfo.currency );
|
|
818
|
+
// Fetch the group BEFORE computing the payment term / due-date fallback.
|
|
819
|
+
// Previously `getgroup` was read while still undefined, so `days` always
|
|
820
|
+
// fell back to 30 and the due-date fallback ignored the real paymentTerm —
|
|
821
|
+
// leaving Due Date out of sync with the "Term N" shown on the invoice.
|
|
818
822
|
let getgroup;
|
|
819
|
-
let days = getgroup?.paymentTerm ? getgroup?.paymentTerm : '30';
|
|
820
|
-
let dueDate = invoiceInfo?.dueDate ? dayjs( invoiceInfo?.dueDate ).format( 'DD/MM/YYYY' ) : dayjs().add( days, 'days' ).format( 'DD/MM/YYYY' );
|
|
821
|
-
|
|
822
|
-
console.log( invoiceInfo.groupId );
|
|
823
823
|
if ( invoiceInfo.groupId ) {
|
|
824
824
|
getgroup = await billingService.findOne( { _id: invoiceInfo.groupId } );
|
|
825
825
|
}
|
|
826
|
+
let days = getgroup?.paymentTerm ? getgroup?.paymentTerm : '30';
|
|
827
|
+
let dueDate = invoiceInfo?.dueDate ? dayjs( invoiceInfo?.dueDate ).format( 'DD/MM/YYYY' ) : dayjs().add( days, 'days' ).format( 'DD/MM/YYYY' );
|
|
826
828
|
let virtualAccount = await paymentAccountService.findOneAccount( { clientId: invoiceInfo.clientId } );
|
|
827
829
|
|
|
828
830
|
invoiceData = {
|
|
@@ -1280,7 +1282,11 @@ async function resolveBasePricingScope( group, getClient ) {
|
|
|
1280
1282
|
|
|
1281
1283
|
async function standardPrice( group, getClient, baseDate ) {
|
|
1282
1284
|
console.log( '🚀 ~ standardPrice ~ baseDate:', baseDate.format( 'MMM YYYY' ) );
|
|
1283
|
-
|
|
1285
|
+
// Prorate against the actual number of days in the invoice's billing month
|
|
1286
|
+
// (e.g. 31 for July, 28/29 for Feb) so invoice line amounts match the
|
|
1287
|
+
// annexure, which uses billingMonth.daysInMonth() in buildAnnexureRows().
|
|
1288
|
+
// Previously hardcoded to 30, which inflated 31-day-month invoices.
|
|
1289
|
+
const currentMonthDays = baseDate.daysInMonth();
|
|
1284
1290
|
console.log( '🚀 ~ standardPrice ~ currentMonthDays:', currentMonthDays );
|
|
1285
1291
|
// Pricing method: 'flat' => bill every store for the full month
|
|
1286
1292
|
// regardless of working days. 'prorate' => bill for actual working days.
|