internal CostEstimate GetCostEstimateFor(Carrier carrier, Invoice invoice, Dimensions dimensions, float[] parcelWeights) { int numParcels = parcelWeights.Length; CostEstimate estimate = new CostEstimate(); double weightTotal = 0.0f, sizeTotal = 0.0f; string new_temp_city = invoice.InvoiceCustomer.City; int parcelNumber = 1; //int numSizeWeights = txtBox_input_dimensions.Text == "" ? 0 : txtBox_input_dimensions.Text.Split('/').Length; // Split the weights and do separate checks for each foreach (float weight in parcelWeights) { if (weight > MAXIMUM_WEIGHT) { throw new PricingException($"Parcel weight is larger than {MAXIMUM_WEIGHT}KGs!"); } Parcel p = new Parcel(weight, parcelNumber, 0.0d, numParcels); p.Size = dimensions; API.InvoicesAPI.AddParcelToInvoice(invoice, p); float sizeWeight = p.getSizeWeight() * carrier.DimensionWeightRate; weightTotal += GetCostEstimate(carrier, p, invoice); sizeTotal += sizeWeight == 0 ? 0.0f : GetCostEstimateByWeight(sizeWeight, carrier, p, invoice); parcelNumber++; } return estimate; }
public Parcel() { this.weight = 0.0f; this.parcelNumber = 1; this.totalParcels = 1; this.costEstimate = 0.0d; this.parcelID = 0; this.articleID = string.Empty; this.size = new Dimensions(); }
public Parcel(float weight, int parcelNumber, double costEstimate) { this.weight = weight; this.parcelNumber = parcelNumber; this.totalParcels = 0; this.costEstimate = costEstimate; this.parcelID = 0; this.articleID = string.Empty; this.size = new Dimensions(); }
public Parcel(float weight, int parcelNumber, double costEstimate, int totalParcels, Dimensions size=null) { this.weight = weight; this.parcelNumber = parcelNumber; this.totalParcels = totalParcels; this.costEstimate = costEstimate; this.parcelID = 0; this.articleID = string.Empty; this.size = size == null ? new Dimensions() : size; }
private Dimensions GetCurrentEnteredDimensions() { txtBox_input_L.Text = string.IsNullOrEmpty(txtBox_input_L.Text) ? "0" : txtBox_input_L.Text; txtBox_input_W.Text = string.IsNullOrEmpty(txtBox_input_W.Text) ? "0" : txtBox_input_W.Text; txtBox_input_H.Text = string.IsNullOrEmpty(txtBox_input_H.Text) ? "0" : txtBox_input_H.Text; Dimensions dimensions = new Dimensions(); dimensions.Length = float.Parse(txtBox_input_L.Text); dimensions.Width = float.Parse(txtBox_input_W.Text); dimensions.Height = float.Parse(txtBox_input_H.Text); return dimensions; }
public static CostEstimate GetCostEstimateFor(Carrier carrier, Invoice invoice, Dimensions dimensions, float[] parcelWeights) { return Actions.GetCostEstimateFor(carrier, invoice, dimensions, parcelWeights); }