Update modello dati x gestione costing + drivers

This commit is contained in:
Samuele Locatelli
2025-10-24 18:31:20 +02:00
parent e2c83a3313
commit 7327ea1a8f
12 changed files with 256 additions and 70 deletions
@@ -0,0 +1,48 @@
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
namespace EgwCoreLib.Lux.Data.DbModel.Cost
{
/// <summary>
/// Dati di dettaglio per Tempi / Costi di uno step (
/// NON associata a tabella ma da gestire serializzata
/// </summary>
public class StepDTO
{
/// <summary>
/// Nome/Descrizione
/// </summary>
public string Name { get; set; } = string.Empty;
/// <summary>
/// Ordinale del record
/// </summary>
public int Ordinal { get; set; } = 0;
/// <summary>
/// Tempo stimato netto per unità di prodotto (LeadTime), sommabile
/// </summary>
public decimal WorkLeadTime { get; set; } = 0;
/// <summary>
/// Tempo Attraversamento complessivo per unità di prodotto (FlowTime), sommabile
/// </summary>
public decimal WorkFlowTime { get; set; } = 0;
/// <summary>
/// Costo delle lavorazioni dato ciclo e costing associati
/// </summary>
public decimal WorkCost { get; set; } = 0;
/// <summary>
/// Prezzo delle lavorazioni dato ciclo e costing associati
/// </summary>
public decimal WorkPrice { get; set; } = 0;
/// <summary>
/// Note (opzionali)
/// </summary>
public string Note { get; set; } = string.Empty;
}
}
@@ -2,12 +2,14 @@
using System.ComponentModel.DataAnnotations.Schema;
using static EgwCoreLib.Lux.Core.Enums;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
namespace EgwCoreLib.Lux.Data.DbModel.Sales
{
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
/// <summary>
/// Classe delle offerte commerciali
/// </summary>
[Table("sales_offer")]
public class OfferModel
{
@@ -68,7 +70,7 @@ namespace EgwCoreLib.Lux.Data.DbModel.Sales
public string DictPresel { get; set; } = "";
/// <summary>
/// Validità offerta
/// Validità Offerta
/// </summary>
public DateTime ValidUntil { get; set; } = DateTime.Now.AddMonths(1);
@@ -151,20 +153,6 @@ namespace EgwCoreLib.Lux.Data.DbModel.Sales
get => (TotalCost > 0 && TotalPrice > TotalCost) ? (TotalPrice - TotalCost) / TotalPrice : 0;
}
#if false
/// <summary>
/// ID Ordine (nullo se non c'è ordine)
/// </summary>
public int? OrderID { get; set; } = null;
/// <summary>
/// Navigazione Ordine
/// </summary>
[ForeignKey("OrderID")]
public virtual OrderModel? OrderNav { get; set; } = null;
#endif
/// <summary>
/// Navigazione Customer
/// </summary>
@@ -177,7 +165,6 @@ namespace EgwCoreLib.Lux.Data.DbModel.Sales
[ForeignKey("DealerID")]
public virtual DealerModel DealerNav { get; set; } = null!;
/// <summary>
/// Navigazione alle righe offerta
/// </summary>
@@ -7,7 +7,6 @@ using System.ComponentModel.DataAnnotations.Schema;
// </Auto-Generated>
namespace EgwCoreLib.Lux.Data.DbModel.Sales
{
[Table("sales_offer_row")]
public class OfferRowModel
{
@@ -67,17 +66,27 @@ namespace EgwCoreLib.Lux.Data.DbModel.Sales
/// </summary>
public double BomPrice { get; set; } = 0;
/// <summary>
/// Costo produzione Fase/Step (RockBottom)
/// Costo produzione Fase/Step (RockBottom): somma dei WorkCost da ItemSteps
/// </summary>
public double StepCost { get; set; } = 0;
/// <summary>
/// Prezzo produzione Fase/Step (scontabile)
/// Prezzo produzione Fase/Step (scontabile): somma dei WorkPrice da ItemSteps
/// </summary>
public double StepPrice { get; set; } = 0;
/// <summary>
/// LeadTime puro (tempo di lavorazione): somma dei LeadTime da ItemSteps
/// </summary>
public double StepLeadTime { get; set; } = 0;
/// <summary>
/// FlowTime totale (tempo di attraversamento): somma dei FlowTime da ItemSteps
/// </summary>
public double StepFlowTime { get; set; } = 0;
/// <summary>
/// Costo Totale Risorsa (BOM + Fase)
/// </summary>
@@ -144,17 +153,21 @@ namespace EgwCoreLib.Lux.Data.DbModel.Sales
/// </summary>
public long FileSize { get; set; } = 0;
/// <summary>
/// Elenco StepDTO (Fasi) per la stima tempi / costi
/// potrebbe contenere anche altre info accessorie x definire dati logistico/gestionali
/// </summary>
public string ItemSteps { get; set; } = "";
/// <summary>
/// BOM serializzata per la produzione dell'item
/// </summary>
public string ItemBOM { get; set; } = "";
/// <summary>
/// Lista dei Job Cost Drivers calcolati dall'engine (necessari x calcolo Steps)
/// </summary>
public string ItemJCD { get; set; } = "";
/// <summary>
/// Elenco StepDTO (Fasi Costificate, sommabili) per la stima tempi / costi
/// </summary>
public string ItemSteps { get; set; } = "";
/// <summary>
/// Validazione dati BOM (Inteso come gruppi tutti trovati/esistenti)
/// </summary>
+62 -12
View File
@@ -1,19 +1,12 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static EgwCoreLib.Lux.Core.Enums;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
namespace EgwCoreLib.Lux.Data.DbModel.Sales
{
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
/// <summary>
/// Classe degli ordini commerciali
/// </summary>
@@ -26,6 +19,11 @@ namespace EgwCoreLib.Lux.Data.DbModel.Sales
[Key]
public int OrderID { get; set; }
/// <summary>
/// Environment della richiesta
/// </summary>
public EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS Envir { get; set; } = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW;
/// <summary>
/// Offerta correlata
/// </summary>
@@ -52,7 +50,7 @@ namespace EgwCoreLib.Lux.Data.DbModel.Sales
[NotMapped]
public string OrderCode
{
get => $"{RefYear:00}.{RefNum:00000}.{RefRev:00}";
get => $"PO.{RefYear:00}.{RefNum:00000}.{RefRev:00}";
}
/// <summary>
@@ -111,6 +109,53 @@ namespace EgwCoreLib.Lux.Data.DbModel.Sales
/// </summary>
public OrderStates OrderState { get; set; } = OrderStates.Created;
/// <summary>
/// Sconto applicato (deve essere < del MAX)
/// </summary>
public double Discount { get; set; } = 0;
/// <summary>
/// Numero Item compresi
/// </summary>
[NotMapped]
public double NumItems
{
get => OrderRowNav?.Sum(x => x.Qty) ?? 0;
}
/// <summary>
/// Numero Item compresi
/// </summary>
[NotMapped]
public int NumRows
{
get => OrderRowNav?.Count ?? 0;
}
/// <summary>
/// Costo totale offerta (rock bottom)
/// </summary>
[NotMapped]
public double TotalCost
{
get => OrderRowNav?.Sum(x => x.TotalCost) ?? 0;
}
/// <summary>
/// Prezzo totale offerta (compreso di amrginalità)
/// </summary>
[NotMapped]
public double TotalPrice
{
get => OrderRowNav?.Sum(x => x.TotalPrice) ?? 0;
}
/// <summary>
/// Sconto massimo applicabile
/// </summary>
[NotMapped]
public double MaxDiscount
{
get => (TotalCost > 0 && TotalPrice > TotalCost) ? (TotalPrice - TotalCost) / TotalPrice : 0;
}
/// <summary>
/// Navigazione Customer
/// </summary>
@@ -128,5 +173,10 @@ namespace EgwCoreLib.Lux.Data.DbModel.Sales
/// </summary>
[ForeignKey("OfferID")]
public virtual OfferModel OfferNav { get; set; } = null!;
/// <summary>
/// Navigazione alle righe ordine
/// </summary>
public virtual ICollection<OrderRowModel> OrderRowNav { get; set; } = new List<OrderRowModel>();
}
}
@@ -1,19 +1,12 @@
using EgwCoreLib.Lux.Data.DbModel.Items;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
namespace EgwCoreLib.Lux.Data.DbModel.Sales
{
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
[Table("sales_order_row")]
public class OrderRowModel
{
@@ -29,10 +22,22 @@ namespace EgwCoreLib.Lux.Data.DbModel.Sales
public int OrderID { get; set; }
/// <summary>
/// Riga Ordine
/// Riga Ordine (per ordinamento)
/// </summary>
public int RowNum { get; set; } = 0;
/// <summary>
/// Environment della richiesta
/// </summary>
public EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS Envir { get; set; } = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW;
/// <summary>
/// Campo salvato dell'UID da codice DataMatrix calcolato
/// inizia per SOR = SalesOfferRow
/// </summary>
public string OrderRowUID { get; set; } = "POR.25.0123ABCD";
/// <summary>
/// Codice calcolato Ordine ANNO.NUMERO
/// inizia per PO = PurchaseOrder
@@ -40,7 +45,7 @@ namespace EgwCoreLib.Lux.Data.DbModel.Sales
[NotMapped]
public string OrderRowCode
{
get => $"PO{OrderRowID:000000}.{RowNum:000}";
get => $"POR.{Inserted:yy}.{OrderRowID:X8}";
}
/// <summary>
@@ -48,16 +53,16 @@ namespace EgwCoreLib.Lux.Data.DbModel.Sales
/// </summary>
public int? SellingItemID { get; set; }
/// <summary>
/// Quantità della risorsa
/// </summary>
public double Qty { get; set; } = 1;
/// <summary>
/// Costo dei componeti BOM (RockBottom)
/// </summary>
public double BomCost { get; set; } = 0;
/// <summary>
/// Margine percentuale standard
/// </summary>
public double Qty { get; set; } = 1;
/// <summary>
/// Prezzo dei componeti BOM (scontabile)
/// </summary>
@@ -74,6 +79,17 @@ namespace EgwCoreLib.Lux.Data.DbModel.Sales
/// </summary>
public double StepPrice { get; set; } = 0;
/// <summary>
/// LeadTime puro (tempo di lavorazione): somma dei LeadTime da ItemSteps
/// </summary>
public double StepLeadTime { get; set; } = 0;
/// <summary>
/// FlowTime totale (tempo di attraversamento): somma dei FlowTime da ItemSteps
/// </summary>
public double StepFlowTime { get; set; } = 0;
/// <summary>
/// Costo Totale Risorsa (BOM + Fase)
/// </summary>
@@ -125,11 +141,46 @@ namespace EgwCoreLib.Lux.Data.DbModel.Sales
public string SerStruct { get; set; } = "";
/// <summary>
/// Elenco StepDTO (Fasi) per la stima tempi / costi
/// potrebbe contenere anche altre info accessorie x definire dati logistico/gestionali
/// Nomi risorsa file associato alla riga offerta (es per BTL)
/// URI come risorsa dentro folder offerta/riga-offerta/guid
/// </summary>
public string FileResource { get; set; } = "";
/// <summary>
/// Nomi file originale associato alla riga offerta (es per BTL)
/// </summary>
public string FileName { get; set; } = "";
/// <summary>
/// Dimensione del file (per visualizzazione rapida)
/// </summary>
public long FileSize { get; set; } = 0;
/// <summary>
/// BOM serializzata per la produzione dell'item
/// </summary>
public string ItemBOM { get; set; } = "";
/// <summary>
/// Lista dei Job Cost Drivers calcolati dall'engine (necessari x calcolo Steps)
/// </summary>
public string ItemJCD { get; set; } = "";
/// <summary>
/// Elenco StepDTO (Fasi Costificate, sommabili) per la stima tempi / costi
/// </summary>
public string ItemSteps { get; set; } = "";
/// <summary>
/// Validazione dati BOM (Inteso come gruppi tutti trovati/esistenti)
/// </summary>
public bool BomOk { get; set; } = false;
/// <summary>
/// Validazione livello item per Costo e range dimensione
/// </summary>
public bool ItemOk { get; set; } = false;
/// <summary>
/// Note libere
/// </summary>
@@ -154,6 +205,16 @@ namespace EgwCoreLib.Lux.Data.DbModel.Sales
/// </summary>
public DateTime Modified { get; set; } = DateTime.Now;
/// <summary>
/// Indica che è in attesa aggiornamento BOM
/// </summary>
public bool AwaitBom { get; set; } = false;
/// <summary>
/// Indica che è in attesa aggiornamento Price
/// </summary>
public bool AwaitPrice { get; set; } = false;
/// <summary>
/// Navigazione Order
/// </summary>
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>0.9.2510.2219</Version>
<Version>0.9.2510.2418</Version>
</PropertyGroup>
<ItemGroup>
+10 -3
View File
@@ -71,6 +71,7 @@ else
@if (DisplayMode == EgwCoreLib.Lux.Core.Enums.DisplayMode.Edit)
{
<th class="text-end" title="Cambio Materiali">Mat.</th>
<th class="text-end" title="Ciclo Lavoro">Lav.</th>
}
<th class="text-end">Totale</th>
<th class="text-end">Marg.</th>
@@ -112,7 +113,7 @@ else
</td>
@if (isNote)
{
<td colspan="8" class="small">
<td colspan="9" class="small">
@if (CurrEditMode == EditMode.RecData && EditRecord != null && EditRecord.OfferRowID == item.OfferRowID)
{
<div class="input-group">
@@ -210,6 +211,12 @@ else
<button class="btn btn-sm btn-info" title="Cambio materiali assegnati" @onclick="() => DoSwapMat(item)"><i class="fa-solid fa-arrow-right-arrow-left"></i></button>
}
</td>
<td class="text-end">
@if (!string.IsNullOrEmpty(item.ItemSteps))
{
<button class="btn btn-sm btn-info" title="Verifica Ciclo/Fasi di Lavoro" @onclick="() => DoSwapJobCycle(item)"><i class="fa-solid fa-arrow-right-arrow-left"></i></button>
}
</td>
}
<td class="text-end text-nowrap">
<div class="fw-bold" title="Prezzo Finito">
@@ -254,11 +261,11 @@ else
<th class="text-end">@($"{GrandTotQty:N0}")</th>
@if (DisplayMode == EgwCoreLib.Lux.Core.Enums.DisplayMode.Edit)
{
<th colspan="2"></th>
<th colspan="3"></th>
}
else
{
<th colspan="1"></th>
<th colspan="2"></th>
}
<th class="text-end">
@($"{GrandTotPrice:C2}")
+21 -1
View File
@@ -43,7 +43,12 @@ namespace Lux.UI.Components.Compo
/// <summary>
/// File editing (es BTL)
/// </summary>
File
File,
/// <summary>
/// Editing ciclo di lavoro
/// </summary>
JobCycle
}
#endregion Public Enums
@@ -352,6 +357,10 @@ namespace Lux.UI.Components.Compo
CurrEditMode = EditMode.None;
}
/// <summary>
/// Imposta modalità ad edit BOM
/// </summary>
/// <param name="currRow"></param>
protected void DoSwapMat(OfferRowModel currRow)
{
CurrEditMode = EditMode.BOM;
@@ -359,6 +368,17 @@ namespace Lux.UI.Components.Compo
CurrBomList = DLService.OffertGetBomList(EditRecord);
}
/// <summary>
/// Imposta modalità edit ciclo di lavoro
/// </summary>
/// <param name="currRow"></param>
protected void DoSwapJobCycle(OfferRowModel currRow)
{
CurrEditMode = EditMode.JobCycle;
EditRecord = currRow;
CurrBomList = DLService.OffertGetBomList(EditRecord);
}
/// <summary>
/// Display fileSize scalato
/// </summary>
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50</UserSecretsId>
<Version>0.9.2510.2219</Version>
<Version>0.9.2510.2418</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>LUX - Web Windows MES</i>
<h4>Versione: 0.9.2510.2219</h4>
<h4>Versione: 0.9.2510.2418</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
0.9.2510.2219
0.9.2510.2418
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>0.9.2510.2219</version>
<version>0.9.2510.2418</version>
<url>http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html</changelog>
<mandatory>false</mandatory>