(bugfix) ViewLocationCart: still fixing conditional hub3a calculation

This commit is contained in:
Knee Cola
2025-11-23 21:42:15 +01:00
parent 6c43c69934
commit 90d6c31678

View File

@@ -74,9 +74,13 @@ export const ViewLocationCard:FC<ViewLocationCardProps> = ({location, userSettin
// 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 hub3a_text = useMemo(() => {
const { hub3aText, paymentParams } = useMemo(() => {
if(!userSettings?.show2dCodeInMonthlyStatement || !generateTenantCode) {
return "";
return {
hub3aText: "",
paymentParams: {} as PaymentParams
};
}
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)
};
return(EncodePayment(paymentParams));
return({
hub3aText: EncodePayment(paymentParams),
paymentParams
});
}, [userSettings?.show2dCodeInMonthlyStatement, generateTenantCode, locationName, tenantName, tenantStreet, tenantTown, userSettings, monthlyExpense, yearMonth]);
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-purpose-code-label")}</strong><pre className="inline pl-1">{paymentParams.SifraNamjene}</pre></li>
</ul>
<Pdf417Barcode hub3aText={hub3a_text} />
<Pdf417Barcode hub3aText={hub3aText} />
</>
: null
}