예제 #1
0
 public JsonResult Cash(CashCommand cmd)
 {
     try
     {
         CompanyProfile cp = new CompanyProfile(this.HttpContext);
         cmd.id = Guid.NewGuid();
         cmd.BranchId = cp.BranchId;
         InvoiceService.Cash(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 Cash(CashCommand cmd, string username)
 {
     FailIfCustomerNotFound(cmd.CustomerId);
     FailIfProductCantSale(cmd.ProductId, cmd.BranchId);
     Invoice inv = new Invoice(new CashParameter
     {
         BranchId = cmd.BranchId,
         CustomerId = cmd.CustomerId,
         id = cmd.id,
         InvoiceNo = InvoiceAutoNumberGenerator.GenerateInvoiceNumber(DateTime.Now, cmd.BranchId),
         InvoiceDate = cmd.InvoiceDate,
         Price = cmd.Price,
         ProductId = cmd.ProductId,
         Status = StatusInvoice.PAID
     });
     Repository.Save(inv);
     ProductService.ChangeStatus(cmd.ProductId, cmd.BranchId, StatusProduct.TERJUAL, username);
     CreateCashReceive(inv, inv.CreateSnapshot().Price);
     PublishInvoiceCreated(inv, username);
 }