Ejemplo n.º 1
0
        public Invoice(CreateParameter p)
        {
            int banyakCicilan = CalculateBanyakCicilan(p.LamaAngsuran, p.TermValue, p.TermType);
            decimal totalKredit = CalculateTotalKredit(p.Price, p.UangMuka, p.LamaAngsuran, p.SukuBunga, p.Status, 0);
            var angsuranBulanan = CalculateAngsuranBulanan(p.Price, p.UangMuka, p.LamaAngsuran, p.SukuBunga, 0, banyakCicilan);

            var dueDate = new DateTime();
            if (p.DueDate.Date == p.InvoiceDate.Date)
            {
                if (p.TermType.Equals(TermType.Day))
                    dueDate = p.DueDate.AddDays(p.TermValue);
                else if (p.TermType.Equals(TermType.Month))
                    dueDate = p.DueDate.AddMonths(p.TermValue);
                else
                    throw new Exception("Type termin pembayaran tidak terdefinisi");
            }
            else
                dueDate = p.DueDate;

            InvoiceSnapshot snapshot = new InvoiceSnapshot
            {
                BranchId = p.BranchId,
                CustomerId = p.CustomerId,
                id = p.id,
                InvoiceNo = p.InvoiceNo,
                InvoiceDate = p.InvoiceDate,
                Price = p.Price,
                ProductId = p.ProductId,
                TransactionDate = DateTime.Now,
                Status = (int)p.Status,
                TermId = p.TermId,
                TermType = (int)p.TermType,
                TermValue = p.TermValue,
                LamaAngsuran = p.LamaAngsuran,
                BanyakCicilan = banyakCicilan,
                SukuBunga = p.SukuBunga,
                DueDate = dueDate,
                StartDueDate = p.DueDate,
                AngsuranBulanan = angsuranBulanan,
                TotalKredit = totalKredit,
                Outstanding = angsuranBulanan * banyakCicilan
            };
            _snapshot = snapshot;
        }
Ejemplo n.º 2
0
 private void FailIfInvoiceNotFound(InvoiceSnapshot snap)
 {
     if (snap == null)
         throw new ApplicationException("Invoice tidak ditemukan");
 }
Ejemplo n.º 3
0
 private void FailIfInvoiceIsNotCredit(InvoiceSnapshot invSnap)
 {
     if (invSnap.Status != (int)StatusInvoice.CREDIT)
     {
         throw new ApplicationException("Hanya jenis transaksi kredit yang bisa mengubah data");
     }
 }
Ejemplo n.º 4
0
 private void FailIfCantChange(InvoiceSnapshot invSnap)
 {
     if (invSnap.Status == (int)StatusInvoice.CREDIT)
     {
         if (Repository.CountAngsuranBulanan(invSnap.id) > 0)
             throw new ApplicationException("Angsuran bulanan transaksi ini telah dibayar, sehingga tidak bisa mengubah data");
     }
     else if (invSnap.Status == (int)StatusInvoice.PAID)
     {
         throw new ApplicationException("Transaksi ini telah lunas, sehingga tidak bisa mengubah data");
     }
 }
Ejemplo n.º 5
0
 private void CreatePelunasanReceive(InvoiceSnapshot invSnap, decimal totalYangHarusDiBayar, decimal denda, long banyakCicilanYangTelahDibayar)
 {
     ReceiveService.CreatePelunasan(invSnap.id, invSnap.BranchId, totalYangHarusDiBayar, denda, banyakCicilanYangTelahDibayar);
 }
Ejemplo n.º 6
0
 public Invoice(CashParameter p)
 {
     InvoiceSnapshot snapshot = new InvoiceSnapshot
     {
         BranchId = p.BranchId,
         CustomerId = p.CustomerId,
         id = p.id,
         InvoiceNo = p.InvoiceNo,
         InvoiceDate = p.InvoiceDate,
         Price = p.Price,
         ProductId = p.ProductId,
         TransactionDate = DateTime.Now,
         Status = (int)p.Status
     };
     _snapshot = snapshot;
 }
Ejemplo n.º 7
0
 public Invoice(BookingParameter p)
 {
     InvoiceSnapshot snapshot = new InvoiceSnapshot
     {
         BranchId = p.BranchId,
         CustomerId = p.CustomerId,
         id = p.id,
         InvoiceNo = p.InvoiceNo,
         InvoiceDate = p.InvoiceDate,
         Price = p.Price,
         ProductId = p.ProductId,
         TransactionDate = DateTime.Now,
         Status = (int)p.Status,
         DueDate = p.DueDate,
         StartDueDate = p.DueDate,
         Outstanding = p.Price - p.UangTandaJadi
     };
     _snapshot = snapshot;
 }
Ejemplo n.º 8
0
 private decimal CalculateOutstanding(InvoiceSnapshot snap)
 {
     return snap.AngsuranBulanan * snap.LamaAngsuran;
 }
Ejemplo n.º 9
0
 public Invoice(InvoiceSnapshot snap)
 {
     _snapshot = snap;
 }