Exemple #1
0
 public JsonResult Booking(BookingCommand cmd)
 {
     try
     {
         CompanyProfile cp = new CompanyProfile(this.HttpContext);
         cmd.id = Guid.NewGuid();
         cmd.BranchId = cp.BranchId;
         InvoiceService.Booking(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);
     }
 }
Exemple #2
0
 public void Booking(BookingCommand cmd, string username)
 {
     FailIfCustomerNotFound(cmd.CustomerId);
     FailIfProductCantSale(cmd.ProductId, cmd.BranchId);
     if (cmd.DebitNote <= 0)
         throw new ApplicationException("Uang Tanda Jadi harus diisi");
     Invoice inv = new Invoice(new BookingParameter
     {
         BranchId = cmd.BranchId,
         CustomerId = cmd.CustomerId,
         id = cmd.id,
         InvoiceNo = InvoiceAutoNumberGenerator.GenerateInvoiceNumber(DateTime.Now, cmd.BranchId),
         InvoiceDate = cmd.InvoiceDate,
         DueDate = cmd.InvoiceDate,
         Price = cmd.Price,
         ProductId = cmd.ProductId,
         UangTandaJadi = cmd.DebitNote,
         Status = StatusInvoice.BOOKING
     });
     Repository.Save(inv);
     ProductService.ChangeStatus(cmd.ProductId, cmd.BranchId, StatusProduct.TERJUAL, username);
     CreateBookingReceive(inv, cmd.DebitNote);
     PublishInvoiceCreated(inv, username);
 }