(bugfix) ViewLocationCart: still fixing conditional hub3a calculation
This commit is contained in:
@@ -74,9 +74,13 @@ export const ViewLocationCard:FC<ViewLocationCardProps> = ({location, userSettin
|
|||||||
// sum all the billAmounts (only for bills billed to tenant)
|
// sum all the billAmounts (only for bills billed to tenant)
|
||||||
const monthlyExpense = bills.reduce((acc, bill) => (bill.paid && (bill.billedTo ?? BilledTo.Tenant) === BilledTo.Tenant) ? acc + (bill.payedAmount ?? 0) : acc, 0);
|
const monthlyExpense = bills.reduce((acc, bill) => (bill.paid && (bill.billedTo ?? BilledTo.Tenant) === BilledTo.Tenant) ? acc + (bill.payedAmount ?? 0) : acc, 0);
|
||||||
|
|
||||||
const hub3a_text = useMemo(() => {
|
const { hub3aText, paymentParams } = useMemo(() => {
|
||||||
|
|
||||||
if(!userSettings?.show2dCodeInMonthlyStatement || !generateTenantCode) {
|
if(!userSettings?.show2dCodeInMonthlyStatement || !generateTenantCode) {
|
||||||
return "";
|
return {
|
||||||
|
hub3aText: "",
|
||||||
|
paymentParams: {} as PaymentParams
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const locationNameTrimmed_max20 = locationName.trimEnd().trimEnd().substring(0,19);
|
const locationNameTrimmed_max20 = locationName.trimEnd().trimEnd().substring(0,19);
|
||||||
@@ -96,7 +100,10 @@ export const ViewLocationCard:FC<ViewLocationCardProps> = ({location, userSettin
|
|||||||
OpisPlacanja: `Režije-${locationNameTrimmed_max20}-${formatYearMonth(yearMonth)}`, // max length 35 = "Režije-" (7) + locationName (20) + "-" (1) + "YYYY-MM" (7)
|
OpisPlacanja: `Režije-${locationNameTrimmed_max20}-${formatYearMonth(yearMonth)}`, // max length 35 = "Režije-" (7) + locationName (20) + "-" (1) + "YYYY-MM" (7)
|
||||||
};
|
};
|
||||||
|
|
||||||
return(EncodePayment(paymentParams));
|
return({
|
||||||
|
hub3aText: EncodePayment(paymentParams),
|
||||||
|
paymentParams
|
||||||
|
});
|
||||||
}, [userSettings?.show2dCodeInMonthlyStatement, generateTenantCode, locationName, tenantName, tenantStreet, tenantTown, userSettings, monthlyExpense, yearMonth]);
|
}, [userSettings?.show2dCodeInMonthlyStatement, generateTenantCode, locationName, tenantName, tenantStreet, tenantTown, userSettings, monthlyExpense, yearMonth]);
|
||||||
|
|
||||||
return(
|
return(
|
||||||
@@ -130,7 +137,7 @@ export const ViewLocationCard:FC<ViewLocationCardProps> = ({location, userSettin
|
|||||||
<li><strong>{t("payment-reference-label")}</strong><pre className="inline pl-1">{paymentParams.PozivNaBroj}</pre></li>
|
<li><strong>{t("payment-reference-label")}</strong><pre className="inline pl-1">{paymentParams.PozivNaBroj}</pre></li>
|
||||||
<li><strong>{t("payment-purpose-code-label")}</strong><pre className="inline pl-1">{paymentParams.SifraNamjene}</pre></li>
|
<li><strong>{t("payment-purpose-code-label")}</strong><pre className="inline pl-1">{paymentParams.SifraNamjene}</pre></li>
|
||||||
</ul>
|
</ul>
|
||||||
<Pdf417Barcode hub3aText={hub3a_text} />
|
<Pdf417Barcode hub3aText={hub3aText} />
|
||||||
</>
|
</>
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user