public JsonResult UpdateToCredit(UpdateToCreditCommand cmd) { try { CompanyProfile cp = new CompanyProfile(this.HttpContext); cmd.BranchId = cp.BranchId; InvoiceService.UpdateToCredit(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 UpdateToCredit(UpdateToCreditCommand cmd, string username) { Invoice inv = Repository.Get(cmd.InvoiceId); InvoiceSnapshot invSnap = inv.CreateSnapshot(); FailIfInvoiceNotFound(invSnap); if (invSnap.Status == (int)StatusInvoice.BOOKING) { Receive bookingRcv = ReceiveRepository.GetBooking(invSnap.id); PaymentTermReport term = PaymentTermRepository.GetById(cmd.TermId); inv.UpdateToCredit(new UpdateToCreditParameter { DueDate = cmd.DueDate, LamaAngsuran = cmd.LamaAngsuran, SukuBunga = cmd.SukuBunga, UangMuka = cmd.UangMuka, UangTandaJadi = bookingRcv.Total, TermId = cmd.TermId, TermValue = term.Value, TermType = term.Type }); Repository.Update(inv); CreateUangMukaReceive(inv, cmd.UangMuka); PerjanjianService.CreateSuratPerjanjian(inv.CreateSnapshot().id, inv.CreateSnapshot().BranchId, DateTime.Now); PublishPaymentTypeChanged(inv, username); } }