Ejemplo n.º 1
0
        public void ModifyPurchaseCreditNoteInvoice(PurchaseCreditNoteDTO creditNoteInvoice)
        {
            Supplier supplier =
                _supplierRepository.GetFiltered(p => p.Id == creditNoteInvoice.SupplierId).FirstOrDefault();
            Order order = _orderRepository.Get(creditNoteInvoice.OrderId);
            Currency currency =
                _currencyRepository.GetFiltered(p => p.Id == creditNoteInvoice.CurrencyId).FirstOrDefault();

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

                UpdateInvoiceLines(creditNoteInvoice.InvoiceLines, updateCreditNoteInvoice, order);
                //更新从表。
            }
            _invoiceRepository.Modify(updateCreditNoteInvoice);
        }
Ejemplo n.º 2
0
 public void DeletePurchaseCreditNoteInvoice(PurchaseCreditNoteDTO creditNoteInvoice)
 {
     if (creditNoteInvoice == null)
     {
         throw new ArgumentException("参数为空!");
     }
     BasePurchaseInvoice delCreditNoteInvoice =
         _invoiceRepository.GetBasePurchaseInvoice(creditNoteInvoice.CreditNoteId);
     //获取需要删除的对象。
     if (delCreditNoteInvoice != null)
     {
         _invoiceRepository.DeleteInvoice(delCreditNoteInvoice); //删除贷项单。
     }
 }
Ejemplo n.º 3
0
        public void InsertPurchaseCreditNoteInvoice(PurchaseCreditNoteDTO creditNoteInvoice)
        {
            Supplier supplier =
                _supplierRepository.GetFiltered(p => p.Id == creditNoteInvoice.SupplierId).FirstOrDefault();
            Order order = _orderRepository.Get(creditNoteInvoice.OrderId);
            Currency currency =
                _currencyRepository.GetFiltered(p => p.Id == creditNoteInvoice.CurrencyId).FirstOrDefault();

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