public dynamic Insert(ReceiptVoucher model) { try { if (!AuthenticationModel.IsAllowed("Create", Core.Constants.Constant.MenuName.ReceiptVoucher, 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 = _receiptVoucherService.CreateObject(model, _receiptVoucherDetailService, _receivableService , _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 CashSalesInvoice PaidObject(CashSalesInvoice cashSalesInvoice, decimal AmountPaid, decimal Allowance, ICashBankService _cashBankService, IReceivableService _receivableService, IReceiptVoucherService _receiptVoucherService, IReceiptVoucherDetailService _receiptVoucherDetailService, IContactService _contactService, ICashMutationService _cashMutationService, ICashSalesReturnService _cashSalesReturnService, IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService, IClosingService _closingService) { cashSalesInvoice.AmountPaid = AmountPaid; cashSalesInvoice.Allowance = Allowance; if (_validator.ValidPaidObject(cashSalesInvoice, _cashBankService, _receiptVoucherService, _cashSalesReturnService, _closingService)) { CashBank cashBank = _cashBankService.GetObjectById((int)cashSalesInvoice.CashBankId.GetValueOrDefault()); cashSalesInvoice.IsBank = cashBank.IsBank; if (cashSalesInvoice.AmountPaid + cashSalesInvoice.Allowance == cashSalesInvoice.Total) { cashSalesInvoice.IsFullPayment = true; } Receivable receivable = _receivableService.GetObjectBySource(Core.Constants.Constant.ReceivableSource.CashSalesInvoice, cashSalesInvoice.Id); receivable.AllowanceAmount = Allowance; receivable.RemainingAmount = receivable.Amount - receivable.AllowanceAmount; _receivableService.UpdateObject(receivable); ReceiptVoucher receiptVoucher = _receiptVoucherService.CreateObject((int)cashSalesInvoice.CashBankId.GetValueOrDefault(), receivable.ContactId, DateTime.Now, cashSalesInvoice.AmountPaid.GetValueOrDefault() /*receivable.RemainingAmount*/, false, (DateTime)cashSalesInvoice.DueDate.GetValueOrDefault(), cashSalesInvoice.IsBank, _receiptVoucherDetailService, _receivableService, _contactService, _cashBankService); ReceiptVoucherDetail receiptVoucherDetail = _receiptVoucherDetailService.CreateObject(receiptVoucher.Id, receivable.Id, cashSalesInvoice.AmountPaid.GetValueOrDefault(), "Automatic Payment", _receiptVoucherService, _cashBankService, _receivableService); cashSalesInvoice = _repository.PaidObject(cashSalesInvoice); _generalLedgerJournalService.CreatePaidJournalForCashSalesInvoice(cashSalesInvoice, _accountService); _receiptVoucherService.ConfirmObject(receiptVoucher, (DateTime)cashSalesInvoice.ConfirmationDate.GetValueOrDefault(), _receiptVoucherDetailService, _cashBankService, _receivableService, _cashMutationService, _generalLedgerJournalService, _accountService, _closingService); } return(cashSalesInvoice); }
public RetailSalesInvoice PaidObject(RetailSalesInvoice retailSalesInvoice, decimal AmountPaid, ICashBankService _cashBankService, IReceivableService _receivableService, IReceiptVoucherService _receiptVoucherService, IReceiptVoucherDetailService _receiptVoucherDetailService, IContactService _contactService, ICashMutationService _cashMutationService, IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService, IClosingService _closingService) { retailSalesInvoice.AmountPaid = AmountPaid; if (_validator.ValidPaidObject(retailSalesInvoice, _cashBankService, _receiptVoucherService)) { CashBank cashBank = _cashBankService.GetObjectById((int)retailSalesInvoice.CashBankId.GetValueOrDefault()); retailSalesInvoice.IsBank = cashBank.IsBank; if (!retailSalesInvoice.IsGBCH) { retailSalesInvoice.GBCH_No = null; retailSalesInvoice.Description = null; } if (retailSalesInvoice.AmountPaid == retailSalesInvoice.Total) { retailSalesInvoice.IsFullPayment = true; } Receivable receivable = _receivableService.GetObjectBySource(Core.Constants.Constant.ReceivableSource.RetailSalesInvoice, retailSalesInvoice.Id); ReceiptVoucher receiptVoucher = _receiptVoucherService.CreateObject((int)retailSalesInvoice.CashBankId.GetValueOrDefault(), retailSalesInvoice.ContactId, DateTime.Now, retailSalesInvoice.Total, retailSalesInvoice.IsGBCH, (DateTime)retailSalesInvoice.DueDate.GetValueOrDefault(), retailSalesInvoice.IsBank, _receiptVoucherDetailService, _receivableService, _contactService, _cashBankService); ReceiptVoucherDetail receiptVoucherDetail = _receiptVoucherDetailService.CreateObject(receiptVoucher.Id, receivable.Id, (decimal)retailSalesInvoice.AmountPaid.GetValueOrDefault(), "Automatic Payment", _receiptVoucherService, _cashBankService, _receivableService); retailSalesInvoice = _repository.PaidObject(retailSalesInvoice); _receiptVoucherService.ConfirmObject(receiptVoucher, (DateTime)retailSalesInvoice.ConfirmationDate, _receiptVoucherDetailService, _cashBankService, _receivableService, _cashMutationService, _generalLedgerJournalService, _accountService, _closingService); } return(retailSalesInvoice); }
void PopulateVoucher() { _salesInvoiceService.ConfirmObject(si1, DateTime.Today, _salesInvoiceDetailService, _salesOrderService, _deliveryOrderService, _deliveryOrderDetailService, _receivableService); _salesInvoiceService.ConfirmObject(si2, DateTime.Today, _salesInvoiceDetailService, _salesOrderService, _deliveryOrderService, _deliveryOrderDetailService, _receivableService); _salesInvoiceService.ConfirmObject(si3, DateTime.Today, _salesInvoiceDetailService, _salesOrderService, _deliveryOrderService, _deliveryOrderDetailService, _receivableService); rv = new ReceiptVoucher() { ContactId = contact.Id, CashBankId = cashBank.Id, ReceiptDate = DateTime.Today.AddDays(14), IsGBCH = true, //IsBank = true, DueDate = DateTime.Today.AddDays(14), TotalAmount = si1.AmountReceivable + si2.AmountReceivable + si3.AmountReceivable }; _receiptVoucherService.CreateObject(rv, _receiptVoucherDetailService, _receivableService, _contactService, _cashBankService); rvd1 = new ReceiptVoucherDetail() { ReceiptVoucherId = rv.Id, ReceivableId = _receivableService.GetObjectBySource(Core.Constants.Constant.ReceivableSource.SalesInvoice, si1.Id).Id, Amount = si1.AmountReceivable, Description = "Receipt buat Sales Invoice 1" }; _receiptVoucherDetailService.CreateObject(rvd1, _receiptVoucherService, _cashBankService, _receivableService); rvd2 = new ReceiptVoucherDetail() { ReceiptVoucherId = rv.Id, ReceivableId = _receivableService.GetObjectBySource(Core.Constants.Constant.ReceivableSource.SalesInvoice, si2.Id).Id, Amount = si2.AmountReceivable, Description = "Receipt buat Sales Invoice 2" }; _receiptVoucherDetailService.CreateObject(rvd2, _receiptVoucherService, _cashBankService, _receivableService); rvd3 = new ReceiptVoucherDetail() { ReceiptVoucherId = rv.Id, ReceivableId = _receivableService.GetObjectBySource(Core.Constants.Constant.ReceivableSource.SalesInvoice, si3.Id).Id, Amount = si3.AmountReceivable, Description = "Receipt buat Sales Invoice 3" }; _receiptVoucherDetailService.CreateObject(rvd3, _receiptVoucherService, _cashBankService, _receivableService); _receiptVoucherService.ConfirmObject(rv, DateTime.Today, _receiptVoucherDetailService, _cashBankService, _receivableService, _cashMutationService, _generalLedgerJournalService, _accountService, _closingService); _receiptVoucherService.ReconcileObject(rv, DateTime.Today.AddDays(10), _receiptVoucherDetailService, _cashMutationService, _cashBankService, _receivableService, _generalLedgerJournalService, _accountService, _closingService); }