public dynamic DeleteDetail(PaymentVoucherDetail model)
        {
            try
            {
                if (!AuthenticationModel.IsAllowed("Edit", 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 Edit record");

                    return(Json(new
                    {
                        Errors
                    }, JsonRequestBehavior.AllowGet));
                }

                var data = _paymentVoucherDetailService.GetObjectById(model.Id);
                model = _paymentVoucherDetailService.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,
            }));
        }
示例#2
0
        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);
        }
示例#3
0
 public PaymentVoucherDetail CreateObject(PaymentVoucherDetail paymentVoucherDetail, IPaymentVoucherService _paymentVoucherService,
                                          ICashBankService _cashBankService, IPayableService _payableService)
 {
     paymentVoucherDetail.Errors = new Dictionary <String, String>();
     return(_validator.ValidCreateObject(paymentVoucherDetail, _paymentVoucherService, this, _cashBankService, _payableService) ?
            _repository.CreateObject(paymentVoucherDetail) : paymentVoucherDetail);
 }
示例#4
0
        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 dynamic InsertDetail(PaymentVoucherDetail model)
        {
            try
            {
                if (!AuthenticationModel.IsAllowed("Edit", 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 Edit record");

                    return(Json(new
                    {
                        Errors
                    }, JsonRequestBehavior.AllowGet));
                }

                model = _paymentVoucherDetailService.CreateObject(model, _paymentVoucherService, _cashBankService, _payableService
                                                                  );
            }
            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 dynamic GetInfoDetail(int Id)
        {
            PaymentVoucherDetail model = new PaymentVoucherDetail();

            try
            {
                model = _paymentVoucherDetailService.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.PayableId,
                Payable = _payableService.GetObjectById(model.PayableId).Code,
                model.Amount,
                model.Description,
                model.Errors
            }, JsonRequestBehavior.AllowGet));
        }
示例#7
0
 public PaymentVoucherDetail VHasNotBeenDeleted(PaymentVoucherDetail paymentVoucherDetail)
 {
     if (paymentVoucherDetail.IsDeleted)
     {
         paymentVoucherDetail.Errors.Add("Generic", "Sudah didelete");
     }
     return(paymentVoucherDetail);
 }
示例#8
0
 public PaymentVoucherDetail VHasBeenConfirmed(PaymentVoucherDetail paymentVoucherDetail)
 {
     if (!paymentVoucherDetail.IsConfirmed)
     {
         paymentVoucherDetail.Errors.Add("Generic", "Belum dikonfirmasi");
     }
     return(paymentVoucherDetail);
 }
示例#9
0
 public PaymentVoucherDetail VHasConfirmationDate(PaymentVoucherDetail obj)
 {
     if (obj.ConfirmationDate == null)
     {
         obj.Errors.Add("ConfirmationDate", "Tidak boleh kosong");
     }
     return(obj);
 }
示例#10
0
 public PaymentVoucherDetail VNonNegativeAmount(PaymentVoucherDetail paymentVoucherDetail)
 {
     if (paymentVoucherDetail.Amount < 0)
     {
         paymentVoucherDetail.Errors.Add("Amount", "Tidak boleh kurang dari 0");
     }
     return(paymentVoucherDetail);
 }
示例#11
0
        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);
        }
示例#12
0
 public PaymentVoucherDetail VConfirmObject(PaymentVoucherDetail paymentVoucherDetail, IPayableService _payableService)
 {
     VHasConfirmationDate(paymentVoucherDetail);
     if (!isValid(paymentVoucherDetail))
     {
         return(paymentVoucherDetail);
     }
     VAmountLessOrEqualPayable(paymentVoucherDetail, _payableService);
     return(paymentVoucherDetail);
 }
示例#13
0
 public PaymentVoucherDetail VDeleteObject(PaymentVoucherDetail paymentVoucherDetail)
 {
     VHasNotBeenConfirmed(paymentVoucherDetail);
     if (!isValid(paymentVoucherDetail))
     {
         return(paymentVoucherDetail);
     }
     VHasNotBeenDeleted(paymentVoucherDetail);
     return(paymentVoucherDetail);
 }
示例#14
0
        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);
        }
示例#15
0
        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);
        }
示例#16
0
 public PaymentVoucherDetail VUpdateObject(PaymentVoucherDetail paymentVoucherDetail, IPaymentVoucherService _paymentVoucherService,
                                           IPaymentVoucherDetailService _paymentVoucherDetailService, ICashBankService _cashBankService, IPayableService _payableService)
 {
     VHasNotBeenConfirmed(paymentVoucherDetail);
     if (!isValid(paymentVoucherDetail))
     {
         return(paymentVoucherDetail);
     }
     VCreateObject(paymentVoucherDetail, _paymentVoucherService, _paymentVoucherDetailService, _cashBankService, _payableService);
     return(paymentVoucherDetail);
 }
示例#17
0
        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);
        }
示例#18
0
        public string PrintError(PaymentVoucherDetail 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);
        }
示例#19
0
        public PaymentVoucherDetail CreateObject(int paymentVoucherId, int payableId, decimal amount, string description,
                                                 IPaymentVoucherService _paymentVoucherService, ICashBankService _cashBankService,
                                                 IPayableService _payableService)
        {
            PaymentVoucherDetail paymentVoucherDetail = new PaymentVoucherDetail
            {
                PaymentVoucherId = paymentVoucherId,
                PayableId        = payableId,
                Amount           = amount,
                Description      = description,
            };

            return(this.CreateObject(paymentVoucherDetail, _paymentVoucherService, _cashBankService, _payableService));
        }
示例#20
0
        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);
        }
示例#21
0
        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);
        }
示例#22
0
        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);
        }
示例#23
0
 public PaymentVoucherDetail VCreateObject(PaymentVoucherDetail paymentVoucherDetail, IPaymentVoucherService _paymentVoucherService,
                                           IPaymentVoucherDetailService _paymentVoucherDetailService, ICashBankService _cashBankService, IPayableService _payableService)
 {
     VHasPaymentVoucher(paymentVoucherDetail, _paymentVoucherService);
     if (!isValid(paymentVoucherDetail))
     {
         return(paymentVoucherDetail);
     }
     VHasNotBeenConfirmed(paymentVoucherDetail);
     if (!isValid(paymentVoucherDetail))
     {
         return(paymentVoucherDetail);
     }
     VHasNotBeenDeleted(paymentVoucherDetail);
     if (!isValid(paymentVoucherDetail))
     {
         return(paymentVoucherDetail);
     }
     VHasPayable(paymentVoucherDetail, _payableService);
     if (!isValid(paymentVoucherDetail))
     {
         return(paymentVoucherDetail);
     }
     VPayableHasNotBeenCompleted(paymentVoucherDetail, _payableService);
     if (!isValid(paymentVoucherDetail))
     {
         return(paymentVoucherDetail);
     }
     VAmountLessOrEqualPayable(paymentVoucherDetail, _payableService);
     if (!isValid(paymentVoucherDetail))
     {
         return(paymentVoucherDetail);
     }
     VUniquePayableId(paymentVoucherDetail, _paymentVoucherDetailService, _payableService);
     return(paymentVoucherDetail);
 }
示例#24
0
 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);
 }
示例#25
0
 public bool ValidConfirmObject(PaymentVoucherDetail paymentVoucherDetail, IPayableService _payableService)
 {
     VConfirmObject(paymentVoucherDetail, _payableService);
     return(isValid(paymentVoucherDetail));
 }
示例#26
0
 public bool ValidUnconfirmObject(PaymentVoucherDetail paymentVoucherDetail)
 {
     VUnconfirmObject(paymentVoucherDetail);
     return(isValid(paymentVoucherDetail));
 }
示例#27
0
 public PaymentVoucherDetail SoftDeleteObject(PaymentVoucherDetail paymentVoucherDetail)
 {
     return(_validator.ValidDeleteObject(paymentVoucherDetail) ? _repository.SoftDeleteObject(paymentVoucherDetail) : paymentVoucherDetail);
 }
示例#28
0
 public PaymentVoucherDetail UpdateObject(PaymentVoucherDetail paymentVoucherDetail, IPaymentVoucherService _paymentVoucherService, ICashBankService _cashBankService, IPayableService _payableService)
 {
     return(_validator.ValidUpdateObject(paymentVoucherDetail, _paymentVoucherService, this, _cashBankService, _payableService) ?
            _repository.UpdateObject(paymentVoucherDetail) : paymentVoucherDetail);
 }
示例#29
0
        public bool isValid(PaymentVoucherDetail obj)
        {
            bool isValid = !obj.Errors.Any();

            return(isValid);
        }
示例#30
0
        void paymentrequest_validation()
        {
            it["validates_paymentrequest"] = () =>
            {
                d.paymentRequest1.Errors.Count().should_be(0);
            };

            it["paymentrequest_without_contact"] = () =>
            {
                PaymentRequest nocontact = new PaymentRequest()
                {
                    RequestedDate = DateTime.Now,
                    Description   = "Tanpa Kontak",
                    DueDate       = DateTime.Today.AddDays(14),
                    Amount        = 200000,
                };
                nocontact = d._paymentRequestService.CreateObject(nocontact, d._contactService);
                nocontact.Errors.Count().should_not_be(0);
            };

            it["update_without_contact"] = () =>
            {
                d.paymentRequest1.ContactId = 0;
                d.paymentRequest1           = d._paymentRequestService.UpdateObject(d.paymentRequest1, d._contactService);
                d.paymentRequest1.Errors.Count().should_not_be(0);
            };

            context["when_paymentrequest_confirmed"] = () =>
            {
                before = () =>
                {
                    d._paymentRequestService.ConfirmObject(d.paymentRequest1, DateTime.Now, d._payableService);
                    d.paymentRequest1.Errors.Count().should_be(0);
                };

                it["validates_confirmed_paymentrequest"] = () =>
                {
                    d.paymentRequest1.IsConfirmed.should_be_true();
                };

                it["update_after_confirmed"] = () =>
                {
                    d.paymentRequest1.Amount = 300000;
                    d.paymentRequest1        = d._paymentRequestService.UpdateObject(d.paymentRequest1, d._contactService);
                    d.paymentRequest1.Errors.Count().should_not_be(0);
                };

                it["delete_after_confirmed"] = () =>
                {
                    d.paymentRequest1 = d._paymentRequestService.SoftDeleteObject(d.paymentRequest1);
                    d.paymentRequest1.Errors.Count().should_not_be(0);
                };

                it["unconfirm_paymentrequest"] = () =>
                {
                    d.paymentRequest1 = d._paymentRequestService.UnconfirmObject(d.paymentRequest1, d._paymentVoucherDetailService, d._payableService);
                    d.paymentRequest1.Errors.Count().should_be(0);
                };

                it["unconfirm_after_payable_have_paymentvoucherdetail"] = () =>
                {
                    PaymentVoucher paymentVoucher = d._paymentVoucherService.CreateObject(d.cashBank1.Id, d.contact.Id, DateTime.Now, d.paymentRequest1.Amount, false, d.paymentRequest1.DueDate, d.cashBank1.IsBank,
                                                                                          d._paymentVoucherDetailService, d._payableService, d._contactService, d._cashBankService);
                    Payable payable = d._payableService.GetObjectBySource(Core.Constants.Constant.PayableSource.PaymentRequest, d.paymentRequest1.Id);
                    PaymentVoucherDetail paymentVoucherDetail = d._paymentVoucherDetailService.CreateObject(paymentVoucher.Id, payable.Id, payable.Amount, "Pembayaran Listrik",
                                                                                                            d._paymentVoucherService, d._cashBankService, d._payableService);
                    d.paymentRequest1 = d._paymentRequestService.UnconfirmObject(d.paymentRequest1, d._paymentVoucherDetailService, d._payableService);
                    d.paymentRequest1.Errors.Count().should_not_be(0);
                };
            };

            it["delete_paymentrequest"] = () =>
            {
                d.paymentRequest1 = d._paymentRequestService.SoftDeleteObject(d.paymentRequest1);
                d.paymentRequest1.Errors.Count().should_be(0);
            };
        }