From 05a4c8b95720a875fe8fecab9587ffd13f4eb504 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 31 Oct 2025 11:21:01 +0100 Subject: [PATCH] Ok prima versione costing resources completata --- .../Services/DataLayerServices.cs | 13 +-- Lux.API/Lux.API.csproj | 2 +- .../Components/Compo/Base/InputDecimal.razor | 59 +++++++++++ .../Components/Compo/Base/InputPercent.razor | 32 ++++++ .../Compo/JobTask/ResourceDetail.razor | 99 ++++++++++++++++--- .../Compo/JobTask/ResourceDetail.razor.cs | 1 + Lux.UI/Components/_Imports.razor | 1 + Lux.UI/Lux.UI.csproj | 2 +- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 11 files changed, 191 insertions(+), 24 deletions(-) create mode 100644 Lux.UI/Components/Compo/Base/InputDecimal.razor create mode 100644 Lux.UI/Components/Compo/Base/InputPercent.razor diff --git a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs index b894dd7f..658f1ba0 100644 --- a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs +++ b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs @@ -1,7 +1,11 @@ using EgwCoreLib.Lux.Core.RestPayload; using EgwCoreLib.Lux.Data.Controllers; -using EgwCoreLib.Lux.Data.DbModel.Utils; +using EgwCoreLib.Lux.Data.DbModel.Config; +using EgwCoreLib.Lux.Data.DbModel.Cost; +using EgwCoreLib.Lux.Data.DbModel.Items; using EgwCoreLib.Lux.Data.DbModel.Sales; +using EgwCoreLib.Lux.Data.DbModel.Task; +using EgwCoreLib.Lux.Data.DbModel.Utils; using EgwMultiEngineManager.Data; using Microsoft.Extensions.Configuration; using Newtonsoft.Json; @@ -12,14 +16,11 @@ using System.Collections.Generic; using System.ComponentModel.Design; using System.Diagnostics; using System.Linq; +using System.Resources; using System.Text; using System.Threading.Tasks; using static EgwCoreLib.Lux.Core.Enums; using static System.Runtime.InteropServices.JavaScript.JSType; -using EgwCoreLib.Lux.Data.DbModel.Items; -using EgwCoreLib.Lux.Data.DbModel.Config; -using EgwCoreLib.Lux.Data.DbModel.Task; -using EgwCoreLib.Lux.Data.DbModel.Cost; namespace EgwCoreLib.Lux.Data.Services { @@ -1204,7 +1205,7 @@ namespace EgwCoreLib.Lux.Data.Services public async Task ResourcesUpsertAsync(ResourceModel upsRec) { bool result = await dbController.ResourcesUpsertAsync(upsRec); - await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Resources"); + await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Resources:*"); return result; } diff --git a/Lux.API/Lux.API.csproj b/Lux.API/Lux.API.csproj index 6eb80564..23a2a325 100644 --- a/Lux.API/Lux.API.csproj +++ b/Lux.API/Lux.API.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 0.9.2510.3110 + 0.9.2510.3111 diff --git a/Lux.UI/Components/Compo/Base/InputDecimal.razor b/Lux.UI/Components/Compo/Base/InputDecimal.razor new file mode 100644 index 00000000..43c06592 --- /dev/null +++ b/Lux.UI/Components/Compo/Base/InputDecimal.razor @@ -0,0 +1,59 @@ +@using System.Globalization +@inherits InputBase + + + +@code { + /// + /// Number of decimal digits to display (default 3). + /// + [Parameter] public int Decimals { get; set; } = 3; + + /// + /// Step increment for the number input (default 0.001). + /// + [Parameter] public decimal Step { get; set; } = 0.001M; + + /// + /// Optional minimum value. + /// + [Parameter] public decimal? Min { get; set; } + + /// + /// Optional maximum value. + /// + [Parameter] public decimal? Max { get; set; } + + protected override string FormatValueAsString(decimal value) + { + return value.ToString($"F{Decimals}", CultureInfo.InvariantCulture); + } + + protected override bool TryParseValueFromString( + string value, + out decimal result, + out string validationErrorMessage) + { + if (decimal.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var parsed)) + { + result = Math.Round(parsed, Decimals); + validationErrorMessage = null; + return true; + } + + result = 0; + validationErrorMessage = "Invalid decimal number"; + return false; + } + + private void OnChange(ChangeEventArgs e) + { + CurrentValueAsString = e.Value?.ToString(); + } +} diff --git a/Lux.UI/Components/Compo/Base/InputPercent.razor b/Lux.UI/Components/Compo/Base/InputPercent.razor new file mode 100644 index 00000000..f710ec18 --- /dev/null +++ b/Lux.UI/Components/Compo/Base/InputPercent.razor @@ -0,0 +1,32 @@ +@inherits InputBase + + + +@code { + // Format the bound value as "10%" when rendering + protected override string FormatValueAsString(decimal value) + { + return value == 0 ? string.Empty : $"{value:P2}"; + } + + // Parse the user's input back into a decimal + protected override bool TryParseValueFromString( + string value, + out decimal result, + out string validationErrorMessage) + { + var cleaned = value?.Replace("%", "").Trim(); + + if (decimal.TryParse(cleaned, out var parsed)) + { + // se > 1 --> divido per 100... + result = parsed < 1 ? parsed : parsed / 100; + validationErrorMessage = null; + return true; + } + + result = 0; + validationErrorMessage = "Invalid percentage"; + return false; + } +} diff --git a/Lux.UI/Components/Compo/JobTask/ResourceDetail.razor b/Lux.UI/Components/Compo/JobTask/ResourceDetail.razor index 5e859847..c6c9afa9 100644 --- a/Lux.UI/Components/Compo/JobTask/ResourceDetail.razor +++ b/Lux.UI/Components/Compo/JobTask/ResourceDetail.razor @@ -17,7 +17,7 @@
-
+
Driver @CurrRecord.DriverNav.Name (@CurrRecord.DriverNav.Unit) @@ -72,7 +72,10 @@ } else { - +
+ + # +
}
@@ -86,7 +89,17 @@
- @($"{CurrRecord.FixedCost:C2}") + @if (!isEditing) + { + @($"{CurrRecord.FixedCost:C2}") + } + else + { +
+ + +
+ }
@@ -99,7 +112,17 @@
- @($"{CurrRecord.VariableCost:C2}") + @if (!isEditing) + { + @($"{CurrRecord.VariableCost:C2}") + } + else + { +
+ + +
+ }
@@ -112,7 +135,17 @@
- @($"{CurrRecord.LaborCost:C2}") + @if (!isEditing) + { + @($"{CurrRecord.LaborCost:C2}") + } + else + { +
+ + +
+ }
@@ -125,7 +158,17 @@
- @($"{CurrRecord.OverHeadCost:C2}") + @if (!isEditing) + { + @($"{CurrRecord.OverHeadCost:C2}") + } + else + { +
+ + +
+ }
@@ -138,7 +181,17 @@
- @($"{CurrRecord.OverHeadPerc:P2}") + @if (!isEditing) + { + @($"{CurrRecord.OverHeadPerc:P2}") + } + else + { +
+ + + +
+ }
@@ -151,7 +204,17 @@
- @($"{CurrRecord.EBTPerc:P2}") + @if (!isEditing) + { + @($"{CurrRecord.EBTPerc:P2}") + } + else + { +
+ + + +
+ }
@@ -164,16 +227,26 @@
- @($"{CurrRecord.PriceMargin:P2}") + @if (!isEditing) + { + @($"{CurrRecord.PriceMargin:P2}") + } + else + { +
+ + + +
+ }
@if (isEditing) - { + {
  • - -
  • - } + + + } \ No newline at end of file diff --git a/Lux.UI/Components/Compo/JobTask/ResourceDetail.razor.cs b/Lux.UI/Components/Compo/JobTask/ResourceDetail.razor.cs index 4a8a05b3..41c223f4 100644 --- a/Lux.UI/Components/Compo/JobTask/ResourceDetail.razor.cs +++ b/Lux.UI/Components/Compo/JobTask/ResourceDetail.razor.cs @@ -33,6 +33,7 @@ namespace Lux.UI.Components.Compo.JobTask CurrRecord.CostDriverBudget = Math.Round(value, 3); } } + protected decimal CostCalc { get => DriverQty * CurrRecord.BaseRockBottomCost; diff --git a/Lux.UI/Components/_Imports.razor b/Lux.UI/Components/_Imports.razor index cc3d02c8..b77fbdc8 100644 --- a/Lux.UI/Components/_Imports.razor +++ b/Lux.UI/Components/_Imports.razor @@ -17,5 +17,6 @@ @using Lux.UI.Client @using Lux.UI.Components @using Lux.UI.Components.Compo +@using Lux.UI.Components.Compo.Base @using Lux.UI.Components.Compo.Config @using Lux.UI.Components.Compo.JobTask diff --git a/Lux.UI/Lux.UI.csproj b/Lux.UI/Lux.UI.csproj index 159a0243..ee9a5fd5 100644 --- a/Lux.UI/Lux.UI.csproj +++ b/Lux.UI/Lux.UI.csproj @@ -5,7 +5,7 @@ enable enable aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50 - 0.9.2510.3110 + 0.9.2510.3111 diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 1971af59..fe056213 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ LUX - Web Windows MES -

    Versione: 0.9.2510.3110

    +

    Versione: 0.9.2510.3111


    Note di rilascio:
    • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 6e3f76d5..53bcb603 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -0.9.2510.3110 +0.9.2510.3111 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index b620ca16..3ed8f4cc 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 0.9.2510.3110 + 0.9.2510.3111 http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html false