public decimal CalculateDiscount(TotalBill order) { Decimal TotalAmount = order.orders.Sum(p => p.Price); int div = (int)TotalAmount / 100; return(div * Convert.ToInt32(GetConfig.BaseDiscount)); }
private void numericDiscount_ValueChanged(object sender, EventArgs e) { decimal CashGiven = 0, TotalBill, Bill, Discount, CashReturn; try { Bill = Convert.ToDecimal(txtBill.Text); Discount = numericDiscount.Value; TotalBill = Bill * ((100 - Discount) / 100); if (txtCashGiven.Text != "") { CashGiven = Convert.ToDecimal(txtCashGiven.Text); } CashReturn = CashGiven - TotalBill; txtTotalBill.Text = TotalBill.ToString(); if (CashReturn >= 0) { txtCashReturn.Text = CashReturn.ToString(); } } catch (Exception er) { MessageBox.Show(er.Message); } }
public async Task <TotalBill> AddBill(TotalBill totalBill) { await _context.TotalBills.AddAsync(totalBill); await Save(); return(totalBill); }
public decimal GetTotalDiscount(TotalBill order) { var dis = new List <decimal>(); foreach (var discount in _discounts) { decimal des = discount.CalculateDiscount(order); dis.Add(des); } return(dis.Sum()); }
public decimal CalculateDiscount(TotalBill order) { TimeSpan Span = DateTime.Now - order.DateCreated; if ((Span.TotalDays / 365) > Convert.ToInt32(GetConfig.LoyalCustomerYears)) { return((decimal)(Convert.ToInt32(GetConfig.LoyalCustomerPercent) * order.orders.Where(p => p.ProductCategory != 1).Sum(p => p.Price)));; } else { return(0m); } }
public ReturnMessage <InvoiceAmount> DiscountPrice(TotalBill Bill) { logger.Information($"Received request to Calculte TOtal Bill => {JsonConvert.SerializeObject(Bill)}"); var Billamount = new ReturnMessage <InvoiceAmount>(); try { if (ModelState.IsValid) { var GetUserDet = getCustomer.GetCustomerByID(Bill.UserId); if (GetUserDet != null) { Bill.UserType = GetUserDet.Body.UserType.ToString(); Bill.DateCreated = GetUserDet.Body.DateCreated; var billamount = discountSystem.ComputePrice(Bill); Billamount.Body = billamount; Billamount.ResponseCode = "00"; Billamount.ResponseDescription = "Success"; } else { Billamount.ResponseCode = GetUserDet.ResponseCode; Billamount.ResponseDescription = GetUserDet.ResponseDescription; } if (Billamount.ResponseCode == "01") { Response.StatusCode = (int)HttpStatusCode.BadRequest; } } else { var errorList = (from item in ModelState.Values from error in item.Errors select error.ErrorMessage).ToArray(); Billamount.ResponseDescription = String.Join('|', errorList); Response.StatusCode = (int)HttpStatusCode.BadRequest; } } catch (Exception ex) { logger.Debug(ex, "Error Calculate Invoice Amount "); Billamount.ResponseCode = "96"; Billamount.ResponseDescription = "Unable to Calculate final price"; } return(Billamount); }
public decimal CalculateDiscount(TotalBill order) { if (order.UserType.ToString() == "AffliateCustomer") { return(Convert.ToDecimal(order.DiscountPercentage) * order.orders.Where(p => p.ProductCategory != 1).Sum(p => p.Price));; } if (order.UserType.ToString() == "Staff") { return(Convert.ToDecimal(order.DiscountPercentage) * order.orders.Where(p => p.ProductCategory != 1).Sum(p => p.Price));; } else { return(0m); } }
public async Task <IActionResult> AddBill([FromBody] TotalBillAddDto[] totalBillAddDto) { TotalBill totalBill = new TotalBill(); double total = 0; //foreach (var bill in totalBillAddDto) //{ //total += bill.price * bill.Quantity; //} //totalBill.SumTotal=total; List <SubBill> SubBillist = new List <SubBill>(); SubBill subBill; foreach (var subBillItem in totalBillAddDto) { subBill = new SubBill(); total += subBillItem.price * subBillItem.Quantity; subBill.ProductId = subBillItem.ProductId; subBill.Quantity = subBillItem.Quantity; subBill.price = subBillItem.price; SubBillist.Add(subBill); } totalBill.SubBill = SubBillist; totalBill.SumTotal = total; // var createSubBill = await _repTotalBill.AddSubBill(SubBillTocreate); await _repTotalBill.AddBill(totalBill); return(Ok()); // for(let data of this.shoppingCartService.dataProducts){ // total += data.price * data.Quantity; // } // var TotalBillTocreate = _mapper.Map<sub>(totalBillAddDto); // var createTotalBill = await _repTotalBill.AddBill(TotalBillTocreate); // totalBillAddDto.TotlBillId= createTotalBill.Id; // var SubBillTocreate = _mapper.Map<IEnumerable<TotalBillAddDto>, IEnumerable<SubBill>>(totalBillAddDto); // totalBill.SubBill=SubBillTocreate; // var SubBillTocreate = _mapper.Map<SubBill>(totalBillAddDto); }
public InvoiceAmount ComputePrice(TotalBill order) { var invoiceAmount = new InvoiceAmount(); var content = (int)System.Enum.Parse(typeof(User_Type), order.UserType); var GetDiscount = getDiscountType.GetDiscountByType(content); order.DiscountPercentage = GetDiscount.Body.DiscountPercentage; decimal nonDiscounted = order.orders.Sum(p => p.Price); #region //OLD IMPLEMENTATION //decimal baseDiscount = _discountPoliciesMethods.BaseDiscount(order); //decimal[] discounts = new[] { // _discountPoliciesMethods.CustomeTypeDiscount(order), // _discountPoliciesMethods.CustomerLoyaltyDiscount(order), //}; //decimal bestDiscount = discounts.Max(discount => discount); //var totalDiscount = bestDiscount + baseDiscount; #endregion var totalDiscount2 = discountMethodProcessor.GetTotalDiscount(order); var total = nonDiscounted - totalDiscount2; invoiceAmount.InvoicePrice = total.ToString(); invoiceAmount.DiscountCalculated = totalDiscount2.ToString(); invoiceAmount.UndiscountedPrice = nonDiscounted.ToString(); logger.Information($"Invoice to be paid => {JsonConvert.SerializeObject(invoiceAmount)}"); return(invoiceAmount); }
protected void btnSearch_Click(object sender, EventArgs e) { OpBal = 0; BillAmt = 0; BillTax = 0; PaidAmt = 0; PaidTax = 0; DueAmt = 0; TaxDueAmt = 0; TotalBill = 0; TotalPaid = 0; TotalDue = 0; BusinessLayer.Common.SemFeesGeneration ObjSemFees = new BusinessLayer.Common.SemFeesGeneration(); Entity.Common.SemFeesGeneration SemFees = new Entity.Common.SemFeesGeneration(); if (txtFromDate.Text == "") { SemFees.FromDate = null; } else { SemFees.FromDate = Convert.ToDateTime(txtFromDate.Text); } if (txtToDate.Text == "") { SemFees.ToDate = null; } else { SemFees.ToDate = Convert.ToDateTime(txtToDate.Text); } SemFees.MembershipCategoryId = int.Parse(ddlMembershipCategory.SelectedValue.Trim()); SemFees.BlockId = int.Parse(ddlBlock.SelectedValue.Trim()); SemFees.DistrictId = int.Parse(ddlDistrict.SelectedValue.Trim()); SemFees.StateId = int.Parse(ddlState.SelectedValue.Trim()); SemFees.Month = ""; // (ddlSubscriptionMonth.SelectedIndex == 0) ? string.Empty : ddlSubscriptionMonth.SelectedValue.Trim(); SemFees.Year = 0; // (ddlSubscriptionYear.SelectedIndex == 0) ? 0 : int.Parse(ddlSubscriptionYear.SelectedValue.Trim()); SemFees.FeesHeadId = int.Parse(ddlFeesHead.SelectedValue.Trim()); DataTable dt = ObjSemFees.GetConsolidated_StudentOutstandingReport(SemFees); if (dt != null) { dgvBill.DataSource = dt; dgvBill.DataBind(); } if (dt.Rows.Count > 0) { btnDownload.Visible = true; ((Literal)dgvBill.FooterRow.FindControl("ltrTotOpBalAmt")).Text = "<b>" + OpBal.ToString("#0.00") + "</b>"; ((Literal)dgvBill.FooterRow.FindControl("ltrTotBillAmt")).Text = "<b>" + BillAmt.ToString("#0.00") + "</b>"; ((Literal)dgvBill.FooterRow.FindControl("ltrTotTaxBillAmt")).Text = "<b>" + BillTax.ToString("#0.00") + "</b>"; ((Literal)dgvBill.FooterRow.FindControl("ltrTotPaidAmt")).Text = "<b>" + PaidAmt.ToString("#0.00") + "</b>"; ((Literal)dgvBill.FooterRow.FindControl("ltrTotTaxPaidAmt")).Text = "<b>" + PaidTax.ToString("#0.00") + "</b>"; ((Literal)dgvBill.FooterRow.FindControl("ltrTotDueAmt")).Text = "<b>" + DueAmt.ToString("#0.00") + "</b>"; ((Literal)dgvBill.FooterRow.FindControl("ltrTotTaxDueAmt")).Text = "<b>" + TaxDueAmt.ToString("#0.00") + "</b>"; ((Literal)dgvBill.FooterRow.FindControl("ltrTotalBill")).Text = "<b>" + TotalBill.ToString("#0.00") + "</b>"; ((Literal)dgvBill.FooterRow.FindControl("ltrTotalPaid")).Text = "<b>" + TotalPaid.ToString("#0.00") + "</b>"; ((Literal)dgvBill.FooterRow.FindControl("ltrTotalDue")).Text = "<b>" + TotalDue.ToString("#0.00") + "</b>"; } else { btnDownload.Visible = false; } }