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 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 PaymentVoucherDetail VAmountLessOrEqualPayable(PaymentVoucherDetail paymentVoucherDetail, IPayableService _payableService) { Payable payable = _payableService.GetObjectById(paymentVoucherDetail.PayableId); if (paymentVoucherDetail.Amount > payable.Amount) { paymentVoucherDetail.Errors.Add("Amount", "Tidak boleh lebih dari payable"); } return(paymentVoucherDetail); }
public PaymentVoucherDetail VPayableHasNotBeenCompleted(PaymentVoucherDetail paymentVoucherDetail, IPayableService _payableService) { Payable payable = _payableService.GetObjectById(paymentVoucherDetail.PayableId); if (payable.IsCompleted) { paymentVoucherDetail.Errors.Add("Generic", "Payable sudah complete"); } return(paymentVoucherDetail); }
public PaymentVoucherDetail VHasPayable(PaymentVoucherDetail paymentVoucherDetail, IPayableService _payableService) { Payable payable = _payableService.GetObjectById(paymentVoucherDetail.PayableId); if (payable == null) { paymentVoucherDetail.Errors.Add("PayableId", "Tidak boleh tidak ada"); } return(paymentVoucherDetail); }
public PaymentVoucherDetail VUniquePayableId(PaymentVoucherDetail paymentVoucherDetail, IPaymentVoucherDetailService _paymentVoucherDetailService, IPayableService _payableService) { IList <PaymentVoucherDetail> paymentVoucherDetails = _paymentVoucherDetailService.GetObjectsByPaymentVoucherId(paymentVoucherDetail.PaymentVoucherId); Payable payable = _payableService.GetObjectById(paymentVoucherDetail.PayableId); foreach (var detail in paymentVoucherDetails) { if (detail.PayableId == paymentVoucherDetail.PayableId && detail.Id != paymentVoucherDetail.Id) { paymentVoucherDetail.Errors.Add("Generic", "PayableId harus unique dibandingkan payment voucher details di dalam satu payment voucher"); return(paymentVoucherDetail); } } return(paymentVoucherDetail); }
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 dynamic GetListDetail(string _search, long nd, int rows, int?page, string sidx, string sord, int id, string filters = "") { // Construct where statement string strWhere = GeneralFunction.ConstructWhere(filters); string filter = null; GeneralFunction.ConstructWhereInLinq(strWhere, out filter); if (filter == "") { filter = "true"; } // Get Data var q = _paymentVoucherDetailService.GetQueryableObjectsByPaymentVoucherId(id).Include("Payable"); var query = (from model in q select new { model.Id, model.Code, model.PayableId, payable = model.Payable.Code, model.Amount, model.Description, }).Where(filter).OrderBy(sidx + " " + sord); //.ToList(); var list = query.AsEnumerable(); var pageIndex = Convert.ToInt32(page) - 1; var pageSize = rows; var totalRecords = query.Count(); var totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize); // default last page if (totalPages > 0) { if (!page.HasValue) { pageIndex = totalPages - 1; page = totalPages; } } list = list.Skip(pageIndex * pageSize).Take(pageSize); return(Json(new { total = totalPages, page = page, records = totalRecords, rows = ( from model in list select new { id = model.Id, cell = new object[] { model.Code, model.PayableId, _payableService.GetObjectById(model.PayableId).Code, model.Amount, model.Description, } }).ToArray() }, JsonRequestBehavior.AllowGet)); }