public ShopifyAddress(IAddress inAddress) { this.Address1 = inAddress.Street1; this.Address2 = inAddress.Street2; this.City = inAddress.City; this.Company = inAddress.Name; this.Country = Enumerable.FirstOrDefault<string>(CountryCodes.Instance().countryToCode.Where(Item => Item.Value == inAddress.CountryCode).Select(Item => Item.Key)); this.CountryCode = inAddress.CountryCode; string[] names = inAddress.Name.Split(' '); if(names!=null && names.Count()>0) { this.FirstName = names[0]; //the remainder of the string is the last name. foreach (string name in names.Where(item => item!= FirstName).Select(item=>item).ToArray<string>()) { this.LastName += (name + " "); } LastName.TrimEnd(' '); //remove the trailing ' ' } else { this.FirstName = "Unnamed"; this.LastName = "Unnamed"; } this.Name = inAddress.Name; this.PhoneNumber = ""; this.Province = inAddress.Region; this.ProvinceCode = inAddress.Region; this.Zip = inAddress.PostalCode; }
public INatterConnection Call(IAddress address) { var connection = CreateNewConnection(CreateConnectionId(), address); _connections[connection.ConnectionId] = connection; connection.Call(); return connection; }
/// <summary> /// Creates a Braintree <see cref="Customer"/> from a Merchello <see cref="ICustomer"/> /// </summary> /// <param name="customer"> /// The customer. /// </param> /// <param name="paymentMethodNonce"> /// The "nonce-from-the-client" /// </param> /// <param name="billingAddress"> /// The billing address /// </param> /// <param name="shippingAddress"> /// The shipping Address. /// </param> /// <returns> /// The <see cref="Attempt{Customer}"/>. /// </returns> public Attempt<Customer> Create(ICustomer customer, string paymentMethodNonce = "", IAddress billingAddress = null, IAddress shippingAddress = null) { if (Exists(customer)) return Attempt.Succeed(GetBraintreeCustomer(customer)); var request = RequestFactory.CreateCustomerRequest(customer, paymentMethodNonce, billingAddress); Creating.RaiseEvent(new Core.Events.NewEventArgs<CustomerRequest>(request), this); // attempt the API call var attempt = TryGetApiResult(() => BraintreeGateway.Customer.Create(request)); if (!attempt.Success) return Attempt<Customer>.Fail(attempt.Exception); var result = attempt.Result; if (result.IsSuccess()) { Created.RaiseEvent(new Core.Events.NewEventArgs<Customer>(result.Target), this); return Attempt.Succeed((Customer)RuntimeCache.GetCacheItem(MakeCustomerCacheKey(customer), () => result.Target)); } var error = new BraintreeApiException(result.Errors); LogHelper.Error<BraintreeCustomerApiService>("Braintree API Customer Create return a failure", error); return Attempt<Customer>.Fail(error); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultWarehousePackagingStrategy"/> class. /// </summary> /// <param name="lineItemCollection"> /// The line item collection. /// </param> /// <param name="destination"> /// The destination. /// </param> /// <param name="versionKey"> /// The version key. /// </param> public DefaultWarehousePackagingStrategy( LineItemCollection lineItemCollection, IAddress destination, Guid versionKey) : base(lineItemCollection, destination, versionKey) { }
public bool AddressIsInZone(IAddress address) { bool result = false; Country c = Country.FindByBvin(address.CountryData.Bvin); if (c != null) { foreach (ZoneArea a in Areas) { if (a.CountryIsoAlpha3.Trim().ToLowerInvariant() == c.IsoAlpha3.Trim().ToLowerInvariant()) { // Country matches if (a.RegionAbbreviation.Trim() == string.Empty) { // empty region abbreviation means match all return true; } else { if (address.RegionData.Abbreviation.Trim().ToLowerInvariant() == a.RegionAbbreviation.Trim().ToLowerInvariant()) { return true; } } } } } return result; }
public static void CopyFrom(this IAddress to, IAddress from) { to.Street = from.Street; to.City = from.City; to.State = from.State; to.Zip = from.Zip; }
internal Shipment(IAddress origin, IAddress destination, LineItemCollection items) { Mandate.ParameterNotNull(origin, "origin"); Mandate.ParameterNotNull(destination, "destination"); Mandate.ParameterNotNull(items, "items"); _fromOrganization = origin.Organization; _fromName = origin.Name; _fromAddress1 = origin.Address1; _fromAddress2 = origin.Address2; _fromLocality = origin.Locality; _fromRegion = origin.Region; _fromPostalCode = origin.PostalCode; _fromCountryCode = origin.CountryCode; _fromIsCommercial = origin.IsCommercial; _toOrganization = destination.Organization; _toName = destination.Name; _toAddress1 = destination.Address1; _toAddress2 = destination.Address2; _toLocality = destination.Locality; _toRegion = destination.Region; _toPostalCode = destination.PostalCode; _toCountryCode = destination.CountryCode; _toIsCommercial = destination.IsCommercial; _phone = destination.Phone; _email = destination.Email; _items = items; }
public void changes_to_the_source_should_be_marshalled_via_a_call_to_send(Mock<SynchronizationContext> synchronizationContext, BindingManager bindingManager, IPerson targetObject, IAddress sourceObject) { synchronizationContext.Setup(x => x.Send(It.IsAny<SendOrPostCallback>(), It.IsAny<object>())); sourceObject.Line1 = "Line 1, mighty fine"; synchronizationContext.VerifyAll(); }
public static MapsLookupResult GeocodeAddress(IAddress addr) { MapsLookupResult result = new MapsLookupResult { Result = LookupResult.Error }; if (addr.Street.ToLower().StartsWith("po box")) { result.Result = LookupResult.NotFound; return result; } WebClient client = new WebClient(); XmlDocument xml = new System.Xml.XmlDocument(); string url = string.Format("http://maps.google.com/maps/geo?q={0}&key={1}&output=xml", System.Web.HttpUtility.UrlEncode(string.Format("{0}, {1} {2} {3}", addr.Street, addr.City, addr.State, addr.Zip)), System.Configuration.ConfigurationManager.AppSettings["MapsKey"] ); xml.LoadXml(client.DownloadString(url)); XmlElement root = xml.DocumentElement; XmlNamespaceManager nsmgr = new XmlNamespaceManager(xml.NameTable); nsmgr.AddNamespace("k", root.NamespaceURI); nsmgr.AddNamespace("d", "urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"); string status = xml.SelectSingleNode("//k:Response/k:Status/k:code", nsmgr).InnerText; if (status != "200") { // Error } else { XmlNode details = xml.SelectSingleNode("//d:AddressDetails", nsmgr); string accuracyString = ((XmlElement)details).GetAttribute("Accuracy"); result.Quality = int.Parse(accuracyString); result.Result = LookupResult.Range; if (result.Quality > 5) { result.Result = LookupResult.Success; result.Street = details.SelectSingleNode("//d:ThoroughfareName", nsmgr).InnerText; } if (result.Quality > 4) { result.Zip = details.SelectSingleNode("//d:PostalCodeNumber", nsmgr).InnerText; } result.City = details.SelectSingleNode("//d:LocalityName", nsmgr).InnerText; result.State = details.SelectSingleNode("//d:AdministrativeAreaName", nsmgr).InnerText; string[] coords = details.SelectSingleNode("//k:Response/k:Placemark/k:Point", nsmgr).InnerText.Split(','); double lat = double.Parse(coords[1]); double lng = double.Parse(coords[0]); double z = GeographyServices.GetElevation(lat, lng); string point = (z > 0) ? string.Format("POINT({0} {1} {2} NULL)", lng, lat, z) : string.Format("POINT({0} {1})", lng, lat); result.Geography = SqlGeography.STGeomFromText(new SqlChars(point.ToCharArray()), GeographyServices.SRID); } return result; }
/// <summary> /// Calculates tax for invoice. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="taxAddress"> /// The tax address. /// </param> /// <returns> /// The <see cref="ITaxCalculationResult"/>. /// </returns> public override ITaxCalculationResult CalculateTaxForInvoice(IInvoice invoice, IAddress taxAddress) { decimal amount = 0m; foreach (var item in invoice.Items) { // can I use?: https://github.com/Merchello/Merchello/blob/5706b8c9466f7417c41fdd29de7930b3e8c4dd2d/src/Merchello.Core/Models/ExtendedDataExtensions.cs#L287-L295 if (item.ExtendedData.GetTaxableValue()) amount = amount + item.TotalPrice; } TaxRequest taxRequest = new TaxRequest(); taxRequest.Amount = amount; taxRequest.Shipping = invoice.TotalShipping(); taxRequest.ToCity = taxAddress.Locality; taxRequest.ToCountry = taxAddress.CountryCode; taxRequest.ToState = taxAddress.Region; taxRequest.ToZip = taxAddress.PostalCode; Models.TaxResult taxResult = _taxjarService.GetTax(taxRequest); if (taxResult.Success) { var extendedData = new ExtendedDataCollection(); extendedData.SetValue(Core.Constants.ExtendedDataKeys.TaxTransactionResults, JsonConvert.SerializeObject(taxResult)); return new TaxCalculationResult(TaxMethod.Name, taxResult.Rate, taxResult.TotalTax, extendedData); } throw new Exception("TaxJar.com error"); }
public ShipmentMock(IAddress origin, IAddress destination, LineItemCollection items) { this.ShippedDate = DateTime.Now; this.FromOrganization = origin.Organization; this.FromName = origin.Name; this.FromAddress1 = origin.Address1; this.FromAddress2 = origin.Address2; this.FromLocality = origin.Locality; this.FromRegion = origin.Region; this.FromPostalCode = origin.PostalCode; this.FromCountryCode = origin.CountryCode; this.FromIsCommercial = origin.IsCommercial; this.ToOrganization = destination.Organization; this.ToName = destination.Name; this.ToAddress1 = destination.Address1; this.ToAddress2 = destination.Address2; this.ToLocality = destination.Locality; this.ToRegion = destination.Region; this.ToPostalCode = destination.PostalCode; this.ToCountryCode = destination.CountryCode; this.ToIsCommercial = destination.IsCommercial; this.Phone = destination.Phone; this.Email = destination.Email; this.Items = items; }
public void it_must_have_a_converter(BindingManager bindingManager, MultiSourceBinding binding, IPerson targetObject, IAddress sourceObject) { bindingManager.Bindings.Remove(binding); binding.Converter = null; var ex = Assert.Throws<InvalidOperationException>(() => bindingManager.Bindings.Add(binding)); Assert.Equal("All MultiSourceBindings require a converter.", ex.Message); }
/// <summary> /// Builds a location from an <see cref="IAddress"/> and <see cref="IGeocodeProviderResponse"/>. /// </summary> /// <param name="address"> /// The address. /// </param> /// <param name="response"> /// The response. /// </param> /// <returns> /// The <see cref="ILocation"/>. /// </returns> public ILocation BuildLocation(IAddress address, IGeocodeProviderResponse response) { //TODO: HLF Fix this //var definitionFactory = new LocationTypeDefinitionFactory(); //var def = definitionFactory.GetEmptyDefaultLocationTypeDefinition(); //def.Fields.Address1().Value = address.Address1; //def.Fields.Address2().Value = address.Address2; //def.Fields.Locality().Value = address.Locality; //def.Fields.Region().Value = address.Region; //def.Fields.PostalCode().Value = address.PostalCode; //def.Fields.CountryCode().Value = address.CountryCode; var location = new Location()//def.Fields { //LocationTypeId = def.Id, GeocodeStatus = response.Status }; if (response.Status != GeocodeStatus.Ok) return location; if (!response.Results.Any()) return location; var result = response.Results.First(); location.Coordinate = new Coordinate() { Latitude = result.Latitude, Longitude = result.Longitude }; location.Viewport = result.Viewport; return location; }
/// <summary> /// Initializes a new instance of the <see cref="FixedRateTaxCalculationStrategy"/> class. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="taxAddress"> /// The tax address. /// </param> /// <param name="taxMethod"> /// The tax method. /// </param> public FixedRateTaxCalculationStrategy(IInvoice invoice, IAddress taxAddress, ITaxMethod taxMethod) : base(invoice, taxAddress) { Mandate.ParameterNotNull(taxMethod, "countryTaxRate"); _taxMethod = taxMethod; }
public bool Equals(IAddress other) { return AddressLine.Equals(other.AddressLine, StringComparison.CurrentCultureIgnoreCase) && City.Equals(other.City, StringComparison.CurrentCultureIgnoreCase) && State.Equals(other.State) && ZipCode.Equals(other.ZipCode, StringComparison.CurrentCultureIgnoreCase); }
public PersonEntry(ILocationService locationService, IAddress address) { _locationService = locationService; _address = address; _roAvailableCountries = new ReadOnlyObservableCollection<ICountry>(_availableCountries); }
/// <summary> /// Builds the <see cref="AddressType"/>. /// </summary> /// <param name="address"> /// The address. /// </param> /// <returns> /// The <see cref="AddressType"/>. /// </returns> public AddressType Build(IAddress address) { try { return new AddressType { Name = address.Name, Street1 = address.Address1, Street2 = address.Address2, PostalCode = address.PostalCode, CityName = address.Locality, StateOrProvince = address.Region, CountryName = address.Country().Name, Country = (CountryCodeType) Enum.Parse(typeof(CountryCodeType), address.Country().CountryCode, true), Phone = address.Phone }; } catch (Exception ex) { var logData = MultiLogger.GetBaseLoggingData(); logData.AddCategory("PayPal"); MultiLogHelper.Error<PayPalBasicAmountTypeFactory>("Failed to build an AddressType", ex, logData); throw; } }
public ILatLong GeocodeAddress(IAddress address) { return new LatLong() { Latitude = 48.858001709, Longitude = 2.29460000992 }; }
public void it_is_not_yet_active(MultiSourceBinding binding, IPerson targetObject, IAddress sourceObject) { sourceObject.Line1 = "Line 1"; Assert.Null(targetObject.Name); targetObject.Name = "Another Name"; Assert.Equal("Line 1", sourceObject.Line1); }
public void updating_the_target_does_not_update_the_source(BindingManager bindingManager, IPerson targetObject, IAddress sourceObject) { targetObject.Name = "A new address"; Assert.Null(sourceObject.Line1); targetObject.Name = "Another new address"; Assert.Null(sourceObject.Line1); }
private System.Timers.Timer CreateTimer(IAddress replyTo, double milliseconds, string text) { var t = new System.Timers.Timer(); t.Interval = milliseconds; t.Elapsed += GetElapsedEvent(t, replyTo, text); t.Enabled = true; return t; }
private System.Timers.ElapsedEventHandler GetElapsedEvent(System.Timers.Timer t, IAddress replyTo, string text) { return (o, e) => { RemoveAndDisposeTimer(t); this.backend.SendMessageAsync(replyTo, text); }; }
/// <summary> /// Initializes a new instance of the <see cref="TaxCalculationStrategyBase"/> class. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="taxAddress"> /// The tax address. /// </param> protected TaxCalculationStrategyBase(IInvoice invoice, IAddress taxAddress) { Mandate.ParameterNotNull(invoice, "invoice"); Mandate.ParameterNotNull(taxAddress, "taxAddress"); _invoice = invoice; _taxAddress = taxAddress; }
/// <summary> /// Initializes a new instance of the <see cref="DefaultWarehousePackagingStrategy"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="lineItemCollection"> /// The line item collection. /// </param> /// <param name="destination"> /// The destination. /// </param> /// <param name="versionKey"> /// The version key. /// </param> public DefaultWarehousePackagingStrategy( IMerchelloContext merchelloContext, LineItemCollection lineItemCollection, IAddress destination, Guid versionKey) : base(merchelloContext, lineItemCollection, destination, versionKey) { }
public void it_becomes_inactive(BindingManager bindingManager, BindingBase binding, IPerson targetObject, IAddress sourceObject) { sourceObject.Line1 = "New Name"; Assert.Null(targetObject.Name); targetObject.Name = "Another Name"; Assert.Equal("New Name", sourceObject.Line1); }
public override ITaxStructured DoCalc( TaxSession session, IAddress fromAddress, IAddress toAddress, Amount amount, Amount shipping) { return TaxStructured.NoneInstance; }
public override ITaxStructured DoCalc( TaxSession session, IAddress fromAddress, IAddress toAddress, Amount amount, Amount shipping) { return DoCalc(session as TaxJarSession, fromAddress, toAddress, amount, shipping); }
public void BindInvoiceAddress(IAddress address) { string addressText = _addressFormatter.FormatAddress(address); litInvoiceAddress.Text = (!string.IsNullOrEmpty(addressText)) ? "<table>" + addressText + "</table>" : ""; if (litDeliveryAddress.Text.Length == 0) { litDeliveryAddress.Text = litInvoiceAddress.Text; } }
public void Send(string connectionId, IMessage message, IAddress address) { var destination = address as UdpAddress; if (destination == null) { throw new Exception("The destination is invalid"); } Send(destination, message.Serialise()); }
public void it_becomes_active(BindingManager bindingManager, MultiSourceBinding binding, IPerson targetObject, IAddress sourceObject) { sourceObject.Line1 = "Line 1, mighty fine"; Assert.Equal("Line 1, mighty fine~", targetObject.Name); targetObject.Name = "Foo~Bar"; Assert.Equal("Foo", sourceObject.Line1); Assert.Equal("Bar", sourceObject.Line2); }
public void updating_the_source_updates_the_target(BindingManager bindingManager, IPerson targetObject, IAddress sourceObject) { sourceObject.Line1 = "A new address"; Assert.Equal("A new address", targetObject.Name); sourceObject.Line1 = "Another new address"; Assert.Equal("Another new address", targetObject.Name); sourceObject.Line1 = null; Assert.Null(targetObject.Name); }
public Task <bool> FlushAsync(IAddress key, CancellationToken cancellationToken) { return(Task.FromResult(true)); }
public static string GetCountryName(this IAddress address) { var country = MrCMSApplication.Get <ICountryService>().GetCountryByCode(address.CountryCode); return(country != null ? country.Name : string.Empty); }
/// <summary> /// Initializes a new instance of <see cref="SenderRouting"/> /// </summary> /// <param name="senderType">Transport specific type of the local <see cref="ISender"/></param> /// <param name="address"><see cref="IAddress"/> of the remote <see cref="IReceiver"/></param> private SenderRouting(Type senderType, IAddress address) { SenderType = senderType ?? throw new ArgumentNullException(nameof(senderType)); Address = address ?? throw new ArgumentNullException(nameof(address)); }
public void PutFlag(string key, string flag, IAddress destination) { dataManager.DispatchData(key, Encoding.UTF8.GetBytes(flag), destination); }
/// <summary> /// Saves the ship to address /// </summary> /// <param name="shipToAddress">The shipping <see cref="IAddress"/></param> public virtual void SaveShipToAddress(IAddress shipToAddress) { _customer.ExtendedData.AddAddress(shipToAddress, AddressType.Shipping); SaveCustomer(_merchelloContext, _customer, RaiseCustomerEvents); }
public ICompletesEventually ProvideCompletesFor(IAddress address, ICompletes?clientCompletes) => new PooledCompletes( completesEventuallyId.GetAndIncrement(), clientCompletes, CompletesEventuallyOf(address));
/// <summary> /// Performs a Braintree sales transaction. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="paymentMethodNonce"> /// The payment method nonce. /// </param> /// <param name="customer"> /// The customer. /// </param> /// <param name="billingAddress"> /// The billing address. /// </param> /// <param name="shippingAddress"> /// The shipping address. /// </param> /// <param name="option"> /// The option. /// </param> /// <returns> /// The <see cref="IPaymentResult"/>. /// </returns> public Result <Transaction> Sale(IInvoice invoice, string paymentMethodNonce, ICustomer customer, IAddress billingAddress, IAddress shippingAddress, TransactionOption option = TransactionOption.SubmitForSettlement) { var request = this.RequestFactory.CreateTransactionRequest(invoice, paymentMethodNonce, customer, option); if (billingAddress != null) { request.BillingAddress = this.RequestFactory.CreateAddressRequest(billingAddress); } if (shippingAddress != null) { request.ShippingAddress = this.RequestFactory.CreateAddressRequest(shippingAddress); } LogHelper.Info <BraintreeTransactionApiService>(string.Format("Braintree Transaction attempt ({0}) for Invoice {1}", option.ToString(), invoice.PrefixedInvoiceNumber())); var attempt = this.TryGetApiResult(() => this.BraintreeGateway.Transaction.Sale(request)); return(attempt.Success ? attempt.Result : null); }
public void updating_the_target_updates_the_source(BindingManager bindingManager, IPerson targetObject, IAddress sourceObject) { targetObject.Name = "A new address"; Assert.Equal("A new address", sourceObject.Line1); targetObject.Name = "Another new address"; Assert.Equal("Another new address", sourceObject.Line1); targetObject.Name = null; Assert.Null(sourceObject.Line1); }
/// <summary> /// Performs a Braintree sales transaction. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="paymentMethodNonce"> /// The payment method nonce. /// </param> /// <param name="customer"> /// The customer. /// </param> /// <param name="billingAddress"> /// The billing address. /// </param> /// <param name="option"> /// The transaction option. /// </param> /// <returns> /// The <see cref="Result{Transaction}"/>. /// </returns> public Result <Transaction> Sale(IInvoice invoice, string paymentMethodNonce, ICustomer customer, IAddress billingAddress, TransactionOption option = TransactionOption.SubmitForSettlement) { return(this.Sale(invoice, paymentMethodNonce, customer, billingAddress, null, option)); }
void IContact.SetAddress1(IAddress address) { Address1 = (Address)address; }
private int MapIndex(IAddress address) => Math.Abs(address.GetHashCode() % maps.Length);
/// <summary> /// Creates a <see cref="IShipment"/> without persisting it to the database. /// </summary> /// <param name="shipmentStatus"> /// The shipment status. /// </param> /// <param name="origin"> /// The origin. /// </param> /// <param name="destination"> /// The destination. /// </param> /// <param name="raiseEvents"> /// Optional boolean indicating whether or not to raise events /// </param> /// <returns> /// The <see cref="IShipment"/>. /// </returns> public IShipment CreateShipment(IShipmentStatus shipmentStatus, IAddress origin, IAddress destination, bool raiseEvents = true) { return(CreateShipment(shipmentStatus, origin, destination, new LineItemCollection())); }
public async Task SaveAsync(IAddress key, BotStoreType botStoreType, BotData botData, CancellationToken cancellationToken) { var entity = new SqlBotDataEntity(botStoreType, key.BotId, key.ChannelId, key.ConversationId, key.UserId, botData.Data) { ETag = botData.ETag, ServiceUrl = key.ServiceUrl }; using (var context = new SqlBotDataContext(_connectionString)) { try { if (string.IsNullOrEmpty(botData.ETag)) { context.BotData.Add(entity); } else if (entity.ETag == "*") { var foundData = await SqlBotDataEntity.GetSqlBotDataEntity(key, botStoreType, context); if (botData.Data != null) { if (foundData == null) { context.BotData.Add(entity); } else { foundData.Data = entity.Data; foundData.ServiceUrl = entity.ServiceUrl; } } else { if (foundData != null) { context.BotData.Remove(foundData); } } } else { var foundData = await SqlBotDataEntity.GetSqlBotDataEntity(key, botStoreType, context); if (botData.Data != null) { if (foundData == null) { context.BotData.Add(entity); } else { foundData.Data = entity.Data; foundData.ServiceUrl = entity.ServiceUrl; foundData.ETag = entity.ETag; } } else { if (foundData != null) { context.BotData.Remove(foundData); } } } await context.SaveChangesAsync(cancellationToken); } catch (System.Data.SqlClient.SqlException err) { throw new HttpException((int)HttpStatusCode.InternalServerError, err.Message); } } }
private void TaxItems(ITaxSchedule schedule, List <ITaxable> items, IAddress address) { if (schedule == null) { return; } if (items == null) { return; } if (address == null) { return; } // Holds all taxes for the schedule summarized TaxableItem summaryForSchedule = new TaxableItem(); summaryForSchedule.ScheduleId = schedule.TaxScheduleId(); // Find all items that match the schedule List <ITaxable> itemsMatchingSchedule = new List <ITaxable>(); foreach (ITaxable item in items) { if (item.TaxScheduleId() == schedule.TaxScheduleId()) { summaryForSchedule.Value += item.TaxableValue(); summaryForSchedule.ShippingValue += item.TaxableShippingValue(); itemsMatchingSchedule.Add(item); } } // Now Apply all taxes in schedule to total price of all items foreach (ITaxRate rate in _app.OrderServices.Taxes.GetRates(_app.CurrentStore.Id, schedule.TaxScheduleId())) { rate.TaxItem(summaryForSchedule, address); } // Total Tax for all items on this schedule is calculated // Now, we assign the tax parts to each line item based on their // linetotal value. The last item should get the remainder of the tax decimal RoundedTotal = Math.Round(summaryForSchedule.TaxedValue, 2); decimal TotalApplied = 0M; for (int i = 0; i < itemsMatchingSchedule.Count(); i++) { ITaxable item = itemsMatchingSchedule[i]; item.ClearTaxValue(); if (i == itemsMatchingSchedule.Count() - 1) { // last item item.IncrementTaxValue(RoundedTotal - TotalApplied); } else { decimal percentOfTotal = 0; if (summaryForSchedule.TaxableValue() != 0) { percentOfTotal = item.TaxableValue() / summaryForSchedule.TaxableValue(); } decimal part = Math.Round(percentOfTotal * summaryForSchedule.TaxedValue, 2); item.IncrementTaxValue(part); TotalApplied += part; } } }
/// <summary> /// INTERNATIONAL SHIPMENTS ONLY. Required if the return shipment is not going to the fromAddress but is instead to an alternate /// return address. /// </summary> public ShipmentFluent <T> AltReturnAddress(IAddress a) { _shipment.AltReturnAddress = a; return(this); }
/// <summary> /// Allows for overriding the creation of <see cref="ICheckoutAddressModel"/> from <see cref="IAddress"/>. /// </summary> /// <param name="model"> /// The <see cref="ICheckoutAddressModel"/>. /// </param> /// <param name="adr"> /// The <see cref="IAddress"/>. /// </param> /// <returns> /// The modified <see cref="ICheckoutAddressModel"/>. /// </returns> protected virtual TAddress OnCreate(TAddress model, IAddress adr) { return(model); }
public DetectChannelCapability(IAddress address) { SetField.NotNull(out this.address, nameof(address), address); }
/// <summary> /// Saves the bill to address /// </summary> /// <param name="billToAddress">The billing <see cref="IAddress"/></param> public virtual void SaveBillToAddress(IAddress billToAddress) { _customer.ExtendedData.AddAddress(billToAddress, AddressType.Billing); SaveCustomer(_merchelloContext, _customer, RaiseCustomerEvents); }
internal bool IsRegistered(IAddress address) => maps[MapIndex(address)].ContainsKey(address);
private void ApplyTaxes(List <ITaxSchedule> schedules, List <ITaxable> items, IAddress address) { if (schedules != null) { foreach (ITaxSchedule ts in schedules) { TaxItems(ts, items, address); } } }
/// <summary> /// REQUIRED. Origin address. See Create a Shipment for considerations when specifying multiple address lines when using /// MINIMAL_ADDRESS_VALIDATION. /// </summary> /// <param name="a"></param> /// <returns></returns> public ShipmentFluent <T> FromAddress(IAddress a) { _shipment.FromAddress = a; return(this); }
/// <summary> /// Initializes a new instance of <see cref="SenderRouting"/> /// </summary> /// <typeparam name="TSender">Transport specific type of the local <see cref="ISender"/></typeparam> /// <param name="address"><see cref="IAddress"/> of the remote <see cref="IReceiver"/></param> /// <returns></returns> public static SenderRouting For <TSender>(IAddress address) where TSender : ISender => new SenderRouting(typeof(TSender), address);
/// <summary> /// The create customer address. /// </summary> /// <param name="customer"> /// The customer. /// </param> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="address"> /// The address. /// </param> /// <param name="label"> /// The customer label /// </param> /// <param name="addressType"> /// The address type. /// </param> /// <returns> /// The <see cref="ICustomerAddress"/>. /// </returns> internal static ICustomerAddress CreateCustomerAddress(this ICustomer customer, IMerchelloContext merchelloContext, IAddress address, string label, AddressType addressType) { var customerAddress = address.ToCustomerAddress(customer, label, addressType); return(customer.SaveCustomerAddress(merchelloContext, customerAddress)); }
public SerializeByConversation(IPostToBot inner, IAddress address, IScope <IAddress> scopeForCookie) { SetField.NotNull(out this.inner, nameof(inner), inner); SetField.NotNull(out this.address, nameof(address), address); SetField.NotNull(out this.scopeForCookie, nameof(scopeForCookie), scopeForCookie); }
/// <summary> /// Creates a <see cref="ICustomerAddress"/> based off an <see cref="IAddress"/> /// </summary> /// <param name="customer"> /// The customer associated with the address /// </param> /// <param name="address"> /// The address. /// </param> /// <param name="label"> /// The address label /// </param> /// <param name="addressType"> /// The <see cref="AddressType"/> /// </param> /// <returns> /// The <see cref="ICustomerAddress"/>. /// </returns> public static ICustomerAddress CreateCustomerAddress(this ICustomer customer, IAddress address, string label, AddressType addressType) { return(customer.CreateCustomerAddress(MerchelloContext.Current, address, label, addressType)); }
/// <summary> /// REQUIRED.Destination address. /// Note: You can specify multiple address lines in the shipment’s destination address.See address object for information on how /// the API processes multiple address lines. /// </summary> /// <param name="a">Address</param> /// <returns></returns> public ShipmentFluent <T> ToAddress(IAddress a) { _shipment.ToAddress = a; return(this); }
public AddressController(ILogger <AddressController> logger, IAddress addressService) { _logger = logger; _addressService = addressService; }
/// <summary> /// Creates a <see cref="IShipment"/> without persisting it to the database. /// </summary> /// <param name="shipmentStatus"> /// The shipment status. /// </param> /// <param name="origin"> /// The origin. /// </param> /// <param name="destination"> /// The destination. /// </param> /// <param name="items"> /// The items. /// </param> /// <param name="raiseEvents"> /// Optional boolean indicating whether or not to raise events /// </param> /// <returns> /// The <see cref="IShipment"/>. /// </returns> public IShipment CreateShipment(IShipmentStatus shipmentStatus, IAddress origin, IAddress destination, LineItemCollection items, bool raiseEvents = true) { Mandate.ParameterNotNull(shipmentStatus, "shipmentStatus"); Mandate.ParameterNotNull(origin, "origin"); Mandate.ParameterNotNull(destination, "destination"); Mandate.ParameterNotNull(items, "items"); // Use the visitor to filter out and validate shippable line items var visitor = new ShippableProductVisitor(); items.Accept(visitor); var lineItemCollection = new LineItemCollection(); foreach (var item in visitor.ShippableItems) { lineItemCollection.Add(item); } var shipment = new Shipment(shipmentStatus, origin, destination, lineItemCollection) { VersionKey = Guid.NewGuid() }; if (!raiseEvents) { return(shipment); } Creating.RaiseEvent(new Events.NewEventArgs <IShipment>(shipment), this); return(shipment); }
internal Directory(IAddress none) { this.none = none; maps = Build(); }