예제 #1
0
 public JsonResult Credit(CreditCommand cmd)
 {
     try
     {
         CompanyProfile cp = new CompanyProfile(this.HttpContext);
         cmd.id = Guid.NewGuid();
         cmd.BranchId = cp.BranchId;
         InvoiceService.Credit(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);
     }
 }
예제 #2
0
 public void Credit(CreditCommand cmd, string username)
 {
     FailIfCustomerNotFound(cmd.CustomerId);
     FailIfProductCantSale(cmd.ProductId, cmd.BranchId);
     PaymentTermReport term = PaymentTermRepository.GetById(cmd.TermId);
     Invoice inv = new Invoice(new CreateParameter
     {
         BranchId = cmd.BranchId,
         CustomerId = cmd.CustomerId,
         id = cmd.id,
         InvoiceNo = InvoiceAutoNumberGenerator.GenerateInvoiceNumber(DateTime.Now, cmd.BranchId),
         InvoiceDate = cmd.InvoiceDate,
         ProductId = cmd.ProductId,
         Status = StatusInvoice.CREDIT,
         Price = cmd.Price,
         UangMuka = cmd.UangMuka,
         SukuBunga = cmd.SukuBunga,
         LamaAngsuran = cmd.LamaAngsuran,
         DueDate = cmd.DueDate,
         TermId = term.id,
         TermValue = term.Value,
         TermType = term.Type
     });
     Repository.Save(inv);
     ProductService.ChangeStatus(cmd.ProductId, cmd.BranchId, StatusProduct.TERJUAL, username);
     CreateUangMukaReceive(inv, cmd.UangMuka);
     PerjanjianService.CreateSuratPerjanjian(inv.CreateSnapshot().id, inv.CreateSnapshot().BranchId, inv.CreateSnapshot().InvoiceDate);
     PublishInvoiceCreated(inv, username);
 }