public PaymentVoucher ConfirmObject(PaymentVoucher paymentVoucher, DateTime ConfirmationDate, IPaymentVoucherDetailService _paymentVoucherDetailService, ICashBankService _cashBankService, IPayableService _payableService, ICashMutationService _cashMutationService, IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService, IClosingService _closingService) { paymentVoucher.ConfirmationDate = ConfirmationDate; if (_validator.ValidConfirmObject(paymentVoucher, this, _paymentVoucherDetailService, _cashBankService, _payableService, _closingService)) { IList <PaymentVoucherDetail> details = _paymentVoucherDetailService.GetObjectsByPaymentVoucherId(paymentVoucher.Id); foreach (var detail in details) { detail.Errors = new Dictionary <string, string>(); _paymentVoucherDetailService.ConfirmObject(detail, ConfirmationDate, this, _payableService); } _repository.ConfirmObject(paymentVoucher); if (!paymentVoucher.IsGBCH) { CashBank cashBank = _cashBankService.GetObjectById(paymentVoucher.CashBankId); CashMutation cashMutation = _cashMutationService.CreateCashMutationForPaymentVoucher(paymentVoucher, cashBank); _cashMutationService.CashMutateObject(cashMutation, _cashBankService); _generalLedgerJournalService.CreateConfirmationJournalForPaymentVoucher(paymentVoucher, cashBank, _accountService); } } return(paymentVoucher); }
public PaymentVoucher ReconcileObject(PaymentVoucher paymentVoucher, DateTime ReconciliationDate, IPaymentVoucherDetailService _paymentVoucherDetailService, ICashMutationService _cashMutationService, ICashBankService _cashBankService, IPayableService _payableService, IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService, IClosingService _closingService) { paymentVoucher.ReconciliationDate = ReconciliationDate; if (_validator.ValidReconcileObject(paymentVoucher, _closingService)) { _repository.ReconcileObject(paymentVoucher); CashBank cashBank = _cashBankService.GetObjectById(paymentVoucher.CashBankId); CashMutation cashMutation = _cashMutationService.CreateCashMutationForPaymentVoucher(paymentVoucher, cashBank); _cashMutationService.CashMutateObject(cashMutation, _cashBankService); IList <PaymentVoucherDetail> paymentVoucherDetails = _paymentVoucherDetailService.GetObjectsByPaymentVoucherId(paymentVoucher.Id); foreach (var paymentVoucherDetail in paymentVoucherDetails) { Payable payable = _payableService.GetObjectById(paymentVoucherDetail.PayableId); payable.PendingClearanceAmount -= paymentVoucherDetail.Amount; if (payable.PendingClearanceAmount == 0 && payable.RemainingAmount == 0) { payable.IsCompleted = true; payable.CompletionDate = DateTime.Now; } _payableService.UpdateObject(payable); } } return(paymentVoucher); }