Пример #1
0
 public void DeletePurchaseInvoice(PurchaseInvoiceDTO purchaseInvoice)
 {
     if (purchaseInvoice == null)
     {
         throw new ArgumentException("参数为空!");
     }
     BasePurchaseInvoice delPurchaseInvoice =
         _invoiceRepository.GetBasePurchaseInvoice(purchaseInvoice.PurchaseInvoiceId);
     //获取需要删除的对象。
     if (delPurchaseInvoice != null)
     {
         _invoiceRepository.DeleteInvoice(delPurchaseInvoice); //删除采购发票。
     }
 }
Пример #2
0
        public void ModifyPurchaseInvoice(PurchaseInvoiceDTO purchaseInvoice)
        {
            Supplier supplier =
                _supplierRepository.GetFiltered(p => p.Id == purchaseInvoice.SupplierId).FirstOrDefault();
            Order order = _orderRepository.Get(purchaseInvoice.OrderId);
            Currency currency =
                _currencyRepository.GetFiltered(p => p.Id == purchaseInvoice.CurrencyId).FirstOrDefault();

            BasePurchaseInvoice updatePurchaseInvoice =
                _invoiceRepository.GetBasePurchaseInvoice(purchaseInvoice.PurchaseInvoiceId);
            //获取需要更新的对象。
            if (updatePurchaseInvoice != null)
            {
                InvoiceFactory.SetInvoice(updatePurchaseInvoice, purchaseInvoice.InvoideCode,
                    purchaseInvoice.InvoiceDate, purchaseInvoice.OperatorName, purchaseInvoice.InvoiceNumber, supplier,
                    order,
                    purchaseInvoice.PaidAmount, currency, purchaseInvoice.PaymentScheduleLineId, purchaseInvoice.Status);
                //更新主表。

                UpdateInvoiceLines(purchaseInvoice.InvoiceLines, updatePurchaseInvoice, order);
                //更新从表。
            }
            _invoiceRepository.Modify(updatePurchaseInvoice);
        }
Пример #3
0
        public void InsertPurchaseInvoice(PurchaseInvoiceDTO purchaseInvoice)
        {
            Supplier supplier =
                _supplierRepository.GetFiltered(p => p.Id == purchaseInvoice.SupplierId).FirstOrDefault();
            Order order = _orderRepository.Get(purchaseInvoice.OrderId);
            Currency currency =
                _currencyRepository.GetFiltered(p => p.Id == purchaseInvoice.CurrencyId).FirstOrDefault();

            PurchaseInvoice newPurchaseInvoice = InvoiceFactory.CreatePurchaseInvoice(purchaseInvoice.InvoideCode,
                purchaseInvoice.InvoiceDate, purchaseInvoice.OperatorName);
            DateTime date = DateTime.Now.Date;
            int seq = _invoiceRepository.GetFiltered(t => t.CreateDate > date).Count() + 1;
            newPurchaseInvoice.SetInvoiceNumber(seq);
            newPurchaseInvoice.SetSupplier(supplier);
            newPurchaseInvoice.SetOrder(order);
            newPurchaseInvoice.SetPaidAmount(purchaseInvoice.PaidAmount);
            newPurchaseInvoice.SetCurrency(currency);
            newPurchaseInvoice.SetPaymentScheduleLine(purchaseInvoice.PaymentScheduleLineId);
            newPurchaseInvoice.SetInvoiceStatus(InvoiceStatus.草稿);
            foreach (InvoiceLineDTO invoiceLine in purchaseInvoice.InvoiceLines)
            {
                if (order != null)
                {
                    OrderLine orderLine = order.OrderLines.FirstOrDefault(p => p.Id == invoiceLine.OrderLineId);
                    newPurchaseInvoice.AddInvoiceLine(invoiceLine.ItemName, invoiceLine.Amount, orderLine,
                        invoiceLine.Note);
                }
                else
                {
                    newPurchaseInvoice.AddInvoiceLine(invoiceLine.ItemName, invoiceLine.Amount, null, invoiceLine.Note);
                }
            }
            newPurchaseInvoice.SetInvoiceValue();
            _invoiceRepository.Add(newPurchaseInvoice);
        }