Пример #1
0
        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);
        }