Add external row quantity foundation
This commit is contained in:
@@ -128,6 +128,7 @@ function createTestDatabase(): DatabaseContext {
|
||||
name: "Leuchte",
|
||||
displayName: "Leuchte lokal",
|
||||
quantity: 1,
|
||||
manualQuantity: 1,
|
||||
powerPerUnit: 0.1,
|
||||
simultaneityFactor: 1,
|
||||
},
|
||||
@@ -138,6 +139,7 @@ function createTestDatabase(): DatabaseContext {
|
||||
name: "Fremdzeile",
|
||||
displayName: "Fremdzeile",
|
||||
quantity: 1,
|
||||
manualQuantity: 1,
|
||||
powerPerUnit: 0.2,
|
||||
simultaneityFactor: 1,
|
||||
},
|
||||
@@ -175,6 +177,7 @@ describe("circuit device-row project-command repository", () => {
|
||||
|
||||
const row = getRow(context);
|
||||
assert.equal(row.quantity, 2);
|
||||
assert.equal(row.manualQuantity, 2);
|
||||
assert.equal(row.roomId, "room-1");
|
||||
assert.equal(row.remark, null);
|
||||
assert.equal(row.overriddenFields, "[\"quantity\"]");
|
||||
@@ -185,6 +188,7 @@ describe("circuit device-row project-command repository", () => {
|
||||
{ field: "quantity", value: 1 },
|
||||
{ field: "roomId", value: null },
|
||||
{ field: "remark", value: null },
|
||||
{ field: "manualQuantity", value: 1 },
|
||||
{ field: "overriddenFields", value: null },
|
||||
],
|
||||
});
|
||||
@@ -203,6 +207,7 @@ describe("circuit device-row project-command repository", () => {
|
||||
{ field: "quantity", value: 2 },
|
||||
{ field: "roomId", value: "room-1" },
|
||||
{ field: "remark", value: null },
|
||||
{ field: "manualQuantity", value: 2 },
|
||||
{ field: "overriddenFields", value: "[\"quantity\"]" },
|
||||
],
|
||||
},
|
||||
@@ -234,6 +239,7 @@ describe("circuit device-row project-command repository", () => {
|
||||
|
||||
const row = getRow(context);
|
||||
assert.equal(row.quantity, 1);
|
||||
assert.equal(row.manualQuantity, 1);
|
||||
assert.equal(row.overriddenFields, null);
|
||||
assert.equal(undone.revision.revisionNumber, 2);
|
||||
assert.deepEqual(
|
||||
@@ -377,4 +383,22 @@ describe("circuit device-row project-command repository", () => {
|
||||
context.close();
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects a manual share above the materialized total", () => {
|
||||
const context = createTestDatabase();
|
||||
try {
|
||||
const store = new CircuitDeviceRowProjectCommandRepository(context.db);
|
||||
assert.throws(() => store.executeUpdate({
|
||||
projectId: "project-1",
|
||||
expectedRevision: 0,
|
||||
source: "user",
|
||||
command: createCircuitDeviceRowUpdateProjectCommand("row-1", {
|
||||
manualQuantity: 2,
|
||||
}),
|
||||
}), /manual quantity/);
|
||||
assert.equal(getRow(context).manualQuantity, 1);
|
||||
} finally {
|
||||
context.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user