using EricksonLopez.Result;
using EricksonLopez.ValueObjects;
namespace Example.ValueObjects;
public static class BillingCalculator
public static Result<Money[]> SplitInvoice(decimal grossAmount, string currencyIso)
var currencyResult = CurrencyCode.Create(currencyIso);
if (currencyResult.IsFailure)
return currencyResult.Error;
var moneyResult = Money.Create(grossAmount, currencyResult.Value);
if (moneyResult.IsFailure)
return moneyResult.Error;
// Lossless distribution across 70% / 30% shares without cent drift
return moneyResult.Value.Allocate(new[] { 70, 30 });