public static DSS1_RetailerDriverStockOptimisation.BO.Response ImportImplementation(System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.StockOnHand> stocks) { string message = ""; foreach (var stock in stocks ?? Enumerable.Empty <DSS1_RetailerDriverStockOptimisation.BO.StockOnHand>()) { if ((stock?.Item == null || stock?.Warehouse == null)) { message = message + (stock?.Id ?? 0) + " ,"; continue; } var _var0 = stock?.Item?.SKU; DSS1_RetailerDriverStockOptimisation.BO.Item existingItem = new DSS1_RetailerDriverStockOptimisation.DAL.Repository().GetAsQueryable <DSS1_RetailerDriverStockOptimisation.BO.Item>((s) => s.SKU == _var0)?.FirstOrDefault(); var _var1 = stock?.Warehouse?.Code; DSS1_RetailerDriverStockOptimisation.BO.Warehouse existingWarehouse = new DSS1_RetailerDriverStockOptimisation.DAL.Repository().GetAsQueryable <DSS1_RetailerDriverStockOptimisation.BO.Warehouse>((w) => w.Code == _var1)?.FirstOrDefault(); if ((existingItem == null || existingWarehouse == null)) { message = message + (stock?.Id ?? 0) + " ,"; continue; } DSS1_RetailerDriverStockOptimisation.BO.StockOnHand newStock = new DSS1_RetailerDriverStockOptimisation.BO.StockOnHand(); newStock.Warehouse = existingWarehouse; newStock.Item = existingItem; newStock.Units = (stock?.Units ?? 0); newStock.StockOnHandDate = (stock?.StockOnHandDate ?? System.Data.SqlTypes.SqlDateTime.MinValue.Value); new DSS1_RetailerDriverStockOptimisation.DAL.Repository().Save <DSS1_RetailerDriverStockOptimisation.BO.StockOnHand>(newStock); } if (((((message == null || message == "")) == false))) { zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "API", DSS1_RetailerDriverStockOptimisation.Hubs.EventsHub.RaiseDebugMessage, "Error message: " + message); return(DSS1_RetailerDriverStockOptimisation.BO.ResponseExtensions.GenerateResponse("Failed", "Failed to import the entries with Ids " + message, "", "-1")); } return(DSS1_RetailerDriverStockOptimisation.BO.ResponseExtensions.GenerateResponse("Succeed", "All entries imported successfully.", "", "1")); }
public virtual void RemoveStockOnHands(StockOnHand __item) { if (__item != null) { __item.Agreement = null; } }
public virtual int _GetUniqueIdentifier() { var hashCode = 399326290; hashCode = hashCode * -1521134295 + (Id?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (TotalUnits?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (Description?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (Result?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (LeadTime?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (WeekDay?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (StockOnHandDate?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (StockOnHand?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (OrderQuantity?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (SalesQuantity?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (QuantitySalesForecast?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (StockOnHandDateFormatted?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (SupplierStock?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (QuantitySum?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (SalesForecastDate?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (SalesForecastDateFormatted?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (Threshold?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (OrderDate?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (OrderDateFormatted?.GetHashCode() ?? 0); hashCode = hashCode * -1521134295 + (RealOrderQuantity?.GetHashCode() ?? 0); return(hashCode); }
public virtual void InternalRemoveStockOnHands(StockOnHand __item) { if (__item == null) { return; } stockOnHands?.Remove(__item); }
public virtual void InternalAddStockOnHands(StockOnHand __item) { if (__item == null || disableInternalAdditions) { return; } stockOnHands?.Add(__item); }
public virtual void AddStockOnHands(StockOnHand __item) { if (__item == null) { return; } if (__item.Agreement != this) { __item.Agreement = this; } }
public virtual void SetStockOnHandsAt(StockOnHand __item, int __index) { if (__item == null) { stockOnHands[__index].Agreement = null; } else { stockOnHands[__index] = __item; if (__item.Agreement != this) { __item.Agreement = this; } } }
public virtual void AddAtIndexStockOnHands(int index, StockOnHand __item) { if (__item == null) { return; } stockOnHands?.Insert(index, __item); disableInternalAdditions = true; try { if (__item.Agreement != this) { __item.Agreement = this; } } finally { disableInternalAdditions = false; } }
/// <summary> /// Returns true if self and the provided entity have the same Id values /// and the Ids are not of the default Id value /// </summary> protected bool HasSameNonDefaultIdAs(StockOnHand compareTo) { return(!this.IsTransient() && !compareTo.IsTransient() && this.Id.Equals(compareTo.Id)); }
/// <summary> /// Copies the current object to a new instance /// </summary> /// <param name="deep">Copy members that refer to objects external to this class (not dependent)</param> /// <param name="copiedObjects">Objects that should be reused</param> /// <param name="asNew">Copy the current object as a new one, ready to be persisted, along all its members.</param> /// <param name="reuseNestedObjects">If asNew is true, this flag if set, forces the reuse of all external objects.</param> /// <param name="copy">Optional - An existing [StockOnHand] instance to use as the destination.</param> /// <returns>A copy of the object</returns> public virtual StockOnHand Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, StockOnHand copy = null) { if (copiedObjects == null) { copiedObjects = new Hashtable(); } if (copy == null && copiedObjects.Contains(this)) { return((StockOnHand)copiedObjects[this]); } copy = copy ?? new StockOnHand(); if (!asNew) { copy.TransientId = this.TransientId; copy.Id = this.Id; } copy.Units = this.Units; copy.CurrentInventoryDays = this.CurrentInventoryDays; copy.StockOnHandDate = this.StockOnHandDate; copy.LeadTime = this.LeadTime; copy.TargetInventoryDays = this.TargetInventoryDays; copy.FullTrackLoad = this.FullTrackLoad; copy.WDDays = this.WDDays; if (!copiedObjects.Contains(this)) { copiedObjects.Add(this, copy); } if (deep && this.agreement != null) { if (!copiedObjects.Contains(this.agreement)) { if (asNew && reuseNestedObjects) { copy.Agreement = this.Agreement; } else if (asNew) { copy.Agreement = this.Agreement.Copy(deep, copiedObjects, true); } else { copy.agreement = this.agreement.Copy(deep, copiedObjects, false); } } else { if (asNew) { copy.Agreement = (Agreement)copiedObjects[this.Agreement]; } else { copy.agreement = (Agreement)copiedObjects[this.Agreement]; } } } if (deep && this.warehouse != null) { if (!copiedObjects.Contains(this.warehouse)) { if (asNew && reuseNestedObjects) { copy.Warehouse = this.Warehouse; } else if (asNew) { copy.Warehouse = this.Warehouse.Copy(deep, copiedObjects, true); } else { copy.warehouse = this.warehouse.Copy(deep, copiedObjects, false); } } else { if (asNew) { copy.Warehouse = (Warehouse)copiedObjects[this.Warehouse]; } else { copy.warehouse = (Warehouse)copiedObjects[this.Warehouse]; } } } if (deep && this.item != null) { if (!copiedObjects.Contains(this.item)) { if (asNew && reuseNestedObjects) { copy.Item = this.Item; } else if (asNew) { copy.Item = this.Item.Copy(deep, copiedObjects, true); } else { copy.item = this.item.Copy(deep, copiedObjects, false); } } else { if (asNew) { copy.Item = (Item)copiedObjects[this.Item]; } else { copy.item = (Item)copiedObjects[this.Item]; } } } return(copy); }
public void Agreement_persistence_test() { DateTime now = DateTime.Now; // Get datetime without milliseconds now = new DateTime(now.Ticks - (now.Ticks % TimeSpan.TicksPerSecond), now.Kind); var _agreement_agreementstatuses_agreement = new DSS1_RetailerDriverStockOptimisation.BO.AgreementStatus { IssuedBy = "AgreementStatus_IssuedBy", Status = "AgreementStatus_Status", DateIssued = now, ApprovedBySonae = true, ApprovedBySupplier = true, InProgress = true, Active = true, UnderRevision = true, }; var _agreement_agreementstatuses_agreement2 = new DSS1_RetailerDriverStockOptimisation.BO.AgreementStatus { IssuedBy = "AgreementStatus_IssuedBy", Status = "AgreementStatus_Status", DateIssued = now, ApprovedBySonae = true, ApprovedBySupplier = true, InProgress = true, Active = true, UnderRevision = true, }; var _agreement_items_agreements = new DSS1_RetailerDriverStockOptimisation.BO.Item { SKU = "85c41988-a9ba-4eda-9414-d5e910f388a2Item_SKU", Description = "Item_Description", UPC = "Item_UPC", AvgDailyDemand = 222222.22M, PalletSize = 5412, SupplierPackSize = 2461, InnerPackSize = 5128, PalletType = "Item_PalletType", PalTI = 965, PalHI = 4274, UOM = "Item_UOM", }; var _agreement_items_agreements2 = new DSS1_RetailerDriverStockOptimisation.BO.Item { SKU = "1111", Description = "Item_Description", UPC = "Item_UPC", AvgDailyDemand = 222222.22M, PalletSize = 2720, SupplierPackSize = 6994, InnerPackSize = 6127, PalletType = "Item_PalletType", PalTI = 161, PalHI = 6362, UOM = "Item_UOM", }; var _agreement_supplier_agreements = new DSS1_RetailerDriverStockOptimisation.BO.Supplier { Code = "Supplier_Code", Name = "Supplier_Name", }; var _agreement_warehouses_agreements = new DSS1_RetailerDriverStockOptimisation.BO.Warehouse { Code = "Warehouse_Code", Description = "Warehouse_Description", FlowType = "Warehouse_FlowType", }; var _agreement_warehouses_agreements2 = new DSS1_RetailerDriverStockOptimisation.BO.Warehouse { Code = "Warehouse_Code", Description = "Warehouse_Description", FlowType = "Warehouse_FlowType", }; var _agreement_stockonhands_agreement = new DSS1_RetailerDriverStockOptimisation.BO.StockOnHand { Units = 3710, CurrentInventoryDays = 222222.22M, StockOnHandDate = now, LeadTime = "StockOnHand_LeadTime", TargetInventoryDays = 222222.22M, FullTrackLoad = true, WDDays = true, }; var _agreement_stockonhands_agreement2 = new DSS1_RetailerDriverStockOptimisation.BO.StockOnHand { Units = 1751, CurrentInventoryDays = 222222.22M, StockOnHandDate = now, LeadTime = "StockOnHand_LeadTime", TargetInventoryDays = 222222.22M, FullTrackLoad = true, WDDays = true, }; var _agreement_transportuncaps_agreement = new DSS1_RetailerDriverStockOptimisation.BO.TransportUnCap { UOP = "TransportUnCap_UOP", PercRound = 2222222222.22222M, Tuc1 = 2222222222.22222M, SplitOcInd = "TransportUnCap_SplitOcInd", Status = "TransportUnCap_Status", }; var _agreement_transportuncaps_agreement2 = new DSS1_RetailerDriverStockOptimisation.BO.TransportUnCap { UOP = "TransportUnCap_UOP", PercRound = 2222222222.22222M, Tuc1 = 2222222222.22222M, SplitOcInd = "TransportUnCap_SplitOcInd", Status = "TransportUnCap_Status", }; new PersistenceSpecification <DSS1_RetailerDriverStockOptimisation.BO.Agreement>(Session) .CheckProperty(p => p.FullTruckLoad, true) .CheckProperty(p => p.AgreementDocument, "Agreement_AgreementDocument") .CheckProperty(p => p.LeadTime, "Agreement_LeadTime") .CheckProperty(p => p.DateCreated, now) .CheckProperty(p => p.WDDeliveries, true) .CheckProperty(p => p.TargetInventoryDays, 6622) .CheckProperty(p => p.Profile, "Agreement_Profile") .CheckBag(p => p.AgreementStatuses, (new List <DSS1_RetailerDriverStockOptimisation.BO.AgreementStatus> { _agreement_agreementstatuses_agreement, _agreement_agreementstatuses_agreement2 })) .CheckBag(p => p.Items, (new List <DSS1_RetailerDriverStockOptimisation.BO.Item> { _agreement_items_agreements, _agreement_items_agreements2 })) .CheckReference(p => p.Supplier, _agreement_supplier_agreements) .CheckBag(p => p.Warehouses, (new List <DSS1_RetailerDriverStockOptimisation.BO.Warehouse> { _agreement_warehouses_agreements, _agreement_warehouses_agreements2 })) .CheckBag(p => p.StockOnHands, (new List <DSS1_RetailerDriverStockOptimisation.BO.StockOnHand> { _agreement_stockonhands_agreement, _agreement_stockonhands_agreement2 })) .CheckBag(p => p.TransportUnCaps, (new List <DSS1_RetailerDriverStockOptimisation.BO.TransportUnCap> { _agreement_transportuncaps_agreement, _agreement_transportuncaps_agreement2 })) .VerifyTheMappings(); }
public void Item_persistence_test() { DateTime now = DateTime.Now; // Get datetime without milliseconds now = new DateTime(now.Ticks - (now.Ticks % TimeSpan.TicksPerSecond), now.Kind); var _agreement_agreements_items = new DSS1_RetailerDriverStockOptimisation.BO.Agreement { FullTruckLoad = true, AgreementDocument = "Agreement_AgreementDocument", LeadTime = "Agreement_LeadTime", DateCreated = now, WDDeliveries = true, TargetInventoryDays = 4750, Profile = "Agreement_Profile", }; var _agreement_agreements_items2 = new DSS1_RetailerDriverStockOptimisation.BO.Agreement { FullTruckLoad = true, AgreementDocument = "Agreement_AgreementDocument", LeadTime = "Agreement_LeadTime", DateCreated = now, WDDeliveries = true, TargetInventoryDays = 6123, Profile = "Agreement_Profile", }; var _forecast_deliveryschedules_item = new DSS1_RetailerDriverStockOptimisation.BO.DeliverySchedule { LeadTime = 2384, Weekday = 2568, NameOfDay = "DeliverySchedule_NameOfDay", DBWeekday = 6397, }; var _forecast_deliveryschedules_item2 = new DSS1_RetailerDriverStockOptimisation.BO.DeliverySchedule { LeadTime = 8869, Weekday = 4507, NameOfDay = "DeliverySchedule_NameOfDay", DBWeekday = 5241, }; var _inventoryitem_inventoryitems_item = new DSS1_RetailerDriverStockOptimisation.BO.InventoryItem { CoverageDays = 4330, SafetyStock = 2511, Status = "InventoryItem_Status", }; var _inventoryitem_inventoryitems_item2 = new DSS1_RetailerDriverStockOptimisation.BO.InventoryItem { CoverageDays = 9286, SafetyStock = 1203, Status = "InventoryItem_Status", }; var _item_suppliercapacities_item = new DSS1_RetailerDriverStockOptimisation.BO.SupplierCapacity { DateOfStockUpdate = now, DailyProduction = 2651, Stock = 9044, }; var _item_suppliercapacities_item2 = new DSS1_RetailerDriverStockOptimisation.BO.SupplierCapacity { DateOfStockUpdate = now, DailyProduction = 5174, Stock = 8303, }; var _item_supplier_items = new DSS1_RetailerDriverStockOptimisation.BO.Supplier { Code = "Supplier_Code", Name = "Supplier_Name", }; var _item_businessunit_item = new DSS1_RetailerDriverStockOptimisation.BO.BusinessUnit { Number = 5353, Description = "BusinessUnit_Description", }; var _item_category_item = new DSS1_RetailerDriverStockOptimisation.BO.Category { Number = 6940, Description = "Category_Description", }; var _item_subcategory_item = new DSS1_RetailerDriverStockOptimisation.BO.SubCategory { Number = 2833, Description = "SubCategory_Description", }; var _item_baseunit_item = new DSS1_RetailerDriverStockOptimisation.BO.BaseUnit { Number = 988, Description = "BaseUnit_Description", }; var _minimumquantity_minimumquantity_item = new DSS1_RetailerDriverStockOptimisation.BO.MinimumQuantity { Country = "MinimumQuantity_Country", Quantity = 7287, }; var _notification_notifications_item = new DSS1_RetailerDriverStockOptimisation.BO.Notification { Message = "Notification_Message", TotalSupplierStock = 2248, OrderForecastQuantity = 4736, Diff = 1992, SalesForecastDate = now, CreatedBy = "Notification_CreatedBy", }; var _notification_notifications_item2 = new DSS1_RetailerDriverStockOptimisation.BO.Notification { Message = "Notification_Message", TotalSupplierStock = 9495, OrderForecastQuantity = 8902, Diff = 4283, SalesForecastDate = now, CreatedBy = "Notification_CreatedBy", }; var _pastorder_pastorders_item = new DSS1_RetailerDriverStockOptimisation.BO.PastOrder { OrderNumber = 9238, WrittenDate = now, NotBeforeDate = now, QuantityOrdered = 4814, ReceiveDate = now, QuantityReceived = 4466, Caller = "PastOrder_Caller", }; var _pastorder_pastorders_item2 = new DSS1_RetailerDriverStockOptimisation.BO.PastOrder { OrderNumber = 1424, WrittenDate = now, NotBeforeDate = now, QuantityOrdered = 4993, ReceiveDate = now, QuantityReceived = 246, Caller = "PastOrder_Caller", }; var _sale_itemsforecast_item = new DSS1_RetailerDriverStockOptimisation.BO.Sales { ForecastDate = now, Units = 1957, }; var _sale_itemsforecast_item2 = new DSS1_RetailerDriverStockOptimisation.BO.Sales { ForecastDate = now, Units = 1789, }; var _sla_slaleadtimes_item = new DSS1_RetailerDriverStockOptimisation.BO.SLALeadTime { AgreedLeadTime = 9208, RealLeadTime = 324, Percentage = 222222.22M, ItemDescription = "SLALeadTime_ItemDescription", DateFormatted = "SLALeadTime_DateFormatted", Threshold = 222222.22M, SLALeadDate = now, Month = 1777, MonthlyDelayed = 222222.22M, MontlhyOrders = 222222.22M, MonthlyPercentage = 222222.22M, }; var _sla_slaleadtimes_item2 = new DSS1_RetailerDriverStockOptimisation.BO.SLALeadTime { AgreedLeadTime = 5943, RealLeadTime = 7596, Percentage = 222222.22M, ItemDescription = "SLALeadTime_ItemDescription", DateFormatted = "SLALeadTime_DateFormatted", Threshold = 222222.22M, SLALeadDate = now, Month = 639, MonthlyDelayed = 222222.22M, MontlhyOrders = 222222.22M, MonthlyPercentage = 222222.22M, }; var _sla_sladeliveries_item = new DSS1_RetailerDriverStockOptimisation.BO.SLADelivery { OrderedQuantities = 222222.22M, DeliveredQuantities = 222222.22M, Percentage = 222222.22M, ItemDescription = "SLADelivery_ItemDescription", Threshold = 222222.22M, SLADate = now, DateFormatted = "SLADelivery_DateFormatted", Month = 396, }; var _sla_sladeliveries_item2 = new DSS1_RetailerDriverStockOptimisation.BO.SLADelivery { OrderedQuantities = 222222.22M, DeliveredQuantities = 222222.22M, Percentage = 222222.22M, ItemDescription = "SLADelivery_ItemDescription", Threshold = 222222.22M, SLADate = now, DateFormatted = "SLADelivery_DateFormatted", Month = 8494, }; var _stockonhand_stocksonhand_item = new DSS1_RetailerDriverStockOptimisation.BO.StockOnHand { Units = 5008, CurrentInventoryDays = 222222.22M, StockOnHandDate = now, LeadTime = "StockOnHand_LeadTime", TargetInventoryDays = 222222.22M, FullTrackLoad = true, WDDays = true, }; var _stockonhand_stocksonhand_item2 = new DSS1_RetailerDriverStockOptimisation.BO.StockOnHand { Units = 5380, CurrentInventoryDays = 222222.22M, StockOnHandDate = now, LeadTime = "StockOnHand_LeadTime", TargetInventoryDays = 222222.22M, FullTrackLoad = true, WDDays = true, }; new PersistenceSpecification <DSS1_RetailerDriverStockOptimisation.BO.Item>(Session) .CheckProperty(p => p.SKU, "e9a08b5a-a00f-45b3-a68b-adb86cb8602cItem_SKU") .CheckProperty(p => p.Description, "Item_Description") .CheckProperty(p => p.UPC, "Item_UPC") .CheckProperty(p => p.AvgDailyDemand, 222222.22M) .CheckProperty(p => p.PalletSize, 9011) .CheckProperty(p => p.SupplierPackSize, 9480) .CheckProperty(p => p.InnerPackSize, 7252) .CheckProperty(p => p.PalletType, "Item_PalletType") .CheckProperty(p => p.PalTI, 7518) .CheckProperty(p => p.PalHI, 4266) .CheckProperty(p => p.UOM, "Item_UOM") .CheckBag(p => p.Agreements, (new List <DSS1_RetailerDriverStockOptimisation.BO.Agreement> { _agreement_agreements_items, _agreement_agreements_items2 })) .CheckBag(p => p.DeliverySchedules, (new List <DSS1_RetailerDriverStockOptimisation.BO.DeliverySchedule> { _forecast_deliveryschedules_item, _forecast_deliveryschedules_item2 })) .CheckBag(p => p.InventoryItems, (new List <DSS1_RetailerDriverStockOptimisation.BO.InventoryItem> { _inventoryitem_inventoryitems_item, _inventoryitem_inventoryitems_item2 })) .CheckBag(p => p.SupplierCapacities, (new List <DSS1_RetailerDriverStockOptimisation.BO.SupplierCapacity> { _item_suppliercapacities_item, _item_suppliercapacities_item2 })) .CheckReference(p => p.Supplier, _item_supplier_items) .CheckReference(p => p.BusinessUnit, _item_businessunit_item) .CheckReference(p => p.Category, _item_category_item) .CheckReference(p => p.SubCategory, _item_subcategory_item) .CheckReference(p => p.BaseUnit, _item_baseunit_item) .CheckReference(p => p.MinimumQuantity, _minimumquantity_minimumquantity_item) .CheckBag(p => p.Notifications, (new List <DSS1_RetailerDriverStockOptimisation.BO.Notification> { _notification_notifications_item, _notification_notifications_item2 })) .CheckBag(p => p.PastOrders, (new List <DSS1_RetailerDriverStockOptimisation.BO.PastOrder> { _pastorder_pastorders_item, _pastorder_pastorders_item2 })) .CheckBag(p => p.ItemsForecast, (new List <DSS1_RetailerDriverStockOptimisation.BO.Sales> { _sale_itemsforecast_item, _sale_itemsforecast_item2 })) .CheckBag(p => p.SLALeadTimes, (new List <DSS1_RetailerDriverStockOptimisation.BO.SLALeadTime> { _sla_slaleadtimes_item, _sla_slaleadtimes_item2 })) .CheckBag(p => p.SLADeliveries, (new List <DSS1_RetailerDriverStockOptimisation.BO.SLADelivery> { _sla_sladeliveries_item, _sla_sladeliveries_item2 })) .CheckBag(p => p.StocksOnHand, (new List <DSS1_RetailerDriverStockOptimisation.BO.StockOnHand> { _stockonhand_stocksonhand_item, _stockonhand_stocksonhand_item2 })) .VerifyTheMappings(); }