From 701e0fa5281ec96fb0ecb5d3bbcbdb38367a2b15 Mon Sep 17 00:00:00 2001 From: Mridul Pathak Date: Tue, 15 Sep 2026 18:10:01 +0530 Subject: [PATCH] Fixed: updatePartyRate does not persist expiry of the previous rate (OFBIZ-13590) - The method set partyRate.thruDate = UtilDateTime.nowTimestamp() to expire the previously active PartyRate but never called .store(), so the mutation only existed in memory and was discarded; multiple "active" PartyRate rows accumulated for the same party/rateType since none of the earlier ones actually got expired - The lookup for that previous PartyRate was also missing filterByDate() (present in the original minilang), so getFirst() could pick an already-expired row instead of the currently active one to expire Both fixes were verified against the original minilang and covered by a temporary RED/GREEN test before removal, and the accounting component's rate test suite passes unchanged. --- .../org/apache/ofbiz/accounting/rate/RateServices.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/rate/RateServices.groovy b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/rate/RateServices.groovy index b3b47dc4cb5..d883049f504 100644 --- a/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/rate/RateServices.groovy +++ b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/rate/RateServices.groovy @@ -83,10 +83,11 @@ Map deleteRateAmount() { } Map updatePartyRate() { - List partyRates = from('PartyRate').where([partyId: partyId, rateTypeId: rateTypeId]).queryList() + List partyRates = from('PartyRate').where([partyId: partyId, rateTypeId: rateTypeId]).filterByDate().queryList() if (partyRates) { GenericValue partyRate = EntityUtil.getFirst(partyRates) partyRate.thruDate = UtilDateTime.nowTimestamp() + partyRate.store() } GenericValue newEntity = delegator.makeValidValue('PartyRate', parameters) newEntity.fromDate = newEntity.fromDate ?: UtilDateTime.nowTimestamp()