예제 #1
0
        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);
        }
예제 #2
0
        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);
        }