コード例 #1
0
        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;
            }
        }
コード例 #2
0
 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));
 }
コード例 #4
0
        public decimal GetFeeForShipmentMethod(ShipmentMethod shipmentMethod)
        {
            switch (shipmentMethod)
            {
            case ShipmentMethod.CeskaPosta:
                return(90);

            case ShipmentMethod.Osobni:
                return(0);

            default:
                throw new NotImplementedException();
            }
        }
コード例 #5
0
ファイル: PartyExtensions.cs プロジェクト: Allors/apps
        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;
        }
コード例 #6
0
        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;
            }
        }
コード例 #7
0
        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;
            }
        }
コード例 #8
0
        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);
 }
コード例 #10
0
        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);
        }
コード例 #11
0
 public decimal CalculateTotalPrice(decimal productsPrice, ShipmentMethod shipmentMethod, PaymentMethod paymentMethod)
 {
     return productsPrice + _feeConfiguration.GetFeeForShipmentMethod(shipmentMethod);
 }
コード例 #12
0
        public static decimal GetShipmentFee(ShipmentMethod shipmentMethod)
        {
            var configuration = MainKernel.Kernel.Get <IFeeConfiguration>();

            return(configuration.GetFeeForShipmentMethod(shipmentMethod));
        }
コード例 #13
0
 public decimal CalculateTotalPrice(decimal productsPrice, ShipmentMethod shipmentMethod, PaymentMethod paymentMethod)
 {
     return(productsPrice + _feeConfiguration.GetFeeForShipmentMethod(shipmentMethod));
 }