Example #1
0
 public void AddToPurchaseInvoices(PurchaseInvoiceDTO purchaseInvoiceDTO)
 {
     base.AddObject("PurchaseInvoices", purchaseInvoiceDTO);
 }
Example #2
0
 public static PurchaseInvoiceDTO CreatePurchaseInvoiceDTO(int purchaseInvoiceId, global::System.DateTime invoiceDate, decimal invoiceValue, decimal paidAmount, global::System.DateTime createDate, bool isValid, bool isCompleted, int status, int orderId, int supplierId, int currencyId, global::System.Collections.ObjectModel.ObservableCollection<InvoiceLineDTO> invoiceLines)
 {
     PurchaseInvoiceDTO purchaseInvoiceDTO = new PurchaseInvoiceDTO();
     purchaseInvoiceDTO.PurchaseInvoiceId = purchaseInvoiceId;
     purchaseInvoiceDTO.InvoiceDate = invoiceDate;
     purchaseInvoiceDTO.InvoiceValue = invoiceValue;
     purchaseInvoiceDTO.PaidAmount = paidAmount;
     purchaseInvoiceDTO.CreateDate = createDate;
     purchaseInvoiceDTO.IsValid = isValid;
     purchaseInvoiceDTO.IsCompleted = isCompleted;
     purchaseInvoiceDTO.Status = status;
     purchaseInvoiceDTO.OrderId = orderId;
     purchaseInvoiceDTO.SupplierId = supplierId;
     purchaseInvoiceDTO.CurrencyId = currencyId;
     if ((invoiceLines == null))
     {
         throw new global::System.ArgumentNullException("invoiceLines");
     }
     purchaseInvoiceDTO.InvoiceLines = invoiceLines;
     return purchaseInvoiceDTO;
 }
Example #3
0
        private void SaveInit3006(PurchaseOrderDTO purchaseOrderDTO, int warehouseID)
        {
            if (this.purchaseOrderService.Save(purchaseOrderDTO))
            {
                PurchaseInvoiceDTO purchaseInvoiceDTO = new PurchaseInvoiceDTO();

                purchaseInvoiceDTO.EntryDate = purchaseOrderDTO.EntryDate;

                purchaseInvoiceDTO.SupplierID = purchaseOrderDTO.SupplierID;
                purchaseInvoiceDTO.PurchaseOrderID = purchaseOrderDTO.PurchaseOrderID;

                purchaseInvoiceDTO.PriceTermID = purchaseOrderDTO.PriceTermID;
                purchaseInvoiceDTO.PaymentTermID = purchaseOrderDTO.PaymentTermID;

                purchaseInvoiceDTO.PreparedPersonID = purchaseOrderDTO.PreparedPersonID;
                purchaseInvoiceDTO.ApproverID = purchaseOrderDTO.ApproverID;

                ICollection<PurchaseInvoiceViewDetail> purchaseInvoiceViewDetails = this.purchaseInvoiceService.GetPurchaseInvoiceViewDetails(purchaseInvoiceDTO.PurchaseInvoiceID, purchaseInvoiceDTO.PurchaseOrderID == null ? 0 : (int)purchaseInvoiceDTO.PurchaseOrderID, purchaseInvoiceDTO.SupplierID, false);

                Mapper.Map<ICollection<PurchaseInvoiceViewDetail>, ICollection<PurchaseInvoiceDetailDTO>>(purchaseInvoiceViewDetails, purchaseInvoiceDTO.ViewDetails);

                if (purchaseInvoiceDTO.GetDetails() != null && purchaseInvoiceDTO.GetDetails().Count > 0)
                    purchaseInvoiceDTO.GetDetails().Each(detailDTO =>
                    {
                        detailDTO.Quantity = detailDTO.QuantityRemains;

                        detailDTO.Amount = Math.Round(detailDTO.Quantity * detailDTO.UnitPrice, 0);
                        detailDTO.GrossAmount = Math.Round(detailDTO.Quantity * detailDTO.GrossPrice, 0);
                        detailDTO.VATAmount = Math.Round(detailDTO.GrossAmount - detailDTO.Amount, 0);

                        detailDTO.QuantityReceipt = 0;

                        purchaseInvoiceDTO.TotalQuantity = Math.Round(purchaseInvoiceDTO.TotalQuantity + detailDTO.Quantity, 0);
                        purchaseInvoiceDTO.TotalAmount = Math.Round(purchaseInvoiceDTO.TotalAmount + detailDTO.Amount, 0);
                        purchaseInvoiceDTO.TotalVATAmount = Math.Round(purchaseInvoiceDTO.TotalVATAmount + detailDTO.VATAmount, 0);
                        purchaseInvoiceDTO.TotalGrossAmount = Math.Round(purchaseInvoiceDTO.TotalGrossAmount + detailDTO.GrossAmount, 0);
                    });

                if (this.purchaseInvoiceService.Save(purchaseInvoiceDTO))
                {
                    GoodsReceiptDTO goodsReceiptDTO = new GoodsReceiptDTO();

                    goodsReceiptDTO.EntryDate = purchaseInvoiceDTO.EntryDate;

                    goodsReceiptDTO.VoucherID = purchaseInvoiceDTO.PurchaseInvoiceID;
                    goodsReceiptDTO.GoodsReceiptTypeID = (int)GlobalEnums.GoodsReceiptTypeID.PurchaseInvoice;

                    goodsReceiptDTO.PreparedPersonID = purchaseInvoiceDTO.PreparedPersonID;
                    goodsReceiptDTO.ApproverID = purchaseInvoiceDTO.ApproverID;

                    ICollection<GoodsReceiptViewDetail> goodsReceiptViewDetails = this.goodsReceiptService.GetGoodsReceiptViewDetails(goodsReceiptDTO.GoodsReceiptID, goodsReceiptDTO.GoodsReceiptTypeID, goodsReceiptDTO.VoucherID, false);

                    Mapper.Map<ICollection<GoodsReceiptViewDetail>, ICollection<GoodsReceiptDetailDTO>>(goodsReceiptViewDetails, goodsReceiptDTO.ViewDetails);

                    if (goodsReceiptDTO.GetDetails() != null && goodsReceiptDTO.GetDetails().Count > 0)
                        goodsReceiptDTO.GetDetails().Each(detailDTO =>
                        {

                            detailDTO.Quantity = detailDTO.QuantityRemains;

                            detailDTO.Amount = Math.Round(detailDTO.Quantity * detailDTO.UnitPrice, 0);
                            detailDTO.GrossAmount = Math.Round(detailDTO.Quantity * detailDTO.GrossPrice, 0);
                            detailDTO.VATAmount = Math.Round(detailDTO.GrossAmount - detailDTO.Amount, 0);

                            detailDTO.QuantityIssue = 0;

                            goodsReceiptDTO.TotalQuantity = Math.Round(goodsReceiptDTO.TotalQuantity + detailDTO.Quantity, 0);
                            goodsReceiptDTO.TotalAmount = Math.Round(goodsReceiptDTO.TotalAmount + detailDTO.Amount, 0);
                            goodsReceiptDTO.TotalVATAmount = Math.Round(goodsReceiptDTO.TotalVATAmount + detailDTO.VATAmount, 0);
                            goodsReceiptDTO.TotalGrossAmount = Math.Round(goodsReceiptDTO.TotalGrossAmount + detailDTO.GrossAmount, 0);

                            detailDTO.WarehouseID = warehouseID;
                        });
                    this.goodsReceiptService.Save(goodsReceiptDTO);
                }
            }
        }