public JsonResult UpdateToCash(UpdateToCashCommand cmd) { try { CompanyProfile cp = new CompanyProfile(this.HttpContext); cmd.BranchId = cp.BranchId; InvoiceService.UpdateToCash(cmd, cp.UserName); return Json(new { error = false, data = cmd }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { return Json(new { error = true, message = ex.Message }, JsonRequestBehavior.AllowGet); } }
public void UpdateToCash(UpdateToCashCommand cmd, string username) { Invoice inv = Repository.Get(cmd.InvoiceId); InvoiceSnapshot invSnap = inv.CreateSnapshot(); FailIfInvoiceNotFound(invSnap); if (invSnap.Status == (int)StatusInvoice.BOOKING) { inv.UpdateToCash(); Repository.Update(inv); Receive bookingRcv = ReceiveRepository.GetBooking(invSnap.id); decimal outstanding = (invSnap.Price - bookingRcv.Total); CreateCashReceive(inv, outstanding); PublishPaymentTypeChanged(inv, username); } }