public virtual DomainModel.Orders.Order Convert([NotNull] Order source) { Assert.ArgumentNotNull(source, "source"); DomainModel.Orders.Order destination = new DomainModel.Orders.Order(); destination.OrderDate = source.IssueDate; destination.OrderNumber = source.OrderId; destination.TrackingNumber = source.Delivery.First().TrackingID; destination.TransactionNumber = source.PaymentMeans.PaymentID; destination.NotificationOption = this.GetNotificationOption(); destination.NotificationOptionValue = source.BuyerCustomerParty.Party.Contact.ElectronicMail; destination.PaymentSystem = new PaymentSystem { Code = source.PaymentMeans.PaymentChannelCode }; destination.Comment = source.Note; destination.Currency = new Currency { Code = source.PricingCurrencyCode, Name = source.PricingCurrencyCode, Title = source.PricingCurrencyCode }; destination.CustomerInfo = new CustomerInfo { CustomerId = source.BuyerCustomerParty.SupplierAssignedAccountID, Email = source.BuyerCustomerParty.Party.Contact.ElectronicMail, Fax = source.BuyerCustomerParty.Party.Contact.Telefax, Phone = source.BuyerCustomerParty.Party.Contact.Telephone, BillingAddress = new AddressInfo { Address = source.AccountingCustomerParty.Party.PostalAddress.StreetName, Address2 = source.AccountingCustomerParty.Party.PostalAddress.StreetName, Zip = source.AccountingCustomerParty.Party.PostalAddress.PostalZone, City = source.AccountingCustomerParty.Party.PostalAddress.CityName, State = source.AccountingCustomerParty.Party.PostalAddress.CountrySubentity, Country = this.GetCountry(source.AccountingCustomerParty.Party.PostalAddress.Country), Name2 = source.AccountingCustomerParty.Party.Contact.Name, Name = source.AccountingCustomerParty.Party.PartyName, }, ShippingAddress = new AddressInfo { Address = source.Delivery.First().DeliveryLocation.Address.StreetName, Address2 = source.Delivery.First().DeliveryLocation.Address.StreetName, Zip = source.Delivery.First().DeliveryLocation.Address.PostalZone, City = source.Delivery.First().DeliveryLocation.Address.CityName, State = source.Delivery.First().DeliveryLocation.Address.CountrySubentity, Country = this.GetCountry(source.Delivery.First().DeliveryLocation.Address.Country), Name2 = source.Delivery.First().DeliveryParty.Contact.Name, Name = source.Delivery.First().DeliveryParty.PartyName, } }; destination.CustomerInfo.CustomProperties.Add(TransactionConstants.CardType, source.PaymentMeans.PaymentMeansCode); destination.Totals = new Totals { TotalPriceIncVat = source.AnticipatedMonetaryTotal.PayableAmount.Value, TotalPriceExVat = source.AnticipatedMonetaryTotal.PayableAmount.Value - source.AnticipatedMonetaryTotal.TaxExclusiveAmount.Value, PriceIncVat = source.AnticipatedMonetaryTotal.PayableAmount.Value, PriceExVat = source.AnticipatedMonetaryTotal.PayableAmount.Value - source.AnticipatedMonetaryTotal.TaxExclusiveAmount.Value, TotalVat = source.AnticipatedMonetaryTotal.TaxExclusiveAmount.Value, VAT = source.TaxTotal.TaxSubtotal.First().TaxCategory.Percent / 100 }; var shippingPrice = source.AllowanceCharge.Sum(ac => ac.ChargeIndicator && ac.AllowanceChargeReasonCode == "ZZZ" ? ac.Amount.Value : 0); destination.ShippingPrice = shippingPrice; destination.ShippingProvider = this.GetShippingProvider(source.FreightForwarderParty.First().PartyIdentification); destination.ShippingProvider.Price = shippingPrice; destination.Status = this.GetStatus(source.State); destination.OrderLines = new List <DomainModel.Orders.OrderLine>(source.OrderLines.Count); uint i = 0; foreach (OrderLine orderLine in source.OrderLines) { DomainModel.Orders.OrderLine newOrderLine = new DomainModel.Orders.OrderLine { Product = new Product { Code = orderLine.LineItem.Item.Code, Name = orderLine.LineItem.Item.Name, Title = orderLine.LineItem.Item.Name, Description = orderLine.LineItem.Item.Description }, Totals = new Totals { TotalPriceExVat = orderLine.LineItem.LineExtensionAmount.Value, PriceExVat = orderLine.LineItem.Price.PriceAmount.Value, TotalVat = orderLine.LineItem.TotalTaxAmount.Value, VAT = source.TaxTotal.TaxSubtotal.First(ts => ts.CalculationSequenceNumeric == i).TaxCategory.Percent / 100 }, Quantity = (uint)orderLine.LineItem.Quantity, ImageUrl = orderLine.LineItem.Item.AdditionalInformation, FriendlyUrl = orderLine.LineItem.Item.Keyword }; newOrderLine.Totals.TotalPriceIncVat = newOrderLine.Totals.TotalPriceExVat + newOrderLine.Totals.TotalVat; newOrderLine.Totals.PriceIncVat = newOrderLine.Totals.PriceExVat * (1 + newOrderLine.Totals.VAT); destination.OrderLines.Add(newOrderLine); i++; } this.MapReservationTicket(source, destination); return(destination); }
public virtual DomainModel.Orders.Order Convert([NotNull] Order source) { Assert.ArgumentNotNull(source, "source"); DomainModel.Orders.Order destination = new DomainModel.Orders.Order(); destination.OrderDate = source.IssueDate; destination.OrderNumber = source.OrderId; destination.TrackingNumber = source.Delivery.First().TrackingID; destination.TransactionNumber = source.PaymentMeans.PaymentID; destination.NotificationOption = this.GetNotificationOption(); destination.NotificationOptionValue = source.BuyerCustomerParty.Party.Contact.ElectronicMail; destination.PaymentSystem = new PaymentSystem { Code = source.PaymentMeans.PaymentChannelCode }; destination.Comment = source.Note; destination.Currency = new Currency { Code = source.PricingCurrencyCode, Name = source.PricingCurrencyCode, Title = source.PricingCurrencyCode }; destination.CustomerInfo = new CustomerInfo { CustomerId = source.BuyerCustomerParty.SupplierAssignedAccountID, Email = source.BuyerCustomerParty.Party.Contact.ElectronicMail, Fax = source.BuyerCustomerParty.Party.Contact.Telefax, Phone = source.BuyerCustomerParty.Party.Contact.Telephone, BillingAddress = new AddressInfo { Address = source.AccountingCustomerParty.Party.PostalAddress.StreetName, Address2 = source.AccountingCustomerParty.Party.PostalAddress.StreetName, Zip = source.AccountingCustomerParty.Party.PostalAddress.PostalZone, City = source.AccountingCustomerParty.Party.PostalAddress.CityName, State = source.AccountingCustomerParty.Party.PostalAddress.CountrySubentity, Country = this.GetCountry(source.AccountingCustomerParty.Party.PostalAddress.Country), Name2 = source.AccountingCustomerParty.Party.Contact.Name, Name = source.AccountingCustomerParty.Party.PartyName, }, ShippingAddress = new AddressInfo { Address = source.Delivery.First().DeliveryLocation.Address.StreetName, Address2 = source.Delivery.First().DeliveryLocation.Address.StreetName, Zip = source.Delivery.First().DeliveryLocation.Address.PostalZone, City = source.Delivery.First().DeliveryLocation.Address.CityName, State = source.Delivery.First().DeliveryLocation.Address.CountrySubentity, Country = this.GetCountry(source.Delivery.First().DeliveryLocation.Address.Country), Name2 = source.Delivery.First().DeliveryParty.Contact.Name, Name = source.Delivery.First().DeliveryParty.PartyName, } }; destination.CustomerInfo.CustomProperties.Add(TransactionConstants.CardType, source.PaymentMeans.PaymentMeansCode); destination.Totals = new Totals { TotalPriceIncVat = source.AnticipatedMonetaryTotal.PayableAmount.Value, TotalPriceExVat = source.AnticipatedMonetaryTotal.PayableAmount.Value - source.AnticipatedMonetaryTotal.TaxExclusiveAmount.Value, PriceIncVat = source.AnticipatedMonetaryTotal.PayableAmount.Value, PriceExVat = source.AnticipatedMonetaryTotal.PayableAmount.Value - source.AnticipatedMonetaryTotal.TaxExclusiveAmount.Value, TotalVat = source.AnticipatedMonetaryTotal.TaxExclusiveAmount.Value, VAT = source.TaxTotal.TaxSubtotal.First().TaxCategory.Percent / 100 }; var shippingPrice = source.AllowanceCharge.Sum(ac => ac.ChargeIndicator && ac.AllowanceChargeReasonCode == "ZZZ" ? ac.Amount.Value : 0); destination.ShippingPrice = shippingPrice; destination.ShippingProvider = this.GetShippingProvider(source.FreightForwarderParty.First().PartyIdentification); destination.ShippingProvider.Price = shippingPrice; destination.Status = this.GetStatus(source.State); destination.OrderLines = new List<DomainModel.Orders.OrderLine>(source.OrderLines.Count); uint i = 0; foreach (OrderLine orderLine in source.OrderLines) { DomainModel.Orders.OrderLine newOrderLine = new DomainModel.Orders.OrderLine { Product = new Product { Code = orderLine.LineItem.Item.Code, Name = orderLine.LineItem.Item.Name, Title = orderLine.LineItem.Item.Name, Description = orderLine.LineItem.Item.Description }, Totals = new Totals { TotalPriceExVat = orderLine.LineItem.LineExtensionAmount.Value, PriceExVat = orderLine.LineItem.Price.PriceAmount.Value, TotalVat = orderLine.LineItem.TotalTaxAmount.Value, VAT = source.TaxTotal.TaxSubtotal.First(ts => ts.CalculationSequenceNumeric == i).TaxCategory.Percent / 100 }, Quantity = (uint)orderLine.LineItem.Quantity, ImageUrl = orderLine.LineItem.Item.AdditionalInformation, FriendlyUrl = orderLine.LineItem.Item.Keyword }; newOrderLine.Totals.TotalPriceIncVat = newOrderLine.Totals.TotalPriceExVat + newOrderLine.Totals.TotalVat; newOrderLine.Totals.PriceIncVat = newOrderLine.Totals.PriceExVat * (1 + newOrderLine.Totals.VAT); destination.OrderLines.Add(newOrderLine); i++; } this.MapReservationTicket(source, destination); return destination; }