Beispiel #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);
        }
        public dynamic Reconcile(PaymentVoucher model)
        {
            try
            {
                if (!AuthenticationModel.IsAllowed("Reconcile", 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 Reconcile Record");

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

                var data = _paymentVoucherService.GetObjectById(model.Id);
                model = _paymentVoucherService.ReconcileObject(data, model.ReconciliationDate.Value, _paymentVoucherDetailService,
                                                               _cashMutationService, _cashBankService, _payableService,
                                                               _generalLedgerJournalService, _accountService, _closingService);
            }
            catch (Exception ex)
            {
                LOG.Error("Reconcile 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
            }));
        }