/// <summary> /// Method that calculates totals for a job /// </summary> /// <param name="mockJob"></param> /// <returns></returns> public JobReceipt CalculateJobCost(Job mockJob) { decimal beforeMarginTotal = 0; decimal margin = (mockJob.AddExtraMargin) ? mockJob.Margin + mockJob.ExtraMargin : mockJob.Margin; decimal marginTotal; JobReceipt receipt = new JobReceipt(); decimal taxTotal = 0; // Loop through the products and calculate totals foreach (var item in mockJob.Items) { beforeMarginTotal += item.ProductPrice; var tax = (!item.TaxExempt) ? item.ProductPrice * item.SalesTax : 0; taxTotal += tax; // Round item total + tax to nearest cent receipt.Products.Add(item.ProductName, Math.Round(item.ProductPrice + tax, 2)); } // Margin is calculated on totals without tax added marginTotal = beforeMarginTotal * margin; // Round total cost to nearest even cent receipt.Total = (0.02m / 1.00m) * decimal.Round((beforeMarginTotal + marginTotal + taxTotal) * (1.00m / 0.02m)); return(receipt); }
protected void grid_wh_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e) { if (Request.QueryString["no"] != null) { try { if (list.Count > 0) { string no = SafeValue.SafeString(Request.QueryString["no"]); string jobNo = SafeValue.SafeString(Request.QueryString["JobNo"]); bool action = false; for (int i = 0; i < list.Count; i++) { int id = list[i].id; decimal qty = list[i].qty; decimal weight = list[i].weight; decimal volume = list[i].volume; decimal sku_qty = list[i].sku_qty; decimal l = list[i].l; decimal h = list[i].h; decimal w = list[i].w; if (qty > 0) { Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(C2.JobHouse), "Id=" + id + ""); C2.JobHouse house = C2.Manager.ORManager.GetObject(query) as C2.JobHouse; if (house != null) { C2.JobReceipt rec = new JobReceipt(); rec.Qty = qty; rec.Weight = weight; rec.Volume = volume; rec.JobNo = jobNo; rec.LineId = id; rec.HblNo = house.HblNo; rec.BookingNo = house.BookingNo; rec.CargoId = id; rec.PackQty = sku_qty; rec.Remark1 = house.Remark1; rec.Remark2 = house.Remark2; rec.Marking1 = house.Marking1; rec.Marking2 = house.Marking2; rec.Location = house.Location; rec.CargoType = "IN"; rec.TrailerId = SafeValue.SafeInt(no, 0); rec.TrailerNo = house.ContNo; C2.Manager.ORManager.StartTracking(rec, Wilson.ORMapper.InitialState.Inserted); C2.Manager.ORManager.PersistChanges(rec); } action = true; } else { action = false; break; } } if (action) { e.Result = "Success"; } else { e.Result = "Pls keyin the Qty"; } } else { e.Result = "Pls Select at least one Cargo"; } } catch { } } }