예제 #1
0
        public dynamic Paid(CashSalesInvoice model)
        {
            try
            {
                if (!AuthenticationModel.IsAllowed("Paid", Core.Constants.Constant.MenuName.CashSalesInvoice, Core.Constants.Constant.MenuGroupName.Transaction))
                {
                    Dictionary <string, string> Errors = new Dictionary <string, string>();
                    Errors.Add("Generic", "You are Not Allowed to Paid record");

                    return(Json(new
                    {
                        Errors
                    }, JsonRequestBehavior.AllowGet));
                }
                if ((model.Allowance > 0) && (!AuthenticationModel.IsAllowed("ManualPricing", Core.Constants.Constant.MenuName.CashSalesInvoice, Core.Constants.Constant.MenuGroupName.Transaction)))
                {
                    Dictionary <string, string> Errors = new Dictionary <string, string>();
                    Errors.Add("Generic", "You are Not Allowed to Use Manual Pricing/Discount/Allowance");

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

                var data = _cashSalesInvoiceService.GetObjectById(model.Id);
                data.Allowance = model.Allowance;
                model          = _cashSalesInvoiceService.PaidObject(data, model.AmountPaid.Value, model.Allowance, _cashBankService, _receivableService, _receiptVoucherService, _receiptVoucherDetailService,
                                                                     _contactService, _cashMutationService, _cashSalesReturnService,
                                                                     _generalLedgerJournalService, _accountService, _closingService);
            }
            catch (Exception ex)
            {
                LOG.Error("Paid 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 void PopulateCashSalesData()
        {
            TimeSpan salesDate = new TimeSpan(10, 0, 0, 0);
            TimeSpan dueDate   = new TimeSpan(3, 0, 0, 0);

            // Cash without Discount & Tax
            csi1 = new CashSalesInvoice()
            {
                SalesDate   = DateTime.Today.Subtract(salesDate),
                WarehouseId = localWarehouse.Id,
                CashBankId  = cashBank.Id,
                DueDate     = DateTime.Today.Subtract(dueDate),
            };
            _cashSalesInvoiceService.CreateObject(csi1, _warehouseService, _cashBankService);

            // Cash with Discount & Tax
            csi2 = new CashSalesInvoice()
            {
                SalesDate   = DateTime.Today.Subtract(salesDate),
                WarehouseId = localWarehouse.Id,
                CashBankId  = cashBank.Id,
                DueDate     = DateTime.Today.Subtract(dueDate),
                Discount    = 25,
                Tax         = 10,
            };
            _cashSalesInvoiceService.CreateObject(csi2, _warehouseService, _cashBankService);

            // Bank without Discount & Tax
            csi3 = new CashSalesInvoice()
            {
                SalesDate   = DateTime.Today.Subtract(salesDate),
                WarehouseId = localWarehouse.Id,
                CashBankId  = cashBank2.Id,
                DueDate     = DateTime.Today.Subtract(dueDate),
            };
            _cashSalesInvoiceService.CreateObject(csi3, _warehouseService, _cashBankService);

            csid1 = new CashSalesInvoiceDetail()
            {
                CashSalesInvoiceId = csi1.Id,
                Quantity           = 100,
                ItemId             = blanket1.Id,
            };
            _cashSalesInvoiceDetailService.CreateObject(csid1, _cashSalesInvoiceService, _itemService, _warehouseItemService, _quantityPricingService);

            csid2 = new CashSalesInvoiceDetail()
            {
                CashSalesInvoiceId = csi2.Id,
                Quantity           = 30,
                ItemId             = blanket2.Id,
            };
            _cashSalesInvoiceDetailService.CreateObject(csid2, _cashSalesInvoiceService, _itemService, _warehouseItemService, _quantityPricingService);

            csid3 = new CashSalesInvoiceDetail()
            {
                CashSalesInvoiceId = csi3.Id,
                Quantity           = 10,
                ItemId             = blanket3.Id,
            };
            _cashSalesInvoiceDetailService.CreateObject(csid3, _cashSalesInvoiceService, _itemService, _warehouseItemService, _quantityPricingService);

            csid4 = new CashSalesInvoiceDetail()
            {
                CashSalesInvoiceId = csi2.Id,
                Quantity           = 10,
                ItemId             = blanket3.Id,
            };
            _cashSalesInvoiceDetailService.CreateObject(csid4, _cashSalesInvoiceService, _itemService, _warehouseItemService, _quantityPricingService);

            _cashSalesInvoiceService.ConfirmObject(csi1, csi1.SalesDate, 0, 0, _cashSalesInvoiceDetailService, _contactService, _priceMutationService, _receivableService, _cashSalesInvoiceService, _warehouseItemService, _warehouseService,
                                                   _itemService, _barringService, _stockMutationService, _cashBankService, _generalLedgerJournalService, _accountService, _closingService);
            _cashSalesInvoiceService.ConfirmObject(csi2, csi2.SalesDate, 0, 0, _cashSalesInvoiceDetailService, _contactService, _priceMutationService, _receivableService, _cashSalesInvoiceService, _warehouseItemService, _warehouseService,
                                                   _itemService, _barringService, _stockMutationService, _cashBankService, _generalLedgerJournalService, _accountService, _closingService);
            _cashSalesInvoiceService.ConfirmObject(csi3, csi3.SalesDate, 0, 0, _cashSalesInvoiceDetailService, _contactService, _priceMutationService, _receivableService, _cashSalesInvoiceService, _warehouseItemService, _warehouseService,
                                                   _itemService, _barringService, _stockMutationService, _cashBankService, _generalLedgerJournalService, _accountService, _closingService);

            _cashSalesInvoiceService.PaidObject(csi1, 200000, 50000, _cashBankService, _receivableService, _receiptVoucherService, _receiptVoucherDetailService, _contactService, _cashMutationService, _cashSalesReturnService,
                                                _generalLedgerJournalService, _accountService, _closingService);
            _cashSalesInvoiceService.PaidObject(csi2, csi2.Total - 50000, 50000, _cashBankService, _receivableService, _receiptVoucherService, _receiptVoucherDetailService, _contactService, _cashMutationService, _cashSalesReturnService,
                                                _generalLedgerJournalService, _accountService, _closingService);
            _cashSalesInvoiceService.PaidObject(csi3, csi3.Total, 50000, _cashBankService, _receivableService, _receiptVoucherService, _receiptVoucherDetailService, _contactService, _cashMutationService, _cashSalesReturnService,
                                                _generalLedgerJournalService, _accountService, _closingService);

            // --------- CashSalesReturn -------------

            csr1 = new CashSalesReturn()
            {
                ReturnDate         = DateTime.Now,
                CashSalesInvoiceId = csi1.Id,
                CashBankId         = csi1.CashBankId,
            };
            _cashSalesReturnService.CreateObject(csr1, _cashSalesInvoiceService, _cashBankService);

            csrd1 = new CashSalesReturnDetail()
            {
                CashSalesReturnId        = csr1.Id,
                CashSalesInvoiceDetailId = csid1.Id,
                Quantity = 50,
            };
            _cashSalesReturnDetailService.CreateObject(csrd1, _cashSalesReturnService, _cashSalesInvoiceDetailService);

            _cashSalesReturnService.ConfirmObject(csr1, DateTime.Now, 50000, _cashSalesReturnDetailService, _contactService, _cashSalesInvoiceService,
                                                  _cashSalesInvoiceDetailService, _priceMutationService, _payableService,
                                                  _cashSalesReturnService, _warehouseItemService, _warehouseService,
                                                  _itemService, _barringService, _stockMutationService, _closingService);

            _cashSalesReturnService.PaidObject(csr1, /*50000,*/ _cashBankService, _payableService, _paymentVoucherService,
                                               _paymentVoucherDetailService, _contactService, _cashMutationService, _generalLedgerJournalService,
                                               _accountService, _closingService);

            //_cashSalesReturnService.UnpaidObject(csr1, _paymentVoucherService, _paymentVoucherDetailService, _cashBankService, _payableService, _cashMutationService);
        }