예제 #1
0
        public void ModifyPurchasePrepaymentInvoice(PurchasePrepaymentInvoiceDTO prepaymentInvoice)
        {
            Supplier supplier =
                _supplierRepository.GetFiltered(p => p.Id == prepaymentInvoice.SupplierId).FirstOrDefault();
            Order order = _orderRepository.Get(prepaymentInvoice.OrderId);
            Currency currency =
                _currencyRepository.GetFiltered(p => p.Id == prepaymentInvoice.CurrencyId).FirstOrDefault();

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

                UpdateInvoiceLines(prepaymentInvoice.InvoiceLines, updatePrepaymentInvoice, order);
                //更新从表。
            }
            _invoiceRepository.Modify(updatePrepaymentInvoice);
        }
예제 #2
0
 public void DeletePurchasePrepaymentInvoice(PurchasePrepaymentInvoiceDTO prepaymentInvoice)
 {
     if (prepaymentInvoice == null)
     {
         throw new ArgumentException("参数为空!");
     }
     BasePurchaseInvoice delPrepaymentInvoice =
         _invoiceRepository.GetBasePurchaseInvoice(prepaymentInvoice.PrepaymentInvoiceId);
     //获取需要删除的对象。
     if (delPrepaymentInvoice != null)
     {
         _invoiceRepository.DeleteInvoice(delPrepaymentInvoice); //删除预付款发票。
     }
 }
예제 #3
0
        public void InsertPurchasePrepaymentInvoice(PurchasePrepaymentInvoiceDTO prepaymentInvoice)
        {
            Supplier supplier =
                _supplierRepository.GetFiltered(p => p.Id == prepaymentInvoice.SupplierId).FirstOrDefault();
            Order order = _orderRepository.Get(prepaymentInvoice.OrderId);
            Currency currency =
                _currencyRepository.GetFiltered(p => p.Id == prepaymentInvoice.CurrencyId).FirstOrDefault();

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