private int CreateSaleTax(VoyagerContext db, ImportSaleItemWise item) { // Always GST and with Local Sale //Calulate Rate decimal rate = 0; rate = ((item.SGST + item.CGST) * 100) / item.BasicRate; int taxId = 1; try { taxId = db.SaleTaxTypes.Where(c => c.CompositeRate == rate).FirstOrDefault().SaleTaxTypeId; return(taxId); } catch (Exception) { SaleTaxType taxType = new SaleTaxType { CompositeRate = rate, TaxName = "OutPut Tax GST(CGST+SGST) @" + rate, TaxType = TaxType.GST }; db.SaleTaxTypes.Add(taxType); db.SaveChanges(); return(taxType.SaleTaxTypeId); } }
// Converting purchase items to stock public int ProcessPurchaseInward(DateTime inDate, bool IsLocal) { using (VoyagerContext db = new VoyagerContext()) { int ctr = 0; var data = db.ImportPurchases.Where(c => c.IsDataConsumed == false && DbFunctions.TruncateTime(c.GRNDate) == DbFunctions.TruncateTime(inDate)).OrderBy(c => c.InvoiceNo).ToList(); if (data != null && data.Count() > 0) { ProductPurchase PurchasedProduct = null; foreach (var item in data) { int pid = CreateProductItem(db, item); if (pid != -999) { CreateStockItem(db, item, pid); } PurchasedProduct = CreatePurchaseInWard(db, item, PurchasedProduct); PurchasedProduct.PurchaseItems.Add(CreatePurchaseItem(db, item, pid, IsLocal)); item.IsDataConsumed = true; db.Entry(item).State = EntityState.Modified; ctr++; } if (PurchasedProduct != null) { db.ProductPurchases.Add(PurchasedProduct); } db.SaveChanges(); } return(ctr); }//end of using }
public static string ExportPurchase(VoyagerContext db, string fileName) { // string rootFolder = _hostingEnvironment.WebRootPath; //string fileName = @"ExportCustomers.xlsx"; FileInfo file = new FileInfo(fileName); using (ExcelPackage package = new ExcelPackage(file)) { IList <ImportPurchase> purchaseList = db.ImportPurchases.ToList(); ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("Purchase"); int totalRows = purchaseList.Count; worksheet.Cells [1, 1].Value = "Bar-code"; worksheet.Cells [1, 2].Value = "MRP"; worksheet.Cells [1, 3].Value = "Cost"; worksheet.Cells [1, 4].Value = "Qty"; worksheet.Cells [1, 5].Value = "Total"; int i = 0; for (int row = 2; row <= totalRows + 1; row++) { worksheet.Cells [row, 1].Value = purchaseList [i].Barcode; worksheet.Cells [row, 2].Value = purchaseList [i].MRP; worksheet.Cells [row, 3].Value = purchaseList [i].Cost; worksheet.Cells [row, 4].Value = purchaseList [i].Quantity; worksheet.Cells [row, 5].Value = purchaseList [i].CostValue; i++; } package.Save(); } return(" Purchase list has been exported successfully"); }
public int CreateSaleEntry(VoyagerContext db, DateTime onDate, AprajitaRetailsContext arDB) { int ctr = 0; bool isVat = false; if (onDate < new DateTime(2017, 7, 1)) { isVat = true; return(-1);// TODO: Temp implement for vat system } RegularInvoice saleInvoice = null; var data = db.ImportSaleItemWises.Where(c => c.IsDataConsumed == false && c.InvoiceDate.Date == onDate.Date).OrderBy(c => c.InvoiceNo).ToList(); if (data != null) { foreach (var item in data) { saleInvoice = CreateSaleInvoice(db, arDB, item, saleInvoice); //Create SaleInvoice saleInvoice.SaleItems.Add(CreateSaleItem(db, item)); // Create SaleItems ctr++; } if (saleInvoice != null) { db.RegularInvoices.Add(saleInvoice); // Save Last Sale Invoice db.SaveChanges(); CreateDailySale(arDB, db, saleInvoice); // Create DailySale Entry } return(ctr); } else { return(ctr); } }
public void CreateStockItem(VoyagerContext db, ImportPurchase purchase, int pItemId) { Stock stcks = db.Stocks.Where(c => c.ProductItemId == pItemId).FirstOrDefault(); if (stcks != null) { stcks.PurchaseQty += purchase.Quantity; stcks.Quantity += purchase.Quantity; db.Entry(stcks).State = EntityState.Modified; } else { Stock stock = new Stock { PurchaseQty = purchase.Quantity, Quantity = purchase.Quantity, ProductItemId = pItemId, SaleQty = 0, Units = db.ProductItems.Find(pItemId).Units, StoreId = StoreID }; db.Stocks.Add(stock); } db.SaveChanges(); }
public int CreateProductItem(VoyagerContext db, ImportPurchase purchase) { int barc = db.ProductItems.Where(c => c.Barcode == purchase.Barcode).Count(); if (barc <= 0) { ProductItem item = new ProductItem { Barcode = purchase.Barcode, Cost = purchase.Cost, MRP = purchase.MRP, StyleCode = purchase.StyleCode, ProductName = purchase.ProductName, ItemDesc = purchase.ItemDesc, BrandId = GetBrand(db, purchase.StyleCode), }; //spliting ProductName string[] PN = purchase.ProductName.Split('/'); // Apparel / Work / Blazers if (PN[0] == "Apparel") { item.Units = Units.Pcs; item.Categorys = ProductCategorys.ReadyMade; } else if (PN[0] == "Suiting" || PN[0] == "Shirting") { item.Units = Units.Meters; item.Categorys = ProductCategorys.Fabric; } else { item.Units = Units.Nos; item.Categorys = ProductCategorys.Others; //TODO: For time being } List <Category> catIds = GetCategory(db, PN[0], PN[1], PN[2]); item.MainCategory = catIds[0]; item.ProductCategory = catIds[1]; item.ProductType = catIds[2]; db.ProductItems.Add(item); db.SaveChanges(); return(item.ProductItemId); } else if (barc > 0) { barc = db.ProductItems.Where(c => c.Barcode == purchase.Barcode).First().ProductItemId; return(barc); // Already Added } else { return(-999); //TODO: Handel this options // See ever here come. } }
public int GetSalesmanId(VoyagerContext db, string salesman) { try { var id = db.Salesmen.Where(c => c.SalesmanName == salesman).FirstOrDefault().SalesmanId; if (id > 0) { return(id); } else { Salesman sm = new Salesman { SalesmanName = salesman }; db.Salesmen.Add(sm); db.SaveChanges(); return(sm.SalesmanId); } } catch (Exception) { Salesman sm = new Salesman { SalesmanName = salesman }; db.Salesmen.Add(sm); db.SaveChanges(); return(sm.SalesmanId); } }
/// <summary> /// UpDate Stock when Sale or Purchase Happen /// </summary> /// <param name="db"></param> /// <param name="ItemCode"></param> /// <param name="Qty"></param> /// <param name="IsPurchased"></param> /// <returns></returns> public static bool UpDateStock(VoyagerContext db, int ItemCode, double Qty, bool IsPurchased) { var stock = db.Stocks.Where(c => c.ProductItemId == ItemCode).FirstOrDefault(); if (stock != null) { if (IsPurchased) { // Purchase Stock; stock.PurchaseQty += Qty; stock.Quantity += Qty; } else { //Sale Stock. stock.SaleQty += Qty; stock.Quantity -= Qty; } db.Entry(stock).State = System.Data.Entity.EntityState.Modified; return(true); } else { return(false); } }
private int GetBrand(VoyagerContext db, string StyleCode) { if (StyleCode.StartsWith("U")) { //USPAit return(GetBrandID(db, "USPA")); } else if (StyleCode.StartsWith("AR")) { //Arvind RTW return(GetBrandID(db, "RTW")); } else if (StyleCode.StartsWith("A")) { //Arrow return(GetBrandID(db, "ARW")); } else if (StyleCode.StartsWith("FM")) { //FM return(GetBrandID(db, "FM")); } else { // Arvind Store return(GetBrandID(db, "AS")); } }
private SaleInvoice CreateSaleInvoice(VoyagerContext db, ImportSaleItemWise item, SaleInvoice invoice) { if (invoice != null) { if (invoice.InvoiceNo == item.InvoiceNo) { // invoice.InvoiceNo = item.InvoiceNo; //invoice.OnDate = item.InvoiceDate; invoice.TotalDiscountAmount += item.Discount; invoice.TotalBillAmount += item.LineTotal; invoice.TotalItems += 1;//TODO: Check for count invoice.TotalQty += item.Quantity; invoice.RoundOffAmount += item.RoundOff; invoice.TotalTaxAmount += item.SGST; //TODO: Check invoice.PaymentDetail = CreatePaymentDetails(db, item); invoice.CustomerId = GetCustomerId(db, item); } else { db.SaleInvoices.Add(invoice); db.SaveChanges(); invoice = new SaleInvoice { InvoiceNo = item.InvoiceNo, OnDate = item.InvoiceDate, TotalDiscountAmount = item.Discount, TotalBillAmount = item.LineTotal, TotalItems = 1,//TODO: Check for count TotalQty = item.Quantity, RoundOffAmount = item.RoundOff, TotalTaxAmount = item.SGST, //TODO: Check PaymentDetail = CreatePaymentDetails(db, item), CustomerId = GetCustomerId(db, item), SaleItems = new List <SaleItem>() }; } } else { invoice = new SaleInvoice { InvoiceNo = item.InvoiceNo, OnDate = item.InvoiceDate, TotalDiscountAmount = item.Discount, TotalBillAmount = item.LineTotal, TotalItems = 1,//TODO: Check for count TotalQty = item.Quantity, RoundOffAmount = item.RoundOff, TotalTaxAmount = item.SGST, //TODO: Check PaymentDetail = CreatePaymentDetails(db, item), CustomerId = GetCustomerId(db, item), SaleItems = new List <SaleItem>() }; } return(invoice); }
public int CreatePurchaseTaxType(VoyagerContext db, ImportPurchase purchase, bool IsLocal = false) { //Calculate tax rate int taxRate = 0; taxRate = (int)((purchase.TaxAmt * 100) / purchase.CostValue); if (IsLocal) { try { int id = db.PurchaseTaxTypes.Where(c => c.CompositeRate == taxRate).Select(c => c.PurchaseTaxTypeId).FirstOrDefault(); if (id == 0) { PurchaseTaxType taxType = new PurchaseTaxType { CompositeRate = taxRate, TaxType = TaxType.GST, TaxName = "Input Tax GST(SGST+CGST) @" + taxRate }; db.PurchaseTaxTypes.Add(taxType); db.SaveChanges(); return(taxType.PurchaseTaxTypeId); } return(id); } catch (Exception) { PurchaseTaxType taxType = new PurchaseTaxType { CompositeRate = taxRate, TaxType = TaxType.GST, TaxName = "Input Tax GST(SGST+CGST) @" + taxRate }; db.PurchaseTaxTypes.Add(taxType); db.SaveChanges(); return(taxType.PurchaseTaxTypeId); } } try { int id = db.PurchaseTaxTypes.Where(c => c.CompositeRate == taxRate).Select(c => c.PurchaseTaxTypeId).FirstOrDefault(); if (id == 0) { PurchaseTaxType taxType = new PurchaseTaxType { CompositeRate = taxRate, TaxType = TaxType.IGST, TaxName = "Input Tax IGST @" + taxRate }; db.PurchaseTaxTypes.Add(taxType); db.SaveChanges(); return(taxType.PurchaseTaxTypeId); } return(id); } catch (Exception) { PurchaseTaxType taxType = new PurchaseTaxType { CompositeRate = taxRate, TaxType = TaxType.IGST, TaxName = "Input Tax IGST @" + taxRate }; db.PurchaseTaxTypes.Add(taxType); db.SaveChanges(); return(taxType.PurchaseTaxTypeId); } }
public ProductPurchase CreatePurchaseInWard(VoyagerContext db, ImportPurchase purchase, ProductPurchase product) { if (product != null) { if (purchase.InvoiceNo == product.InvoiceNo) { product.TotalAmount += (purchase.CostValue + purchase.TaxAmt); product.ShippingCost += 0;//TODO: add option for adding shipping cost for fabric product.TotalBasicAmount += purchase.CostValue; product.TotalTax += purchase.TaxAmt; product.TotalQty += purchase.Quantity; } else { db.ProductPurchases.Add(product); db.SaveChanges(); product = new ProductPurchase { InvoiceNo = purchase.InvoiceNo, InWardDate = purchase.GRNDate, InWardNo = purchase.GRNNo, IsPaid = false, PurchaseDate = purchase.InvoiceDate, ShippingCost = 0,//TODO: add option for adding shipping cost for fabric TotalBasicAmount = purchase.CostValue, TotalTax = purchase.TaxAmt, TotalQty = purchase.Quantity, TotalAmount = purchase.CostValue + purchase.TaxAmt,// TODO: Check for actual DATA. Remarks = "", SupplierID = GetSupplierIdOrAdd(db, purchase.SupplierName), StoreId = StoreID }; product.PurchaseItems = new List <PurchaseItem> (); } } else { product = new ProductPurchase { InvoiceNo = purchase.InvoiceNo, InWardDate = purchase.GRNDate, InWardNo = purchase.GRNNo, IsPaid = false, PurchaseDate = purchase.InvoiceDate, ShippingCost = 0,//TODO: add option for adding shipping cost for fabric TotalBasicAmount = purchase.CostValue, TotalTax = purchase.TaxAmt, TotalQty = purchase.Quantity, TotalAmount = purchase.CostValue + purchase.TaxAmt,// TODO: Check for actual DATA. Remarks = "", SupplierID = GetSupplierIdOrAdd(db, purchase.SupplierName), StoreId = StoreID }; product.PurchaseItems = new List <PurchaseItem> (); } return(product); }
private int ImportSaleRegister(VoyagerContext db, string StoreCode, string fileName) { //string rootFolder = IHostingEnvironment.WebRootPath; //string fileName = @"ImportCustomers.xlsx"; FileInfo file = new FileInfo(fileName); using ExcelPackage package = new ExcelPackage(file); ExcelWorksheet workSheet = package.Workbook.Worksheets ["Sheet1"]; int totalRows = workSheet.Dimension.Rows; int StoreID = 1;//Default StoreID = db.Stores.Where(c => c.StoreCode == StoreCode).Select(c => c.StoreId).FirstOrDefault(); if (StoreID < 1) { StoreID = 1; } List <ImportSaleRegister> saleList = new List <ImportSaleRegister> (); //GRNNo GRNDate Invoice No Invoice Date Supplier Name Barcode Product Name Style Code Item Desc Quantity MRP MRP Value Cost Cost Value TaxAmt ExmillCost Excise1 Excise2 Excise3 int xo = 0; for (int i = 2; i <= totalRows; i++) { //Invoice No 1 Invoice Date 2 Invoice Type 3 //Brand Name 4 Product Name 5 Item Desc 6 HSN Code 7 BAR CODE 8 // //Style Code 9 Quantity 10 MRP 11 Discount Amt 12 Basic Amt 13 Tax Amt 14 SGST Amt 15 //CGST Amt 16 CESS Amt 17 Line Total 18 Round Off 19 Bill Amt 20 Payment Mode 21 SalesMan Name 22 // //Coupon % Coupon Amt SUB TYPE Bill Discount LP Flag Inst Order CD TAILORING FLAG ImportSaleRegister p = new ImportSaleRegister { InvoiceNo = workSheet.Cells [i, 1].Value.ToString(), InvoiceDate = workSheet.Cells [i, 2].Value.ToString(), InvoiceType = workSheet.Cells [i, 3].Value.ToString(), Quantity = (double)workSheet.Cells [i, 4].Value, MRP = (decimal)workSheet.Cells [i, 5].GetValue <decimal> (), Discount = (decimal)workSheet.Cells [i, 6].GetValue <decimal> (), BasicRate = (decimal)workSheet.Cells [i, 7].GetValue <decimal> (), Tax = (decimal)workSheet.Cells [i, 8].GetValue <decimal> (), RoundOff = (decimal)workSheet.Cells [i, 9].GetValue <decimal> (), BillAmnt = (decimal)workSheet.Cells [i, 10].GetValue <decimal> (), PaymentType = workSheet.Cells [i, 11].Value.ToString(), StoreId = StoreID, IsConsumed = false }; saleList.Add(p); xo++; } db.ImportSaleRegisters.AddRange(saleList); return(db.SaveChanges()); //return purchaseList; }
public int GetCustomerId(VoyagerContext db, ImportSaleItemWise item) { if (item.PaymentType == "CAS") //TODO: Check For Actual Data. { return(1); } else { return(2); } //return 1; }
private SalePaymentDetail CreatePaymentDetails(VoyagerContext db, ImportSaleItemWise item) { if (item.PaymentType == null || item.PaymentType == "") { return(null); } else if (item.PaymentType == "CAS") { //cash Payment SalePaymentDetail payment = new SalePaymentDetail { CashAmount = item.BillAmnt, PayMode = SalePayMode.Cash }; return(payment); } else if (item.PaymentType == "CRD") { SalePaymentDetail payment = new SalePaymentDetail { CardAmount = item.BillAmnt, PayMode = SalePayMode.Card }; //Mix Payment return(payment); } else if (item.PaymentType == "MIX") { SalePaymentDetail payment = new SalePaymentDetail { MixAmount = item.BillAmnt, PayMode = SalePayMode.Mix }; //CASH return(payment); } else if (item.PaymentType == "SR") { SalePaymentDetail payment = new SalePaymentDetail { CashAmount = item.BillAmnt, PayMode = SalePayMode.SR }; return(payment); } else { return(null); } }
private int ImportPurchase(VoyagerContext db, string fileName, string StoreCode, bool IsVat, bool IsLocal) { //string rootFolder = IHostingEnvironment.WebRootPath; //string fileName = @"ImportCustomers.xlsx"; FileInfo file = new FileInfo(fileName); using ExcelPackage package = new ExcelPackage(file); ExcelWorksheet workSheet = package.Workbook.Worksheets ["Sheet1"]; int totalRows = workSheet.Dimension.Rows; int StoreID = 1;//Default StoreID = db.Stores.Where(c => c.StoreCode == StoreCode).Select(c => c.StoreId).FirstOrDefault(); if (StoreID < 1) { StoreID = 1; } List <ImportPurchase> purchaseList = new List <ImportPurchase> (); //GRNNo GRNDate Invoice No Invoice Date Supplier Name Barcode Product Name Style Code Item Desc Quantity MRP MRP Value Cost Cost Value TaxAmt ExmillCost Excise1 Excise2 Excise3 for (int i = 2; i <= totalRows; i++) { purchaseList.Add(new ImportPurchase { GRNNo = workSheet.Cells [i, 1].Value.ToString(), GRNDate = (DateTime)workSheet.Cells [i, 2].GetValue <DateTime> (), InvoiceNo = workSheet.Cells [i, 3].Value.ToString(), InvoiceDate = (DateTime)workSheet.Cells [i, 4].GetValue <DateTime> (), SupplierName = workSheet.Cells [i, 5].Value.ToString(), Barcode = workSheet.Cells [i, 6].Value.ToString(), ProductName = workSheet.Cells [i, 7].Value.ToString(), StyleCode = workSheet.Cells [i, 8].Value.ToString(), ItemDesc = workSheet.Cells [i, 9].Value.ToString(), Quantity = (double)workSheet.Cells [i, 10].Value, MRP = (decimal)workSheet.Cells [i, 11].GetValue <decimal> (), MRPValue = (decimal)workSheet.Cells [i, 12].GetValue <decimal> (), Cost = (decimal)workSheet.Cells [i, 13].GetValue <decimal> (), CostValue = (decimal)workSheet.Cells [i, 14].GetValue <decimal> (), TaxAmt = (decimal)workSheet.Cells [i, 15].GetValue <decimal> (), IsDataConsumed = false, // ImportTime = DateTime.Today, IsLocal = IsLocal, IsVatBill = IsVat, StoreId = StoreID }); } db.ImportPurchases.AddRange(purchaseList); return(db.SaveChanges()); //return purchaseList; }
private RegularPaymentDetail CreatePaymentDetails(VoyagerContext db, ImportSaleItemWise item) { RegularPaymentDetail payment = null; if (string.IsNullOrEmpty(item.PaymentType) /*== null || item.PaymentType == "" */) { return(null); } else if (item.PaymentType == "CAS") { //cash Payment payment = new RegularPaymentDetail { CashAmount = item.BillAmnt, PayMode = SalePayMode.Cash }; //return payment; } else if (item.PaymentType == "CRD") { payment = new RegularPaymentDetail { CardAmount = item.BillAmnt, PayMode = SalePayMode.Card }; //Mix Payment //return payment; } else if (item.PaymentType == "MIX") { payment = new RegularPaymentDetail { MixAmount = item.BillAmnt, PayMode = SalePayMode.Mix }; //CASH //return payment; } else if (item.PaymentType == "SR") { payment = new RegularPaymentDetail { CashAmount = item.BillAmnt, PayMode = SalePayMode.SR }; // return payment; } //else return(payment); }
//Invoice No Invoice Date Invoice Type //Brand Name Product Name Item Desc //HSN Code BAR CODE Style Code Quantity //MRP Discount Amt Basic Amt Tax Amt SGST Amt CGST Amt Line Total Round Off //Bill Amt Payment Mode SalesMan Name private int StockItem(VoyagerContext db, ImportSaleItemWise item, out Units unit) { ProductItem pItem = new ProductItem { Barcode = item.Barcode, Cost = -999, MRP = item.MRP, StyleCode = item.StyleCode, ProductName = item.ProductName, ItemDesc = item.ItemDesc, BrandId = GetBrand(db, item.StyleCode), }; //spliting ProductName string [] PN = item.ProductName.Split('/'); // Apparel / Work / Blazers if (PN [0] == "Apparel") { pItem.Units = Units.Pcs; pItem.Categorys = ProductCategorys.ReadyMade; } else if (PN [0] == "Suiting" || PN [0] == "Shirting") { pItem.Units = Units.Meters; pItem.Categorys = ProductCategorys.Fabric; } else if (PN [0] == "Tailoring") { pItem.Units = Units.Nos; pItem.Categorys = ProductCategorys.Tailoring; } else { pItem.Units = Units.Nos; pItem.Categorys = ProductCategorys.Others; //TODO: For time being } List <Category> catIds = GetCategory(db, PN [0], PN [1], PN [2]); pItem.MainCategory = catIds [0]; pItem.ProductCategory = catIds [1]; pItem.ProductType = catIds [2]; db.ProductItems.Add(pItem); db.SaveChanges(); unit = pItem.Units; return(pItem.ProductItemId); }
/// <summary> /// For Creating Stock list for Sale . which can be later ajusted /// </summary> /// <param name="db">Database Context</param> /// <param name="qty"> Sale Qty</param> /// <param name="pItemId">Item Code</param> /// <param name="unts">Units</param> public void CreateStockItem(VoyagerContext db, double qty, int pItemId, Units unts) { Stock stock = new Stock { PurchaseQty = 0, Quantity = 0 - qty, ProductItemId = pItemId, SaleQty = qty, Units = unts }; db.Stocks.Add(stock); db.SaveChanges(); }
public PurchaseItem CreatePurchaseItem(VoyagerContext db, ImportPurchase purchase, int productId, bool IsLocal = false) { PurchaseItem item = new PurchaseItem { Barcode = purchase.Barcode, Cost = purchase.Cost, CostValue = purchase.CostValue, Qty = purchase.Quantity, TaxAmout = purchase.TaxAmt, Unit = db.ProductItems.Find(productId).Units, PurchaseTaxTypeId = CreatePurchaseTaxType(db, purchase, IsLocal), ProductItemId = productId }; return(item); }
private int CreateSaleTax(VoyagerContext db, ImportSaleItemWise item, bool isIGST = false) { if (item.Tax != 0 && item.SGST != 0) { //GST Bill } else if (item.Tax == 0 && item.SGST == 0) { //TODO: Tax implementation } else { } return(1); }
private int GetBrandID(VoyagerContext db, string code) { //TODO: Null Object is found //TODO: create if not exsits try { int ids = (int?)db.Brands.Where(c => c.BCode == code).FirstOrDefault().BrandId ?? -1; return(ids); } catch (Exception ex) { Brand brand = new Brand { BCode = code, BrandName = code }; db.Brands.Add(brand); db.SaveChanges(); return(brand.BrandId); } }
private SaleItem CreateSaleItem(VoyagerContext db, ImportSaleItemWise item) { var pi = db.ProductItems.Where(c => c.Barcode == item.Barcode).Select(c => new { c.ProductItemId, c.Units }).FirstOrDefault(); SaleItem saleItem = new SaleItem { BarCode = item.Barcode, MRP = item.MRP, BasicAmount = item.BasicRate, Discount = item.Discount, Qty = item.Quantity, TaxAmount = item.SGST, BillAmount = item.LineTotal, Units = pi.Units, ProductItemId = pi.ProductItemId, SalesmanId = GetSalesmanId(db, item.Saleman), SaleTaxTypeId = CreateSaleTax(db, item) }; SalePurchaseManager.UpDateStock(db, pi.ProductItemId, item.Quantity, false);// TODO: Check for this working return(saleItem); }
public int CreateSaleEntry(DateTime onDate) { using (VoyagerContext db = new VoyagerContext()) { int ctr = 0; //bool isVat = false; if (onDate < new DateTime(2017, 7, 1)) { // isVat = true; return(-1);// TODO: Temp implemenent for vat system } SaleInvoice saleInvoice = null; var data = db.ImportSaleItemWises.Where(c => c.IsDataConsumed == false && DbFunctions.TruncateTime(c.InvoiceDate) == DbFunctions.TruncateTime(onDate)).OrderBy(c => c.InvoiceNo).ToList(); if (data != null) { foreach (var item in data) { saleInvoice = CreateSaleInvoice(db, item, saleInvoice); //Create SaleInvoice saleInvoice.SaleItems.Add(CreateSaleItem(db, item)); // Create SaleItems ctr++; } if (saleInvoice != null) { db.SaleInvoices.Add(saleInvoice); // Save Last Sale Invoice db.SaveChanges(); } return(ctr); } else { return(ctr); } } }
private async Task <Uri> AddBill(VoyagerBillInfo bill) { HttpResponseMessage response = await client.PostAsJsonAsync("api/VoyagerBills", bill); LogEvent.WriteEvent("Header:" + response.Headers.ToString()); LogEvent.WriteEvent("Content:" + response.Content.ToString()); LogEvent.WriteEvent("Status Code:" + response.StatusCode.ToString()); response.EnsureSuccessStatusCode(); if (response.IsSuccessStatusCode) { LogEvent.WriteEvent("Invocie is saved: " + bill.InvoiceNo); using (VoyagerContext db = new VoyagerContext()) { InsertDataLog log = db.InsertDataLogs.Where(c => c.BillNumber == bill.InvoiceNo).FirstOrDefault(); log.Remark = response.Content.ToString(); db.Entry(log).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } } return(response.Headers.Location); }
private int GetSupplierIdOrAdd(VoyagerContext db, string sup) { try { int ids = (int?)db.Suppliers.Where(c => c.SuppilerName == sup).FirstOrDefault().SupplierID ?? -1; if (ids > 0) { return(ids); } else if (ids == -1) { Supplier supplier = new Supplier { SuppilerName = sup, Warehouse = sup }; db.Suppliers.Add(supplier); db.SaveChanges(); return(supplier.SupplierID); } else { return(1);// Suspense Supplier } } catch (Exception) { Supplier supplier = new Supplier { SuppilerName = sup, Warehouse = sup }; db.Suppliers.Add(supplier); db.SaveChanges(); return(supplier.SupplierID); } }
private SaleItem CreateSaleItem(VoyagerContext db, ImportSaleItemWise item) { var pi = db.ProductItems.Where(c => c.Barcode == item.Barcode).Select(c => new { c.ProductItemId, c.Units }).FirstOrDefault(); if (pi == null) { //TODO: Handle for ProductItem Doesnt Exsist. //create item and stock int id = StockItem(db, item, out Units UNTS); pi = new { ProductItemId = id, Units = UNTS }; } SaleItem saleItem = new SaleItem { BarCode = item.Barcode, MRP = item.MRP, BasicAmount = item.BasicRate, Discount = item.Discount, Qty = item.Quantity, TaxAmount = item.SGST + item.CGST, BillAmount = item.LineTotal, Units = pi.Units, ProductItemId = pi.ProductItemId, SalesmanId = GetSalesmanId(db, item.Saleman), SaleTaxTypeId = CreateSaleTax(db, item) }; if (!SalePurchaseManager.UpDateStock(db, pi.ProductItemId, item.Quantity, false)) { //TODO: Create Stock and update CreateStockItem(db, saleItem.Qty, saleItem.ProductItemId, saleItem.Units); } item.IsDataConsumed = true; db.Entry(item).State = EntityState.Modified; return(saleItem); }
public PassengerLoginController(VoyagerContext context, IMemoryCache memoryCache) { _context = context; }
public CommentController(VoyagerContext context) { _context = context; }
public AdminCommentController(VoyagerContext context, IMemoryCache memoryCache) : base(context, memoryCache) { _context = context; }