예제 #1
0
 public void DeleteLeaseInvoice(LeaseInvoiceDTO leaseInvoice)
 {
     if (leaseInvoice == null)
     {
         throw new ArgumentException("参数为空!");
     }
     BasePurchaseInvoice delLeaseInvoice = _invoiceRepository.GetBasePurchaseInvoice(leaseInvoice.LeaseInvoiceId);
     //获取需要删除的对象。
     if (delLeaseInvoice != null)
     {
         _invoiceRepository.DeleteInvoice(delLeaseInvoice); //删除租赁发票。
     }
 }
예제 #2
0
        public void ModifyLeaseInvoice(LeaseInvoiceDTO leaseInvoice)
        {
            Supplier supplier = _supplierRepository.GetFiltered(p => p.Id == leaseInvoice.SupplierId).FirstOrDefault();
            Order order = _orderRepository.Get(leaseInvoice.OrderId);
            Currency currency = _currencyRepository.GetFiltered(p => p.Id == leaseInvoice.CurrencyId).FirstOrDefault();

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

                UpdateInvoiceLines(leaseInvoice.InvoiceLines, updateLeaseInvoice, order);
                //更新从表。
            }
            _invoiceRepository.Modify(updateLeaseInvoice);
        }
예제 #3
0
        public void InsertLeaseInvoice(LeaseInvoiceDTO leaseInvoice)
        {
            Supplier supplier = _supplierRepository.GetFiltered(p => p.Id == leaseInvoice.SupplierId).FirstOrDefault();
            Order order = _orderRepository.Get(leaseInvoice.OrderId);
            Currency currency = _currencyRepository.GetFiltered(p => p.Id == leaseInvoice.CurrencyId).FirstOrDefault();

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