public dynamic Insert(PaymentVoucher model) { try { if (!AuthenticationModel.IsAllowed("Create", 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 Add record"); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } model = _paymentVoucherService.CreateObject(model, _paymentVoucherDetailService, _payableService , _contactService, _cashBankService); } catch (Exception ex) { LOG.Error("Insert 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 })); }
public RetailPurchaseInvoice PaidObject(RetailPurchaseInvoice retailPurchaseInvoice, decimal AmountPaid, ICashBankService _cashBankService, IPayableService _payableService, IPaymentVoucherService _paymentVoucherService, IPaymentVoucherDetailService _paymentVoucherDetailService, IContactService _contactService, ICashMutationService _cashMutationService, IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService, IClosingService _closingService) { retailPurchaseInvoice.AmountPaid = AmountPaid; if (_validator.ValidPaidObject(retailPurchaseInvoice, _cashBankService, _paymentVoucherService)) { CashBank cashBank = _cashBankService.GetObjectById((int)retailPurchaseInvoice.CashBankId.GetValueOrDefault()); retailPurchaseInvoice.IsBank = cashBank.IsBank; if (!retailPurchaseInvoice.IsGBCH) { retailPurchaseInvoice.GBCH_No = null; retailPurchaseInvoice.Description = null; } if (retailPurchaseInvoice.AmountPaid == retailPurchaseInvoice.Total) { retailPurchaseInvoice.IsFullPayment = true; } Payable payable = _payableService.GetObjectBySource(Core.Constants.Constant.PayableSource.RetailPurchaseInvoice, retailPurchaseInvoice.Id); PaymentVoucher paymentVoucher = _paymentVoucherService.CreateObject((int)retailPurchaseInvoice.CashBankId.GetValueOrDefault(), retailPurchaseInvoice.ContactId, DateTime.Now, retailPurchaseInvoice.Total, retailPurchaseInvoice.IsGBCH, (DateTime)retailPurchaseInvoice.DueDate.GetValueOrDefault(), retailPurchaseInvoice.IsBank, _paymentVoucherDetailService, _payableService, _contactService, _cashBankService); PaymentVoucherDetail paymentVoucherDetail = _paymentVoucherDetailService.CreateObject(paymentVoucher.Id, payable.Id, (decimal)retailPurchaseInvoice.AmountPaid.GetValueOrDefault(), "Automatic Payment", _paymentVoucherService, _cashBankService, _payableService); retailPurchaseInvoice = _repository.PaidObject(retailPurchaseInvoice); _paymentVoucherService.ConfirmObject(paymentVoucher, (DateTime)retailPurchaseInvoice.ConfirmationDate.GetValueOrDefault(), _paymentVoucherDetailService, _cashBankService, _payableService, _cashMutationService, _generalLedgerJournalService, _accountService, _closingService); } return(retailPurchaseInvoice); }
void PopulatePaymentVouher() { _purchaseInvoiceService.ConfirmObject(pi1, DateTime.Today, _purchaseInvoiceDetailService, _purchaseOrderService, _purchaseReceivalService, _purchaseReceivalDetailService, _payableService); _purchaseInvoiceService.ConfirmObject(pi2, DateTime.Today, _purchaseInvoiceDetailService, _purchaseOrderService, _purchaseReceivalService, _purchaseReceivalDetailService, _payableService); _purchaseInvoiceService.ConfirmObject(pi3, DateTime.Today, _purchaseInvoiceDetailService, _purchaseOrderService, _purchaseReceivalService, _purchaseReceivalDetailService, _payableService); pv = new PaymentVoucher() { ContactId = contact.Id, CashBankId = cashBank.Id, PaymentDate = DateTime.Today.AddDays(14), IsGBCH = true, //IsBank = true, DueDate = DateTime.Today.AddDays(14), TotalAmount = pi1.AmountPayable + pi2.AmountPayable + pi3.AmountPayable }; _paymentVoucherService.CreateObject(pv, _paymentVoucherDetailService, _payableService, _contactService, _cashBankService); pvd1 = new PaymentVoucherDetail() { PaymentVoucherId = pv.Id, PayableId = _payableService.GetObjectBySource(Core.Constants.Constant.PayableSource.PurchaseInvoice, pi1.Id).Id, Amount = pi1.AmountPayable, Description = "Payment buat Purchase Invoice 1" }; _paymentVoucherDetailService.CreateObject(pvd1, _paymentVoucherService, _cashBankService, _payableService); pvd2 = new PaymentVoucherDetail() { PaymentVoucherId = pv.Id, PayableId = _payableService.GetObjectBySource(Core.Constants.Constant.PayableSource.PurchaseInvoice, pi2.Id).Id, Amount = pi2.AmountPayable, Description = "Payment buat Purchase Invoice 2" }; _paymentVoucherDetailService.CreateObject(pvd2, _paymentVoucherService, _cashBankService, _payableService); pvd3 = new PaymentVoucherDetail() { PaymentVoucherId = pv.Id, PayableId = _payableService.GetObjectBySource(Core.Constants.Constant.PayableSource.PurchaseInvoice, pi3.Id).Id, Amount = pi3.AmountPayable, Description = "Payment buat Purchase Invoice 3" }; _paymentVoucherDetailService.CreateObject(pvd3, _paymentVoucherService, _cashBankService, _payableService); _paymentVoucherService.ConfirmObject(pv, DateTime.Today, _paymentVoucherDetailService, _cashBankService, _payableService, _cashMutationService, _generalLedgerJournalService, _accountService, _closingService); _paymentVoucherService.ReconcileObject(pv, DateTime.Today.AddDays(10), _paymentVoucherDetailService, _cashMutationService, _cashBankService, _payableService, _generalLedgerJournalService, _accountService, _closingService); }
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 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); }