Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
 public PaymentRequest UnconfirmObject(PaymentRequest paymentRequest, IPaymentVoucherDetailService _paymentVoucherDetailService, IPayableService _payableService)
 {
     if (_validator.ValidUnconfirmObject(paymentRequest, _paymentVoucherDetailService, _payableService))
     {
         _repository.UnconfirmObject(paymentRequest);
         Payable payable = _payableService.GetObjectBySource(Constant.PayableSource.PaymentRequest, paymentRequest.Id);
         _payableService.SoftDeleteObject(payable);
     }
     return(paymentRequest);
 }
Exemplo n.º 6
0
        public PurchaseInvoice VHasPaymentVoucherDetails(PurchaseInvoice purchaseInvoice, IPayableService _payableService, IPaymentVoucherDetailService _paymentVoucherDetailService)
        {
            Payable payable = _payableService.GetObjectBySource(Constant.PayableSource.PurchaseInvoice, purchaseInvoice.Id);
            IList <PaymentVoucherDetail> pvdetails = _paymentVoucherDetailService.GetObjectsByPayableId(payable.Id);

            if (pvdetails.Any())
            {
                purchaseInvoice.Errors.Add("Generic", "Tidak boleh sudah ada proses pembayaran");
            }
            return(purchaseInvoice);
        }
Exemplo n.º 7
0
        public PaymentRequest VPayableHasNoOtherAssociation(PaymentRequest paymentRequest, IPayableService _payableService, IPaymentVoucherDetailService _paymentVoucherDetailService)
        {
            Payable payable = _payableService.GetObjectBySource(Constant.PayableSource.PaymentRequest, paymentRequest.Id);
            IList <PaymentVoucherDetail> paymentVoucherDetails = _paymentVoucherDetailService.GetObjectsByPayableId(payable.Id);

            if (paymentVoucherDetails.Any())
            {
                paymentRequest.Errors.Add("Generic", "Payable memiliki asosiasi dengan payment voucher detail");
                return(paymentRequest);
            }
            return(paymentRequest);
        }
Exemplo n.º 8
0
        /*public CashSalesReturn VIsCashBankTypeNotBank(CashSalesReturn cashSalesReturn, ICashBankService _cashBankService)
         * {
         *  CashBank cashBank = _cashBankService.GetObjectById((int)cashSalesReturn.CashBankId.GetValueOrDefault());
         *  if (cashBank.IsBank)
         *  {
         *      cashSalesReturn.Errors.Add("Generic", "CashBank harus bukan tipe Bank");
         *      return cashSalesReturn;
         *  }
         *  return cashSalesReturn;
         * }*/

        public CashSalesReturn VHasNoPaymentVoucherDetails(CashSalesReturn cashSalesReturn, IPayableService _payableService, IPaymentVoucherDetailService _paymentVoucherDetailService)
        {
            Payable payable = _payableService.GetObjectBySource(Core.Constants.Constant.PayableSource.CashSalesReturn, cashSalesReturn.Id);

            if (payable != null)
            {
                IList <PaymentVoucherDetail> paymentVoucherDetails = _paymentVoucherDetailService.GetObjectsByPayableId(payable.Id);
                if (paymentVoucherDetails.Any())
                {
                    cashSalesReturn.Errors.Add("Generic", "Tidak boleh terasosiasi dengan PaymentVoucherDetails");
                }
            }
            return(cashSalesReturn);
        }
        public RetailPurchaseInvoice VHasNoPaymentVoucherDetails(RetailPurchaseInvoice retailPurchaseInvoice, IPayableService _payableService, IPaymentVoucherDetailService _paymentVoucherDetailService)
        {
            Payable payable = _payableService.GetObjectBySource(Core.Constants.Constant.PayableSource.RetailPurchaseInvoice, retailPurchaseInvoice.Id);

            if (payable != null)
            {
                IList <PaymentVoucherDetail> paymentVoucherDetails = _paymentVoucherDetailService.GetObjectsByPayableId(payable.Id);
                if (paymentVoucherDetails.Any())
                {
                    retailPurchaseInvoice.Errors.Add("Generic", "Tidak boleh terasosiasi dengan PaymentVoucherDetails");
                }
            }
            return(retailPurchaseInvoice);
        }
Exemplo n.º 10
0
 public RetailPurchaseInvoice UnconfirmObject(RetailPurchaseInvoice retailPurchaseInvoice, IRetailPurchaseInvoiceDetailService _retailPurchaseInvoiceDetailService,
                                              IPayableService _payableService, IPaymentVoucherDetailService _paymentVoucherDetailService,
                                              IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService, IItemService _itemService,
                                              IBarringService _barringService, IStockMutationService _stockMutationService, IClosingService _closingService)
 {
     if (_validator.ValidUnconfirmObject(retailPurchaseInvoice, _retailPurchaseInvoiceDetailService, _payableService, _paymentVoucherDetailService))
     {
         retailPurchaseInvoice = _repository.UnconfirmObject(retailPurchaseInvoice);
         IList <RetailPurchaseInvoiceDetail> retailPurchaseInvoiceDetails = _retailPurchaseInvoiceDetailService.GetObjectsByRetailPurchaseInvoiceId(retailPurchaseInvoice.Id);
         foreach (var retailPurchaseInvoiceDetail in retailPurchaseInvoiceDetails)
         {
             retailPurchaseInvoiceDetail.Errors = new Dictionary <string, string>();
             _retailPurchaseInvoiceDetailService.UnconfirmObject(retailPurchaseInvoiceDetail, _warehouseItemService, _warehouseService, _itemService, _barringService, _stockMutationService);
         }
         Payable payable = _payableService.GetObjectBySource(Core.Constants.Constant.PayableSource.RetailPurchaseInvoice, retailPurchaseInvoice.Id);
         _payableService.SoftDeleteObject(payable);
     }
     return(retailPurchaseInvoice);
 }
Exemplo n.º 11
0
 public PurchaseInvoice UnconfirmObject(PurchaseInvoice purchaseInvoice, IPurchaseInvoiceDetailService _purchaseInvoiceDetailService,
                                        IPurchaseReceivalService _purchaseReceivalService, IPurchaseReceivalDetailService _purchaseReceivalDetailService,
                                        IPaymentVoucherDetailService _paymentVoucherDetailService, IPayableService _payableService)
 {
     if (_validator.ValidUnconfirmObject(purchaseInvoice, _purchaseInvoiceDetailService, _paymentVoucherDetailService, _payableService))
     {
         IList <PurchaseInvoiceDetail> details = _purchaseInvoiceDetailService.GetObjectsByPurchaseInvoiceId(purchaseInvoice.Id);
         foreach (var detail in details)
         {
             detail.Errors = new Dictionary <string, string>();
             _purchaseInvoiceDetailService.UnconfirmObject(detail, _purchaseReceivalService, _purchaseReceivalDetailService);
         }
         _repository.UnconfirmObject(purchaseInvoice);
         PurchaseReceival purchaseReceival = _purchaseReceivalService.GetObjectById(purchaseInvoice.PurchaseReceivalId);
         _purchaseReceivalService.UnsetInvoiceComplete(purchaseReceival);
         Payable payable = _payableService.GetObjectBySource(Constant.PayableSource.PurchaseInvoice, purchaseInvoice.Id);
         _payableService.SoftDeleteObject(payable);
     }
     return(purchaseInvoice);
 }
Exemplo n.º 12
0
        public PurchaseInvoice VPayableHasNoOtherAssociation(PurchaseInvoice purchaseInvoice, IPayableService _payableService, IPaymentVoucherDetailService _paymentVoucherDetailService)
        {
            Payable payable = _payableService.GetObjectBySource(Constant.PayableSource.PurchaseInvoice, purchaseInvoice.Id);
            IList <PaymentVoucherDetail> paymentVoucherDetails = _paymentVoucherDetailService.GetObjectsByPayableId(payable.Id);

            if (paymentVoucherDetails.Any())
            {
                purchaseInvoice.Errors.Add("Generic", "Payable memiliki asosiasi dengan payment voucher detail");
                return(purchaseInvoice);
            }

            /*
             * IList<PurchaseAllowanceAllocationDetail> purchaseAllowanceAllocationDetails = _purchaseAllowanceAllocationDetailService.GetObjectsByPayableId(payable.Id);
             * if (purchaseAllowanceAllocationDetails.Any())
             * {
             *  purchaseInvoice.Errors.Add("Generic", "Payable memiliki asosiasi dengan purchase allowance allocation detail");
             * }
             */
            return(purchaseInvoice);
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
0
 public CustomPurchaseInvoice UnconfirmObject(CustomPurchaseInvoice customPurchaseInvoice, ICustomPurchaseInvoiceDetailService _customPurchaseInvoiceDetailService,
                                              IPayableService _payableService, IPaymentVoucherDetailService _paymentVoucherDetailService,
                                              IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService, IItemService _itemService,
                                              IBarringService _barringService, IStockMutationService _stockMutationService, IPriceMutationService _priceMutationService,
                                              IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService, IClosingService _closingService)
 {
     if (_validator.ValidUnconfirmObject(customPurchaseInvoice, _customPurchaseInvoiceDetailService, _payableService, _paymentVoucherDetailService, _closingService))
     {
         IList <CustomPurchaseInvoiceDetail> customPurchaseInvoiceDetails = _customPurchaseInvoiceDetailService.GetObjectsByCustomPurchaseInvoiceId(customPurchaseInvoice.Id);
         foreach (var customPurchaseInvoiceDetail in customPurchaseInvoiceDetails)
         {
             customPurchaseInvoiceDetail.Errors = new Dictionary <string, string>();
             _customPurchaseInvoiceDetailService.UnconfirmObject(customPurchaseInvoiceDetail, _warehouseItemService, _warehouseService, _itemService, _barringService, _stockMutationService, _priceMutationService);
         }
         Payable payable = _payableService.GetObjectBySource(Core.Constants.Constant.PayableSource.CustomPurchaseInvoice, customPurchaseInvoice.Id);
         _payableService.SoftDeleteObject(payable);
         customPurchaseInvoice.Total = 0;
         customPurchaseInvoice.CoGS  = 0;
         _generalLedgerJournalService.CreateUnconfirmationJournalForCustomPurchaseInvoice(customPurchaseInvoice, _accountService);
         customPurchaseInvoice = _repository.UnconfirmObject(customPurchaseInvoice);
     }
     return(customPurchaseInvoice);
 }
Exemplo n.º 15
0
 public CashSalesReturn UnconfirmObject(CashSalesReturn cashSalesReturn, ICashSalesReturnDetailService _cashSalesReturnDetailService,
                                        ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService,
                                        IPayableService _payableService, IPaymentVoucherDetailService _paymentVoucherDetailService,
                                        IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService, IItemService _itemService,
                                        IBarringService _barringService, IStockMutationService _stockMutationService, IClosingService _closingService)
 {
     if (_validator.ValidUnconfirmObject(cashSalesReturn, _cashSalesReturnDetailService, _payableService, _paymentVoucherDetailService))
     {
         cashSalesReturn = _repository.UnconfirmObject(cashSalesReturn);
         IList <CashSalesReturnDetail> cashSalesReturnDetails = _cashSalesReturnDetailService.GetObjectsByCashSalesReturnId(cashSalesReturn.Id);
         foreach (var cashSalesReturnDetail in cashSalesReturnDetails)
         {
             cashSalesReturnDetail.Errors = new Dictionary <string, string>();
             _cashSalesReturnDetailService.UnconfirmObject(cashSalesReturnDetail, _cashSalesInvoiceDetailService, _warehouseItemService,
                                                           _warehouseService, _itemService, _barringService, _stockMutationService);
         }
         Payable payable = _payableService.GetObjectBySource(Core.Constants.Constant.PayableSource.CashSalesReturn, cashSalesReturn.Id);
         _payableService.SoftDeleteObject(payable);
         cashSalesReturn.Total     = 0;
         cashSalesReturn.Allowance = 0;
     }
     return(cashSalesReturn);
 }
Exemplo n.º 16
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);
 }