From 6c43c699343bdcd65492667edc6c289c5d10df67 Mon Sep 17 00:00:00 2001 From: Knee Cola Date: Sun, 23 Nov 2025 21:39:05 +0100 Subject: [PATCH 01/11] (bugfix) ViewLocationCard: hub3a string was calculated even if this option was disabled --- app/ui/ViewLocationCard.tsx | 40 +++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/app/ui/ViewLocationCard.tsx b/app/ui/ViewLocationCard.tsx index 3f1043f..0cceb9a 100644 --- a/app/ui/ViewLocationCard.tsx +++ b/app/ui/ViewLocationCard.tsx @@ -1,6 +1,6 @@ 'use client'; -import { FC, useState } from "react"; +import { FC, useEffect, useMemo, useState } from "react"; import { BillAttachment, BilledTo, BillingLocation, UserSettings } from "../lib/db-types"; import { formatYearMonth } from "../lib/format"; import { formatCurrency } from "../lib/formatStrings"; @@ -74,24 +74,30 @@ export const ViewLocationCard:FC = ({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 locationNameTrimmed_max20 = locationName.trimEnd().trimEnd().substring(0,19); + const hub3a_text = useMemo(() => { + if(!userSettings?.show2dCodeInMonthlyStatement || !generateTenantCode) { + return ""; + } - const paymentParams:PaymentParams = { - Iznos: (monthlyExpense/100).toFixed(2).replace(".",","), - ImePlatitelja: tenantName ?? "", - AdresaPlatitelja: tenantStreet ?? "", - SjedistePlatitelja: tenantTown ?? "", - Primatelj: userSettings?.ownerName ?? "", - AdresaPrimatelja: userSettings?.ownerStreet ?? "", - SjedistePrimatelja: userSettings?.ownerTown ?? "", - IBAN: userSettings?.ownerIBAN ?? "", - ModelPlacanja: "HR00", - PozivNaBroj: formatYearMonth(yearMonth), - SifraNamjene: "", - OpisPlacanja: `Režije-${locationNameTrimmed_max20}-${formatYearMonth(yearMonth)}`, // max length 35 = "Režije-" (7) + locationName (20) + "-" (1) + "YYYY-MM" (7) - }; + const locationNameTrimmed_max20 = locationName.trimEnd().trimEnd().substring(0,19); - const hub3a_text = EncodePayment(paymentParams); + const paymentParams:PaymentParams = { + Iznos: (monthlyExpense/100).toFixed(2).replace(".",","), + ImePlatitelja: tenantName ?? "", + AdresaPlatitelja: tenantStreet ?? "", + SjedistePlatitelja: tenantTown ?? "", + Primatelj: userSettings?.ownerName ?? "", + AdresaPrimatelja: userSettings?.ownerStreet ?? "", + SjedistePrimatelja: userSettings?.ownerTown ?? "", + IBAN: userSettings?.ownerIBAN ?? "", + ModelPlacanja: "HR00", + PozivNaBroj: formatYearMonth(yearMonth), + SifraNamjene: "", + OpisPlacanja: `Režije-${locationNameTrimmed_max20}-${formatYearMonth(yearMonth)}`, // max length 35 = "Režije-" (7) + locationName (20) + "-" (1) + "YYYY-MM" (7) + }; + + return(EncodePayment(paymentParams)); + }, [userSettings?.show2dCodeInMonthlyStatement, generateTenantCode, locationName, tenantName, tenantStreet, tenantTown, userSettings, monthlyExpense, yearMonth]); return(
From 90d6c31678635395ab54a2d6cf530d6d32a6d1d6 Mon Sep 17 00:00:00 2001 From: Knee Cola Date: Sun, 23 Nov 2025 21:42:15 +0100 Subject: [PATCH 02/11] (bugfix) ViewLocationCart: still fixing conditional hub3a calculation --- app/ui/ViewLocationCard.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/ui/ViewLocationCard.tsx b/app/ui/ViewLocationCard.tsx index 0cceb9a..298cb4e 100644 --- a/app/ui/ViewLocationCard.tsx +++ b/app/ui/ViewLocationCard.tsx @@ -74,9 +74,13 @@ export const ViewLocationCard:FC = ({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 = ({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 = ({location, userSettin
  • {t("payment-reference-label")}
    {paymentParams.PozivNaBroj}
  • {t("payment-purpose-code-label")}
    {paymentParams.SifraNamjene}
  • - + : null } From 7722cbdf0a8c1245f1c91fbd76a32560fba373c3 Mon Sep 17 00:00:00 2001 From: Knee Cola Date: Sun, 23 Nov 2025 21:49:22 +0100 Subject: [PATCH 03/11] (refactor) ViewLocationCard: formatting 2D code --- app/ui/ViewLocationCard.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/ui/ViewLocationCard.tsx b/app/ui/ViewLocationCard.tsx index 298cb4e..cddf54b 100644 --- a/app/ui/ViewLocationCard.tsx +++ b/app/ui/ViewLocationCard.tsx @@ -107,7 +107,7 @@ export const ViewLocationCard:FC = ({location, userSettin }, [userSettings?.show2dCodeInMonthlyStatement, generateTenantCode, locationName, tenantName, tenantStreet, tenantTown, userSettings, monthlyExpense, yearMonth]); return( -
    +

    {formatYearMonth(yearMonth)} {locationName}

    @@ -131,13 +131,14 @@ export const ViewLocationCard:FC = ({location, userSettin
  • {t("payment-recipient-label")}
    {paymentParams.Primatelj}
  • {t("payment-recipient-address-label")}
    {paymentParams.AdresaPrimatelja}
  • {t("payment-recipient-city-label")}
    {paymentParams.SjedistePrimatelja}
  • -
  • {t("payment-amount-label")}
    {paymentParams.Iznos}
  • +
  • {t("payment-amount-label")}
    {paymentParams.Iznos} { userSettings?.currency }
  • {t("payment-description-label")}
    {paymentParams.OpisPlacanja}
  • {t("payment-model-label")}
    {paymentParams.ModelPlacanja}
  • {t("payment-reference-label")}
    {paymentParams.PozivNaBroj}
  • -
  • {t("payment-purpose-code-label")}
    {paymentParams.SifraNamjene}
  • - + : null } From 54a9de77d32e7dbb17b17c3ac1a0a5c825fe7242 Mon Sep 17 00:00:00 2001 From: Knee Cola Date: Sun, 23 Nov 2025 21:52:09 +0100 Subject: [PATCH 04/11] (refactor) ViewBillCard: formatting 3D bar code --- app/ui/ViewBillCard.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/ui/ViewBillCard.tsx b/app/ui/ViewBillCard.tsx index 905ef35..de9d9f0 100644 --- a/app/ui/ViewBillCard.tsx +++ b/app/ui/ViewBillCard.tsx @@ -61,7 +61,7 @@ export const ViewBillCard:FC = ({ location, bill }) => { { hub3aText ?
    -
    )} - {utilBillsProofOfPaymentAttachment && ( + {utilBillsProofOfPaymentUploadedAt && ( = ({location, userSettin tenantTown, generateTenantCode, // NOTE: only the fileName is projected from the DB to reduce data transfer - utilBillsProofOfPaymentAttachment + utilBillsProofOfPaymentAttachment, + utilBillsProofOfPaymentUploadedAt, } = location; const t = useTranslations("home-page.location-card"); const [isUploading, setIsUploading] = useState(false); const [uploadError, setUploadError] = useState(null); + const [attachmentUploadedAt, setAttachmentUploadedAt ] = useState(utilBillsProofOfPaymentUploadedAt ?? null); const [attachmentFilename, setAttachmentFilename] = useState(utilBillsProofOfPaymentAttachment?.fileName); const handleFileChange = async (e: React.ChangeEvent) => { @@ -60,6 +62,7 @@ export const ViewLocationCard:FC = ({location, userSettin if (result.success) { setAttachmentFilename(file.name); + setAttachmentUploadedAt(new Date()); } else { setUploadError(result.error || 'Upload failed'); } @@ -144,19 +147,25 @@ export const ViewLocationCard:FC = ({location, userSettin }
    {t("upload-proof-of-payment-legend")} - - {attachmentFilename ? ( -
    - - - {decodeURIComponent(attachmentFilename)} - -
    - ) : ( + { + // IF proof of payment was uploaded + attachmentUploadedAt ? ( + // IF file name is available, show link to download + // ELSE it's not available that means that the uploaded file was purged by housekeeping + // -> don't show anything + attachmentFilename ? ( +
    + + + {decodeURIComponent(attachmentFilename)} + +
    + ) : null + ) : /* ELSE show upload input */ (
    {t("tenant-2d-code-legend")} - {t("tenant-2d-code-info")}
    diff --git a/messages/en.json b/messages/en.json index 05fee99..087e2fd 100644 --- a/messages/en.json +++ b/messages/en.json @@ -124,9 +124,10 @@ }, "attachment": "Attachment", "back-button": "Back", - "billed-to-label": "Billed to", - "billed-to-tenant-option": "tenant", - "billed-to-landlord-option": "landlord" + "billed-to-legend": "Who bears the cost?", + "billed-to-tenant-option": "the tenant bears this cost", + "billed-to-landlord-option": "the landlord bears this cost", + "billed-to-info": "This option is intended for cases where part of the utility costs are not charged to the tenant. If 'the landlord bears this cost' is selected, this bill will not be included in the monthly statement shown to the tenant." }, "location-delete-form": { "text": "Please confirm deletion of realestate \"{name}\".", diff --git a/messages/hr.json b/messages/hr.json index a1efb23..047c1e7 100644 --- a/messages/hr.json +++ b/messages/hr.json @@ -123,9 +123,10 @@ }, "attachment": "Privitak", "back-button": "Nazad", - "billed-to-label": "Račun plaća", - "billed-to-tenant-option": "podstanar", - "billed-to-landlord-option": "vlasnik" + "billed-to-legend": "Tko snosi trošak?", + "billed-to-tenant-option": "ovaj trošak snosi podstanar", + "billed-to-landlord-option": "ovaj trošak snosi vlasnik", + "billed-to-info": "Ova opcija je predviđena za slučaj kada se dio režija ne naplaćuje od podstanara. Ako je odabrano 'trošak snosi vlasnik', ovaj račun neće biti uključen u mjesečni obračun koji se prikazuje podstanaru." }, "location-delete-form": { "text": "Molim potvrdi brisanje nekretnine \"{name}\".", From f8ae0c780e0fd7ba765126570ce0c9bc72b91e06 Mon Sep 17 00:00:00 2001 From: Knee Cola Date: Sun, 23 Nov 2025 22:51:45 +0100 Subject: [PATCH 11/11] 2.1.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 175f677..f9ca732 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { "name": "evidencija-rezija", - "version": "2.0.1", + "version": "2.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "version": "2.0.1", + "version": "2.1.0", "dependencies": { "@emotion/react": "^11.14.0", "@emotion/styled": "^11.14.1", diff --git a/package.json b/package.json index 1199c9b..fb3c882 100644 --- a/package.json +++ b/package.json @@ -58,5 +58,5 @@ "engines": { "node": ">=18.17.0" }, - "version": "2.0.1" + "version": "2.1.0" }