예제 #1
0
파일: Invoice.cs 프로젝트: AsliMotor/AMQ
        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;
        }
예제 #2
0
 private void FailIfInvoiceNotFound(InvoiceSnapshot snap)
 {
     if (snap == null)
         throw new ApplicationException("Invoice tidak ditemukan");
 }
예제 #3
0
 private void FailIfInvoiceIsNotCredit(InvoiceSnapshot invSnap)
 {
     if (invSnap.Status != (int)StatusInvoice.CREDIT)
     {
         throw new ApplicationException("Hanya jenis transaksi kredit yang bisa mengubah data");
     }
 }
예제 #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");
     }
 }
예제 #5
0
 private void CreatePelunasanReceive(InvoiceSnapshot invSnap, decimal totalYangHarusDiBayar, decimal denda, long banyakCicilanYangTelahDibayar)
 {
     ReceiveService.CreatePelunasan(invSnap.id, invSnap.BranchId, totalYangHarusDiBayar, denda, banyakCicilanYangTelahDibayar);
 }
예제 #6
0
파일: Invoice.cs 프로젝트: AsliMotor/AMQ
 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;
 }
예제 #7
0
파일: Invoice.cs 프로젝트: AsliMotor/AMQ
 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;
 }
예제 #8
0
파일: Invoice.cs 프로젝트: AsliMotor/AMQ
 private decimal CalculateOutstanding(InvoiceSnapshot snap)
 {
     return snap.AngsuranBulanan * snap.LamaAngsuran;
 }
예제 #9
0
파일: Invoice.cs 프로젝트: AsliMotor/AMQ
 public Invoice(InvoiceSnapshot snap)
 {
     _snapshot = snap;
 }