/// <summary> /// Saves a single <see cref="ITaxMethod"/> /// </summary> /// <param name="taxMethod">The <see cref="ITaxMethod"/> to be saved</param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param> public void Save(ITaxMethod taxMethod, bool raiseEvents = true) { if (raiseEvents) { if (Saving.IsRaisedEventCancelled(new SaveEventArgs <ITaxMethod>(taxMethod), this)) { ((TaxMethod)taxMethod).WasCancelled = true; return; } } taxMethod.Name = string.IsNullOrEmpty(taxMethod.Name) ? GetTaxMethodName(taxMethod) : taxMethod.Name; using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateTaxMethodRepository(uow)) { repository.AddOrUpdate(taxMethod); uow.Commit(); } } if (raiseEvents) { Saved.RaiseEvent(new SaveEventArgs <ITaxMethod>(taxMethod), this); } }
/// <summary> /// Initializes a new instance of the <see cref="TaxJarTaxationGatewayMethod"/> class. /// </summary> /// <param name="taxMethod"> /// The tax method. /// </param> /// <param name="extendedData"> /// The extended Data collection from the provider. /// </param> public TaxJarTaxationGatewayMethod(ITaxMethod taxMethod, ExtendedDataCollection extendedData) : base(taxMethod) { _settings = extendedData.GetTaxJarProviderSettings(); _taxjarService = new TaxJarTaxService(_settings); }
/// <summary> /// Deletes a single <see cref="ITaxMethod"/> /// </summary> /// <param name="taxMethod">The <see cref="ITaxMethod"/> to be deleted</param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param> public void Delete(ITaxMethod taxMethod, bool raiseEvents = true) { if (raiseEvents) { if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <ITaxMethod>(taxMethod), this)) { ((TaxMethod)taxMethod).WasCancelled = true; return; } } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreateTaxMethodRepository(uow)) { repository.Delete(taxMethod); uow.Commit(); } } if (raiseEvents) { Deleted.RaiseEvent(new DeleteEventArgs <ITaxMethod>(taxMethod), this); } }
/// <summary> /// Initializes a new instance of the <see cref="AvaTaxTaxationGatewayMethod"/> class. /// </summary> /// <param name="taxMethod"> /// The tax method. /// </param> /// <param name="extendedData"> /// The extended Data collection from the provider. /// </param> public AvaTaxTaxationGatewayMethod(ITaxMethod taxMethod, ExtendedDataCollection extendedData) : base(taxMethod) { _settings = extendedData.GetAvaTaxProviderSettings(); _avaTaxService = new AvaTaxService(_settings); }
/// <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; }
/// <summary> /// The get tax method name. /// </summary> /// <param name="taxMethod"> /// The tax method. /// </param> /// <returns> /// The <see cref="string"/>. /// </returns> private string GetTaxMethodName(ITaxMethod taxMethod) { if (taxMethod.CountryCode == "ELSE") { return("Everywhere Else"); } var country = _storeSettingService.GetCountryByCode(taxMethod.CountryCode); return(country.Name); }
internal static TaxMethodDisplay ToTaxMethodDisplay(this ITaxMethod taxMethod) { return(AutoMapper.Mapper.Map <TaxMethodDisplay>(taxMethod)); }
internal static ITaxMethod ToTaxMethod(this TaxMethodDisplay taxMethodDisplay, ITaxMethod destination) { if (taxMethodDisplay.Key != Guid.Empty) { destination.Key = taxMethodDisplay.Key; } destination.Name = taxMethodDisplay.Name; destination.PercentageTaxRate = taxMethodDisplay.PercentageTaxRate; // this may occur when creating a new tax method since the UI does not // query for provinces // TODO fix if (destination.HasProvinces && !taxMethodDisplay.Provinces.Any()) { taxMethodDisplay.Provinces = destination.Provinces.Select(x => x.ToTaxProvinceDisplay()).ToArray(); } foreach (var province in taxMethodDisplay.Provinces) { var p = destination.Provinces.FirstOrDefault(x => x.Code == province.Code); if (p != null) { p.PercentAdjustment = province.PercentAdjustment; } } return(destination); }
/// <summary> /// Deletes a single <see cref="ITaxMethod"/> /// </summary> /// <param name="taxMethod">The <see cref="ITaxMethod"/> to be deleted</param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param> public void Delete(ITaxMethod taxMethod, bool raiseEvents = true) { if(raiseEvents) if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs<ITaxMethod>(taxMethod), this)) { ((TaxMethod) taxMethod).WasCancelled = true; return; } using (new WriteLock(Locker)) { var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateTaxMethodRepository(uow)) { repository.Delete(taxMethod); uow.Commit(); } } if(raiseEvents) Deleted.RaiseEvent(new DeleteEventArgs<ITaxMethod>(taxMethod), this); }
private string GetTaxMethodName(ITaxMethod taxMethod) { if (taxMethod.CountryCode == "ELSE") return "Everywhere Else"; var country = _storeSettingService.GetCountryByCode(taxMethod.CountryCode); return country.Name; }
/// <summary> /// Saves a single <see cref="ITaxMethod"/> /// </summary> /// <param name="taxMethod">The <see cref="ITaxMethod"/> to be saved</param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param> public void Save(ITaxMethod taxMethod, bool raiseEvents = true) { if(raiseEvents) if (Saving.IsRaisedEventCancelled(new SaveEventArgs<ITaxMethod>(taxMethod), this)) { ((TaxMethod) taxMethod).WasCancelled = true; return; } //TODO refactor this taxMethod.Name = string.IsNullOrEmpty(taxMethod.Name) ? GetTaxMethodName(taxMethod) : taxMethod.Name; using (new WriteLock(Locker)) { var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateTaxMethodRepository(uow)) { repository.AddOrUpdate(taxMethod); uow.Commit(); } } if(raiseEvents) Saved.RaiseEvent(new SaveEventArgs<ITaxMethod>(taxMethod), this); }
/// <summary> /// Initializes a new instance of the <see cref="TaxationGatewayMethodBase"/> class. /// </summary> /// <param name="taxMethod"> /// The tax method. /// </param> protected TaxationGatewayMethodBase(ITaxMethod taxMethod) { Mandate.ParameterNotNull(taxMethod, "taxMethod"); _taxMethod = taxMethod; }
/// <summary> /// Initializes a new instance of the <see cref="AvalaraTaxationGatewayMethod"/> class. /// </summary> /// <param name="taxMethod"> /// The tax method. /// </param> public AvalaraTaxationGatewayMethod(ITaxMethod taxMethod) : base(taxMethod) { }
/// <summary> /// Saves a single <see cref="ITaxMethod"/> /// </summary> /// <param name="taxMethod">The <see cref="ITaxMethod"/> to be saved</param> public void Save(ITaxMethod taxMethod) { _taxMethodService.Save(taxMethod); }
/// <summary> /// Returns an <see cref="ITaxJarTaxationGatewayMethod"/> given the <see cref="ITaxMethod"/> (settings) /// </summary> /// <param name="taxMethod"> /// The tax method. /// </param> /// <returns> /// The <see cref="ITaxJarTaxationGatewayMethod"/>. /// </returns> public ITaxJarTaxationGatewayMethod GetTaxJarTaxationGatewayMethod(ITaxMethod taxMethod) { return(new TaxJarTaxationGatewayMethod(taxMethod, ExtendedData)); }
public FixRateTaxationGatewayMethod(ITaxMethod taxMethod) : base(taxMethod) { }
/// <summary> /// Returns an <see cref="IAvaTaxTaxationGatewayMethod"/> given the <see cref="ITaxMethod"/> (settings) /// </summary> /// <param name="taxMethod"> /// The tax method. /// </param> /// <returns> /// The <see cref="IAvaTaxTaxationGatewayMethod"/>. /// </returns> public IAvaTaxTaxationGatewayMethod GetAvaTaxationGatewayMethod(ITaxMethod taxMethod) { return(new AvaTaxTaxationGatewayMethod(taxMethod, ExtendedData)); }
/// <summary> /// Deletes a <see cref="ITaxMethod"/> /// </summary> /// <param name="taxMethod">The <see cref="ITaxMethod"/> to be deleted</param> public void Delete(ITaxMethod taxMethod) { _taxMethodService.Delete(taxMethod); }
/// <summary> /// Returns an <see cref="ITaxJarTaxationGatewayMethod"/> given the <see cref="ITaxMethod"/> (settings) /// </summary> /// <param name="taxMethod"> /// The tax method. /// </param> /// <returns> /// The <see cref="ITaxJarTaxationGatewayMethod"/>. /// </returns> public ITaxJarTaxationGatewayMethod GetTaxJarTaxationGatewayMethod(ITaxMethod taxMethod) { return new TaxJarTaxationGatewayMethod(taxMethod, ExtendedData); }
internal static ITaxMethod ToTaxMethod(this TaxMethodDisplay taxMethodDisplay, ITaxMethod destination) { if (taxMethodDisplay.Key != Guid.Empty) destination.Key = taxMethodDisplay.Key; destination.Name = taxMethodDisplay.Name; destination.PercentageTaxRate = taxMethodDisplay.PercentageTaxRate; // this may occur when creating a new tax method since the UI does not // query for provinces // TODO fix if (destination.HasProvinces && !taxMethodDisplay.Provinces.Any()) { taxMethodDisplay.Provinces = destination.Provinces.Select(x => x.ToTaxProvinceDisplay()).ToArray(); } foreach (var province in taxMethodDisplay.Provinces) { var p = destination.Provinces.FirstOrDefault(x => x.Code == province.Code); if (p != null) p.PercentAdjustment = province.PercentAdjustment; } return destination; }
/// <summary> /// Returns an <see cref="IAvaTaxTaxationGatewayMethod"/> given the <see cref="ITaxMethod"/> (settings) /// </summary> /// <param name="taxMethod"> /// The tax method. /// </param> /// <returns> /// The <see cref="IAvaTaxTaxationGatewayMethod"/>. /// </returns> public IAvaTaxTaxationGatewayMethod GetAvaTaxationGatewayMethod(ITaxMethod taxMethod) { return new AvaTaxTaxationGatewayMethod(taxMethod, ExtendedData); }