public dynamic Insert(CustomPurchaseInvoice model) { try { if (!AuthenticationModel.IsAllowed("Create", Core.Constants.Constant.MenuName.CustomPurchaseInvoice, Core.Constants.Constant.MenuGroupName.Transaction)) { Dictionary <string, string> Errors = new Dictionary <string, string>(); Errors.Add("Generic", "You are Not Allowed to Add record"); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } model = _customPurchaseInvoiceService.CreateObject(model, _warehouseService, _contactService, _cashBankService); } 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 void PopulateCustomPurchaseData() { TimeSpan salesDate = new TimeSpan(10, 0, 0, 0); TimeSpan dueDate = new TimeSpan(3, 0, 0, 0); // Cash with GroupPricing cpi1 = new CustomPurchaseInvoice() { PurchaseDate = DateTime.Today.Subtract(salesDate), WarehouseId = localWarehouse.Id, CashBankId = cashBank.Id, DueDate = DateTime.Today.Subtract(dueDate), ContactId = contact.Id, }; _customPurchaseInvoiceService.CreateObject(cpi1, _warehouseService, _contactService, _cashBankService); // Cash with GroupPricing cpi2 = new CustomPurchaseInvoice() { PurchaseDate = DateTime.Today.Subtract(salesDate), WarehouseId = localWarehouse.Id, CashBankId = cashBank.Id, DueDate = DateTime.Today.Subtract(dueDate), IsGroupPricing = true, Discount = 25, Tax = 10, ContactId = contact2.Id, }; _customPurchaseInvoiceService.CreateObject(cpi2, _warehouseService, _contactService, _cashBankService); // Bank without GroupPricing cpi3 = new CustomPurchaseInvoice() { PurchaseDate = DateTime.Today.Subtract(salesDate), WarehouseId = localWarehouse.Id, CashBankId = cashBank2.Id, DueDate = DateTime.Today.Subtract(dueDate), IsGBCH = true, GBCH_DueDate = DateTime.Today.Subtract(dueDate), GBCH_No = "G0001", ContactId = contact3.Id, }; _customPurchaseInvoiceService.CreateObject(cpi3, _warehouseService, _contactService, _cashBankService); cpid1 = new CustomPurchaseInvoiceDetail() { CustomPurchaseInvoiceId = cpi1.Id, Quantity = 100, ItemId = blanket1.Id, Discount = 10, ListedUnitPrice = 10000, }; _customPurchaseInvoiceDetailService.CreateObject(cpid1, _customPurchaseInvoiceService, _itemService, _warehouseItemService); cpid2 = new CustomPurchaseInvoiceDetail() { CustomPurchaseInvoiceId = cpi2.Id, Quantity = 100, ItemId = blanket1.Id, ListedUnitPrice = 10000, }; _customPurchaseInvoiceDetailService.CreateObject(cpid2, _customPurchaseInvoiceService, _itemService, _warehouseItemService); cpid3 = new CustomPurchaseInvoiceDetail() { CustomPurchaseInvoiceId = cpi3.Id, Quantity = 100, ItemId = blanket1.Id, ListedUnitPrice = 10000, }; _customPurchaseInvoiceDetailService.CreateObject(cpid3, _customPurchaseInvoiceService, _itemService, _warehouseItemService); _customPurchaseInvoiceService.ConfirmObject(cpi1, cpi1.PurchaseDate, _customPurchaseInvoiceDetailService, _contactService, _priceMutationService, _payableService, _customPurchaseInvoiceService, _warehouseItemService, _warehouseService, _itemService, _barringService, _stockMutationService, _generalLedgerJournalService, _accountService, _closingService); _customPurchaseInvoiceService.ConfirmObject(cpi2, cpi2.PurchaseDate, _customPurchaseInvoiceDetailService, _contactService, _priceMutationService, _payableService, _customPurchaseInvoiceService, _warehouseItemService, _warehouseService, _itemService, _barringService, _stockMutationService, _generalLedgerJournalService, _accountService, _closingService); _customPurchaseInvoiceService.ConfirmObject(cpi3, cpi3.PurchaseDate, _customPurchaseInvoiceDetailService, _contactService, _priceMutationService, _payableService, _customPurchaseInvoiceService, _warehouseItemService, _warehouseService, _itemService, _barringService, _stockMutationService, _generalLedgerJournalService, _accountService, _closingService); _customPurchaseInvoiceService.PaidObject(cpi1, 200000, _cashBankService, _payableService, _paymentVoucherService, _paymentVoucherDetailService, _contactService, _cashMutationService, _generalLedgerJournalService, _accountService, _closingService); _customPurchaseInvoiceService.PaidObject(cpi2, cpi2.Total, _cashBankService, _payableService, _paymentVoucherService, _paymentVoucherDetailService, _contactService, _cashMutationService, _generalLedgerJournalService, _accountService, _closingService); _customPurchaseInvoiceService.PaidObject(cpi3, cpi3.Total, _cashBankService, _payableService, _paymentVoucherService, _paymentVoucherDetailService, _contactService, _cashMutationService, _generalLedgerJournalService, _accountService, _closingService); }