/// <summary> /// Saves the new receive doc entry from picklist detail. /// </summary> /// <param name="pld">The PLD.</param> /// <param name="userID">The user ID.</param> /// <param name="activityID">The new store ID.</param> /// <param name="newPhysicalStoreID">The new physical store ID.</param> /// <param name="convertedEthDate">The converted eth date.</param> /// <param name="supplierID">Activity or Store where it has Transfered from </param> /// <exception cref="System.Exception"></exception> internal void SaveNewReceiveDocEntryFromPicklistDetail(PickListDetail pld, int userID, int activityID, int newPhysicalStoreID, DateTime convertedEthDate,int receiptID,int? supplierID) { BLL.User user = new User(); user.LoadByPrimaryKey(userID); BLL.ReceiveDoc rdOriginal = new ReceiveDoc(); rdOriginal.LoadByPrimaryKey(pld.ReceiveDocID); //Now Save the receive doc entry this.AddNew(); this.SetColumn("BatchNo", pld.GetColumn("BatchNumber")); this.ItemID = pld.ItemID; if (supplierID != null) this.SupplierID = supplierID.Value; this.Quantity = pld.QuantityInBU; //this.Date= this.Date = convertedEthDate; this.SetColumn("ExpDate", rdOriginal.GetColumn("ExpDate")); this.Out = false; this.ReceivedBy = user.UserName; this.StoreID = activityID; SetColumn("LocalBatchNo", rdOriginal.GetColumn("LocalBatchNo")); this.RefNo = receiptID.ToString(); this.SetColumn("Cost", rdOriginal.GetColumn("Cost")); this.SetColumn("IsApproved", rdOriginal.GetColumn("IsApproved")); this.ManufacturerId = rdOriginal.ManufacturerId; this.QuantityLeft = this.Quantity; this.NoOfPack = pld.Packs; this.QtyPerPack = rdOriginal.QtyPerPack; this.EurDate = DateTimeHelper.ServerDateTime; this.SetColumn("SellingPrice", rdOriginal.GetColumn("SellingPrice")); this.SetColumn("UnitCost", rdOriginal.GetColumn("Cost")); this.SetColumn("Cost", rdOriginal.GetColumn("Cost")); this.SetColumn("PricePerPack", rdOriginal.GetColumn("Cost")); this.SetColumn("UnitID", rdOriginal.GetColumn("UnitID")); this.SetColumn("DeliveryNote", rdOriginal.GetColumn("DeliveryNote")); this.Confirmed = false; this.ConfirmedDateTime = DateTimeHelper.ServerDateTime; this.ReturnedStock = false; this.ReceiptID = receiptID; this.PhysicalStoreID = newPhysicalStoreID; PhysicalStore physicalStore = new PhysicalStore(); physicalStore.LoadByPrimaryKey(newPhysicalStoreID); this.InventoryPeriodID = physicalStore.CurrentInventoryPeriodID; this.SetColumn("Margin", rdOriginal.GetColumn("Margin")); this.InvoicedNoOfPack = pld.Packs; this.IsDamaged = (bool) rdOriginal.GetColumn("IsDamaged"); this.Save(); //Now Save the ReceiveDocConfirmation ReceiveDocConfirmation rdConf = new ReceiveDocConfirmation(); rdConf.AddNew(); rdConf.ReceiveDocID = this.ID; rdConf.ReceivedByUserID = userID; rdConf.ReceiptConfirmationStatusID = BLL.ReceiptConfirmationStatus.Constants.RECEIVE_ENTERED; rdConf.Save(); //Now Save the palletization. ReceivePallet rp = new ReceivePallet(); rp.AddNew(); rp.ReceivedQuantity = this.Quantity; rp.Balance = this.Quantity; rp.ReservedStock = 0; rp.ReceiveID = this.ID; PalletLocation pLocation = new PalletLocation(); pLocation.LoadFirstOrDefault(newPhysicalStoreID, int.Parse(BLL.StorageType.BulkStore)); if (pLocation.RowCount == 0) { throw new Exception("No locations created in the destination store. Please check if there are Bulk store pallet locations in the physical store."); } else { if (pLocation.IsColumnNull("PalletID")) { Pallet pallet = new Pallet(); pallet.AddNew(); pallet.PalletNo = BLL.Pallet.GetLastPanelNumber() + 1; pallet.StorageTypeID = int.Parse(BLL.StorageType.Free); pallet.Save(); pLocation.PalletID = pallet.ID; } rp.PalletID = pLocation.PalletID; rp.PalletLocationID = pLocation.ID; rp.BoxSize = 0; rp.IsOriginalReceive = true; rp.Save(); } }