public CustomPurchaseInvoice UnpaidObject(CustomPurchaseInvoice customPurchaseInvoice, IPaymentVoucherService _paymentVoucherService, IPaymentVoucherDetailService _paymentVoucherDetailService, ICashBankService _cashBankService, IPayableService _payableService, ICashMutationService _cashMutationService, IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService, IClosingService _closingService) { if (_validator.ValidUnpaidObject(customPurchaseInvoice, _closingService)) { Payable payable = _payableService.GetObjectBySource(Core.Constants.Constant.PayableSource.CustomPurchaseInvoice, customPurchaseInvoice.Id); IList <PaymentVoucher> paymentVouchers = _paymentVoucherService.GetObjectsByCashBankId((int)customPurchaseInvoice.CashBankId.GetValueOrDefault()); foreach (var paymentVoucher in paymentVouchers) { if (paymentVoucher.ContactId == customPurchaseInvoice.ContactId) { paymentVoucher.Errors = new Dictionary <string, string>(); _paymentVoucherService.UnconfirmObject(paymentVoucher, _paymentVoucherDetailService, _cashBankService, _payableService, _cashMutationService, _generalLedgerJournalService, _accountService, _closingService); IList <PaymentVoucherDetail> paymentVoucherDetails = _paymentVoucherDetailService.GetObjectsByPaymentVoucherId(paymentVoucher.Id); foreach (var paymentVoucherDetail in paymentVoucherDetails) { paymentVoucherDetail.Errors = new Dictionary <string, string>(); _paymentVoucherDetailService.SoftDeleteObject(paymentVoucherDetail); } _paymentVoucherService.SoftDeleteObject(paymentVoucher, _paymentVoucherDetailService); } } customPurchaseInvoice.AmountPaid = 0; customPurchaseInvoice.IsFullPayment = false; _generalLedgerJournalService.CreateUnpaidJournalForCustomPurchaseInvoice(customPurchaseInvoice, _accountService); customPurchaseInvoice = _repository.UnpaidObject(customPurchaseInvoice); } return(customPurchaseInvoice); }
public CashSalesReturn UnpaidObject(CashSalesReturn cashSalesReturn, IPaymentVoucherService _paymentVoucherService, IPaymentVoucherDetailService _paymentVoucherDetailService, ICashBankService _cashBankService, IPayableService _payableService, ICashMutationService _cashMutationService, IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService, IClosingService _closingService) { if (_validator.ValidUnpaidObject(cashSalesReturn)) { Payable payable = _payableService.GetObjectBySource(Core.Constants.Constant.PayableSource.CashSalesReturn, cashSalesReturn.Id); IList <PaymentVoucher> paymentVouchers = _paymentVoucherService.GetObjectsByCashBankId((int)cashSalesReturn.CashBankId.GetValueOrDefault()); foreach (var paymentVoucher in paymentVouchers) { if (paymentVoucher.ContactId == payable.ContactId) { paymentVoucher.Errors = new Dictionary <string, string>(); _paymentVoucherService.UnconfirmObject(paymentVoucher, _paymentVoucherDetailService, _cashBankService, _payableService, _cashMutationService, _generalLedgerJournalService, _accountService, _closingService); IList <PaymentVoucherDetail> paymentVoucherDetails = _paymentVoucherDetailService.GetObjectsByPaymentVoucherId(paymentVoucher.Id); foreach (var paymentVoucherDetail in paymentVoucherDetails) { paymentVoucherDetail.Errors = new Dictionary <string, string>(); _paymentVoucherDetailService.SoftDeleteObject(paymentVoucherDetail); } _paymentVoucherService.SoftDeleteObject(paymentVoucher, _paymentVoucherDetailService); } } payable.AllowanceAmount = 0; _payableService.UpdateObject(payable); cashSalesReturn.Allowance = 0; cashSalesReturn = _repository.UnpaidObject(cashSalesReturn); } return(cashSalesReturn); }