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 dynamic GetInfoDetail(int Id) { ReceiptVoucherDetail model = new ReceiptVoucherDetail(); try { model = _receiptVoucherDetailService.GetObjectById(Id); } catch (Exception ex) { LOG.Error("GetInfo", ex); Dictionary <string, string> Errors = new Dictionary <string, string>(); Errors.Add("Generic", "Error " + ex); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } return(Json(new { model.Id, model.Code, model.ReceivableId, Receivable = _receivableService.GetObjectById(model.ReceivableId).Code, model.Amount, model.Description, model.Errors }, JsonRequestBehavior.AllowGet)); }
public ReceiptVoucherDetail CreateObject(ReceiptVoucherDetail receiptVoucherDetail, IReceiptVoucherService _receiptVoucherService, ICashBankService _cashBankService, IReceivableService _receivableService) { receiptVoucherDetail.Errors = new Dictionary <String, String>(); return(_validator.ValidCreateObject(receiptVoucherDetail, _receiptVoucherService, this, _cashBankService, _receivableService) ? _repository.CreateObject(receiptVoucherDetail) : receiptVoucherDetail); }
public dynamic InsertDetail(ReceiptVoucherDetail model) { try { if (!AuthenticationModel.IsAllowed("Edit", 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 Edit record"); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } model = _receiptVoucherDetailService.CreateObject(model, _receiptVoucherService, _cashBankService, _receivableService); } 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 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); }
public dynamic DeleteDetail(ReceiptVoucherDetail model) { try { if (!AuthenticationModel.IsAllowed("Edit", 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 Edit record"); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } var data = _receiptVoucherDetailService.GetObjectById(model.Id); model = _receiptVoucherDetailService.SoftDeleteObject(data); } catch (Exception ex) { LOG.Error("Delete 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 ReceiptVoucherDetail VHasBeenConfirmed(ReceiptVoucherDetail receiptVoucherDetail) { if (!receiptVoucherDetail.IsConfirmed) { receiptVoucherDetail.Errors.Add("Generic", "Belum dikonfirmasi"); } return(receiptVoucherDetail); }
public ReceiptVoucherDetail VHasNotBeenDeleted(ReceiptVoucherDetail receiptVoucherDetail) { if (receiptVoucherDetail.IsDeleted) { receiptVoucherDetail.Errors.Add("Generic", "Sudah didelete"); } return(receiptVoucherDetail); }
public ReceiptVoucherDetail VHasConfirmationDate(ReceiptVoucherDetail obj) { if (obj.ConfirmationDate == null) { obj.Errors.Add("ConfirmationDate", "Tidak boleh kosong"); } return(obj); }
public ReceiptVoucherDetail VNonNegativeAmount(ReceiptVoucherDetail receiptVoucherDetail) { if (receiptVoucherDetail.Amount < 0) { receiptVoucherDetail.Errors.Add("Amount", "Tidak boleh kurang dari 0"); } return(receiptVoucherDetail); }
public ReceiptVoucherDetail VHasReceivable(ReceiptVoucherDetail receiptVoucherDetail, IReceivableService _receivableService) { Receivable receivable = _receivableService.GetObjectById(receiptVoucherDetail.ReceivableId); if (receivable == null) { receiptVoucherDetail.Errors.Add("Receivable", "Tidak boleh tidak ada"); } return(receiptVoucherDetail); }
public ReceiptVoucherDetail VReceivableHasNotBeenCompleted(ReceiptVoucherDetail receiptVoucherDetail, IReceivableService _receivableService) { Receivable receivable = _receivableService.GetObjectById(receiptVoucherDetail.ReceivableId); if (receivable.IsCompleted) { receiptVoucherDetail.Errors.Add("Generic", "Receivable sudah complete"); } return(receiptVoucherDetail); }
public ReceiptVoucherDetail VConfirmObject(ReceiptVoucherDetail receiptVoucherDetail, IReceivableService _receivableService) { VHasConfirmationDate(receiptVoucherDetail); if (!isValid(receiptVoucherDetail)) { return(receiptVoucherDetail); } VAmountLessOrEqualReceivable(receiptVoucherDetail, _receivableService); return(receiptVoucherDetail); }
public ReceiptVoucherDetail VDeleteObject(ReceiptVoucherDetail receiptVoucherDetail) { VHasNotBeenConfirmed(receiptVoucherDetail); if (!isValid(receiptVoucherDetail)) { return(receiptVoucherDetail); } VHasNotBeenDeleted(receiptVoucherDetail); return(receiptVoucherDetail); }
public ReceiptVoucherDetail VAmountLessOrEqualReceivable(ReceiptVoucherDetail receiptVoucherDetail, IReceivableService _receivableService) { Receivable receivable = _receivableService.GetObjectById(receiptVoucherDetail.ReceivableId); if (receiptVoucherDetail.Amount > receivable.Amount) { receiptVoucherDetail.Errors.Add("Amount", "Tidak boleh lebih dari receivable"); } return(receiptVoucherDetail); }
public ReceiptVoucherDetail VUpdateObject(ReceiptVoucherDetail receiptVoucherDetail, IReceiptVoucherService _receiptVoucherService, IReceiptVoucherDetailService _receiptVoucherDetailService, ICashBankService _cashBankService, IReceivableService _receivableService) { VHasNotBeenConfirmed(receiptVoucherDetail); if (!isValid(receiptVoucherDetail)) { return(receiptVoucherDetail); } VCreateObject(receiptVoucherDetail, _receiptVoucherService, _receiptVoucherDetailService, _cashBankService, _receivableService); return(receiptVoucherDetail); }
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); }
public string PrintError(ReceiptVoucherDetail obj) { string erroroutput = ""; KeyValuePair <string, string> first = obj.Errors.ElementAt(0); erroroutput += first.Key + "," + first.Value; foreach (KeyValuePair <string, string> pair in obj.Errors.Skip(1)) { erroroutput += Environment.NewLine; erroroutput += pair.Key + "," + pair.Value; } return(erroroutput); }
public ReceiptVoucherDetail CreateObject(int receiptVoucherId, int receivableId, decimal amount, string description, IReceiptVoucherService _receiptVoucherService, ICashBankService _cashBankService, IReceivableService _receivableService) { ReceiptVoucherDetail receiptVoucherDetail = new ReceiptVoucherDetail { ReceiptVoucherId = receiptVoucherId, ReceivableId = receivableId, Amount = amount, Description = description, }; return(this.CreateObject(receiptVoucherDetail, _receiptVoucherService, _cashBankService, _receivableService)); }
public ReceiptVoucherDetail VUniqueReceivableId(ReceiptVoucherDetail receiptVoucherDetail, IReceiptVoucherDetailService _receiptVoucherDetailService, IReceivableService _receivableService) { IList <ReceiptVoucherDetail> receiptVoucherDetails = _receiptVoucherDetailService.GetObjectsByReceiptVoucherId(receiptVoucherDetail.ReceiptVoucherId); Receivable receivable = _receivableService.GetObjectById(receiptVoucherDetail.ReceivableId); foreach (var detail in receiptVoucherDetails) { if (detail.ReceivableId == receiptVoucherDetail.ReceivableId && detail.Id != receiptVoucherDetail.Id) { receiptVoucherDetail.Errors.Add("Generic", "ReceivableId harus unique dibandingkan receipt voucher details di dalam satu receipt voucher"); return(receiptVoucherDetail); } } return(receiptVoucherDetail); }
public ReceiptVoucherDetail UnconfirmObject(ReceiptVoucherDetail receiptVoucherDetail, IReceiptVoucherService _receiptVoucherService, IReceivableService _receivableService) { if (_validator.ValidUnconfirmObject(receiptVoucherDetail)) { ReceiptVoucher receiptVoucher = _receiptVoucherService.GetObjectById(receiptVoucherDetail.ReceiptVoucherId); Receivable receivable = _receivableService.GetObjectById(receiptVoucherDetail.ReceivableId); if (receiptVoucher.IsGBCH) { receivable.PendingClearanceAmount -= receiptVoucherDetail.Amount; } receivable.RemainingAmount += receiptVoucherDetail.Amount; if (receivable.RemainingAmount != 0 || receivable.PendingClearanceAmount != 0) { receivable.IsCompleted = false; receivable.CompletionDate = null; } _receivableService.UpdateObject(receivable); receiptVoucherDetail = _repository.UnconfirmObject(receiptVoucherDetail); } return(receiptVoucherDetail); }
public ReceiptVoucherDetail ConfirmObject(ReceiptVoucherDetail receiptVoucherDetail, DateTime ConfirmationDate, IReceiptVoucherService _receiptVoucherService, IReceivableService _receivableService) { receiptVoucherDetail.ConfirmationDate = ConfirmationDate; if (_validator.ValidConfirmObject(receiptVoucherDetail, _receivableService)) { ReceiptVoucher receiptVoucher = _receiptVoucherService.GetObjectById(receiptVoucherDetail.ReceiptVoucherId); Receivable receivable = _receivableService.GetObjectById(receiptVoucherDetail.ReceivableId); if (receiptVoucher.IsGBCH) { receivable.PendingClearanceAmount += receiptVoucherDetail.Amount; } receivable.RemainingAmount -= receiptVoucherDetail.Amount; if (receivable.RemainingAmount == 0 && receivable.PendingClearanceAmount == 0) { receivable.IsCompleted = true; receivable.CompletionDate = DateTime.Now; } _receivableService.UpdateObject(receivable); receiptVoucherDetail = _repository.ConfirmObject(receiptVoucherDetail); } return(receiptVoucherDetail); }
public ReceiptVoucherDetail VCreateObject(ReceiptVoucherDetail receiptVoucherDetail, IReceiptVoucherService _receiptVoucherService, IReceiptVoucherDetailService _receiptVoucherDetailService, ICashBankService _cashBankService, IReceivableService _receivableService) { VHasReceiptVoucher(receiptVoucherDetail, _receiptVoucherService); if (!isValid(receiptVoucherDetail)) { return(receiptVoucherDetail); } VHasNotBeenConfirmed(receiptVoucherDetail); if (!isValid(receiptVoucherDetail)) { return(receiptVoucherDetail); } VHasNotBeenDeleted(receiptVoucherDetail); if (!isValid(receiptVoucherDetail)) { return(receiptVoucherDetail); } VHasReceivable(receiptVoucherDetail, _receivableService); if (!isValid(receiptVoucherDetail)) { return(receiptVoucherDetail); } VReceivableHasNotBeenCompleted(receiptVoucherDetail, _receivableService); if (!isValid(receiptVoucherDetail)) { return(receiptVoucherDetail); } VAmountLessOrEqualReceivable(receiptVoucherDetail, _receivableService); if (!isValid(receiptVoucherDetail)) { return(receiptVoucherDetail); } VUniqueReceivableId(receiptVoucherDetail, _receiptVoucherDetailService, _receivableService); return(receiptVoucherDetail); }
public bool ValidUnconfirmObject(ReceiptVoucherDetail receiptVoucherDetail) { VUnconfirmObject(receiptVoucherDetail); return(isValid(receiptVoucherDetail)); }
public ReceiptVoucherDetail VUpdateObject(ReceiptVoucherDetail receiptVoucherDetail, IReceiptVoucherService _receiptVoucherService, IReceiptVoucherDetailService _receiptVoucherDetailService, ICashBankService _cashBankService, IReceivableService _receivableService) { VCreateObject(receiptVoucherDetail, _receiptVoucherService, _receiptVoucherDetailService, _cashBankService, _receivableService); return(receiptVoucherDetail); }
public ReceiptVoucherDetail VUnconfirmObject(ReceiptVoucherDetail receiptVoucherDetail) { VHasBeenConfirmed(receiptVoucherDetail); return(receiptVoucherDetail); }
public bool ValidUpdateObject(ReceiptVoucherDetail receiptVoucherDetail, IReceiptVoucherService _receiptVoucherService, IReceiptVoucherDetailService _receiptVoucherDetailService, ICashBankService _cashBankService, IReceivableService _receivableService) { VUpdateObject(receiptVoucherDetail, _receiptVoucherService, _receiptVoucherDetailService, _cashBankService, _receivableService); return(isValid(receiptVoucherDetail)); }
public bool ValidDeleteObject(ReceiptVoucherDetail receiptVoucherDetail) { VDeleteObject(receiptVoucherDetail); return(isValid(receiptVoucherDetail)); }
public bool ValidConfirmObject(ReceiptVoucherDetail receiptVoucherDetail, IReceivableService _receivableService) { VConfirmObject(receiptVoucherDetail, _receivableService); return(isValid(receiptVoucherDetail)); }
public bool isValid(ReceiptVoucherDetail obj) { bool isValid = !obj.Errors.Any(); return(isValid); }