public Archive(ArchiveMetadata metadata, Signature signature, TaxSummary taxSummary, ReportedValue reportedValue) { Metadata = metadata; Signature = signature; TaxSummary = taxSummary; ReportedValue = reportedValue; }
public static ITry <Archive, IEnumerable <string> > Parse(Dto.Archive archive) { return(ArchiveMetadata.Create(archive).FlatMap(metadata => { return Try.Aggregate( TaxSummary.Create(archive, metadata.Version), ReportedValue.Create(archive, metadata.Version), Signature.Create(archive.Signature.Content), (taxSummary, reportedValue, signature) => new Archive(metadata, signature, taxSummary, reportedValue) ); })); }
private static ITry <TaxSummary, IEnumerable <string> > GetV4TaxSummary(Dto.Archive archive) { var invoiceFooter = archive.InvoiceFooter.ToTry(_ => "Invoice footer file not found.".ToEnumerable()); return(invoiceFooter.FlatMap(f => { var taxBreakdownNet = Try.Aggregate(f.Rows.Select(row => ParseLineTaxSummary(row.Values[1]))); var taxBreakdownTax = Try.Aggregate(f.Rows.Select(row => ParseLineTaxSummary(row.Values[2]))); return Try.Aggregate( taxBreakdownNet, taxBreakdownTax, (net, tax) => TaxSummary.Sum(net.Concat(tax)) ); })); }