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); }
public dynamic UnConfirm(PaymentVoucher model) { try { if (!AuthenticationModel.IsAllowed("UnConfirm", Core.Constants.Constant.MenuName.PaymentVoucher, Core.Constants.Constant.MenuGroupName.Transaction)) { Dictionary <string, string> Errors = new Dictionary <string, string>(); Errors.Add("Generic", "You are Not Allowed to UnConfirm record"); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } var data = _paymentVoucherService.GetObjectById(model.Id); model = _paymentVoucherService.UnconfirmObject(data, _paymentVoucherDetailService, _cashBankService, _payableService, _cashMutationService, _generalLedgerJournalService, _accountService, _closingService); } catch (Exception ex) { LOG.Error("Unconfirm Failed", ex); Dictionary <string, string> Errors = new Dictionary <string, string>(); Errors.Add("Generic", "Error " + ex); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } return(Json(new { model.Errors })); }