forked from jappel/leistungsbilanz-ts
Add external row quantity foundation
This commit is contained in:
parent
bc2bc7ece5
commit
dac19b093c
30 changed files with 2750 additions and 22 deletions
|
|
@ -18,6 +18,7 @@ export interface CircuitDeviceRowUpdateValues {
|
|||
roomNumberSnapshot: string | null;
|
||||
roomNameSnapshot: string | null;
|
||||
quantity: number;
|
||||
manualQuantity: number;
|
||||
powerPerUnit: number;
|
||||
simultaneityFactor: number;
|
||||
cosPhi: number | null;
|
||||
|
|
@ -51,7 +52,18 @@ export function createCircuitDeviceRowUpdateProjectCommand(
|
|||
rowId: string,
|
||||
patch: CircuitDeviceRowUpdatePatch
|
||||
): CircuitDeviceRowUpdateProjectCommand {
|
||||
const changes = Object.entries(patch).map(([field, value]) => ({
|
||||
const normalizedPatch =
|
||||
patch.quantity !== undefined && patch.manualQuantity === undefined
|
||||
? { ...patch, manualQuantity: patch.quantity }
|
||||
: patch;
|
||||
if (
|
||||
normalizedPatch.quantity !== undefined &&
|
||||
normalizedPatch.manualQuantity !== undefined &&
|
||||
normalizedPatch.manualQuantity > normalizedPatch.quantity
|
||||
) {
|
||||
throw new Error("manualQuantity must not exceed quantity.");
|
||||
}
|
||||
const changes = Object.entries(normalizedPatch).map(([field, value]) => ({
|
||||
field: field as CircuitDeviceRowUpdateField,
|
||||
value,
|
||||
})) as CircuitDeviceRowUpdateFieldChange[];
|
||||
|
|
@ -125,6 +137,7 @@ function assertCircuitDeviceRowUpdateFieldValue(
|
|||
}
|
||||
if (
|
||||
field === "quantity" ||
|
||||
field === "manualQuantity" ||
|
||||
field === "powerPerUnit" ||
|
||||
field === "simultaneityFactor"
|
||||
) {
|
||||
|
|
@ -164,6 +177,7 @@ function isCircuitDeviceRowUpdateField(
|
|||
"roomNumberSnapshot",
|
||||
"roomNameSnapshot",
|
||||
"quantity",
|
||||
"manualQuantity",
|
||||
"powerPerUnit",
|
||||
"simultaneityFactor",
|
||||
"cosPhi",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue