public void update_Cancelled(Guid Id, string CancelNotes) { WebDBConnection.Update(db.Database, "Payments", DBConnection.getSqlParameter(PaymentsModel.COL_Id.Name, Id), DBConnection.getSqlParameter(PaymentsModel.COL_Cancelled.Name, 1), DBConnection.getSqlParameter(PaymentsModel.COL_CancelNotes.Name, CancelNotes) ); ActivityLogsController.AddEditLog(db, Session, Id, string.Format(PaymentsModel.COL_CancelNotes.LogDisplay, CancelNotes)); //Adjust sale invoice due amount List <PaymentItemsModel> paymentItems = PaymentItemsController.get(null, Id); List <SaleInvoicesModel> saleInvoices; foreach (PaymentItemsModel paymentitem in paymentItems) { saleInvoices = SaleInvoicesController.get(Session, paymentitem.ReferenceId.ToString()); if (saleInvoices.Count > 0) { WebDBConnection.Update(db.Database, "SaleInvoices", DBConnection.getSqlParameter(SaleInvoicesModel.COL_Id.Name, saleInvoices[0].Id), DBConnection.getSqlParameter(SaleInvoicesModel.COL_Due.Name, saleInvoices[0].Due + paymentitem.Amount) ); } } db.SaveChanges(); }
public JsonResult Ajax_GetDetails(Guid id) { UserAccountRolesModel access = UserAccountsController.getUserAccess(Session); List <PaymentItemsModel> models = PaymentItemsController.get(null, id); string content = string.Format(@" <div class='table-responsive'> <table class='table table-striped table-bordered'> <thead> <tr> <th>Invoice</th> <th class='text-right'>Due before</th> <th class='text-right'>Payment</th> <th class='text-right'>Due now</th> </tr> </thead> <tbody> "); string saleInvoiceLink; foreach (PaymentItemsModel model in models) { saleInvoiceLink = !access.SaleInvoices_View ? model.SaleInvoices_No : string.Format("<a href='/SaleInvoices?FILTER_chkDateFrom=false&FILTER_chkDateTo=false&FILTER_Keyword={0}' target='_blank'>{0}</a>", model.SaleInvoices_No); content += string.Format(@" <tr> <td style='width:50px;'>{0}</td> <td class='text-right'>{1:N0}</td> <td class='text-right'><strong>{2:N0}</strong></td> <td class='text-right'>{3:N0}</td> </tr> ", saleInvoiceLink, model.DueBefore, model.Amount, model.DueAfter ); } PaymentsModel payment = get(id); content += string.Format(@" </tbody></table></div> <div class='mt-2'> <div class='h3 ml-2 float-right font-weight-bold'>TOTAL: {0:N0}</div> </div> ", payment.CashAmount + payment.DebitAmount + payment.ConsignmentAmount ); return(Json(new { content = content }, JsonRequestBehavior.AllowGet)); }
/* PRINT **********************************************************************************************************************************************/ // GET: Payments/Print public ActionResult Print(Guid?id) { if (id == null || !UserAccountsController.getUserAccess(Session).Payments_View) { return(RedirectToAction(nameof(HomeController.Index), "Home")); } PaymentsModel model = get((Guid)id); ViewBag.InvoiceHeaderText = new BranchesController().get(Helper.getActiveBranchId(Session)).InvoiceHeaderText; ViewData["SaleInvoiceItems"] = SaleInvoiceItemsController.get(null, null, null, model.Id, null, null, null, null, null, null) .OrderBy(x => x.SaleInvoices_No) .ThenBy(x => x.RowNo) .ToList(); ViewData["PaymentItems"] = PaymentItemsController.get(null, model.Id); ViewBag.TotalAmount = model.CashAmount + model.ConsignmentAmount + model.DebitAmount; return(View(model)); }