Send Selvvask import period dates

Include selected invoice-period dates when importing XLVask usage from the Selvvask period view.
This commit is contained in:
Jeppe Bundgaard
2026-07-06 23:49:36 +02:00
parent ca2003f2d6
commit 2108dd6c94
3 changed files with 32 additions and 1 deletions
@@ -112,13 +112,24 @@ if (router.currentRoute.value.params.departmentId) {
}
const isImportLoading = ref(false);
const buildImportUsageParams = () => {
if (!props.inheritPeriodFilters) {
return {};
}
return {
...(props.initialDateFrom ? { dateFrom: props.initialDateFrom } : {}),
...(props.initialDateTo ? { dateTo: props.initialDateTo } : {}),
};
};
const importUsageButton = async () => {
isImportLoading.value = true;
try {
await SessionUser.request(
'/modules/xlvask/tasks/import-usage',
'GET',
{},
buildImportUsageParams(),
function (error) {
// This function is called when the request fails
console.error("Failed to import orders.", error);
+16
View File
@@ -1112,6 +1112,7 @@ test.describe("Invoicing period tab", () => {
const usageOrderRequests = [];
const fastLinkRequests = [];
const automationAcceptRequests = [];
const importUsageRequests = [];
let automation = {
id: 7101,
status: "suggested",
@@ -1133,6 +1134,15 @@ test.describe("Invoicing period tab", () => {
await openPeriodView(page);
await page.route("**/modules/xlvask/tasks/import-usage**", async (route) => {
const url = new URL(route.request().url());
importUsageRequests.push({
dateFrom: url.searchParams.get("dateFrom"),
dateTo: url.searchParams.get("dateTo"),
});
await route.fulfill(json({ data: "Usage logs imported" }));
});
await page.route("**/modules/xlvask/services/usage/orders**", async (route) => {
const path = new URL(route.request().url()).pathname;
if (
@@ -1285,6 +1295,12 @@ test.describe("Invoicing period tab", () => {
request.filters.includes("StartTime-date_to:2026-03-31")
)
).toBe(true);
await selfWashView.getByRole("button", { name: /import/i }).click();
await expect.poll(() => importUsageRequests.length).toBe(1);
expect(importUsageRequests[0]).toEqual({
dateFrom: "2026-03-01",
dateTo: "2026-03-31",
});
});
test("@smoke period view shows flags and saves automatic flag decisions", async ({ page }) => {
@@ -491,6 +491,10 @@ describe("Periode tab contract", () => {
expect(xlvaskUsagePaginationSource).toContain('v-if="shouldShowLocalFilters"');
expect(xlvaskUsagePaginationSource).toContain('v-if="!hideSearchField && shouldShowLocalFilters"');
expect(xlvaskUsagePaginationSource).toContain('v-if="!props.loadAllAtOnce"');
expect(xlvaskUsagePaginationSource).toContain("const buildImportUsageParams = () => {");
expect(xlvaskUsagePaginationSource).toContain("dateFrom: props.initialDateFrom");
expect(xlvaskUsagePaginationSource).toContain("dateTo: props.initialDateTo");
expect(xlvaskUsagePaginationSource).toContain("buildImportUsageParams()");
});
it("loads Selvvask selector counts and progress from the selected period", () => {