From c11daad71180b162e28e0fb3d37797ed3d5952aa Mon Sep 17 00:00:00 2001 From: Ross Stewart Date: Thu, 5 Feb 2026 14:58:01 +0000 Subject: [PATCH 1/2] Stewart bug --- src/Domain.LinnApps/PurchaseOrders/PurchaseOrderDetail.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Domain.LinnApps/PurchaseOrders/PurchaseOrderDetail.cs b/src/Domain.LinnApps/PurchaseOrders/PurchaseOrderDetail.cs index 4f1eb2fc5..d53d519fc 100644 --- a/src/Domain.LinnApps/PurchaseOrders/PurchaseOrderDetail.cs +++ b/src/Domain.LinnApps/PurchaseOrders/PurchaseOrderDetail.cs @@ -130,7 +130,12 @@ public bool ValidPrices() { return false; } - + + if (this.BaseOrderUnitPrice < 0) + { + return false; + } + return true; } From 100774db4831b31d9556120aa6da49b322c82e33 Mon Sep 17 00:00:00 2001 From: Ross Stewart Date: Mon, 9 Feb 2026 09:40:29 +0000 Subject: [PATCH 2/2] add a test --- .../WhenUpdatingAndNegativeBaseUnitPrice.cs | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 tests/Unit/Domain.LinnApps.Tests/PurchaseOrderServiceTests/WhenUpdatingAndNegativeBaseUnitPrice.cs diff --git a/tests/Unit/Domain.LinnApps.Tests/PurchaseOrderServiceTests/WhenUpdatingAndNegativeBaseUnitPrice.cs b/tests/Unit/Domain.LinnApps.Tests/PurchaseOrderServiceTests/WhenUpdatingAndNegativeBaseUnitPrice.cs new file mode 100644 index 000000000..a1da723e9 --- /dev/null +++ b/tests/Unit/Domain.LinnApps.Tests/PurchaseOrderServiceTests/WhenUpdatingAndNegativeBaseUnitPrice.cs @@ -0,0 +1,63 @@ +namespace Linn.Purchasing.Domain.LinnApps.Tests.PurchaseOrderServiceTests +{ + using System; + using System.Collections.Generic; + + using FluentAssertions; + + using Linn.Purchasing.Domain.LinnApps.Exceptions; + using Linn.Purchasing.Domain.LinnApps.PurchaseLedger; + using Linn.Purchasing.Domain.LinnApps.PurchaseOrders; + + using NSubstitute; + + using NUnit.Framework; + + public class WhenUpdatingAndNegativeBaseUnitPrice : ContextBase + { + private readonly int orderNumber = 600179; + + private PurchaseOrder updated; + + private Action act; + + [SetUp] + public void SetUp() + { + this.updated = new PurchaseOrder + { + OrderNumber = this.orderNumber, + Details = + new List + { + new PurchaseOrderDetail + { + Cancelled = "N", + Line = 1, + BaseNetTotal = 100m, + NetTotalCurrency = 120m, + BaseOrderUnitPrice = -100m, + OrderNumber = this.orderNumber, + OurQty = 99m, + OrderQty = 12m, + PartNumber = "P" + } + } + }; + + this.MockAuthService.HasPermissionFor(AuthorisedAction.PurchaseOrderUpdate, Arg.Any>()) + .Returns(true); + + this.PurchaseLedgerMaster.GetRecord().Returns(new PurchaseLedgerMaster { OkToRaiseOrder = "Y" }); + + this.act = () => this.Sut.UpdateOrder(new PurchaseOrder(), this.updated, new List()); + } + + + [Test] + public void ShouldThrow() + { + this.act.Should().Throw("Prices must be positive numbers"); + } + } +}