コード例 #1
0
        private void AddItemToInventory(long CreditMemoID)
        {
            CreditMemoDetails clsCreditMemoDetails = Details(CreditMemoID);
            ERPConfig         clsERPConfig         = new ERPConfig(base.Connection, base.Transaction);
            ERPConfigDetails  clsERPConfigDetails  = clsERPConfig.Details();

            CreditMemoItems         clsCreditMemoItems         = new CreditMemoItems(base.Connection, base.Transaction);
            ProductUnit             clsProductUnit             = new ProductUnit(base.Connection, base.Transaction);
            Products                clsProduct                 = new Products(base.Connection, base.Transaction);
            ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);

            Inventory clsInventory = new Inventory(base.Connection, base.Transaction);

            System.Data.DataTable dt = clsCreditMemoItems.ListAsDataTable(CreditMemoID);

            foreach (System.Data.DataRow dr in dt.Rows)
            {
                long lngProductID     = long.Parse(dr["ProductID"].ToString());
                int  intProductUnitID = int.Parse(dr["ProductUnitID"].ToString());

                decimal decItemQuantity = decimal.Parse(dr["Quantity"].ToString());
                decimal decQuantity     = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long    lngVariationMatrixID = long.Parse(dr["VariationMatrixID"].ToString());
                string  strMatrixDescription = "" + dr["MatrixDescription"].ToString();
                string  strProductCode       = "" + dr["ProductCode"].ToString();
                decimal decUnitCost          = decimal.Parse(dr["UnitCost"].ToString());
                decimal decItemCost          = decimal.Parse(dr["Amount"].ToString());
                decimal decVAT = decimal.Parse(dr["VAT"].ToString());

                /*******************************************
                 * Do not Add to Inventory coz this is a Debit Memo and no effect on inventory
                 * ****************************************/

                /*******************************************
                 * Add to Inventory Analysis
                 * ****************************************/
                InventoryDetails clsInventoryDetails = new InventoryDetails();
                clsInventoryDetails.PostingDateFrom   = clsERPConfigDetails.PostingDateFrom;
                clsInventoryDetails.PostingDateTo     = clsERPConfigDetails.PostingDateTo;
                clsInventoryDetails.PostingDate       = clsCreditMemoDetails.PostingDate;
                clsInventoryDetails.ReferenceNo       = clsCreditMemoDetails.CNNo;
                clsInventoryDetails.ContactID         = clsCreditMemoDetails.CustomerID;
                clsInventoryDetails.ContactCode       = clsCreditMemoDetails.CustomerCode;
                clsInventoryDetails.ProductID         = lngProductID;
                clsInventoryDetails.ProductCode       = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                clsInventoryDetails.MatrixDescription = strMatrixDescription;
                clsInventoryDetails.SCreditQuantity   = decQuantity;
                clsInventoryDetails.SCreditCost       = decItemCost - decVAT;
                clsInventoryDetails.SCreditVAT        = decItemCost; //Sales Return with VAT

                clsInventory.Insert(clsInventoryDetails);
            }
            //myReader.Close();
        }
コード例 #2
0
        /// <summary>
        /// Jul 28, 2011 : Lemu
        //  - Remove the adding/subtracting and SynchronizeQuantity in clsProductVariationsMatrix,
        //    already included in the new AddQuantity and SubtractQuantity.
        /// </summary>
        /// <param name="Details"></param>
        /// <param name="StockDirection"></param>
        /// <returns></returns>
        public Int64 AddItem(int BranchID, string TransactionNo, string CreatedBy, StockItemDetails Details, StockDirections StockDirection)
        {
            try
            {
                StockItem clsStockItem = new StockItem(base.Connection, base.Transaction);
                Int64     StockItemID  = clsStockItem.Insert(Details);

                ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
                decimal     Quantity       = clsProductUnit.GetBaseUnitValue(Details.ProductID, Details.ProductUnitID, Details.Quantity);
                string      strRemarks     = string.Empty;

                Products clsProduct = new Products(base.Connection, base.Transaction);
                if (StockDirection == StockDirections.Decrement)
                {
                    strRemarks = Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.DEDUCT_STOCK_INVENTORY) + " " + Details.Remarks;
                    clsProduct.SubtractQuantity(BranchID, Details.ProductID, Details.VariationMatrixID, Quantity, strRemarks, Details.StockDate, TransactionNo, CreatedBy);
                }
                else
                {
                    strRemarks = Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.ADD_STOCK_INVENTORY) + " " + Details.Remarks;
                    clsProduct.AddQuantity(BranchID, Details.ProductID, Details.VariationMatrixID, Quantity, strRemarks, Details.StockDate, TransactionNo, CreatedBy);
                }

                // Removed
                //ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);
                //if (Details.VariationMatrixID != 0)
                //{
                //    if (StockDirection == StockDirections.Decrement)
                //    {	clsProductVariationsMatrix.SubtractQuantity(Details.VariationMatrixID, Quantity);	}
                //    else
                //    {	clsProductVariationsMatrix.AddQuantity(Details.VariationMatrixID, Quantity);	}

                //    clsProductVariationsMatrix.SynchronizeQuantity(Details.ProductID);
                //}

                return(StockItemID);
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
コード例 #3
0
ファイル: _Post.ascx.cs プロジェクト: marioricci/erp-luma
        protected void cboProductUnit_SelectedIndexChanged(object sender, EventArgs e)
        {
            ProductPackage clsProductPackage = new ProductPackage();
            ProductPackageDetails clsDetails = clsProductPackage.DetailsByProductIDAndUnitID(long.Parse(cboProductCode.SelectedValue), long.Parse(cboProductUnit.SelectedValue));
            if (clsDetails.PackageID == 0)
            {
                ProductUnit clsProductUnit = new ProductUnit(clsProductPackage.Connection, clsProductPackage.Transaction);
                Products clsProduct = new Products(clsProductPackage.Connection, clsProductPackage.Transaction);
                ProductDetails clsProductDetails = clsProduct.Details(long.Parse(cboProductCode.SelectedItem.Value));
                decimal decBaseUnitValue = clsProductUnit.GetBaseUnitValue(long.Parse(cboProductCode.SelectedItem.Value), int.Parse(cboProductUnit.SelectedItem.Value), 1);

                clsDetails.Price = decBaseUnitValue * clsProductDetails.Price;
                clsDetails.PurchasePrice = decBaseUnitValue * clsProductDetails.PurchasePrice;
            }
            clsProductPackage.CommitAndDispose();


            txtPrice.Text = clsDetails.PurchasePrice.ToString("#####0.##0");
        }
コード例 #4
0
ファイル: DebitMemo.cs プロジェクト: marioricci/erp-luma
        private void AddItemToInventory(long pvtDebitMemoID)
        {
            DebitMemoDetails clsDebitMemoDetails = Details(pvtDebitMemoID);
            ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
            ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

            DebitMemoItems clsDebitMemoItems = new DebitMemoItems(base.Connection, base.Transaction);
            ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);

            ProductDetails clsProductDetails = new ProductDetails();
            Products clsProduct = new Products(base.Connection, base.Transaction);
            ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);
            ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);
            MatrixPackage clsMatrixPackage = new MatrixPackage(base.Connection, base.Transaction);

            Inventory clsInventory = new Inventory(base.Connection, base.Transaction);

            ProductPackagePriceHistoryDetails clsProductPackagePriceHistoryDetails;
            ProductPackagePriceHistory clsProductPackagePriceHistory = new ProductPackagePriceHistory(base.Connection, base.Transaction);

            System.Data.DataTable dt = clsDebitMemoItems.ListAsDataTable(pvtDebitMemoID, SortField: "DebitMemoItemID", SortOrder: SortOption.Ascending);

            foreach (System.Data.DataRow dr in dt.Rows)
            {
                long lngProductID = Convert.ToInt64(dr["ProductID"]);
                int intProductUnitID = Convert.ToInt16(dr["ProductUnitID"]);

                decimal decItemQuantity = Convert.ToDecimal(dr["Quantity"]);
                decimal decQuantity = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long lngVariationMatrixID = Convert.ToInt64(dr["VariationMatrixID"]);
                string strMatrixDescription = dr["MatrixDescription"].ToString();
                string strProductCode = dr["ProductCode"].ToString();
                string strProductUnitCode = dr["ProductUnitCode"].ToString();
                decimal decNewUnitCost = Convert.ToDecimal(dr["UnitCost"]);
                decimal decAmount = Convert.ToDecimal(dr["Amount"]);
                //decimal decSellingPrice = Convert.ToDecimal(dr["SellingPrice"]);
                decimal decVAT = Convert.ToDecimal(dr["VAT"]);
                //decimal decEVAT = Convert.ToDecimal(dr["EVAT"]);
                //decimal decLocalTax = Convert.ToDecimal(dr["LocalTax"]); 

                clsProductDetails = clsProduct.Details1(clsDebitMemoDetails.BranchID, lngProductID);
                /*******************************************
				 * Add in the Purchase Price History based on Debit Memo
				 * ****************************************/
                // Update ProductPackagePriceHistory first to get the history
                clsProductPackagePriceHistoryDetails = new ProductPackagePriceHistoryDetails();
                clsProductPackagePriceHistoryDetails.UID = clsDebitMemoDetails.PurchaserID;
                clsProductPackagePriceHistoryDetails.PackageID = clsProductPackage.GetPackageID(lngProductID, intProductUnitID);
                clsProductPackagePriceHistoryDetails.ChangeDate = DateTime.Now;
                clsProductPackagePriceHistoryDetails.PurchasePrice = decNewUnitCost * (decItemQuantity / decQuantity);
                clsProductPackagePriceHistoryDetails.Price = -1;
                clsProductPackagePriceHistoryDetails.VAT = -1;
                clsProductPackagePriceHistoryDetails.EVAT = -1;
                clsProductPackagePriceHistoryDetails.LocalTax = -1;
                clsProductPackagePriceHistoryDetails.Remarks = "Based on DebitMemo #: " + clsDebitMemoDetails.MemoNo;
                clsProductPackagePriceHistory.Insert(clsProductPackagePriceHistoryDetails);

                /*******************************************
                 * Subtract from Inventory : Remove this since this is a Debit Memo
                 * ****************************************/
                //clsProduct.SubtractQuantity(lngProductID, decQuantity);
                //if (lngVariationMatrixID != 0)
                //{
                //    clsProductVariationsMatrix.SubtractQuantity(lngVariationMatrixID, decQuantity);
                //}

                /*******************************************
				 * Update Purchasing Information
				 * ****************************************/
                int iBaseUnitID = clsProduct.get_BaseUnitID(lngProductID);
                if (iBaseUnitID != intProductUnitID)
                {
                    clsProduct.UpdatePurchasing(lngProductID, lngVariationMatrixID, clsDebitMemoDetails.SupplierID, iBaseUnitID, (decItemQuantity * decNewUnitCost) / decQuantity);
                }
                clsProduct.UpdatePurchasing(lngProductID, lngVariationMatrixID, clsDebitMemoDetails.SupplierID, intProductUnitID, decNewUnitCost);

                /*******************************************
                 * Add to Inventory Analysis
                 * ****************************************/
                InventoryDetails clsInventoryDetails = new InventoryDetails();
                clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
                clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
                clsInventoryDetails.PostingDate = clsDebitMemoDetails.PostingDate;
                clsInventoryDetails.ReferenceNo = clsDebitMemoDetails.MemoNo;
                clsInventoryDetails.ContactID = clsDebitMemoDetails.SupplierID;
                clsInventoryDetails.ContactCode = clsDebitMemoDetails.SupplierCode;
                clsInventoryDetails.ProductID = lngProductID;
                clsInventoryDetails.ProductCode = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                clsInventoryDetails.MatrixDescription = strMatrixDescription;
                clsInventoryDetails.PDebitQuantity = decQuantity;
                clsInventoryDetails.PDebitCost = decAmount - decVAT;
                clsInventoryDetails.PDebitVAT = decAmount;

                clsInventory.Insert(clsInventoryDetails);

            }
        }
コード例 #5
0
ファイル: _Post.ascx.cs プロジェクト: marioricci/erp-luma
        protected void cboProductUnit_SelectedIndexChanged(object sender, EventArgs e)
        {
            ProductPackage clsProductPackage = new ProductPackage();
            ProductPackageDetails clsDetails = clsProductPackage.DetailsByProductIDAndUnitID(long.Parse(cboProductCode.SelectedValue), long.Parse(cboProductUnit.SelectedValue));
            if (clsDetails.PackageID == 0)
            {
                ProductUnit clsProductUnit = new ProductUnit(clsProductPackage.Connection, clsProductPackage.Transaction);
                Products clsProduct = new Products(clsProductPackage.Connection, clsProductPackage.Transaction);
                ProductDetails clsProductDetails = clsProduct.Details(long.Parse(cboProductCode.SelectedItem.Value));
                decimal decBaseUnitValue = clsProductUnit.GetBaseUnitValue(long.Parse(cboProductCode.SelectedItem.Value), int.Parse(cboProductUnit.SelectedItem.Value), 1);

                clsDetails.Price = decBaseUnitValue * clsProductDetails.Price;
                clsDetails.PurchasePrice = decBaseUnitValue * clsProductDetails.PurchasePrice;
            }
            clsProductPackage.CommitAndDispose();


            txtPrice.Text = clsDetails.PurchasePrice.ToString("#####0.##0");
            txtSellingPrice.Text = clsDetails.Price.ToString("#####0.##0");
            txtOldSellingPrice.Text = clsDetails.Price.ToString("#####0.##0");
            decimal decMargin = clsDetails.Price - clsDetails.PurchasePrice;
            try { decMargin = decMargin / clsDetails.PurchasePrice; }
            catch { decMargin = 1; }
            decMargin = decMargin * 100;
            txtMargin.Text = decMargin.ToString("#,##0.##0");
            txtVAT.Text = clsDetails.VAT.ToString("#,##0.##0");
            txtEVAT.Text = clsDetails.EVAT.ToString("#,##0.##0");
            txtLocalTax.Text = clsDetails.LocalTax.ToString("#,##0.##0");

            ComputeItemAmount();
            lstItemFixCssClass();
        }
コード例 #6
0
ファイル: SO.cs プロジェクト: marioricci/erp-luma
		private void SubtractItemToInventory(long SOID)
		{

			SODetails clsSODetails = Details(SOID);
            ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
			ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

            SOItem clsSOItem = new SOItem(base.Connection, base.Transaction);
            ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
            Products clsProduct = new Products(base.Connection, base.Transaction);
            ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);
            ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);
            MatrixPackage clsMatrixPackage = new MatrixPackage(base.Connection, base.Transaction);

            Inventory clsInventory = new Inventory(base.Connection, base.Transaction);
			InventoryDetails clsInventoryDetails;

            //MatrixPackagePriceHistoryDetails clsMatrixPackagePriceHistoryDetails;
            //ProductPackagePriceHistoryDetails clsProductPackagePriceHistoryDetails;

            System.Data.DataTable dt = clsSOItem.ListAsDataTable(SOID, "SOItemID", SortOption.Ascending);
            foreach (System.Data.DataRow dr in dt.Rows)
			{
                long lngProductID = long.Parse(dr["ProductID"].ToString());
                int intProductUnitID = int.Parse(dr["ProductUnitID"].ToString());

                decimal decItemQuantity = decimal.Parse(dr["Quantity"].ToString());
                decimal decQuantity = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long lngVariationMatrixID = long.Parse(dr["VariationMatrixID"].ToString());
                string strMatrixDescription = "" + dr["MatrixDescription"].ToString();
                string strProductCode = "" + dr["ProductCode"].ToString();
                decimal decUnitCost = decimal.Parse(dr["UnitCost"].ToString());
                decimal decItemCost = decimal.Parse(dr["Amount"].ToString());
                decimal decVAT = decimal.Parse(dr["VAT"].ToString());

                ///*******************************************
                // * Add in the Sales Price History
                // * ****************************************/
                //if (lngVariationMatrixID != 0)
                //{
                //    // Update MatrixPackagePriceHistory first to get the history
                //    clsMatrixPackagePriceHistoryDetails = new MatrixPackagePriceHistoryDetails();
                //    clsMatrixPackagePriceHistoryDetails.UID = clsSODetails.SellerID;
                //    clsMatrixPackagePriceHistoryDetails.PackageID = clsMatrixPackage.GetPackageID(lngVariationMatrixID, intProductUnitID);
                //    clsMatrixPackagePriceHistoryDetails.ChangeDate = DateTime.Now;
                //    clsMatrixPackagePriceHistoryDetails.Price = decUnitCost;
                //    clsMatrixPackagePriceHistoryDetails.PurchasePrice = -1; //-1 = nochange
                //    clsMatrixPackagePriceHistoryDetails.VAT = -1; //-1 = nochange
                //    clsMatrixPackagePriceHistoryDetails.EVAT = -1; //-1 = nochange
                //    clsMatrixPackagePriceHistoryDetails.LocalTax = -1; //-1 = nochange
                //    clsMatrixPackagePriceHistoryDetails.Remarks = "Based on SO #: " + clsSODetails.SONo;
                //    MatrixPackagePriceHistory clsMatrixPackagePriceHistory = new MatrixPackagePriceHistory(base.Connection, base.Transaction);
                //    clsMatrixPackagePriceHistory.Insert(clsMatrixPackagePriceHistoryDetails);
                //}
                //else
                //{
                //    // Update ProductPackagePriceHistory first to get the history
                //    clsProductPackagePriceHistoryDetails = new ProductPackagePriceHistoryDetails();
                //    clsProductPackagePriceHistoryDetails.UID = clsSODetails.SellerID;
                //    clsProductPackagePriceHistoryDetails.PackageID = clsProductPackage.GetPackageID(lngProductID, intProductUnitID);
                //    clsProductPackagePriceHistoryDetails.ChangeDate = DateTime.Now;
                //    clsProductPackagePriceHistoryDetails.Price = decUnitCost;
                //    clsProductPackagePriceHistoryDetails.PurchasePrice = -1; //-1 = nochange
                //    clsProductPackagePriceHistoryDetails.VAT = -1; //-1 = nochange
                //    clsProductPackagePriceHistoryDetails.EVAT = -1; //-1 = nochange
                //    clsProductPackagePriceHistoryDetails.LocalTax = -1; //-1 = nochange
                //    clsProductPackagePriceHistoryDetails.Remarks = "Based on SO #: " + clsSODetails.SONo;
                //    ProductPackagePriceHistory clsProductPackagePriceHistory = new ProductPackagePriceHistory(base.Connection, base.Transaction);
                //    clsProductPackagePriceHistory.Insert(clsProductPackagePriceHistoryDetails);
                //}


				/*******************************************
				 * Subtract to Inventory
				 * ****************************************/
				// clsProduct.SubtractQuantity(lngProductID, decQuantity);
				// if (lngVariationMatrixID != 0) { clsProductVariationsMatrix.SubtractQuantity(lngVariationMatrixID, decQuantity); }
				// July 28, 2011: change the above codes to the following
				clsProduct.SubtractQuantity(clsSODetails.BranchID, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.DEDUCT_SOLD_WHOLESALE), DateTime.Now, clsSODetails.SONo, clsSODetails.SellerName);

				/*******************************************
				 * Update Selling Information
				 * ****************************************/
                int iBaseUnitID = clsProduct.get_BaseUnitID(lngProductID);
                if (iBaseUnitID != intProductUnitID)
                {
                    clsProduct.UpdateSellingPrice(lngProductID, lngVariationMatrixID, clsSODetails.CustomerID, intProductUnitID, (decItemQuantity * decUnitCost) / decQuantity, -1, -1, -1,- 1, -1); // Price should be the sugegsted selling price
                }
                clsProduct.UpdateSellingWSPrice(lngProductID, lngVariationMatrixID, clsSODetails.CustomerID, intProductUnitID, decUnitCost); // WS Price should be the unit cost


				/*******************************************
				 * Add to Inventory Analysis
				 * ****************************************/
				clsInventoryDetails = new InventoryDetails();
				clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
				clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
				clsInventoryDetails.PostingDate = clsSODetails.DeliveryDate;
				clsInventoryDetails.ReferenceNo = clsSODetails.SONo;
				clsInventoryDetails.ContactID = clsSODetails.CustomerID;
				clsInventoryDetails.ContactCode = clsSODetails.CustomerCode;
				clsInventoryDetails.ProductID = lngProductID;
				clsInventoryDetails.ProductCode = strProductCode;
				clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
				clsInventoryDetails.MatrixDescription = strMatrixDescription;
				clsInventoryDetails.SoldQuantity = decQuantity;
				clsInventoryDetails.SoldCost = decItemCost - decVAT;
				clsInventoryDetails.SoldVAT = decItemCost;	// Sales Cost with VAT

				clsInventory.Insert(clsInventoryDetails);
			}

		}
コード例 #7
0
ファイル: POReturns.cs プロジェクト: marioricci/erp-luma
		private void AddItemToInventory(long DebitMemoID)
		{

			POReturnDetails clsPOReturnDetails = Details(DebitMemoID);
			ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
			ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

			POReturnItems clsPOReturnItems = new POReturnItems(base.Connection, base.Transaction);
			ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
			Products clsProduct = new Products(base.Connection, base.Transaction);
			ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);

			Inventory clsInventory = new Inventory(base.Connection, base.Transaction);

			//MySqlDataReader myReader = clsPOReturnItems.List(DebitMemoID, "DebitMemoItemID", SortOption.Ascending);
            System.Data.DataTable dt = clsPOReturnItems.ListAsDataTable(DebitMemoID);

            foreach (System.Data.DataRow dr in dt.Rows)
			{
                long lngProductID = Convert.ToInt64(dr["ProductID"]); // myReader.GetInt64("ProductID");
                int intProductUnitID = Convert.ToInt16(dr["ProductUnitID"]); // myReader.GetInt16("ProductUnitID");

                decimal decItemQuantity = Convert.ToDecimal(dr["Quantity"]); // myReader.GetDecimal("Quantity");
                decimal decQuantity = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long lngVariationMatrixID = Convert.ToInt64(dr["VariationMatrixID"]); // myReader.GetInt64("VariationMatrixID");
                string strMatrixDescription = dr["MatrixDescription"].ToString(); //  "" + myReader["MatrixDescription"].ToString();
                string strProductCode = dr["ProductCode"].ToString(); // "" + myReader["ProductCode"].ToString();
                string strProductUnitCode = dr["ProductUnitCode"].ToString(); // "" + myReader["ProductUnitCode"].ToString();
                decimal decUnitCost = Convert.ToDecimal(dr["UnitCost"]); // myReader.GetDecimal("UnitCost");
                decimal decItemCost = Convert.ToDecimal(dr["Amount"]); // myReader.GetDecimal("Amount");
                decimal decVAT = Convert.ToDecimal(dr["VAT"]); // myReader.GetDecimal("VAT");

				/*******************************************
				 * Subtract from Inventory
				 * ****************************************/
                // clsProduct.SubtractQuantity(ProductID, Quantity);
                // if (VariationMatrixID != 0) { clsProductVariationsMatrix.SubtractQuantity(VariationMatrixID, Quantity);}
                // July 26, 2011: change the above codes to the following
                clsProduct.SubtractQuantity(clsPOReturnDetails.BranchID, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.DEDUCT_PURCHASE_RETURN), DateTime.Now, clsPOReturnDetails.MemoNo, clsPOReturnDetails.PurchaserName);

				/*******************************************
				 * Add to Inventory Analysis
				 * ****************************************/
				InventoryDetails clsInventoryDetails = new InventoryDetails();
				clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
				clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
				clsInventoryDetails.PostingDate = clsPOReturnDetails.PostingDate;
				clsInventoryDetails.ReferenceNo = clsPOReturnDetails.MemoNo;
				clsInventoryDetails.ContactID = clsPOReturnDetails.SupplierID;
				clsInventoryDetails.ContactCode = clsPOReturnDetails.SupplierCode;
                clsInventoryDetails.ProductID = lngProductID;
                clsInventoryDetails.ProductCode = strProductCode;
				clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                clsInventoryDetails.MatrixDescription = strMatrixDescription;
				clsInventoryDetails.PReturnQuantity = decQuantity;
                clsInventoryDetails.PReturnCost = decItemCost - decVAT;
                clsInventoryDetails.PReturnVAT = decItemCost;	//Purchase Return with VAT

				clsInventory.Insert(clsInventoryDetails);
			}
		}
コード例 #8
0
		private void AddItemToInventory(long WBranchTransferID)
		{

			WBranchTransferDetails clsWBranchTransferDetails = Details(WBranchTransferID);
            ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
			ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

			WBranchTransferItem clsWBranchTransferItem = new WBranchTransferItem(base.Connection, base.Transaction);
            ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
            Products clsProduct = new Products(base.Connection, base.Transaction);

            Inventory clsInventory = new Inventory(base.Connection, base.Transaction);
            InventoryDetails clsInventoryDetails;

			System.Data.DataTable dt = clsWBranchTransferItem.ListAsDataTable(WBranchTransferID, "WBranchTransferItemID", SortOption.Ascending);

            foreach (System.Data.DataRow dr in dt.Rows)
			{
				long lngProductID = Int64.Parse(dr["ProductID"].ToString());
				int intProductUnitID = Int16.Parse(dr["ProductUnitID"].ToString());

				decimal decItemQuantity = decimal.Parse(dr["Quantity"].ToString());
                decimal decQuantity = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);
				
				long lngVariationMatrixID = Int64.Parse(dr["VariationMatrixID"].ToString());
				string strMatrixDescription = "" + dr["MatrixDescription"].ToString();
				string strProductCode = "" + dr["ProductCode"].ToString();
                string strProductUnitCode = "" + dr["ProductUnitCode"].ToString();
				decimal decUnitCost = decimal.Parse(dr["UnitCost"].ToString());
				decimal decItemCost = decimal.Parse(dr["Amount"].ToString());
                decimal decVAT = decimal.Parse(dr["VAT"].ToString());

				/*******************************************
				 * Subtract BranchIDFrom then Add to BranchIDTo -- Inventory
				 * ****************************************/
                clsProduct.SubtractQuantity(clsWBranchTransferDetails.BranchIDFrom, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.DEDUCT_BRANCH_TRANSFER_FROM) + " " + clsWBranchTransferDetails.BranchCodeFrom + " @ " + decUnitCost.ToString("#,##0.#0") + "/" + strProductUnitCode, DateTime.Now, clsWBranchTransferDetails.WBranchTransferNo, clsWBranchTransferDetails.TransferrerName);
                clsProduct.AddQuantity(clsWBranchTransferDetails.BranchIDTo, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.ADD_BRANCH_TRANSFER_TO) + " " + clsWBranchTransferDetails.BranchCodeTo + " @ " + decUnitCost.ToString("#,##0.#0") + "/" + strProductUnitCode, DateTime.Now, clsWBranchTransferDetails.WBranchTransferNo, clsWBranchTransferDetails.TransferrerName);

				/*******************************************
				 * Add to Inventory Analysis
				 * ****************************************/
				clsInventoryDetails = new InventoryDetails();
				clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
				clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
				clsInventoryDetails.PostingDate = clsWBranchTransferDetails.DeliveryDate;
				clsInventoryDetails.ReferenceNo = clsWBranchTransferDetails.WBranchTransferNo;
				clsInventoryDetails.ContactID = Constants.C_RETAILPLUS_SUPPLIERID;
                clsInventoryDetails.ContactCode = Constants.C_RETAILPLUS_SUPPLIER;
                clsInventoryDetails.ProductID = lngProductID;
                clsInventoryDetails.ProductCode = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                clsInventoryDetails.MatrixDescription = strMatrixDescription;
				
                clsInventoryDetails.PurchaseCost = decItemCost - decVAT;
                clsInventoryDetails.PurchaseVAT = decItemCost;	// Purchase Cost with VAT

                // insert into branchid from with minus quantity
                clsInventoryDetails.BranchID = clsWBranchTransferDetails.BranchIDFrom;
                clsInventoryDetails.PurchaseQuantity = -decQuantity;
                clsInventory.Insert(clsInventoryDetails);

                // insert into branchid to with add quantity
                clsInventoryDetails.BranchID = clsWBranchTransferDetails.BranchIDTo;
                clsInventoryDetails.PurchaseQuantity = decQuantity;
                clsInventory.Insert(clsInventoryDetails);
			}
		}
コード例 #9
0
ファイル: PO.cs プロジェクト: marioricci/erp-luma
		private void AddItemToInventory(long POID)
		{

			PODetails clsPODetails = Details(POID);
            ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
			ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

			POItem clsPOItem = new POItem(base.Connection, base.Transaction);
            ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
            Products clsProduct = new Products(base.Connection, base.Transaction);
            ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);
            ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);

			Inventory clsInventory = new Inventory(base.Connection, base.Transaction);
            InventoryDetails clsInventoryDetails;

            ProductPackagePriceHistoryDetails clsProductPackagePriceHistoryDetails;

			//MySqlDataReader myReader = clsPOItem.List(POID, "POItemID", SortOption.Ascending);
            System.Data.DataTable dt = clsPOItem.ListAsDataTable(POID, "POItemID", SortOption.Ascending);

			//while (myReader.Read())
            foreach (System.Data.DataRow dr in dt.Rows)
			{
                long lngProductID = Convert.ToInt64(dr["ProductID"]);
                int intProductUnitID = Convert.ToInt16(dr["ProductUnitID"]);

                decimal decItemQuantity = Convert.ToDecimal(dr["Quantity"]);
                decimal decQuantity = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long lngVariationMatrixID = Convert.ToInt64(dr["VariationMatrixID"]);
                string strMatrixDescription = dr["MatrixDescription"].ToString();
                string strProductCode = dr["ProductCode"].ToString();
                string strProductUnitCode = dr["ProductUnitCode"].ToString();
                decimal decUnitCost = Convert.ToDecimal(dr["UnitCost"]);
                decimal decItemCost = Convert.ToDecimal(dr["Amount"]);
                decimal decSellingPrice = Convert.ToDecimal(dr["SellingPrice"]);
                decimal decVAT = Convert.ToDecimal(dr["VAT"]);
                decimal decEVAT = Convert.ToDecimal(dr["EVAT"]);
                decimal decLocalTax = Convert.ToDecimal(dr["LocalTax"]); 

                /*******************************************
				 * Add in the Price History
				 * ****************************************/
                // Update ProductPackagePriceHistory first to get the history
                clsProductPackagePriceHistoryDetails = new ProductPackagePriceHistoryDetails();
                clsProductPackagePriceHistoryDetails.UID = clsPODetails.PurchaserID;
                clsProductPackagePriceHistoryDetails.PackageID = clsProductPackage.GetPackageID(lngProductID, intProductUnitID);
                clsProductPackagePriceHistoryDetails.ChangeDate = DateTime.Now;
                clsProductPackagePriceHistoryDetails.PurchasePrice = (decItemQuantity * decUnitCost) / decQuantity;
                clsProductPackagePriceHistoryDetails.Price = decSellingPrice;
                clsProductPackagePriceHistoryDetails.VAT = decVAT;
                clsProductPackagePriceHistoryDetails.EVAT = decEVAT;
                clsProductPackagePriceHistoryDetails.LocalTax = decLocalTax;
                clsProductPackagePriceHistoryDetails.Remarks = "Based on PO #: " + clsPODetails.PONo;
                ProductPackagePriceHistory clsProductPackagePriceHistory = new ProductPackagePriceHistory(base.Connection, base.Transaction);
                clsProductPackagePriceHistory.Insert(clsProductPackagePriceHistoryDetails);


				/*******************************************
				 * Add to Inventory
				 * ****************************************/
                //clsProduct.AddQuantity(lngProductID, decQuantity);
                //if (lngVariationMatrixID != 0) { clsProductVariationsMatrix.AddQuantity(lngVariationMatrixID, decQuantity); }
                // July 26, 2011: change the above codes to the following
                clsProduct.AddQuantity(clsPODetails.BranchID, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.ADD_PURCHASE) + " @ " + decUnitCost.ToString("#,##0.#0") + "/" + strProductUnitCode, DateTime.Now, clsPODetails.PONo, clsPODetails.PurchaserName);

                /*******************************************
				 * Update Purchasing Information
                 * 
                 * 30May2013 Include variation in the package.
				 * ****************************************/
                int iBaseUnitID = clsProduct.get_BaseUnitID(lngProductID);
                if (iBaseUnitID != intProductUnitID)
                {
                    clsProduct.UpdatePurchasing(lngProductID, lngVariationMatrixID, clsPODetails.SupplierID, iBaseUnitID, (decItemQuantity * decUnitCost) / decQuantity);
                }
                clsProduct.UpdatePurchasing(lngProductID, lngVariationMatrixID, clsPODetails.SupplierID, intProductUnitID, decUnitCost);

				/*******************************************
				 * Add to Inventory Analysis
				 * ****************************************/
				clsInventoryDetails = new InventoryDetails();
                clsInventoryDetails.BranchID = clsPODetails.BranchID;
				clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
				clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
				clsInventoryDetails.PostingDate = clsPODetails.DeliveryDate;
				clsInventoryDetails.ReferenceNo = clsPODetails.PONo;
				clsInventoryDetails.ContactID = clsPODetails.SupplierID;
				clsInventoryDetails.ContactCode = clsPODetails.SupplierCode;
                clsInventoryDetails.ProductID = lngProductID;
                clsInventoryDetails.ProductCode = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                clsInventoryDetails.MatrixDescription = strMatrixDescription;
				clsInventoryDetails.PurchaseQuantity = decQuantity;
                clsInventoryDetails.PurchaseCost = decItemCost - decVAT;
                clsInventoryDetails.PurchaseVAT = decItemCost;	// Purchase Cost with VAT

				clsInventory.Insert(clsInventoryDetails);

                /*******************************************
				 * Added Jan 1, 2010 4:20PM
                 * Update Selling Information when PO is posted
				 * ****************************************/
                clsProduct.UpdateSellingPrice(lngProductID, lngVariationMatrixID, clsPODetails.SupplierID, intProductUnitID, Convert.ToDecimal(dr["SellingPrice"]), -1, -1, -1, -1, -1);

                /*******************************************
				 * Added Mar 8, 2010 4:20PM
                 * Update the purchase price history to check who has the lowest price.
				 * ****************************************/
                ProductPurchasePriceHistoryDetails clsProductPurchasePriceHistoryDetails = new ProductPurchasePriceHistoryDetails();
                clsProductPurchasePriceHistoryDetails.ProductID = lngProductID;
                clsProductPurchasePriceHistoryDetails.MatrixID = lngVariationMatrixID;
                clsProductPurchasePriceHistoryDetails.SupplierID = clsPODetails.SupplierID;
                clsProductPurchasePriceHistoryDetails.PurchasePrice = decUnitCost;
                clsProductPurchasePriceHistoryDetails.PurchaseDate = clsPODetails.PODate;
                clsProductPurchasePriceHistoryDetails.Remarks = clsPODetails.PONo;
                clsProductPurchasePriceHistoryDetails.PurchaserName = clsPODetails.PurchaserName;
                ProductPurchasePriceHistory clsProductPurchasePriceHistory = new ProductPurchasePriceHistory(base.Connection, base.Transaction);
                clsProductPurchasePriceHistory.AddToList(clsProductPurchasePriceHistoryDetails);
			}
			//myReader.Close();

		}
コード例 #10
0
ファイル: Closing.cs プロジェクト: marioricci/erp-luma
		private void AddItemToInventory(long ClosingID)
		{

			ClosingDetails clsClosingDetails = Details(ClosingID);
			ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
			ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

			ClosingItem clsClosingItem = new ClosingItem(base.Connection, base.Transaction);
			ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
			Products clsProduct = new Products(base.Connection, base.Transaction);
			ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);

            Inventory clsInventory = new Inventory(base.Connection, base.Transaction);

			MySqlDataReader myReader = clsClosingItem.List(ClosingID, "ClosingItemID", SortOption.Ascending);

			while (myReader.Read())
			{
                long lngProductID = myReader.GetInt64("ProductID");
				int intProductUnitID = myReader.GetInt16("ProductUnitID");

				decimal decItemQuantity = myReader.GetDecimal("Quantity");
                decimal decQuantity = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long lngMatrixID = myReader.GetInt64("VariationMatrixID");
				string strMatrixDescription = "" + myReader["MatrixDescription"].ToString();
				string strProductCode = "" + myReader["ProductCode"].ToString();
				decimal decUnitCost = myReader.GetDecimal("UnitCost");
				decimal decItemCost = myReader.GetDecimal("Amount");
				decimal decVAT = myReader.GetDecimal("VAT");

				/*******************************************
				 * Update Purchasing Information
				 * ****************************************/
                clsProduct.UpdatePurchasing(lngProductID, lngMatrixID, clsClosingDetails.SupplierID, intProductUnitID, (decItemQuantity * decUnitCost) / decQuantity);

                ///*******************************************
                // * Add to Inventory
                // * ****************************************/
                //clsProduct.AddQuantity(ProductID, Quantity);
                //if (VariationMatrixID != 0)
                //{ clsProductVariationsMatrix.AddQuantity(VariationMatrixID, Quantity);}
                // July 26, 2011: change the above codes to the following
                clsProduct.AddQuantity(clsClosingDetails.BranchID, lngProductID, lngMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.ADD_PURCHASE) + " @ " + decUnitCost.ToString("#,##0.#0"), DateTime.Now, clsClosingDetails.ClosingNo, clsClosingDetails.TransferredByID.ToString());

				/*******************************************
				 * Add to Inventory Analysis
				 * ****************************************/
				InventoryDetails clsInventoryDetails = new InventoryDetails();
				clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
				clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
				clsInventoryDetails.PostingDate = clsClosingDetails.DeliveryDate;
				clsInventoryDetails.ReferenceNo = clsClosingDetails.ClosingNo;
				clsInventoryDetails.ContactID = clsClosingDetails.SupplierID;
				clsInventoryDetails.ContactCode = clsClosingDetails.SupplierCode;
                clsInventoryDetails.ProductID = lngProductID;
				clsInventoryDetails.ProductCode = strProductCode;
				clsInventoryDetails.VariationMatrixID = lngMatrixID;
				clsInventoryDetails.MatrixDescription = strMatrixDescription;
				clsInventoryDetails.ClosingQuantity = decQuantity;
				clsInventoryDetails.ClosingCost = decItemCost - decVAT;
				clsInventoryDetails.ClosingVAT = decItemCost;	// Closing Cost with VAT

				clsInventory.Insert(clsInventoryDetails);

			}
			myReader.Close();

		}
コード例 #11
0
        private void AddItemToInventory(long WBranchTransferID)
        {
            WBranchTransferDetails clsWBranchTransferDetails = Details(WBranchTransferID);
            ERPConfig        clsERPConfig        = new ERPConfig(base.Connection, base.Transaction);
            ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

            WBranchTransferItem clsWBranchTransferItem = new WBranchTransferItem(base.Connection, base.Transaction);
            ProductUnit         clsProductUnit         = new ProductUnit(base.Connection, base.Transaction);
            Products            clsProduct             = new Products(base.Connection, base.Transaction);

            Inventory        clsInventory = new Inventory(base.Connection, base.Transaction);
            InventoryDetails clsInventoryDetails;

            System.Data.DataTable dt = clsWBranchTransferItem.ListAsDataTable(WBranchTransferID, "WBranchTransferItemID", SortOption.Ascending);

            foreach (System.Data.DataRow dr in dt.Rows)
            {
                long lngProductID     = Int64.Parse(dr["ProductID"].ToString());
                int  intProductUnitID = Int16.Parse(dr["ProductUnitID"].ToString());

                decimal decItemQuantity = decimal.Parse(dr["Quantity"].ToString());
                decimal decQuantity     = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long    lngVariationMatrixID = Int64.Parse(dr["VariationMatrixID"].ToString());
                string  strMatrixDescription = "" + dr["MatrixDescription"].ToString();
                string  strProductCode       = "" + dr["ProductCode"].ToString();
                string  strProductUnitCode   = "" + dr["ProductUnitCode"].ToString();
                decimal decUnitCost          = decimal.Parse(dr["UnitCost"].ToString());
                decimal decItemCost          = decimal.Parse(dr["Amount"].ToString());
                decimal decVAT = decimal.Parse(dr["VAT"].ToString());

                /*******************************************
                 * Subtract BranchIDFrom then Add to BranchIDTo -- Inventory
                 * ****************************************/
                clsProduct.SubtractQuantity(clsWBranchTransferDetails.BranchIDFrom, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.DEDUCT_BRANCH_TRANSFER_FROM) + " " + clsWBranchTransferDetails.BranchCodeFrom + " @ " + decUnitCost.ToString("#,##0.#0") + "/" + strProductUnitCode, DateTime.Now, clsWBranchTransferDetails.WBranchTransferNo, clsWBranchTransferDetails.TransferrerName);
                clsProduct.AddQuantity(clsWBranchTransferDetails.BranchIDTo, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.ADD_BRANCH_TRANSFER_TO) + " " + clsWBranchTransferDetails.BranchCodeTo + " @ " + decUnitCost.ToString("#,##0.#0") + "/" + strProductUnitCode, DateTime.Now, clsWBranchTransferDetails.WBranchTransferNo, clsWBranchTransferDetails.TransferrerName);

                /*******************************************
                 * Add to Inventory Analysis
                 * ****************************************/
                clsInventoryDetails = new InventoryDetails();
                clsInventoryDetails.PostingDateFrom   = clsERPConfigDetails.PostingDateFrom;
                clsInventoryDetails.PostingDateTo     = clsERPConfigDetails.PostingDateTo;
                clsInventoryDetails.PostingDate       = clsWBranchTransferDetails.DeliveryDate;
                clsInventoryDetails.ReferenceNo       = clsWBranchTransferDetails.WBranchTransferNo;
                clsInventoryDetails.ContactID         = Constants.C_RETAILPLUS_SUPPLIERID;
                clsInventoryDetails.ContactCode       = Constants.C_RETAILPLUS_SUPPLIER;
                clsInventoryDetails.ProductID         = lngProductID;
                clsInventoryDetails.ProductCode       = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                clsInventoryDetails.MatrixDescription = strMatrixDescription;

                clsInventoryDetails.PurchaseCost = decItemCost - decVAT;
                clsInventoryDetails.PurchaseVAT  = decItemCost; // Purchase Cost with VAT

                // insert into branchid from with minus quantity
                clsInventoryDetails.BranchID         = clsWBranchTransferDetails.BranchIDFrom;
                clsInventoryDetails.PurchaseQuantity = -decQuantity;
                clsInventory.Insert(clsInventoryDetails);

                // insert into branchid to with add quantity
                clsInventoryDetails.BranchID         = clsWBranchTransferDetails.BranchIDTo;
                clsInventoryDetails.PurchaseQuantity = decQuantity;
                clsInventory.Insert(clsInventoryDetails);
            }
        }
コード例 #12
0
ファイル: Stock.cs プロジェクト: marioricci/erp-luma
        /// <summary>
        /// Jul 28, 2011 : Lemu
        //  - Remove the adding/subtracting and SynchronizeQuantity in clsProductVariationsMatrix,
        //    already included in the new AddQuantity and SubtractQuantity.
        /// </summary>
        /// <param name="Details"></param>
        /// <param name="StockDirection"></param>
        /// <returns></returns>
		public Int64 AddItem(int BranchID, string TransactionNo, string CreatedBy, StockItemDetails Details, StockDirections StockDirection)
		{
			try  
			{
				StockItem clsStockItem = new StockItem(base.Connection, base.Transaction);
				Int64 StockItemID = clsStockItem.Insert(Details);

				ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
				decimal Quantity = clsProductUnit.GetBaseUnitValue(Details.ProductID, Details.ProductUnitID, Details.Quantity);
                string strRemarks = string.Empty;

				Products clsProduct = new Products(base.Connection, base.Transaction);
				if (StockDirection == StockDirections.Decrement)
                {
                    strRemarks = Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.DEDUCT_STOCK_INVENTORY) + " " + Details.Remarks;
                    clsProduct.SubtractQuantity(BranchID, Details.ProductID, Details.VariationMatrixID, Quantity, strRemarks, Details.StockDate, TransactionNo, CreatedBy);	
                }
				else
                {
                    strRemarks = Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.ADD_STOCK_INVENTORY) + " " + Details.Remarks;
                    clsProduct.AddQuantity(BranchID, Details.ProductID, Details.VariationMatrixID, Quantity, strRemarks, Details.StockDate, TransactionNo, CreatedBy);	
                }

                // Removed
                //ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);
                //if (Details.VariationMatrixID != 0)
                //{
                //    if (StockDirection == StockDirections.Decrement)
                //    {	clsProductVariationsMatrix.SubtractQuantity(Details.VariationMatrixID, Quantity);	}
                //    else
                //    {	clsProductVariationsMatrix.AddQuantity(Details.VariationMatrixID, Quantity);	}

                //    clsProductVariationsMatrix.SynchronizeQuantity(Details.ProductID);
                //}
				
				return StockItemID;
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
コード例 #13
0
ファイル: SOReturns.cs プロジェクト: marioricci/erp-luma
		private void AddItemToInventory(long CreditMemoID)
		{

			SOReturnDetails clsSOReturnDetails = Details(CreditMemoID);
            ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
			ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

			SOReturnItems clsSOReturnItems = new SOReturnItems(base.Connection, base.Transaction);
			ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
			Products clsProduct = new Products(base.Connection, base.Transaction);
			ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);

            Inventory clsInventory = new Inventory(base.Connection, base.Transaction);

            System.Data.DataTable dt = clsSOReturnItems.ListAsDataTable(CreditMemoID);

            foreach (System.Data.DataRow dr in dt.Rows)
			{
                long lngProductID = long.Parse(dr["ProductID"].ToString());
                int intProductUnitID = int.Parse(dr["ProductUnitID"].ToString());

                decimal decItemQuantity = decimal.Parse(dr["Quantity"].ToString());
                decimal decQuantity = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long lngVariationMatrixID = long.Parse(dr["VariationMatrixID"].ToString());
                string strMatrixDescription = "" + dr["MatrixDescription"].ToString();
                string strProductCode = "" + dr["ProductCode"].ToString();
                decimal decUnitCost = decimal.Parse(dr["UnitCost"].ToString());
                decimal decItemCost = decimal.Parse(dr["Amount"].ToString());
                decimal decVAT = decimal.Parse(dr["VAT"].ToString());

				/*******************************************
				 * Add from Inventory
				 * ****************************************/
				// clsProduct.AddQuantity(ProductID, Quantity);
				// if (VariationMatrixID != 0){ clsProductVariationsMatrix.AddQuantity(VariationMatrixID, Quantity); }
                // July 28, 2011: change the above codes to the following
                clsProduct.AddQuantity(clsSOReturnDetails.BranchID, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.ADD_SALES_RETURN), DateTime.Now, clsSOReturnDetails.CNNo, clsSOReturnDetails.SellerName);

				/*******************************************
				 * Add to Inventory Analysis
				 * ****************************************/
				InventoryDetails clsInventoryDetails = new InventoryDetails();
				clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
				clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
				clsInventoryDetails.PostingDate = clsSOReturnDetails.PostingDate;
				clsInventoryDetails.ReferenceNo = clsSOReturnDetails.CNNo;
				clsInventoryDetails.ContactID = clsSOReturnDetails.CustomerID;
				clsInventoryDetails.ContactCode = clsSOReturnDetails.CustomerCode;
                clsInventoryDetails.ProductID = lngProductID;
				clsInventoryDetails.ProductCode = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
				clsInventoryDetails.MatrixDescription = strMatrixDescription;
                clsInventoryDetails.SReturnQuantity = decQuantity;
				clsInventoryDetails.SReturnCost = decItemCost - decVAT;
				clsInventoryDetails.SReturnVAT = decItemCost;	//Purchase Return with VAT

				clsInventory.Insert(clsInventoryDetails);

			}
            //myReader.Close();

		}
コード例 #14
0
ファイル: TransferOut.cs プロジェクト: marioricci/erp-luma
        private void SubtractItemFromInventory(long TransferOutID)
        {

            TransferOutDetails clsTransferOutDetails = Details(TransferOutID);
            ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
            ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

            TransferOutItem clsTransferOutItem = new TransferOutItem(base.Connection, base.Transaction);
            ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
            Products clsProduct = new Products(base.Connection, base.Transaction);
            ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);
            ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);
            MatrixPackage clsMatrixPackage = new MatrixPackage(base.Connection, base.Transaction);

            Inventory clsInventory = new Inventory(base.Connection, base.Transaction);
            InventoryDetails clsInventoryDetails;

            //MatrixPackagePriceHistoryDetails clsMatrixPackagePriceHistoryDetails;
            //ProductPackagePriceHistoryDetails clsProductPackagePriceHistoryDetails;

            System.Data.DataTable dt = clsTransferOutItem.ListAsDataTable(TransferOutID, "TransferOutItemID", SortOption.Ascending);

            foreach (System.Data.DataRow dr in dt.Rows)
            {
                long lngProductID = long.Parse(dr["ProductID"].ToString());
                int intProductUnitID = int.Parse(dr["ProductUnitID"].ToString());

                decimal decItemQuantity = decimal.Parse(dr["Quantity"].ToString());
                decimal decQuantity = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long lngVariationMatrixID = long.Parse(dr["VariationMatrixID"].ToString());
                string strMatrixDescription = "" + dr["MatrixDescription"].ToString();
                string strProductCode = "" + dr["ProductCode"].ToString();
                decimal decUnitCost = decimal.Parse(dr["UnitCost"].ToString());
                decimal decItemCost = decimal.Parse(dr["Amount"].ToString());
                decimal decVAT = decimal.Parse(dr["VAT"].ToString());

                ///*******************************************
                // * Add in the Purchase Price History
                // * ****************************************/
                //if (lngVariationMatrixID != 0)
                //{
                //    // Update MatrixPackagePriceHistory first to get the history
                //    clsMatrixPackagePriceHistoryDetails = new MatrixPackagePriceHistoryDetails();
                //    clsMatrixPackagePriceHistoryDetails.UID = clsTransferOutDetails.TransferrerID;
                //    clsMatrixPackagePriceHistoryDetails.PackageID = clsMatrixPackage.GetPackageID(lngVariationMatrixID, intProductUnitID);
                //    clsMatrixPackagePriceHistoryDetails.ChangeDate = DateTime.Now;
                //    clsMatrixPackagePriceHistoryDetails.PurchasePrice = (decItemQuantity * decUnitCost) / decQuantity;
                //    clsMatrixPackagePriceHistoryDetails.Price = -1;
                //    clsMatrixPackagePriceHistoryDetails.VAT = -1;
                //    clsMatrixPackagePriceHistoryDetails.EVAT = -1;
                //    clsMatrixPackagePriceHistoryDetails.LocalTax = -1;
                //    clsMatrixPackagePriceHistoryDetails.Remarks = "Based on TransferOut #: " + clsTransferOutDetails.TransferOutNo;
                //    MatrixPackagePriceHistory clsMatrixPackagePriceHistory = new MatrixPackagePriceHistory(base.Connection, base.Transaction);
                //    clsMatrixPackagePriceHistory.Insert(clsMatrixPackagePriceHistoryDetails);
                //}
                //else
                //{
                //    // Update ProductPackagePriceHistory first to get the history
                //    clsProductPackagePriceHistoryDetails = new ProductPackagePriceHistoryDetails();
                //    clsProductPackagePriceHistoryDetails.UID = clsTransferOutDetails.TransferrerID;
                //    clsProductPackagePriceHistoryDetails.PackageID = clsProductPackage.GetPackageID(lngProductID, intProductUnitID);
                //    clsProductPackagePriceHistoryDetails.ChangeDate = DateTime.Now;
                //    clsProductPackagePriceHistoryDetails.PurchasePrice = (decItemQuantity * decUnitCost) / decQuantity;
                //    clsProductPackagePriceHistoryDetails.Price = -1;
                //    clsProductPackagePriceHistoryDetails.VAT = -1;
                //    clsProductPackagePriceHistoryDetails.EVAT = -1;
                //    clsProductPackagePriceHistoryDetails.LocalTax = -1;
                //    clsProductPackagePriceHistoryDetails.Remarks = "Based on TransferOut #: " + clsTransferOutDetails.TransferOutNo;
                //    ProductPackagePriceHistory clsProductPackagePriceHistory = new ProductPackagePriceHistory(base.Connection, base.Transaction);
                //    clsProductPackagePriceHistory.Insert(clsProductPackagePriceHistoryDetails);
                //}

                /*******************************************
                 * Add to Inventory
                 * ****************************************/
                //clsProduct.AddQuantity(lngProductID, decQuantity);
                //if (lngVariationMatrixID != 0)
                //{
                //    clsProductVariationsMatrix.AddQuantity(lngVariationMatrixID, decQuantity);
                //}
                // July 26, 2011: change the above codes to the following
                clsProduct.SubtractQuantity(clsTransferOutDetails.BranchID, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.DEDUCT_TRANSFER_OUT), DateTime.Now, clsTransferOutDetails.TransferOutNo, clsTransferOutDetails.TransferrerName);

                ///*******************************************
                // * Update Purchasing Information
                // * ****************************************/
                //clsProduct.UpdatePurchasing(lngProductID, clsTransferOutDetails.SupplierID, intProductUnitID, (decItemQuantity * decUnitCost) / decQuantity);
                //if (lngVariationMatrixID != 0)
                //{
                //    clsProductVariationsMatrix.UpdatePurchasing(lngVariationMatrixID, clsTransferOutDetails.SupplierID, intProductUnitID, (decItemQuantity * decUnitCost) / decQuantity);
                //}

                /*******************************************
                 * Add to Inventory Analysis
                 * ****************************************/
                clsInventoryDetails = new InventoryDetails();
                clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
                clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
                clsInventoryDetails.PostingDate = clsTransferOutDetails.DeliveryDate;
                clsInventoryDetails.ReferenceNo = clsTransferOutDetails.TransferOutNo;
                clsInventoryDetails.ContactID = clsTransferOutDetails.SupplierID;
                clsInventoryDetails.ContactCode = clsTransferOutDetails.SupplierCode;
                clsInventoryDetails.ProductID = lngProductID;
                clsInventoryDetails.ProductCode = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                clsInventoryDetails.MatrixDescription = strMatrixDescription;
                clsInventoryDetails.TransferOutQuantity = decQuantity;
                clsInventoryDetails.TransferOutCost = decItemCost - decVAT;
                clsInventoryDetails.TransferOutVAT = decItemCost;	// TransferOut Cost with VAT

                clsInventory.Insert(clsInventoryDetails);

                /*******************************************
				 * Added April 28, 2010 4:20PM
                 * Update Selling Information when TransferOut is posted
				 * ****************************************/
                //clsProduct.UpdateSellingIncludingAllMatrixWithSameQuantityAndUnit(lngProductID, clsTransferOutDetails.SupplierID, intProductUnitID, decimal.Parse(myReader["SellingPrice");
                //if (lngVariationMatrixID != 0)
                //{
                //    clsProductVariationsMatrix.UpdateSellingWithSameQuantityAndUnit(lngVariationMatrixID, clsPODetails.SupplierID, intProductUnitID, decimal.Parse(myReader["SellingPrice");
                //}

                /*******************************************
				 * Added April 28, 2010 4:20PM
                 * Update the purchase price history to check who has the lowest price.
				 * ****************************************/
                //ProductPurchasePriceHistoryDetails clsProductPurchasePriceHistoryDetails = new ProductPurchasePriceHistoryDetails();
                //clsProductPurchasePriceHistoryDetails.ProductID = lngProductID;
                //clsProductPurchasePriceHistoryDetails.MatrixID = lngVariationMatrixID;
                //clsProductPurchasePriceHistoryDetails.SupplierID = clsTransferOutDetails.SupplierID;
                //clsProductPurchasePriceHistoryDetails.PurchasePrice = decUnitCost;
                //clsProductPurchasePriceHistoryDetails.PurchaseDate = clsTransferOutDetails.TransferOutDate;
                //clsProductPurchasePriceHistoryDetails.Remarks = clsTransferOutDetails.TransferOutNo;
                //ProductPurchasePriceHistory clsProductPurchasePriceHistory = new ProductPurchasePriceHistory(base.Connection, base.Transaction);
                //clsProductPurchasePriceHistory.AddToList(clsProductPurchasePriceHistoryDetails);
            }

        }
コード例 #15
0
ファイル: CreditMemo.cs プロジェクト: marioricci/erp-luma
        private void AddItemToInventory(long CreditMemoID)
        {

            CreditMemoDetails clsCreditMemoDetails = Details(CreditMemoID);
            ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
            ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

            CreditMemoItems clsCreditMemoItems = new CreditMemoItems(base.Connection, base.Transaction);
            ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
            Products clsProduct = new Products(base.Connection, base.Transaction);
            ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);

            Inventory clsInventory = new Inventory(base.Connection, base.Transaction);

            System.Data.DataTable dt = clsCreditMemoItems.ListAsDataTable(CreditMemoID);

            foreach (System.Data.DataRow dr in dt.Rows)
            {
                long lngProductID = long.Parse(dr["ProductID"].ToString());
                int intProductUnitID = int.Parse(dr["ProductUnitID"].ToString());

                decimal decItemQuantity = decimal.Parse(dr["Quantity"].ToString());
                decimal decQuantity = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long lngVariationMatrixID = long.Parse(dr["VariationMatrixID"].ToString());
                string strMatrixDescription = "" + dr["MatrixDescription"].ToString();
                string strProductCode = "" + dr["ProductCode"].ToString();
                decimal decUnitCost = decimal.Parse(dr["UnitCost"].ToString());
                decimal decItemCost = decimal.Parse(dr["Amount"].ToString());
                decimal decVAT = decimal.Parse(dr["VAT"].ToString());

                /*******************************************
                 * Do not Add to Inventory coz this is a Debit Memo and no effect on inventory
                 * ****************************************/

                /*******************************************
                 * Add to Inventory Analysis
                 * ****************************************/
                InventoryDetails clsInventoryDetails = new InventoryDetails();
                clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
                clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
                clsInventoryDetails.PostingDate = clsCreditMemoDetails.PostingDate;
                clsInventoryDetails.ReferenceNo = clsCreditMemoDetails.CNNo;
                clsInventoryDetails.ContactID = clsCreditMemoDetails.CustomerID;
                clsInventoryDetails.ContactCode = clsCreditMemoDetails.CustomerCode;
                clsInventoryDetails.ProductID = lngProductID;
                clsInventoryDetails.ProductCode = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                clsInventoryDetails.MatrixDescription = strMatrixDescription;
                clsInventoryDetails.SCreditQuantity = decQuantity;
                clsInventoryDetails.SCreditCost = decItemCost - decVAT;
                clsInventoryDetails.SCreditVAT = decItemCost;	//Sales Return with VAT

                clsInventory.Insert(clsInventoryDetails);

            }
            //myReader.Close();

        }