Example #1
0
        public void PayInvoice(Guid paymentId, 
            decimal amountPaid, decimal bankCharge,
            DateTime paymentDate, PaymentMode paymentMode,
            string reference, string notes, string username)
        {
            Contract.Requires(amountPaid > 0m, "Jumlah yang dibayarkan tidak boleh nol");
            Contract.Requires(paymentDate.Date >= InvoiceDate, "Pembayaran hanya bisa dilakukan setelah atau pada hari yang bersamaan dengan tanggal invoice");
            Contract.Requires(amountPaid <= BalanceDue, "Jumlah yang dibayarkan melebihi sisa hutang yang harus dibayarkan");

            decimal balDue = _balanceDue - amountPaid;
            bool paidOff = balDue == 0m;

            ApplyEvent(new InvoicePaid
            {
                InvoiceId = this.EventSourceId,
                PaymentId = paymentId,
                PaymentDate = paymentDate,
                AmountPaid = amountPaid,
                BankCharge = bankCharge,
                PaymentMode = paymentMode,
                Reference = reference,
                Notes = notes,
                BalanceDue = balDue,
                PaidOff = paidOff,
                OwnerId = _ownerId,
                Username = username
            });
        }
Example #2
0
        public void ChangePaymentMode(Guid paymentId, PaymentMode paymentMode, string username)
        {
            Contract.Requires(RevisedPaymentExist(paymentId));

            ApplyEvent(new PaymentModeChanged
            {
                OwnerId = this._ownerId,
                InvoiceId = this.EventSourceId,
                PaymentId = paymentId,
                PaymentMode = paymentMode,
                Username = username
            });
        }