Example #1
0
 public void Update(Invoice inv)
 {
     ReportingRepository.Update<InvoiceSnapshot>(inv.CreateSnapshot(), new { id = inv.CreateSnapshot().id });
 }
Example #2
0
 public void Remove(Invoice inv)
 {
     ReportingRepository.Delete<InvoiceSnapshot>(new { id = inv.CreateSnapshot().id });
 }
Example #3
0
 public void Save(Invoice inv)
 {
     ReportingRepository.Save<InvoiceSnapshot>(inv.CreateSnapshot());
 }
Example #4
0
 private void PublishUangMukaChanged(Invoice inv, string username)
 {
     _bus.Publish(new UangMukaChanged { Payload = inv.CreateSnapshot(), Username = username });
 }
Example #5
0
 private void UpdateUangMukaReceive(Invoice inv, decimal totalUangMuka)
 {
     InvoiceSnapshot invSnapshot = inv.CreateSnapshot();
     ReceiveService.ChangeUangMuka(invSnapshot.id, totalUangMuka);
 }
Example #6
0
 private void PublishLamaAngsuranChanged(Invoice inv, string username)
 {
     _bus.Publish(new LamaAngsuranChanged { Payload = inv.CreateSnapshot(), Username = username });
 }
Example #7
0
 private void PublishPaymentTypeChanged(Invoice inv, string username)
 {
     _bus.Publish(new PaymentTypeChanged { Payload = inv.CreateSnapshot(), Username = username });
 }
Example #8
0
 private void PublishAngsuranPaid(Invoice inv, string username)
 {
     _bus.Publish(new AngsuranPaid { Payload = inv.CreateSnapshot(), Username = username });
 }
Example #9
0
 private void PublishInvoicePulled(Invoice inv, string username)
 {
     _bus.Publish(new InvoicePulled { Payload = inv.CreateSnapshot(), Username = username });
 }
Example #10
0
 private void CreateCashReceive(Invoice inv, decimal total)
 {
     InvoiceSnapshot invSnapshot = inv.CreateSnapshot();
     ReceiveService.CreateCash(new CreateCashReceive
     {
         InvoiceId = invSnapshot.id,
         BranchId = invSnapshot.BranchId,
         Total = total
     });
 }
Example #11
0
 private void CreateUangMukaReceive(Invoice inv, decimal totalUangMuka)
 {
     InvoiceSnapshot invSnapshot = inv.CreateSnapshot();
     ReceiveService.CreateUangMuka(new CreateUangMukaReceive
     {
         InvoiceId = invSnapshot.id,
         BranchId = invSnapshot.BranchId,
         Total = totalUangMuka
     });
 }
Example #12
0
 private void CreateBookingReceive(Invoice inv, decimal debitnote)
 {
     InvoiceSnapshot invSnapshot = inv.CreateSnapshot();
     if (invSnapshot.Status == (int)StatusInvoice.BOOKING && debitnote > 0)
     {
         ReceiveService.CreateBooking(new CreateBookingReceive
         {
             InvoiceId = invSnapshot.id,
             BranchId = invSnapshot.BranchId,
             Total = debitnote
         });
     }
 }
Example #13
0
        private void CreateAngsuranReceive(Invoice inv, DateTime date, decimal denda, long totalangsuran, decimal creditNote)
        {
            InvoiceSnapshot invSnapshot = inv.CreateSnapshot();
            var perbayaranBulanKe = (Convert.ToInt32(totalangsuran) + 1) * invSnapshot.TermValue;
            string bulanAngsuran = string.Empty;
            if (invSnapshot.TermType.Equals((int)TermType.Day))
                bulanAngsuran = invSnapshot.InvoiceDate.AddDays(perbayaranBulanKe).ToString("MMyyyy");
            else if (invSnapshot.TermType.Equals((int)TermType.Month))
                bulanAngsuran = invSnapshot.InvoiceDate.AddMonths(perbayaranBulanKe).ToString("MMyyyy");
            else
                throw new Exception("Type termin pembayaran tidak terdefinisi");

            ReceiveService.CreateAngsuran(new CreateAngsuranReceive
            {
                BranchId = invSnapshot.BranchId,
                Denda = Math.Round(denda),
                Total = Math.Round(invSnapshot.AngsuranBulanan + denda),
                InvoiceId = invSnapshot.id,
                BulanAngsuran = bulanAngsuran,
                PaymentDate = date,
                BulanAngsuranNumber = totalangsuran + 1,
                CreditNote = creditNote
            });
        }
Example #14
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);
 }
Example #15
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);
 }
Example #16
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);
 }