From bb5c5ad7673d71579640dce50355c74480db8b1a Mon Sep 17 00:00:00 2001 From: Howard Askew <19271569+howaskew@users.noreply.github.com> Date: Thu, 19 Nov 2026 10:47:43 +0000 Subject: [PATCH] fix: Use decimal literals for tax rate and coordinates Casting a double literal to decimal, e.g. (decimal?)0.2, gives the exact binary value when compiled with the .NET 11 SDK, whatever the target framework. The tax rate became 0.2000000000000000111, so B failed with TotalPaymentDueMismatchError in the tax-calculation-net tests. Co-Authored-By: Claude Opus 5.5 --- .../Helpers/FeedGenerationHelper.cs | 12 ++++++------ .../BookingSystem.AspNetCore/Stores/FacilityStore.cs | 4 ++-- .../BookingSystem.AspNetCore/Stores/SessionStore.cs | 4 ++-- .../Stores/FacilityStore.cs | 4 ++-- .../Stores/SessionStore.cs | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Examples/BookingSystem.AspNetCore/Helpers/FeedGenerationHelper.cs b/Examples/BookingSystem.AspNetCore/Helpers/FeedGenerationHelper.cs index cc099062..037fdb75 100644 --- a/Examples/BookingSystem.AspNetCore/Helpers/FeedGenerationHelper.cs +++ b/Examples/BookingSystem.AspNetCore/Helpers/FeedGenerationHelper.cs @@ -49,8 +49,8 @@ public static Place GetPlaceById(long placeId) }, Geo = new GeoCoordinates { - Latitude = (decimal?)51.7502, - Longitude = (decimal?)-1.2674 + Latitude = 51.7502M, + Longitude = -1.2674M }, Image = new List { new ImageObject @@ -97,8 +97,8 @@ public static Place GetPlaceById(long placeId) }, Geo = new GeoCoordinates { - Latitude = (decimal?)51.7504933, - Longitude = (decimal?)-1.2620685 + Latitude = 51.7504933M, + Longitude = -1.2620685M }, Image = new List { new ImageObject @@ -145,8 +145,8 @@ public static Place GetPlaceById(long placeId) }, Geo = new GeoCoordinates { - Latitude = (decimal?)51.749826, - Longitude = (decimal?)-1.261492 + Latitude = 51.749826M, + Longitude = -1.261492M }, Image = new List { new ImageObject diff --git a/Examples/BookingSystem.AspNetCore/Stores/FacilityStore.cs b/Examples/BookingSystem.AspNetCore/Stores/FacilityStore.cs index f506d119..5a736fbb 100644 --- a/Examples/BookingSystem.AspNetCore/Stores/FacilityStore.cs +++ b/Examples/BookingSystem.AspNetCore/Stores/FacilityStore.cs @@ -652,9 +652,9 @@ private List GetUnitTaxSpecification(BookingFlowContext new TaxChargeSpecification { Name = "VAT at 20%", - Price = slot.Price * (decimal?) 0.2, + Price = slot.Price * 0.2M, PriceCurrency = "GBP", - Rate = (decimal?) 0.2 + Rate = 0.2M } }; case TaxPayeeRelationship.BusinessToBusiness when !_appSettings.Payment.TaxCalculationB2B: diff --git a/Examples/BookingSystem.AspNetCore/Stores/SessionStore.cs b/Examples/BookingSystem.AspNetCore/Stores/SessionStore.cs index 912579f7..ee75f5f7 100644 --- a/Examples/BookingSystem.AspNetCore/Stores/SessionStore.cs +++ b/Examples/BookingSystem.AspNetCore/Stores/SessionStore.cs @@ -674,9 +674,9 @@ private List GetUnitTaxSpecification(BookingFlowContext new TaxChargeSpecification { Name = "VAT at 20%", - Price = classes.Price * (decimal?)0.2, + Price = classes.Price * 0.2M, PriceCurrency = "GBP", - Rate = (decimal?)0.2 + Rate = 0.2M } }; case TaxPayeeRelationship.BusinessToBusiness when !_appSettings.Payment.TaxCalculationB2B: diff --git a/Examples/BookingSystem.AspNetFramework/Stores/FacilityStore.cs b/Examples/BookingSystem.AspNetFramework/Stores/FacilityStore.cs index f506d119..5a736fbb 100644 --- a/Examples/BookingSystem.AspNetFramework/Stores/FacilityStore.cs +++ b/Examples/BookingSystem.AspNetFramework/Stores/FacilityStore.cs @@ -652,9 +652,9 @@ private List GetUnitTaxSpecification(BookingFlowContext new TaxChargeSpecification { Name = "VAT at 20%", - Price = slot.Price * (decimal?) 0.2, + Price = slot.Price * 0.2M, PriceCurrency = "GBP", - Rate = (decimal?) 0.2 + Rate = 0.2M } }; case TaxPayeeRelationship.BusinessToBusiness when !_appSettings.Payment.TaxCalculationB2B: diff --git a/Examples/BookingSystem.AspNetFramework/Stores/SessionStore.cs b/Examples/BookingSystem.AspNetFramework/Stores/SessionStore.cs index 912579f7..ee75f5f7 100644 --- a/Examples/BookingSystem.AspNetFramework/Stores/SessionStore.cs +++ b/Examples/BookingSystem.AspNetFramework/Stores/SessionStore.cs @@ -674,9 +674,9 @@ private List GetUnitTaxSpecification(BookingFlowContext new TaxChargeSpecification { Name = "VAT at 20%", - Price = classes.Price * (decimal?)0.2, + Price = classes.Price * 0.2M, PriceCurrency = "GBP", - Rate = (decimal?)0.2 + Rate = 0.2M } }; case TaxPayeeRelationship.BusinessToBusiness when !_appSettings.Payment.TaxCalculationB2B: