コード例 #1
0
ファイル: DbInit.cs プロジェクト: olifantix/MC_Web3
        public static IList<Invoice> InitInvoicesFactory()
        {
            IList<CostCenter> costCenters = InitCostCenters();
            IList<CreditorData> creditorData = InitCreditorData();

            var retVal = new List<Invoice>();

            for (var i = 1; i <= 10; i++)
            {
                var cred = creditorData[i % creditorData.Count];
                var cost = costCenters[i % costCenters.Count];

                var dto = new DateTime(2016, 02, 05, 10, 00, 00);

                var invoice = new Invoice
                                  {
                                      Id = i,
                                      HeaderInfo = RandomHeaderInfo(cred),
                                      ScanImageUri = string.Format("/images/document_{0:yyyyMMdd}_{1:d6}.png",dto,i),
                                      Status = RandomInvoiceStatus()
                                  };
                invoice.Details = RandomInvoiceDetails(invoice, r.Next(2, 7), cost);

                invoice.HeaderInfo.TotalAmount = invoice.Details.Sum(d => d.Price);
                invoice.HeaderInfo.VatAmount = invoice.HeaderInfo.TotalAmount * 0.19m;

                retVal.Add(invoice);
            }

            return retVal;
        }
コード例 #2
0
ファイル: DbInit.cs プロジェクト: olifantix/MC_Web3
        private static ICollection<InvoiceDetail> RandomInvoiceDetails(Invoice invoice, int count, CostCenter cost)
        {
            IList<InvoiceDetail> retVal = new List<InvoiceDetail>();

            for (var i = 0; i < count; i++)
            {
                var artNr = CrazyNumber().Replace("-", ".");
                var detail = new InvoiceDetail
                                 {
                                     Id = invoiceDetailId++,
                                     Amount = r.Next(1, 6) * 100 + r.Next(0, 2) * 50,
                                     ArticleNumber = artNr,
                                     Invoice = invoice,
                                     CostCenter = cost,
                                     Description = string.Format("Desc for item # {0}", artNr),
                                     OrderNumber = CrazyNumber().Replace("-", ""),
                                     Price = 5 + r.Next(0, 10000) + r.Next(0, 100) / 100m
                                 };

                retVal.Add(detail);
            }

            return retVal;
        }