public void CloneReceiveForErrorCorrection(int confirmationStatusID, ReceivePallet receivePallet, ReceiveDoc receiveDoc, decimal pack, User user, int itemId, int storeId, int receiptId, int manufacturerId, ItemUnit itemUnit, DateTime convertedEthDate, bool changeExpiryDate = false, DateTime?ExpiryDate = null, bool changeBatchNo = false, string batchNo = null) { var newReceiveDoc = receiveDoc.Clone(); newReceiveDoc.ItemID = itemId; if (changeBatchNo) { newReceiveDoc.BatchNo = batchNo; } if (changeExpiryDate) { if (ExpiryDate.HasValue) { newReceiveDoc.ExpDate = ExpiryDate.Value; } else { newReceiveDoc.SetColumnNull("ExpDate"); } } newReceiveDoc.ManufacturerId = manufacturerId; newReceiveDoc.SetColumn("UnitID", itemUnit.ID); newReceiveDoc.Quantity = pack * itemUnit.QtyPerUnit; newReceiveDoc.QuantityLeft = pack * itemUnit.QtyPerUnit; newReceiveDoc.NoOfPack = pack; newReceiveDoc.InvoicedNoOfPack = pack; newReceiveDoc.QtyPerPack = itemUnit.QtyPerUnit; newReceiveDoc.Date = convertedEthDate; newReceiveDoc.ReceivedBy = user.UserName; newReceiveDoc.StoreID = storeId; newReceiveDoc.RefNo = receiptId.ToString(); newReceiveDoc.EurDate = DateTimeHelper.ServerDateTime; newReceiveDoc.Confirmed = true; newReceiveDoc.ConfirmedDateTime = DateTimeHelper.ServerDateTime; newReceiveDoc.ReturnedStock = false; newReceiveDoc.ReceiptID = receiptId; newReceiveDoc.Save(); //Now Save the ReceiveDocConfirmation ReceiveDocConfirmation rdConf = new ReceiveDocConfirmation(); rdConf.AddNew(); rdConf.ReceiveDocID = newReceiveDoc.ID; rdConf.ReceivedByUserID = user.ID; rdConf.ReceiptConfirmationStatusID = confirmationStatusID; rdConf.Save(); ReceivePallet newReceivePallet = new ReceivePallet(); newReceivePallet.AddNew(); newReceivePallet.ReceiveID = newReceiveDoc.ID; newReceivePallet.ReceivedQuantity = pack * itemUnit.QtyPerUnit; newReceivePallet.Balance = pack * itemUnit.QtyPerUnit; newReceivePallet.ReservedStock = 0; newReceivePallet.BoxSize = 0; newReceivePallet.PalletID = receivePallet.PalletID; newReceivePallet.IsOriginalReceive = true; if (!receivePallet.IsColumnNull("PalletLocationID")) { newReceivePallet.PalletLocationID = receivePallet.PalletLocationID; } newReceivePallet.Save(); }
public ReceiveDoc CreateInventoryReceive(Inventory inventory, int receiptID, Inventory.QuantityType quantityType, DateTime ethiopianDate, User user) { ItemUnit itemUnit = new ItemUnit(); itemUnit.LoadByPrimaryKey(inventory.UnitID); ReceiveDoc receiveDoc = new ReceiveDoc(); receiveDoc.AddNew(); receiveDoc.ItemID = inventory.ItemID; receiveDoc.UnitID = inventory.UnitID; receiveDoc.ManufacturerId = inventory.ManufacturerID; receiveDoc.StoreID = inventory.ActivityID; receiveDoc.Date = ethiopianDate; receiveDoc.EurDate = DateTimeHelper.ServerDateTime; receiveDoc.PhysicalStoreID = inventory.PhysicalStoreID; receiveDoc.SetColumn("BatchNo", inventory.GetColumn("BatchNo")); decimal quantity = quantityType == Inventory.QuantityType.Sound ? inventory.InventorySoundQuantity : quantityType == Inventory.QuantityType.Damaged ? inventory.InventoryDamagedQuantity :inventory.InventoryExpiredQuantity; if (quantityType == Inventory.QuantityType.Damaged) { receiveDoc.ShortageReasonID = ShortageReasons.Constants.DAMAGED; } receiveDoc.Quantity = receiveDoc.QuantityLeft = quantity * itemUnit.QtyPerUnit; receiveDoc.NoOfPack = receiveDoc.InvoicedNoOfPack = quantity; receiveDoc.QtyPerPack = itemUnit.QtyPerUnit; receiveDoc.SetColumn("ExpDate", inventory.GetColumn("ExpiryDate")); receiveDoc.Out = false; receiveDoc.ReceivedBy = user.UserName; receiveDoc.StoreID = inventory.ActivityID; receiveDoc.RefNo = "BeginningBalance"; decimal cost = 0; decimal margin = 0; if (!inventory.IsColumnNull("Cost")) { cost = inventory.Cost; } if (!inventory.IsColumnNull("Margin")) { margin = inventory.Margin; } receiveDoc.Cost = Convert.ToDouble(cost); receiveDoc.PricePerPack = Convert.ToDouble(cost); receiveDoc.UnitCost = cost; receiveDoc.Margin = Convert.ToDouble(margin); receiveDoc.SellingPrice = Convert.ToDouble(BLL.Settings.IsCenter ? cost : cost * (1 + margin)); receiveDoc.SupplierID = 2; //TODO: HARDCODE WARNING WARNING WARNING receiveDoc.DeliveryNote = false; receiveDoc.Confirmed = true; receiveDoc.ConfirmedDateTime = DateTimeHelper.ServerDateTime; receiveDoc.ReturnedStock = false; receiveDoc.ReceiptID = receiptID; receiveDoc.RefNo = "BeginningBalance"; receiveDoc.InventoryPeriodID = inventory.InventoryPeriodID; receiveDoc.IsDamaged = (quantityType == Inventory.QuantityType.Damaged || quantityType == Inventory.QuantityType.Expired); receiveDoc.Save(); //Now Save the ReceiveDocConfirmation ReceiveDocConfirmation rdConf = new ReceiveDocConfirmation(); rdConf.AddNew(); rdConf.ReceiveDocID = receiveDoc.ID; rdConf.ReceivedByUserID = user.ID; rdConf.ReceiptConfirmationStatusID = ReceiptConfirmationStatus.Constants.RECEIVE_QUANTITY_CONFIRMED; rdConf.Save(); //TODO: Create Receive Pallet Here PalletLocation palletLocation = new PalletLocation(); palletLocation.LoadByPrimaryKey(quantityType != Inventory.QuantityType.Damaged ? inventory.PalletLocationID : inventory.DamagedPalletLocationID); ReceivePallet receivePallet = new ReceivePallet(); receivePallet.AddNew(); receivePallet.Balance = quantity * itemUnit.QtyPerUnit; receivePallet.ReceivedQuantity = quantity * itemUnit.QtyPerUnit; receivePallet.ReservedStock = 0; receivePallet.ReceiveID = receiveDoc.ID; if (palletLocation.IsColumnNull("PalletID")) { Pallet pallet = new Pallet(); pallet.AddNew(); pallet.Save(); palletLocation.PalletID = pallet.ID; palletLocation.Save(); } receivePallet.PalletID = palletLocation.PalletID; receivePallet.PalletLocationID = palletLocation.ID; receivePallet.BoxSize = 0; receivePallet.IsOriginalReceive = true; receivePallet.Save(); return(receiveDoc); }
private ReceiveDoc CreateReceiveDocForInventory(Inventory inventory, int confirmationStatusID, decimal foundQty, int receiptID, DateTime convertedEthDate, User user, string remark) { ReceiveDoc newReceiveDoc = new ReceiveDoc(); newReceiveDoc.AddNew(); newReceiveDoc.SetColumn("BatchNo", inventory.GetColumn("BatchNo")); newReceiveDoc.ItemID = inventory.ItemID; newReceiveDoc.ManufacturerId = inventory.ManufacturerID; newReceiveDoc.SetColumn("UnitID", inventory.UnitID); if (!inventory.IsColumnNull("SupplierID")) { newReceiveDoc.SupplierID = inventory.SupplierID; } BLL.ItemUnit iu = new ItemUnit(); iu.LoadByPrimaryKey(inventory.UnitID); newReceiveDoc.Quantity = newReceiveDoc.QuantityLeft = foundQty * iu.QtyPerUnit; newReceiveDoc.NoOfPack = foundQty; newReceiveDoc.InvoicedNoOfPack = foundQty; newReceiveDoc.QtyPerPack = iu.QtyPerUnit; newReceiveDoc.Date = convertedEthDate; newReceiveDoc.SetColumn("ExpDate", inventory.GetColumn("ExpiryDate")); newReceiveDoc.Out = false; newReceiveDoc.ReceivedBy = user.UserName; newReceiveDoc.StoreID = inventory.ActivityID; newReceiveDoc.SetColumn("LocalBatchNo", inventory.GetColumn("BatchNo")); newReceiveDoc.RefNo = receiptID.ToString(); newReceiveDoc.SetColumn("Cost", inventory.GetColumn("Cost")); newReceiveDoc.SetColumn("IsApproved", DBNull.Value); newReceiveDoc.EurDate = DateTimeHelper.ServerDateTime; newReceiveDoc.SetColumn("SellingPrice", inventory.GetColumn("SellingPrice")); newReceiveDoc.SetColumn("UnitCost", inventory.GetColumn("Cost")); newReceiveDoc.SetColumn("Cost", inventory.GetColumn("Cost")); newReceiveDoc.SetColumn("PricePerPack", inventory.GetColumn("Cost")); newReceiveDoc.SetColumn("DeliveryNote", DBNull.Value); newReceiveDoc.Confirmed = true; newReceiveDoc.ConfirmedDateTime = DateTimeHelper.ServerDateTime; newReceiveDoc.ReturnedStock = false; newReceiveDoc.ReceiptID = receiptID; newReceiveDoc.SetColumn("Margin", inventory.GetColumn("Margin")); newReceiveDoc.RefNo = "BeginningBalance"; if (!string.IsNullOrEmpty(remark)) { newReceiveDoc.IsDamaged = false; } if (!string.IsNullOrEmpty(remark)) { newReceiveDoc.Remark = remark; } newReceiveDoc.Save(); //Now Save the ReceiveDocConfirmation ReceiveDocConfirmation rdConf = new ReceiveDocConfirmation(); rdConf.AddNew(); rdConf.ReceiveDocID = newReceiveDoc.ID; rdConf.ReceivedByUserID = user.ID; rdConf.ReceiptConfirmationStatusID = confirmationStatusID; rdConf.Save(); return(newReceiveDoc); }
private ReceiveDoc CreateReceiveDocForInventory(Inventory inventory, int confirmationStatusID, decimal foundQty, int receiptID, DateTime convertedEthDate, User user,string remark) { ReceiveDoc newReceiveDoc = new ReceiveDoc(); newReceiveDoc.AddNew(); newReceiveDoc.SetColumn("BatchNo", inventory.GetColumn("BatchNo")); newReceiveDoc.ItemID = inventory.ItemID; newReceiveDoc.ManufacturerId = inventory.ManufacturerID; newReceiveDoc.SetColumn("UnitID", inventory.UnitID); if (!inventory.IsColumnNull("SupplierID")) newReceiveDoc.SupplierID = inventory.SupplierID; BLL.ItemUnit iu = new ItemUnit(); iu.LoadByPrimaryKey(inventory.UnitID); newReceiveDoc.Quantity = newReceiveDoc.QuantityLeft = foundQty*iu.QtyPerUnit; newReceiveDoc.NoOfPack = foundQty; newReceiveDoc.InvoicedNoOfPack = foundQty; newReceiveDoc.QtyPerPack = iu.QtyPerUnit; newReceiveDoc.Date = convertedEthDate; newReceiveDoc.SetColumn("ExpDate", inventory.GetColumn("ExpiryDate")); newReceiveDoc.Out = false; newReceiveDoc.ReceivedBy = user.UserName; newReceiveDoc.StoreID = inventory.ActivityID; newReceiveDoc.SetColumn("LocalBatchNo", inventory.GetColumn("BatchNo")); newReceiveDoc.RefNo = receiptID.ToString(); newReceiveDoc.SetColumn("Cost", inventory.GetColumn("Cost")); newReceiveDoc.SetColumn("IsApproved", DBNull.Value); newReceiveDoc.EurDate = DateTimeHelper.ServerDateTime; newReceiveDoc.SetColumn("SellingPrice", inventory.GetColumn("SellingPrice")); newReceiveDoc.SetColumn("UnitCost", inventory.GetColumn("Cost")); newReceiveDoc.SetColumn("Cost", inventory.GetColumn("Cost")); newReceiveDoc.SetColumn("PricePerPack", inventory.GetColumn("Cost")); newReceiveDoc.SetColumn("DeliveryNote", DBNull.Value); newReceiveDoc.Confirmed = true; newReceiveDoc.ConfirmedDateTime = DateTimeHelper.ServerDateTime; newReceiveDoc.ReturnedStock = false; newReceiveDoc.ReceiptID = receiptID; newReceiveDoc.SetColumn("Margin", inventory.GetColumn("Margin")); newReceiveDoc.RefNo = "BeginningBalance"; if(!string.IsNullOrEmpty(remark)) newReceiveDoc.IsDamaged = false; if (!string.IsNullOrEmpty(remark)) { newReceiveDoc.Remark = remark; } newReceiveDoc.Save(); //Now Save the ReceiveDocConfirmation ReceiveDocConfirmation rdConf = new ReceiveDocConfirmation(); rdConf.AddNew(); rdConf.ReceiveDocID = newReceiveDoc.ID; rdConf.ReceivedByUserID = user.ID; rdConf.ReceiptConfirmationStatusID = confirmationStatusID; rdConf.Save(); return newReceiveDoc; }
public ReceiveDoc CreateInventoryReceive(Inventory inventory,int receiptID,Inventory.QuantityType quantityType,DateTime ethiopianDate,User user) { ItemUnit itemUnit = new ItemUnit(); itemUnit.LoadByPrimaryKey(inventory.UnitID); ReceiveDoc receiveDoc = new ReceiveDoc(); receiveDoc.AddNew(); receiveDoc.ItemID = inventory.ItemID; receiveDoc.UnitID = inventory.UnitID; receiveDoc.ManufacturerId = inventory.ManufacturerID; receiveDoc.StoreID = inventory.ActivityID; receiveDoc.Date = ethiopianDate; receiveDoc.EurDate = DateTimeHelper.ServerDateTime; receiveDoc.PhysicalStoreID = inventory.PhysicalStoreID; receiveDoc.SetColumn("BatchNo", inventory.GetColumn("BatchNo")); decimal quantity = quantityType == Inventory.QuantityType.Sound ? inventory.InventorySoundQuantity : quantityType == Inventory.QuantityType.Damaged ? inventory.InventoryDamagedQuantity :inventory.InventoryExpiredQuantity; if(quantityType == Inventory.QuantityType.Damaged) receiveDoc.ShortageReasonID = ShortageReasons.Constants.DAMAGED; receiveDoc.Quantity = receiveDoc.QuantityLeft = quantity * itemUnit.QtyPerUnit; receiveDoc.NoOfPack = receiveDoc.InvoicedNoOfPack = quantity; receiveDoc.QtyPerPack = itemUnit.QtyPerUnit; receiveDoc.SetColumn("ExpDate", inventory.GetColumn("ExpiryDate")); receiveDoc.Out = false; receiveDoc.ReceivedBy = user.UserName; receiveDoc.StoreID = inventory.ActivityID; receiveDoc.RefNo = "BeginningBalance"; decimal cost = 0; decimal margin = 0; if (!inventory.IsColumnNull("Cost")) { cost = inventory.Cost; } if(!inventory.IsColumnNull("Margin")) { margin = inventory.Margin; } receiveDoc.Cost = Convert.ToDouble(cost); receiveDoc.PricePerPack = Convert.ToDouble(cost); receiveDoc.UnitCost = cost; receiveDoc.Margin = Convert.ToDouble(margin); receiveDoc.SellingPrice = Convert.ToDouble(BLL.Settings.IsCenter ? cost : cost * (1 + margin)); receiveDoc.SupplierID = 2; //TODO: HARDCODE WARNING WARNING WARNING receiveDoc.DeliveryNote = false; receiveDoc.Confirmed = true; receiveDoc.ConfirmedDateTime = DateTimeHelper.ServerDateTime; receiveDoc.ReturnedStock = false; receiveDoc.ReceiptID = receiptID; receiveDoc.RefNo = "BeginningBalance"; receiveDoc.InventoryPeriodID = inventory.InventoryPeriodID; receiveDoc.IsDamaged = (quantityType == Inventory.QuantityType.Damaged || quantityType == Inventory.QuantityType.Expired); receiveDoc.Save(); //Now Save the ReceiveDocConfirmation ReceiveDocConfirmation rdConf = new ReceiveDocConfirmation(); rdConf.AddNew(); rdConf.ReceiveDocID = receiveDoc.ID; rdConf.ReceivedByUserID = user.ID; rdConf.ReceiptConfirmationStatusID = ReceiptConfirmationStatus.Constants.RECEIVE_QUANTITY_CONFIRMED; rdConf.Save(); //TODO: Create Receive Pallet Here PalletLocation palletLocation = new PalletLocation(); palletLocation.LoadByPrimaryKey(quantityType != Inventory.QuantityType.Damaged ? inventory.PalletLocationID : inventory.DamagedPalletLocationID); ReceivePallet receivePallet = new ReceivePallet(); receivePallet.AddNew(); receivePallet.Balance = quantity * itemUnit.QtyPerUnit; receivePallet.ReceivedQuantity = quantity * itemUnit.QtyPerUnit; receivePallet.ReservedStock = 0; receivePallet.ReceiveID = receiveDoc.ID; if(palletLocation.IsColumnNull("PalletID")) { Pallet pallet = new Pallet(); pallet.AddNew(); pallet.Save(); palletLocation.PalletID = pallet.ID; palletLocation.Save(); } receivePallet.PalletID = palletLocation.PalletID; receivePallet.PalletLocationID =palletLocation.ID; receivePallet.BoxSize = 0; receivePallet.IsOriginalReceive = true; receivePallet.Save(); return receiveDoc; }
public void CloneReceiveForErrorCorrection(int confirmationStatusID, ReceivePallet receivePallet, ReceiveDoc receiveDoc, decimal pack, User user, int itemId, int storeId, int receiptId, int manufacturerId, ItemUnit itemUnit, DateTime convertedEthDate, bool changeExpiryDate = false, DateTime? ExpiryDate = null, bool changeBatchNo = false, string batchNo = null) { var newReceiveDoc = receiveDoc.Clone(); newReceiveDoc.ItemID = itemId; if (changeBatchNo) { newReceiveDoc.BatchNo = batchNo; } if (changeExpiryDate) { if (ExpiryDate.HasValue) { newReceiveDoc.ExpDate = ExpiryDate.Value; } else { newReceiveDoc.SetColumnNull("ExpDate"); } } newReceiveDoc.ManufacturerId = manufacturerId; newReceiveDoc.SetColumn("UnitID", itemUnit.ID); newReceiveDoc.Quantity = pack * itemUnit.QtyPerUnit; newReceiveDoc.QuantityLeft = pack * itemUnit.QtyPerUnit; newReceiveDoc.NoOfPack = pack; newReceiveDoc.InvoicedNoOfPack = pack; newReceiveDoc.QtyPerPack = itemUnit.QtyPerUnit; newReceiveDoc.Date = convertedEthDate; newReceiveDoc.ReceivedBy = user.UserName; newReceiveDoc.StoreID = storeId; newReceiveDoc.RefNo = receiptId.ToString(); newReceiveDoc.EurDate = DateTimeHelper.ServerDateTime; newReceiveDoc.Confirmed = true; newReceiveDoc.ConfirmedDateTime = DateTimeHelper.ServerDateTime; newReceiveDoc.ReturnedStock = false; newReceiveDoc.ReceiptID = receiptId; newReceiveDoc.Save(); //Now Save the ReceiveDocConfirmation ReceiveDocConfirmation rdConf = new ReceiveDocConfirmation(); rdConf.AddNew(); rdConf.ReceiveDocID = newReceiveDoc.ID; rdConf.ReceivedByUserID = user.ID; rdConf.ReceiptConfirmationStatusID = confirmationStatusID; rdConf.Save(); ReceivePallet newReceivePallet = new ReceivePallet(); newReceivePallet.AddNew(); newReceivePallet.ReceiveID = newReceiveDoc.ID; newReceivePallet.ReceivedQuantity = pack * itemUnit.QtyPerUnit; newReceivePallet.Balance = pack * itemUnit.QtyPerUnit; newReceivePallet.ReservedStock = 0; newReceivePallet.BoxSize = 0; newReceivePallet.PalletID = receivePallet.PalletID; newReceivePallet.IsOriginalReceive = true; if (!receivePallet.IsColumnNull("PalletLocationID")) { newReceivePallet.PalletLocationID = receivePallet.PalletLocationID; } newReceivePallet.Save(); }