Example #1
0
        public PaymentVoucher VAllPaymentVoucherDetailsAreConfirmable(PaymentVoucher paymentVoucher, IPaymentVoucherService _paymentVoucherService,
                                                                      IPaymentVoucherDetailService _paymentVoucherDetailService, ICashBankService _cashBankService,
                                                                      IPayableService _payableService)
        {
            IList <PaymentVoucherDetail> details = _paymentVoucherDetailService.GetObjectsByPaymentVoucherId(paymentVoucher.Id);

            foreach (var detail in details)
            {
                detail.Errors           = new Dictionary <string, string>();
                detail.ConfirmationDate = paymentVoucher.ConfirmationDate;
                detail.Errors           = new Dictionary <string, string>();
                if (!_paymentVoucherDetailService.GetValidator().ValidConfirmObject(detail, _payableService))
                {
                    foreach (var error in detail.Errors)
                    {
                        paymentVoucher.Errors.Add(error.Key, error.Value);
                    }
                    if (paymentVoucher.Errors.Any())
                    {
                        return(paymentVoucher);
                    }
                }
            }
            return(paymentVoucher);
        }
        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 PaymentVoucher ConfirmObject(PaymentVoucher paymentVoucher, DateTime ConfirmationDate, IPaymentVoucherDetailService _paymentVoucherDetailService,
                                            ICashBankService _cashBankService, IPayableService _payableService, ICashMutationService _cashMutationService,
                                            IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService, IClosingService _closingService)
        {
            paymentVoucher.ConfirmationDate = ConfirmationDate;
            if (_validator.ValidConfirmObject(paymentVoucher, this, _paymentVoucherDetailService, _cashBankService, _payableService, _closingService))
            {
                IList <PaymentVoucherDetail> details = _paymentVoucherDetailService.GetObjectsByPaymentVoucherId(paymentVoucher.Id);
                foreach (var detail in details)
                {
                    detail.Errors = new Dictionary <string, string>();
                    _paymentVoucherDetailService.ConfirmObject(detail, ConfirmationDate, this, _payableService);
                }

                _repository.ConfirmObject(paymentVoucher);

                if (!paymentVoucher.IsGBCH)
                {
                    CashBank     cashBank     = _cashBankService.GetObjectById(paymentVoucher.CashBankId);
                    CashMutation cashMutation = _cashMutationService.CreateCashMutationForPaymentVoucher(paymentVoucher, cashBank);
                    _cashMutationService.CashMutateObject(cashMutation, _cashBankService);
                    _generalLedgerJournalService.CreateConfirmationJournalForPaymentVoucher(paymentVoucher, cashBank, _accountService);
                }
            }
            return(paymentVoucher);
        }
        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 PaymentVoucher UnconfirmObject(PaymentVoucher paymentVoucher, IPaymentVoucherDetailService _paymentVoucherDetailService,
                                              ICashBankService _cashBankService, IPayableService _payableService, ICashMutationService _cashMutationService,
                                              IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService, IClosingService _closingService)
        {
            if (_validator.ValidUnconfirmObject(paymentVoucher, _closingService))
            {
                IList <PaymentVoucherDetail> details = _paymentVoucherDetailService.GetObjectsByPaymentVoucherId(paymentVoucher.Id);
                foreach (var detail in details)
                {
                    detail.Errors = new Dictionary <string, string>();
                    _paymentVoucherDetailService.UnconfirmObject(detail, this, _payableService);
                }
                _repository.UnconfirmObject(paymentVoucher);

                if (!paymentVoucher.IsGBCH)
                {
                    CashBank             cashBank      = _cashBankService.GetObjectById(paymentVoucher.CashBankId);
                    IList <CashMutation> cashMutations = _cashMutationService.SoftDeleteCashMutationForPaymentVoucher(paymentVoucher, cashBank);
                    foreach (var cashMutation in cashMutations)
                    {
                        _cashMutationService.ReverseCashMutateObject(cashMutation, _cashBankService);
                    }
                    _generalLedgerJournalService.CreateUnconfirmationJournalForPaymentVoucher(paymentVoucher, cashBank, _accountService);
                }
            }
            return(paymentVoucher);
        }
Example #6
0
        public CustomPurchaseInvoice UnpaidObject(CustomPurchaseInvoice customPurchaseInvoice, IPaymentVoucherService _paymentVoucherService,
                                                  IPaymentVoucherDetailService _paymentVoucherDetailService, ICashBankService _cashBankService, IPayableService _payableService,
                                                  ICashMutationService _cashMutationService, IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService,
                                                  IClosingService _closingService)
        {
            if (_validator.ValidUnpaidObject(customPurchaseInvoice, _closingService))
            {
                Payable payable = _payableService.GetObjectBySource(Core.Constants.Constant.PayableSource.CustomPurchaseInvoice, customPurchaseInvoice.Id);
                IList <PaymentVoucher> paymentVouchers = _paymentVoucherService.GetObjectsByCashBankId((int)customPurchaseInvoice.CashBankId.GetValueOrDefault());
                foreach (var paymentVoucher in paymentVouchers)
                {
                    if (paymentVoucher.ContactId == customPurchaseInvoice.ContactId)
                    {
                        paymentVoucher.Errors = new Dictionary <string, string>();
                        _paymentVoucherService.UnconfirmObject(paymentVoucher, _paymentVoucherDetailService, _cashBankService,
                                                               _payableService, _cashMutationService, _generalLedgerJournalService, _accountService, _closingService);

                        IList <PaymentVoucherDetail> paymentVoucherDetails = _paymentVoucherDetailService.GetObjectsByPaymentVoucherId(paymentVoucher.Id);
                        foreach (var paymentVoucherDetail in paymentVoucherDetails)
                        {
                            paymentVoucherDetail.Errors = new Dictionary <string, string>();
                            _paymentVoucherDetailService.SoftDeleteObject(paymentVoucherDetail);
                        }
                        _paymentVoucherService.SoftDeleteObject(paymentVoucher, _paymentVoucherDetailService);
                    }
                }
                customPurchaseInvoice.AmountPaid    = 0;
                customPurchaseInvoice.IsFullPayment = false;
                _generalLedgerJournalService.CreateUnpaidJournalForCustomPurchaseInvoice(customPurchaseInvoice, _accountService);
                customPurchaseInvoice = _repository.UnpaidObject(customPurchaseInvoice);
            }
            return(customPurchaseInvoice);
        }
Example #7
0
        public CashSalesReturn UnpaidObject(CashSalesReturn cashSalesReturn, IPaymentVoucherService _paymentVoucherService, IPaymentVoucherDetailService _paymentVoucherDetailService,
                                            ICashBankService _cashBankService, IPayableService _payableService, ICashMutationService _cashMutationService,
                                            IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService, IClosingService _closingService)
        {
            if (_validator.ValidUnpaidObject(cashSalesReturn))
            {
                Payable payable = _payableService.GetObjectBySource(Core.Constants.Constant.PayableSource.CashSalesReturn, cashSalesReturn.Id);
                IList <PaymentVoucher> paymentVouchers = _paymentVoucherService.GetObjectsByCashBankId((int)cashSalesReturn.CashBankId.GetValueOrDefault());
                foreach (var paymentVoucher in paymentVouchers)
                {
                    if (paymentVoucher.ContactId == payable.ContactId)
                    {
                        paymentVoucher.Errors = new Dictionary <string, string>();
                        _paymentVoucherService.UnconfirmObject(paymentVoucher, _paymentVoucherDetailService, _cashBankService, _payableService,
                                                               _cashMutationService, _generalLedgerJournalService, _accountService, _closingService);

                        IList <PaymentVoucherDetail> paymentVoucherDetails = _paymentVoucherDetailService.GetObjectsByPaymentVoucherId(paymentVoucher.Id);
                        foreach (var paymentVoucherDetail in paymentVoucherDetails)
                        {
                            paymentVoucherDetail.Errors = new Dictionary <string, string>();
                            _paymentVoucherDetailService.SoftDeleteObject(paymentVoucherDetail);
                        }
                        _paymentVoucherService.SoftDeleteObject(paymentVoucher, _paymentVoucherDetailService);
                    }
                }
                payable.AllowanceAmount = 0;
                _payableService.UpdateObject(payable);
                cashSalesReturn.Allowance = 0;
                cashSalesReturn           = _repository.UnpaidObject(cashSalesReturn);
            }
            return(cashSalesReturn);
        }
Example #8
0
        public PaymentVoucher VHasNoPaymentVoucherDetail(PaymentVoucher paymentVoucher, IPaymentVoucherDetailService _paymentVoucherDetailService)
        {
            IList <PaymentVoucherDetail> details = _paymentVoucherDetailService.GetObjectsByPaymentVoucherId(paymentVoucher.Id);

            if (details.Any())
            {
                paymentVoucher.Errors.Add("Generic", "Tidak boleh ada payment voucher details");
            }
            return(paymentVoucher);
        }
Example #9
0
        public PaymentVoucher VHasPaymentVoucherDetails(PaymentVoucher paymentVoucher, IPaymentVoucherDetailService _paymentVoucherDetailService)
        {
            IList <PaymentVoucherDetail> details = _paymentVoucherDetailService.GetObjectsByPaymentVoucherId(paymentVoucher.Id);

            if (!details.Any())
            {
                paymentVoucher.Errors.Add("Generic", "Harus memiliki payment voucher details");
            }
            return(paymentVoucher);
        }
Example #10
0
        public PaymentVoucher VTotalAmountIsNotZero(PaymentVoucher paymentVoucher, IPaymentVoucherDetailService _paymentVoucherDetailService)
        {
            decimal totalamount = 0;
            IList <PaymentVoucherDetail> details = _paymentVoucherDetailService.GetObjectsByPaymentVoucherId(paymentVoucher.Id);

            foreach (var detail in details)
            {
                totalamount += detail.Amount;
            }
            if (totalamount == 0)
            {
                paymentVoucher.Errors.Add("Generic", "Total Amount tidak boleh 0");
            }
            return(paymentVoucher);
        }
Example #11
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);
        }
Example #12
0
        public PaymentVoucher VCashBankHasMoreAmountPaymentVoucherDetails(PaymentVoucher paymentVoucher, IPaymentVoucherDetailService _paymentVoucherDetailService, ICashBankService _cashBankService)
        {
            decimal totalamount = 0;
            IList <PaymentVoucherDetail> details = _paymentVoucherDetailService.GetObjectsByPaymentVoucherId(paymentVoucher.Id);

            foreach (var detail in details)
            {
                totalamount += detail.Amount;
            }

            CashBank cashBank = _cashBankService.GetObjectById(paymentVoucher.CashBankId);

            if (cashBank.Amount < totalamount)
            {
                paymentVoucher.Errors.Add("Generic", "Cash bank tidak boleh kurang dari total amount");
            }
            return(paymentVoucher);
        }