public static void ApplyTaxRates(this ShipmentMethod shipmentMethod, IEnumerable <TaxRate> taxRates) { shipmentMethod.TaxPercentRate = 0m; var taxLineId = string.Join("&", shipmentMethod.ShipmentMethodCode, shipmentMethod.OptionName); var taxRate = taxRates.FirstOrDefault(x => x.Line.Id == taxLineId); if (taxRate != null && taxRate.Rate > 0) { if (taxRate.PercentRate > 0) { shipmentMethod.TaxPercentRate = taxRate.PercentRate; } else { var amount = shipmentMethod.Total > 0 ? shipmentMethod.Total : shipmentMethod.Price; if (amount > 0) { shipmentMethod.TaxPercentRate = Math.Round(taxRate.Rate / amount, 4, MidpointRounding.AwayFromZero); } } // TODO: No TaxDetails in shipmentMethod //shipmentMethod.TaxDetails = taxRate.TaxDetails; } }
public decimal GetFeeForShipmentMethod(ShipmentMethod shipmentMethod) { switch (shipmentMethod) { case ShipmentMethod.CeskaPosta: return 90; case ShipmentMethod.Osobni: return 0; default: throw new NotImplementedException(); } }
public IActionResult Post([FromBody] ShipmentMethod shipmentMethod) { if (ModelState.IsValid) { var result = this._shipmentMethodManager.Add(shipmentMethod); if (result) { return(StatusCode(201)); } return(StatusCode(500, "Object could not be created")); } return(BadRequest(this.ModelState)); }
public decimal GetFeeForShipmentMethod(ShipmentMethod shipmentMethod) { switch (shipmentMethod) { case ShipmentMethod.CeskaPosta: return(90); case ShipmentMethod.Osobni: return(0); default: throw new NotImplementedException(); } }
public static CustomerShipment AppsGetPendingCustomerShipmentForStore(this Party party, PostalAddress address, Store store, ShipmentMethod shipmentMethod) { var shipments = party.ShipmentsWhereShipToParty; shipments.Filter.AddEquals(Shipments.Meta.ShipToAddress, address); shipments.Filter.AddEquals(Shipments.Meta.Store, store); shipments.Filter.AddEquals(Shipments.Meta.ShipmentMethod, shipmentMethod); foreach (CustomerShipment shipment in shipments) { if (shipment.CurrentObjectState.Equals(new CustomerShipmentObjectStates(party.Strategy.Session).Created) || shipment.CurrentObjectState.Equals(new CustomerShipmentObjectStates(party.Strategy.Session).Picked) || shipment.CurrentObjectState.Equals(new CustomerShipmentObjectStates(party.Strategy.Session).OnHold) || shipment.CurrentObjectState.Equals(new CustomerShipmentObjectStates(party.Strategy.Session).Packed)) { return shipment; } } return null; }
public void Delete(ShipmentMethodDto item, bool save = true) { try { // Get existing model object from database ShipmentMethod oldItem = GetFromModel().FirstOrDefault(c => c.Id.Equals(item.Id)); if (oldItem != null) { Context.ShipmentMethods.Remove(oldItem); } if (save) { Context.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public void Update(ShipmentMethodDto item, bool save = true) { try { // Get existing Category object from database ShipmentMethod oldItem = GetFromModel().FirstOrDefault(x => x.Id.Equals(item.Id)); // Set the new values for the fetched Category object if (oldItem != null) { oldItem.Description = item.Description; if (save) { this.Context.SaveChanges(); } } } catch (Exception ex) { throw ex; } }
public static decimal GetShipmentFee(ShipmentMethod shipmentMethod) { var configuration = MainKernel.Kernel.Get<IFeeConfiguration>(); return configuration.GetFeeForShipmentMethod(shipmentMethod); }
public IActionResult Put(int id, [FromBody] ShipmentMethod value) { return(null); }
public static CustomerShipment BaseGetPendingCustomerShipmentForStore(this Party @this, PostalAddress address, Store store, ShipmentMethod shipmentMethod) { var shipments = @this.ShipmentsWhereShipToParty; if (address != null) { shipments.Filter.AddEquals(M.Shipment.ShipToAddress, address); } if (store != null) { shipments.Filter.AddEquals(M.Shipment.Store, store); } if (shipmentMethod != null) { shipments.Filter.AddEquals(M.Shipment.ShipmentMethod, shipmentMethod); } foreach (CustomerShipment shipment in shipments) { if (shipment.ShipmentState.Equals(new ShipmentStates(@this.Strategy.Session).Created) || shipment.ShipmentState.Equals(new ShipmentStates(@this.Strategy.Session).Picking) || shipment.ShipmentState.Equals(new ShipmentStates(@this.Strategy.Session).Picked) || shipment.ShipmentState.Equals(new ShipmentStates(@this.Strategy.Session).OnHold) || shipment.ShipmentState.Equals(new ShipmentStates(@this.Strategy.Session).Packed)) { return(shipment); } } return(null); }
public decimal CalculateTotalPrice(decimal productsPrice, ShipmentMethod shipmentMethod, PaymentMethod paymentMethod) { return productsPrice + _feeConfiguration.GetFeeForShipmentMethod(shipmentMethod); }
public static decimal GetShipmentFee(ShipmentMethod shipmentMethod) { var configuration = MainKernel.Kernel.Get <IFeeConfiguration>(); return(configuration.GetFeeForShipmentMethod(shipmentMethod)); }
public decimal CalculateTotalPrice(decimal productsPrice, ShipmentMethod shipmentMethod, PaymentMethod paymentMethod) { return(productsPrice + _feeConfiguration.GetFeeForShipmentMethod(shipmentMethod)); }