示例#1
0
 public WaybillContent(
     WaybillHeader header,
     IReadOnlyCollection <WaybillItem> items,
     WaybillTotals totals)
 {
     Header = header ?? throw new ArgumentNullException(nameof(header));
     Items  = items ?? throw new ArgumentNullException(nameof(items));
     Totals = totals ?? throw new ArgumentNullException(nameof(totals));
 }
示例#2
0
        private static WaybillTotalsValidationResult ValidateTotals(
            WaybillTotals totals,
            IReadOnlyCollection <WaybillItem> waybillItems)
        {
            var hasEmptyTotalVatSum        = totals.TotalVatSum.GetValueOrDefault() == 0;
            var hasEmptyTotalSumWithVat    = totals.TotalSumWithVat.GetValueOrDefault() == 0;
            var hasEmptyTotalSumWithoutVat = totals.TotalSumWithoutVat.GetValueOrDefault() == 0;

            var sumWithoutVat = waybillItems.Sum(x => x.MonetaryValue.SumWithoutVat ?? 0);
            var sumWithVat    = waybillItems.Sum(x => x.MonetaryValue.SumWithVat ?? 0);
            var sumVat        = waybillItems.Sum(x => x.MonetaryValue.VatSum ?? 0);

            return(new WaybillTotalsValidationResult(
                       hasEmptySumWithoutVat: hasEmptyTotalSumWithoutVat,
                       hasEmptyTotalVatSum: hasEmptyTotalVatSum,
                       hasEmptySumWithVat: hasEmptyTotalSumWithVat,
                       hasInvalidSumWithoutVat: sumWithoutVat != totals.TotalSumWithoutVat,
                       hasInvalidTotalVatSum: sumVat != totals.TotalSumWithVat,
                       hasInvalidSumWithVat: sumWithVat != totals.TotalSumWithVat));
        }
示例#3
0
        private static WaybillContent MapToModel(this WaybillContentDto dto)
        {
            var documentHeader = new WaybillHeader(
                documentNumber: dto.DocumentNumber,
                documentDate: dto.DocumentDate,
                consignee: dto.Consignee);

            var documentItems = dto.Items
                                .Select(WaybillItemMapper.MapToModel)
                                .ToArray();

            var documentTotals = new WaybillTotals(
                totalSumWithoutVat: dto.TotalSumWithVat,
                totalVatSum: dto.TotalVat,
                totalSumWithVat: dto.TotalSumWithoutVat);

            return(new WaybillContent(
                       header: documentHeader,
                       items: documentItems,
                       totals: documentTotals));
        }
        public Task <WaybillContent> Parse(Stream waybillFileStream)
        {
            var header = new WaybillHeader(
                documentDate: new DateTime(2019, 06, 28),
                documentNumber: "1",
                consignee: "ООО ВЕКТОР"
                );

            var totals = new WaybillTotals(
                totalSumWithoutVat: 80508.47m,
                totalVatSum: 14491.53m,
                totalSumWithVat: 95000m
                );

            var content = new WaybillContent(
                header,
                new[] { CreateItem() },
                totals
                );

            return(Task.FromResult(content));
        }