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); }
public PaymentVoucher UnreconcileObject(PaymentVoucher paymentVoucher, IPaymentVoucherDetailService _paymentVoucherDetailService, ICashMutationService _cashMutationService, ICashBankService _cashBankService, IPayableService _payableService, IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService, IClosingService _closingService) { if (_validator.ValidUnreconcileObject(paymentVoucher, _closingService)) { _repository.UnreconcileObject(paymentVoucher); CashBank cashBank = _cashBankService.GetObjectById(paymentVoucher.CashBankId); IList <CashMutation> cashMutations = _cashMutationService.SoftDeleteCashMutationForPaymentVoucher(paymentVoucher, cashBank); foreach (var cashMutation in cashMutations) { _cashMutationService.ReverseCashMutateObject(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 = false; payable.CompletionDate = null; } _payableService.UpdateObject(payable); } } return(paymentVoucher); }
public PaymentVoucherDetail ConfirmObject(PaymentVoucherDetail paymentVoucherDetail, DateTime ConfirmationDate, IPaymentVoucherService _paymentVoucherService, IPayableService _payableService) { paymentVoucherDetail.ConfirmationDate = ConfirmationDate; if (_validator.ValidConfirmObject(paymentVoucherDetail, _payableService)) { PaymentVoucher paymentVoucher = _paymentVoucherService.GetObjectById(paymentVoucherDetail.PaymentVoucherId); Payable payable = _payableService.GetObjectById(paymentVoucherDetail.PayableId); if (paymentVoucher.IsGBCH) { payable.PendingClearanceAmount += paymentVoucherDetail.Amount; } payable.RemainingAmount -= paymentVoucherDetail.Amount; if (payable.RemainingAmount == 0 && payable.PendingClearanceAmount == 0) { payable.IsCompleted = true; payable.CompletionDate = DateTime.Now; } _payableService.UpdateObject(payable); paymentVoucherDetail = _repository.ConfirmObject(paymentVoucherDetail); } return(paymentVoucherDetail); }
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 CustomPurchaseInvoice PaidObject(CustomPurchaseInvoice customPurchaseInvoice, decimal AmountPaid, ICashBankService _cashBankService, IPayableService _payableService, IPaymentVoucherService _paymentVoucherService, IPaymentVoucherDetailService _paymentVoucherDetailService, IContactService _contactService, ICashMutationService _cashMutationService, IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService, IClosingService _closingService) { customPurchaseInvoice.AmountPaid = AmountPaid; if (_validator.ValidPaidObject(customPurchaseInvoice, _cashBankService, _paymentVoucherService, _closingService)) { CashBank cashBank = _cashBankService.GetObjectById((int)customPurchaseInvoice.CashBankId.GetValueOrDefault()); customPurchaseInvoice.IsBank = cashBank.IsBank; if (!customPurchaseInvoice.IsGBCH) { customPurchaseInvoice.GBCH_No = null; customPurchaseInvoice.Description = null; } if (customPurchaseInvoice.AmountPaid == customPurchaseInvoice.Total) { customPurchaseInvoice.IsFullPayment = true; } Payable payable = _payableService.GetObjectBySource(Core.Constants.Constant.PayableSource.CustomPurchaseInvoice, customPurchaseInvoice.Id); payable.AllowanceAmount = customPurchaseInvoice.Allowance; payable.RemainingAmount = payable.Amount - customPurchaseInvoice.Allowance; _payableService.UpdateObject(payable); PaymentVoucher paymentVoucher = _paymentVoucherService.CreateObject((int)customPurchaseInvoice.CashBankId.GetValueOrDefault(), customPurchaseInvoice.ContactId, DateTime.Now, customPurchaseInvoice.AmountPaid.GetValueOrDefault() /*payable.RemainingAmount*/, customPurchaseInvoice.IsGBCH, (DateTime)customPurchaseInvoice.DueDate.GetValueOrDefault(), customPurchaseInvoice.IsBank, _paymentVoucherDetailService, _payableService, _contactService, _cashBankService); PaymentVoucherDetail paymentVoucherDetail = _paymentVoucherDetailService.CreateObject(paymentVoucher.Id, payable.Id, customPurchaseInvoice.AmountPaid.GetValueOrDefault(), "Automatic Payment", _paymentVoucherService, _cashBankService, _payableService); customPurchaseInvoice = _repository.PaidObject(customPurchaseInvoice); _generalLedgerJournalService.CreatePaidJournalForCustomPurchaseInvoice(customPurchaseInvoice, _accountService); _paymentVoucherService.ConfirmObject(paymentVoucher, (DateTime)customPurchaseInvoice.ConfirmationDate.GetValueOrDefault(), _paymentVoucherDetailService, _cashBankService, _payableService, _cashMutationService, _generalLedgerJournalService, _accountService, _closingService); } return(customPurchaseInvoice); }
public PaymentVoucherDetail UnconfirmObject(PaymentVoucherDetail paymentVoucherDetail, IPaymentVoucherService _paymentVoucherService, IPayableService _payableService) { if (_validator.ValidUnconfirmObject(paymentVoucherDetail)) { PaymentVoucher paymentVoucher = _paymentVoucherService.GetObjectById(paymentVoucherDetail.PaymentVoucherId); Payable payable = _payableService.GetObjectById(paymentVoucherDetail.PayableId); if (paymentVoucher.IsGBCH) { payable.PendingClearanceAmount -= paymentVoucherDetail.Amount; } payable.RemainingAmount += paymentVoucherDetail.Amount; if (payable.RemainingAmount != 0 || payable.PendingClearanceAmount != 0) { payable.IsCompleted = false; payable.CompletionDate = null; } _payableService.UpdateObject(payable); paymentVoucherDetail = _repository.UnconfirmObject(paymentVoucherDetail); } return(paymentVoucherDetail); }
public CashSalesReturn PaidObject(CashSalesReturn cashSalesReturn, /*decimal Allowance,*/ ICashBankService _cashBankService, IPayableService _payableService, IPaymentVoucherService _paymentVoucherService, IPaymentVoucherDetailService _paymentVoucherDetailService, IContactService _contactService, ICashMutationService _cashMutationService, IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService, IClosingService _closingService) { if (_validator.ValidPaidObject(cashSalesReturn, _cashBankService)) { CashBank cashBank = _cashBankService.GetObjectById((int)cashSalesReturn.CashBankId.GetValueOrDefault()); //cashSalesReturn.Allowance = Allowance; Payable payable = _payableService.GetObjectBySource(Core.Constants.Constant.PayableSource.CashSalesReturn, cashSalesReturn.Id); payable.AllowanceAmount = cashSalesReturn.Allowance; payable.RemainingAmount = payable.Amount - payable.AllowanceAmount; _payableService.UpdateObject(payable); PaymentVoucher paymentVoucher = _paymentVoucherService.CreateObject((int)cashSalesReturn.CashBankId.GetValueOrDefault(), payable.ContactId, DateTime.Now, payable.RemainingAmount, false, payable.DueDate, cashBank.IsBank, _paymentVoucherDetailService, _payableService, _contactService, _cashBankService); PaymentVoucherDetail paymentVoucherDetail = _paymentVoucherDetailService.CreateObject(paymentVoucher.Id, payable.Id, payable.RemainingAmount, "Automatic Payment", _paymentVoucherService, _cashBankService, _payableService); _paymentVoucherService.ConfirmObject(paymentVoucher, (DateTime)cashSalesReturn.ConfirmationDate.GetValueOrDefault(), _paymentVoucherDetailService, _cashBankService, _payableService, _cashMutationService, _generalLedgerJournalService, _accountService, _closingService); cashSalesReturn = _repository.PaidObject(cashSalesReturn); } return(cashSalesReturn); }