internal static Expression <Func <SalesOrder, SalesOrderInvoiceReturn> > SelectCustomerOrderInvoice() { var contractKey = ContractProjectors.SelectKey(); var loBac = LotProjectors.SelectLoBac(); var salesOrderItemKey = SalesOrderItemProjectors.SelectKey(); return(o => new SalesOrderInvoiceReturn { MovementNumber = o.InventoryShipmentOrder.MoveNum, InvoiceDateReturn = o.InvoiceDate, PONumber = o.InventoryShipmentOrder.PurchaseOrderNumber, FreightCharge = o.FreightCharge, InvoiceNotes = o.InvoiceNotes, CreditMemo = o.CreditMemo, Origin = o.InventoryShipmentOrder.SourceFacility.Name, ShipDate = o.InventoryShipmentOrder.ShipmentInformation.ShipmentDate, Broker = new[] { o.Broker }.Where(b => b != null).Select(b => b.Name).FirstOrDefault(), PaymentTerms = o.PaymentTerms, Freight = o.InventoryShipmentOrder.ShipmentInformation.FreightBillType, ShipVia = o.InventoryShipmentOrder.ShipmentInformation.ShipmentMethod, SoldTo = o.SoldTo, ShipTo = o.InventoryShipmentOrder.ShipmentInformation.ShipTo, PickedItems = o.SalesOrderPickedItems.Select(i => new SalesOrderInvoicePickedItemReturn { SalesOrderItemKeyReturn = salesOrderItemKey.Invoke(i.SalesOrderItem), ProductCode = i.PickedInventoryItem.Lot.ChileLot.ChileProduct.Product.ProductCode, ProductName = i.PickedInventoryItem.Lot.ChileLot.ChileProduct.Product.Name, ProductType = i.PickedInventoryItem.Lot.ChileLot.ChileProduct.ChileType.Description, CustomerProductCode = i.PickedInventoryItem.CustomerProductCode, PackagingName = i.PickedInventoryItem.PackagingProduct.Product.Name, TreatmentNameShort = i.PickedInventoryItem.Treatment.ShortName, QuantityShipped = i.PickedInventoryItem.Quantity, NetWeight = i.PickedInventoryItem.PackagingProduct.Weight * i.PickedInventoryItem.Quantity, LoBac = loBac.Invoke(i.PickedInventoryItem.Lot) }), OrderItems = o.SalesOrderItems.Select(i => new SalesOrderInvoiceOrderItemReturn { ProductCode = i.InventoryPickOrderItem.Product.ProductCode, ProductName = i.InventoryPickOrderItem.Product.Name, PackagingName = i.InventoryPickOrderItem.PackagingProduct.Product.Name, NetWeight = i.InventoryPickOrderItem.PackagingProduct.Weight * i.InventoryPickOrderItem.Quantity, SalesOrderItemKeyReturn = salesOrderItemKey.Invoke(i), ContractKeyReturn = new[] { i.ContractItem }.Where(n => n != null).Select(n => contractKey.Invoke(n.Contract)).FirstOrDefault(), ContractId = new[] { i.ContractItem }.Where(n => n != null).Select(n => n.Contract.ContractId).FirstOrDefault(), QuantityOrdered = i.InventoryPickOrderItem.Quantity, PriceBase = i.PriceBase, PriceFreight = i.PriceFreight, PriceTreatment = i.PriceTreatment, PriceWarehouse = i.PriceWarehouse, PriceRebate = i.PriceRebate }) }); }
internal static Expression <Func <SalesOrderItem, SalesOrderItemInternalAcknowledgement> > SelectInternalAcknoweldgement() { var key = SelectKey(); var contractKey = ContractProjectors.SelectKey(); return(Projector <SalesOrderItem> .To(i => new SalesOrderItemInternalAcknowledgement { OrderItemKeyReturn = key.Invoke(i), ContractKeyReturn = new[] { i.ContractItem }.Where(n => n != null).Select(n => contractKey.Invoke(n.Contract)).FirstOrDefault(), ContractId = new[] { i.ContractItem }.Where(n => n != null).Select(n => n.Contract.ContractId).FirstOrDefault(), TotalPrice = i.PriceBase + i.PriceFreight + i.PriceTreatment + i.PriceWarehouse - i.PriceRebate })); }
internal static Expression <Func <LotContractAllowance, LotContractAllowanceReturn> > Select() { var contractKey = ContractProjectors.SelectKey(); var customerKey = CustomerProjectors.SelectKey(); return(a => new LotContractAllowanceReturn { ContractKeyReturn = contractKey.Invoke(a.Contract), TermBegin = a.Contract.TermBegin, TermEnd = a.Contract.TermEnd, CustomerKeyReturn = customerKey.Invoke(a.Contract.Customer), CustomerName = a.Contract.Customer.Company.Name }); }