diff --git a/src/Basque/Mews.Fiscalizations.Basque/Model/Invoice/InvoiceData.cs b/src/Basque/Mews.Fiscalizations.Basque/Model/Invoice/InvoiceData.cs index 11df7813..9c02bac3 100644 --- a/src/Basque/Mews.Fiscalizations.Basque/Model/Invoice/InvoiceData.cs +++ b/src/Basque/Mews.Fiscalizations.Basque/Model/Invoice/InvoiceData.cs @@ -46,7 +46,7 @@ public static Try> Create( return Try.Aggregate( ObjectValidations.NotNull(description), items.ToList().ToTry(i => i.Any() && i.Count <= 1000, _ => new Error($"{nameof(items)} count must be in range [1, 1000].")), - taxModes.ToTry(t => t.NonEmptyNorNull(), _ => new Error($"{nameof(taxModes)} shouldn't be empty.")), + taxModes.ToTry(t => t.NonEmpty(), _ => new Error($"{nameof(taxModes)} shouldn't be empty.")), (d, i, t) => new InvoiceData(d, i, totalAmount, t, supportWithheldAmount, tax, transactionDate) ); } diff --git a/src/Core/Mews.Fiscalizations.Core/Model/Extensions/CollectionExtensions.cs b/src/Core/Mews.Fiscalizations.Core/Model/Extensions/CollectionExtensions.cs index 4406ad9d..e5b075f0 100644 --- a/src/Core/Mews.Fiscalizations.Core/Model/Extensions/CollectionExtensions.cs +++ b/src/Core/Mews.Fiscalizations.Core/Model/Extensions/CollectionExtensions.cs @@ -14,35 +14,6 @@ public static bool IsSequential(this IEnumerable source, int startIndex) return source.Select((value, index) => (value, index)).All(x => x.value == startIndex + x.index); } - /// - /// Retuns an empty Enumerable if source is null, otherwise source. - /// - public static IEnumerable OrEmptyIfNull(this IEnumerable source) - { - if (source == null) - { - return Enumerable.Empty(); - } - - return source; - } - - public static bool NonEmptyNorNull(this IEnumerable source) - { - return source is not null && source.Any(); - } - - public static bool IsEmptyOrNull(this IEnumerable source) - { - return source is null || !source.Any(); - } - - [Pure] - public static bool NonEmptyNorNull(this IReadOnlyCollection source) - { - return source is not null && source.Count > 0; - } - [Pure] public static bool IsEmptyOrNull(this IReadOnlyCollection source) { @@ -63,7 +34,9 @@ public static Option SafeFirstOption(this IEnumerable source) case null: return Option.Empty(); case IReadOnlyList list: - return list.SafeFirstOption(); + return list.Count == 0 + ? Option.Empty() + : Option.Valued(list[0]); default: { using var enumerator = source.GetEnumerator(); @@ -73,12 +46,4 @@ public static Option SafeFirstOption(this IEnumerable source) } } } - - [Pure] - public static Option SafeFirstOption(this IReadOnlyList list) - { - return list is null || list.Count == 0 - ? Option.Empty() - : Option.Valued(list[0]); - } } \ No newline at end of file diff --git a/src/Italy/Mews.Fiscalizations.Italy/Uniwix/Communication/UniwixClient.cs b/src/Italy/Mews.Fiscalizations.Italy/Uniwix/Communication/UniwixClient.cs index 0904095d..1d21d725 100644 --- a/src/Italy/Mews.Fiscalizations.Italy/Uniwix/Communication/UniwixClient.cs +++ b/src/Italy/Mews.Fiscalizations.Italy/Uniwix/Communication/UniwixClient.cs @@ -46,7 +46,7 @@ public async Task> GetInvoiceStateAsync(string fi var url = $"{UniwixBaseUrl}/Invoices/{fileId}"; var result = await GetAsync>(url); - var validatedResult = result.Where(a => a.NonEmptyNorNull(), _ => ErrorResult.Create($"Invoice {fileId} not found.", ErrorType.InvoiceNotFound)); + var validatedResult = result.Where(a => a is not null && a.NonEmpty(), _ => ErrorResult.Create($"Invoice {fileId} not found.", ErrorType.InvoiceNotFound)); return validatedResult.Map(r => { var state = r.OrderByDescending(s => s.Date).First(); diff --git a/src/Mews.Fiscalizations.All.props b/src/Mews.Fiscalizations.All.props index 46073070..15719843 100644 --- a/src/Mews.Fiscalizations.All.props +++ b/src/Mews.Fiscalizations.All.props @@ -3,6 +3,6 @@ false - + diff --git a/src/Mews.Fiscalizations.All/Mews.Fiscalizations.All.csproj b/src/Mews.Fiscalizations.All/Mews.Fiscalizations.All.csproj index c4459cad..7f430f53 100644 --- a/src/Mews.Fiscalizations.All/Mews.Fiscalizations.All.csproj +++ b/src/Mews.Fiscalizations.All/Mews.Fiscalizations.All.csproj @@ -10,7 +10,7 @@ https://github.com/MewsSystems/fiscalizations https://raw.githubusercontent.com/msigut/eet/master/receipt.png true - 25.0.3 + 25.0.4 10 true $(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage