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; }
private void FailIfInvoiceNotFound(InvoiceSnapshot snap) { if (snap == null) throw new ApplicationException("Invoice tidak ditemukan"); }
private void FailIfInvoiceIsNotCredit(InvoiceSnapshot invSnap) { if (invSnap.Status != (int)StatusInvoice.CREDIT) { throw new ApplicationException("Hanya jenis transaksi kredit yang bisa mengubah data"); } }
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"); } }
private void CreatePelunasanReceive(InvoiceSnapshot invSnap, decimal totalYangHarusDiBayar, decimal denda, long banyakCicilanYangTelahDibayar) { ReceiveService.CreatePelunasan(invSnap.id, invSnap.BranchId, totalYangHarusDiBayar, denda, banyakCicilanYangTelahDibayar); }
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; }
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; }
private decimal CalculateOutstanding(InvoiceSnapshot snap) { return snap.AngsuranBulanan * snap.LamaAngsuran; }
public Invoice(InvoiceSnapshot snap) { _snapshot = snap; }