Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7ce3fbb56 | ||
|
|
61a27a0e8e | ||
|
|
4637cb867b | ||
|
|
3873849de1 | ||
|
|
f22ca71558 | ||
|
|
7d5ec8894c | ||
|
|
f2fc7643a2 | ||
|
|
06b6498f7a |
@@ -49,7 +49,8 @@ platform :ios do
|
||||
automatic_release: true,
|
||||
phased_release: false,
|
||||
run_precheck_before_submit: false,
|
||||
precheck_include_in_app_purchases: false
|
||||
precheck_include_in_app_purchases: false,
|
||||
ignore_language_directory_validation: true
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
Before Width: | Height: | Size: 270 KiB After Width: | Height: | Size: 270 KiB |
|
Before Width: | Height: | Size: 194 KiB After Width: | Height: | Size: 194 KiB |
|
Before Width: | Height: | Size: 178 KiB After Width: | Height: | Size: 178 KiB |
|
Before Width: | Height: | Size: 113 KiB After Width: | Height: | Size: 113 KiB |
|
Before Width: | Height: | Size: 213 KiB After Width: | Height: | Size: 213 KiB |
|
Before Width: | Height: | Size: 189 KiB After Width: | Height: | Size: 189 KiB |
|
Before Width: | Height: | Size: 227 KiB After Width: | Height: | Size: 227 KiB |
|
Before Width: | Height: | Size: 187 KiB After Width: | Height: | Size: 187 KiB |
|
Before Width: | Height: | Size: 165 KiB After Width: | Height: | Size: 165 KiB |
|
Before Width: | Height: | Size: 239 KiB After Width: | Height: | Size: 239 KiB |
|
Before Width: | Height: | Size: 162 KiB After Width: | Height: | Size: 162 KiB |
|
Before Width: | Height: | Size: 168 KiB After Width: | Height: | Size: 168 KiB |
@@ -38,7 +38,7 @@
|
||||
<string>Main</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
<string>arm64</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
|
||||
@@ -7,8 +7,11 @@ const strict = argv.includes("--strict");
|
||||
const failures = [];
|
||||
const warnings = [];
|
||||
const root = process.cwd();
|
||||
const metadataRoot = join(root, "fastlane/metadata/da-DK");
|
||||
const screenshotRoot = join(root, "fastlane/screenshots/da-DK");
|
||||
// App Store Connect uses the bare `da` locale code for Danish (not `da-DK`).
|
||||
// Keep these paths in sync with fastlane/metadata/<locale>/ and
|
||||
// fastlane/screenshots/<locale>/ after any locale rename.
|
||||
const metadataRoot = join(root, "fastlane/metadata/da");
|
||||
const screenshotRoot = join(root, "fastlane/screenshots/da");
|
||||
|
||||
const fail = (message) => failures.push(message);
|
||||
const warn = (message) => warnings.push(message);
|
||||
|
||||
@@ -328,6 +328,47 @@ const getCustomerDetailItems = (scan) => {
|
||||
return items;
|
||||
};
|
||||
|
||||
const getLastWashDetailItem = (scan) => {
|
||||
// TRU-78 / DRIFT 17: surface the "last washed" timestamp for a scanned
|
||||
// license plate on the landing page so the operator can see at a glance
|
||||
// when a trailer was last washed (DHL pick-up use case).
|
||||
const lastWash = formatLastWashTimestamp(scan?.last_wash);
|
||||
if (!lastWash) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
label: SessionUser.objects.global.language.last_wash || t('admin.pos.recent_washes'),
|
||||
value: lastWash,
|
||||
testKey: 'last-wash',
|
||||
};
|
||||
};
|
||||
|
||||
const getLastWashEmptyStateText = () => {
|
||||
return t('admin.pos.never_washed');
|
||||
};
|
||||
|
||||
const formatLastWashTimestamp = (value) => {
|
||||
if (!isMeaningfulValue(value)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const parsedDate = new Date(String(value).replace(' ', 'T'));
|
||||
if (Number.isNaN(parsedDate.getTime())) {
|
||||
return String(value);
|
||||
}
|
||||
|
||||
try {
|
||||
return new Intl.DateTimeFormat(locale.value || undefined, {
|
||||
dateStyle: 'medium',
|
||||
timeStyle: 'short',
|
||||
}).format(parsedDate);
|
||||
} catch (error) {
|
||||
console.error('Unable to format last_wash timestamp', error);
|
||||
return String(value);
|
||||
}
|
||||
};
|
||||
|
||||
const getVehicleDetailItems = (scan) => {
|
||||
const detailState = getPlateDetailState(scan.plate);
|
||||
if (detailState.status !== 'loaded') {
|
||||
@@ -493,19 +534,29 @@ setTimeout(() => {
|
||||
:data-testid="`pos-recent-scan-details-${scan.id}`"
|
||||
>
|
||||
<div
|
||||
v-if="getCustomerDetailItems(scan).length > 0"
|
||||
v-if="getCustomerDetailItems(scan).length > 0 || getLastWashDetailItem(scan)"
|
||||
class="pos-scan-details__grid pos-scan-details__grid--customer"
|
||||
>
|
||||
<div
|
||||
v-for="item in getCustomerDetailItems(scan)"
|
||||
v-for="item in [...getCustomerDetailItems(scan), getLastWashDetailItem(scan)].filter(Boolean)"
|
||||
:key="item.label"
|
||||
class="pos-scan-detail-field"
|
||||
:data-testid="`pos-recent-scan-detail-${scan.id}-${item.testKey || item.label}`"
|
||||
>
|
||||
<span class="pos-scan-detail-field__label">{{ item.label }}</span>
|
||||
<span class="pos-scan-detail-field__value">{{ item.value }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p
|
||||
v-if="!getLastWashDetailItem(scan) && scan.last_wash == null"
|
||||
class="pos-scan-details__state"
|
||||
:data-testid="`pos-recent-scan-never-washed-${scan.id}`"
|
||||
>
|
||||
<i class="fas fa-info-circle" aria-hidden="true"></i>
|
||||
<span>{{ getLastWashEmptyStateText() }}</span>
|
||||
</p>
|
||||
|
||||
<div v-if="getPlateDetailState(scan.plate).status === 'loading'" class="pos-scan-details__state">
|
||||
<i class="fas fa-spinner fa-spin"></i>
|
||||
<span>{{ $t('admin.pos.recent_scan_details_loading') }}</span>
|
||||
|
||||
@@ -5448,6 +5448,7 @@
|
||||
},
|
||||
"last_wash_matches_current_selection": "@.capitalize:{'words.generated.samme'} @:{'words.generated.ydelse'}, @:{'words.generated.tilvalg'} @:{'words.generated.og'} @:{'words.generated.ekstra'} @:{'words.generated.varer'} @:{'words.generated.som'} @:{'words.generated.sidste'} @:{'words.generated.vask'}",
|
||||
"manual_entry": "Manuell @:{'words.generated.registrering'}",
|
||||
"never_washed": "Aldrig vasket",
|
||||
"new_order": "@.capitalize:{'words.generated.ny'} order",
|
||||
"new_sale": "@.capitalize:{'words.generated.nyt'} @:{'words.generated.salg'}",
|
||||
"no_bookings": "@.capitalize:{'words.generated.ingen'} @:{'words.generated.bookinger'} @:{'words.generated.fundet'}",
|
||||
|
||||
@@ -5558,6 +5558,7 @@
|
||||
},
|
||||
"last_wash_matches_current_selection": "@.capitalize:{'words.generated.gleiche'} @:{'words.generated.leistung'}, @:{'words.generated.zusatzoptionen'} @:{'words.generated.und'} @:{'words.generated.zusatzartikel'} @:{'words.generated.wie'} @:{'words.generated.bei'} @:{'words.generated.der'} @:{'words.generated.letzten'} @:{'words.generated.wasche'}",
|
||||
"manual_entry": "@.capitalize:{'words.generated.manuell'} registrering",
|
||||
"never_washed": "Noch nie gewaschen",
|
||||
"new_order": "@.capitalize:{'words.generated.neuer'} @:{'words.generated.auftrag'}",
|
||||
"new_sale": "Nytt salg",
|
||||
"no_bookings": "@.capitalize:{'words.generated.keine'} @:{'words.generated.buchungen'} @:{'words.generated.gefunden'}",
|
||||
|
||||
@@ -5279,6 +5279,7 @@
|
||||
},
|
||||
"last_wash_matches_current_selection": "@.capitalize:{'words.generated.same'} @:{'words.generated.service'}, @:{'words.generated.add'}-@:{'words.generated.ons'}, @:{'words.generated.and'} @:{'words.generated.extra'} @:{'words.generated.items'} @:{'words.generated.as'} @:{'words.replication.article.host_mention'} @:{'words.generated.previous'} @:{'words.generated.wash'}",
|
||||
"manual_entry": "@:{'words.generated.manual'} @:{'words.generated.registration'}",
|
||||
"never_washed": "Never washed",
|
||||
"new_order": "@.capitalize:{'words.generated.new'} @:{'words.generated.order'}",
|
||||
"new_sale": "@.capitalize:{'words.generated.new'} sale",
|
||||
"no_bookings": "@.capitalize:{'words.generated.no'} @:{'words.generated.orders'} @:{'words.generated.found'}",
|
||||
|
||||
@@ -4852,6 +4852,8 @@
|
||||
"last_wash_matches_current_selection": "@:{'templates.generated.compat.pos.last_wash_matches_current_selection'}",
|
||||
"license_plate": "@:{'templates.generated.compat.tables.common.registration_number'}",
|
||||
"manual_entry": "@:{'templates.generated.compat.pos.manual_entry'}",
|
||||
"last_wash": "@:{'templates.generated.compat.global.last_wash'}",
|
||||
"never_washed": "@:{'templates.generated.compat.pos.never_washed'}",
|
||||
"new_order": "@:{'templates.generated.compat.pos.new_order'}",
|
||||
"new_sale": "@:{'templates.generated.compat.pos.new_sale'}",
|
||||
"no_bookings": "@:{'templates.generated.compat.pos.no_bookings'}",
|
||||
|
||||
@@ -5561,6 +5561,7 @@
|
||||
},
|
||||
"last_wash_matches_current_selection": "@.capitalize:{'words.generated.samme'} @:{'words.generated.tjeneste'}, @:{'words.generated.tillegg'} @:{'words.generated.og'} @:{'words.generated.ekstra'} @:{'words.generated.varer'} @:{'words.generated.som'} @:{'words.generated.forrige'} @:{'words.generated.vask'}",
|
||||
"manual_entry": "Manuell @:{'words.generated.registrering'}",
|
||||
"never_washed": "Aldri vasket",
|
||||
"new_order": "@.capitalize:{'words.generated.bestillingen'}",
|
||||
"new_sale": "@.capitalize:{'words.generated.nytt'} @:{'words.generated.salg'}",
|
||||
"no_bookings": "@.capitalize:{'words.generated.ingen'} @:{'words.generated.bestillinger'} @:{'words.generated.funnet'}",
|
||||
|
||||
@@ -5611,6 +5611,7 @@
|
||||
},
|
||||
"last_wash_matches_current_selection": "@.capitalize:{'words.generated.samma'} @:{'words.generated.tjanst'}, @:{'words.generated.tillval'} @:{'words.generated.och'} @:{'words.generated.extra'} @:{'words.generated.artiklar'} @:{'words.generated.som'} @:{'words.generated.senaste'} @:{'words.generated.tvatten'}",
|
||||
"manual_entry": "Manuell @:{'words.generated.registrering'}",
|
||||
"never_washed": "Aldrig tvättad",
|
||||
"new_order": "@.capitalize:{'words.generated.ny'} @:{'words.generated.order'}",
|
||||
"new_sale": "@.capitalize:{'words.generated.nytt'} salg",
|
||||
"no_bookings": "@.capitalize:{'words.generated.ingen'} @:{'words.generated.bestillinger'} @:{'words.generated.funnet'}",
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
},
|
||||
"last_wash_matches_current_selection": "@.capitalize:{'terms.glossary.samme'} @:{'terms.glossary.ydelse'}, @:{'terms.glossary.tilvalg'} @:{'terms.glossary.og'} @:{'terms.glossary.ekstra'} @:{'terms.glossary.varer'} @:{'terms.glossary.som'} @:{'terms.glossary.sidste'} @:{'terms.glossary.vask'}",
|
||||
"manual_entry": "Manuell @:{'terms.glossary.registrering'}",
|
||||
"never_washed": "Aldrig vasket",
|
||||
"new_order": "@.capitalize:{'terms.glossary.ny'} order",
|
||||
"new_sale": "@.capitalize:{'terms.glossary.nyt'} @:{'terms.glossary.salg'}",
|
||||
"no_bookings": "@.capitalize:{'terms.glossary.ingen'} @:{'terms.glossary.bookinger'} @:{'terms.glossary.fundet'}",
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
},
|
||||
"last_wash_matches_current_selection": "@.capitalize:{'terms.glossary.gleiche'} @:{'terms.glossary.leistung'}, @:{'terms.glossary.zusatzoptionen'} @:{'terms.glossary.und'} @:{'terms.glossary.zusatzartikel'} @:{'terms.glossary.wie'} @:{'terms.glossary.bei'} @:{'terms.glossary.der'} @:{'terms.glossary.letzten'} @:{'terms.glossary.wasche'}",
|
||||
"manual_entry": "@.capitalize:{'terms.glossary.manuell'} registrering",
|
||||
"never_washed": "Noch nie gewaschen",
|
||||
"new_order": "@.capitalize:{'terms.glossary.neuer'} @:{'terms.glossary.auftrag'}",
|
||||
"new_sale": "Nytt salg",
|
||||
"no_bookings": "@.capitalize:{'terms.glossary.keine'} @:{'terms.glossary.buchungen'} @:{'terms.glossary.gefunden'}",
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
},
|
||||
"last_wash_matches_current_selection": "@.capitalize:{'terms.glossary.same'} @:{'terms.glossary.service'}, @:{'terms.glossary.add'}-@:{'terms.glossary.ons'}, @:{'terms.glossary.and'} @:{'terms.glossary.extra'} @:{'terms.glossary.items'} @:{'terms.glossary.as'} @:{'terms.replication.article.host_mention'} @:{'terms.glossary.previous'} @:{'terms.glossary.wash'}",
|
||||
"manual_entry": "@:{'terms.glossary.manual'} @:{'terms.glossary.registration'}",
|
||||
"never_washed": "Never washed",
|
||||
"new_order": "@.capitalize:{'terms.glossary.new'} @:{'terms.glossary.order'}",
|
||||
"new_sale": "@.capitalize:{'terms.glossary.new'} sale",
|
||||
"no_bookings": "@.capitalize:{'terms.glossary.no'} @:{'terms.glossary.orders'} @:{'terms.glossary.found'}",
|
||||
|
||||
@@ -76,6 +76,8 @@
|
||||
"last_wash_matches_current_selection": "@:{'phrases.compat.pos.last_wash_matches_current_selection'}",
|
||||
"license_plate": "@:{'phrases.compat.tables.common.registration_number'}",
|
||||
"manual_entry": "@:{'phrases.compat.pos.manual_entry'}",
|
||||
"last_wash": "@:{'phrases.compat.global.last_wash'}",
|
||||
"never_washed": "@:{'phrases.compat.pos.never_washed'}",
|
||||
"new_order": "@:{'phrases.compat.pos.new_order'}",
|
||||
"new_sale": "@:{'phrases.compat.pos.new_sale'}",
|
||||
"no_bookings": "@:{'phrases.compat.pos.no_bookings'}",
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
},
|
||||
"last_wash_matches_current_selection": "@.capitalize:{'terms.glossary.samme'} @:{'terms.glossary.tjeneste'}, @:{'terms.glossary.tillegg'} @:{'terms.glossary.og'} @:{'terms.glossary.ekstra'} @:{'terms.glossary.varer'} @:{'terms.glossary.som'} @:{'terms.glossary.forrige'} @:{'terms.glossary.vask'}",
|
||||
"manual_entry": "Manuell @:{'terms.glossary.registrering'}",
|
||||
"never_washed": "Aldri vasket",
|
||||
"new_order": "@.capitalize:{'terms.glossary.bestillingen'}",
|
||||
"new_sale": "@.capitalize:{'terms.glossary.nytt'} @:{'terms.glossary.salg'}",
|
||||
"no_bookings": "@.capitalize:{'terms.glossary.ingen'} @:{'terms.glossary.bestillinger'} @:{'terms.glossary.funnet'}",
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
},
|
||||
"last_wash_matches_current_selection": "@.capitalize:{'terms.glossary.samma'} @:{'terms.glossary.tjanst'}, @:{'terms.glossary.tillval'} @:{'terms.glossary.och'} @:{'terms.glossary.extra'} @:{'terms.glossary.artiklar'} @:{'terms.glossary.som'} @:{'terms.glossary.senaste'} @:{'terms.glossary.tvatten'}",
|
||||
"manual_entry": "Manuell @:{'terms.glossary.registrering'}",
|
||||
"never_washed": "Aldrig tvättad",
|
||||
"new_order": "@.capitalize:{'terms.glossary.ny'} @:{'terms.glossary.order'}",
|
||||
"new_sale": "@.capitalize:{'terms.glossary.nytt'} salg",
|
||||
"no_bookings": "@.capitalize:{'terms.glossary.ingen'} @:{'terms.glossary.bestillinger'} @:{'terms.glossary.funnet'}",
|
||||
|
||||
@@ -0,0 +1,439 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { SessionUser } from "@/components/session/token/SessionUser.vue";
|
||||
|
||||
type ProductAggregate = {
|
||||
product_id?: number | string;
|
||||
product_name: string;
|
||||
quantity: number;
|
||||
total_amount?: number | string | null;
|
||||
};
|
||||
|
||||
type AggregatesPayload = {
|
||||
customer_number?: number | string | null;
|
||||
date_from?: string | null;
|
||||
date_to?: string | null;
|
||||
primary_products: ProductAggregate[];
|
||||
addons: ProductAggregate[];
|
||||
};
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
customer: any;
|
||||
dateFrom?: string | null;
|
||||
dateTo?: string | null;
|
||||
useMockData?: boolean;
|
||||
}>(),
|
||||
{
|
||||
dateFrom: null,
|
||||
dateTo: null,
|
||||
useMockData: false,
|
||||
}
|
||||
);
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
|
||||
const AGGREGATES_ENDPOINT = "/superuser/invoicing/period/customer-aggregates";
|
||||
|
||||
const translate = (key: string, fallback: string, params: Record<string, any> = {}) => {
|
||||
const translated = t(key, params);
|
||||
return translated === key ? fallback : translated;
|
||||
};
|
||||
|
||||
const localeValue = () => (typeof locale === "string" ? locale : locale.value);
|
||||
|
||||
const aggregates = ref<AggregatesPayload | null>(null);
|
||||
const isLoading = ref(false);
|
||||
const errorMessage = ref<string | null>(null);
|
||||
|
||||
let pendingRequest = 0;
|
||||
|
||||
const buildMockAggregates = (): AggregatesPayload => {
|
||||
const primaryProducts: ProductAggregate[] = [
|
||||
{ product_id: "bilvask", product_name: "Bilvask", quantity: 5, total_amount: 750 },
|
||||
{ product_id: "storvask", product_name: "Storvask", quantity: 2, total_amount: 480 },
|
||||
];
|
||||
const addons: ProductAggregate[] = [
|
||||
{ product_id: "traekker", product_name: "Trækker", quantity: 1, total_amount: 25 },
|
||||
{ product_id: "spot_free", product_name: "Spot Free", quantity: 2, total_amount: 60 },
|
||||
];
|
||||
return {
|
||||
customer_number: props.customer?.customer_number ?? null,
|
||||
date_from: props.dateFrom ?? null,
|
||||
date_to: props.dateTo ?? null,
|
||||
primary_products: primaryProducts,
|
||||
addons,
|
||||
};
|
||||
};
|
||||
|
||||
const fetchAggregates = async () => {
|
||||
const customerNumber = Number(props.customer?.customer_number || 0);
|
||||
if (customerNumber < 1) {
|
||||
aggregates.value = null;
|
||||
return;
|
||||
}
|
||||
|
||||
const requestId = ++pendingRequest;
|
||||
isLoading.value = true;
|
||||
errorMessage.value = null;
|
||||
|
||||
try {
|
||||
if (props.useMockData) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 150));
|
||||
if (requestId !== pendingRequest) {
|
||||
return;
|
||||
}
|
||||
aggregates.value = buildMockAggregates();
|
||||
return;
|
||||
}
|
||||
|
||||
const params: Record<string, string> = { customer_number: String(customerNumber) };
|
||||
if (props.dateFrom) {
|
||||
params.date_from = props.dateFrom;
|
||||
}
|
||||
if (props.dateTo) {
|
||||
params.date_to = props.dateTo;
|
||||
}
|
||||
const response: any = await SessionUser.request(AGGREGATES_ENDPOINT, "GET", params);
|
||||
if (requestId !== pendingRequest) {
|
||||
return;
|
||||
}
|
||||
const data = response?.data?.data ?? response?.data ?? null;
|
||||
if (data && Array.isArray(data.primary_products) && Array.isArray(data.addons)) {
|
||||
aggregates.value = data as AggregatesPayload;
|
||||
} else {
|
||||
aggregates.value = { primary_products: [], addons: [] };
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (requestId !== pendingRequest) {
|
||||
return;
|
||||
}
|
||||
const status = Number(error?.response?.status || 0);
|
||||
if (status === 404 || status === 501) {
|
||||
aggregates.value = buildMockAggregates();
|
||||
errorMessage.value = translate(
|
||||
"invoicing_period.aggregates.using_mock_notice",
|
||||
"Backend endpoint not available — showing sample aggregates."
|
||||
);
|
||||
} else {
|
||||
errorMessage.value =
|
||||
error?.response?.data?.message ||
|
||||
error?.message ||
|
||||
translate("invoicing_period.aggregates.error", "Kunne ikke hente produkt- og tilvalgsoversigt.");
|
||||
aggregates.value = null;
|
||||
}
|
||||
} finally {
|
||||
if (requestId === pendingRequest) {
|
||||
isLoading.value = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const refresh = () => {
|
||||
fetchAggregates();
|
||||
};
|
||||
|
||||
defineExpose({ refresh });
|
||||
|
||||
watch(
|
||||
() => [
|
||||
Number(props.customer?.customer_number || 0),
|
||||
String(props.dateFrom || ""),
|
||||
String(props.dateTo || ""),
|
||||
Boolean(props.useMockData),
|
||||
],
|
||||
() => {
|
||||
fetchAggregates();
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
pendingRequest += 1;
|
||||
});
|
||||
|
||||
const hasPrimaryProducts = computed(
|
||||
() => Array.isArray(aggregates.value?.primary_products) && (aggregates.value?.primary_products?.length ?? 0) > 0
|
||||
);
|
||||
const hasAddons = computed(
|
||||
() => Array.isArray(aggregates.value?.addons) && (aggregates.value?.addons?.length ?? 0) > 0
|
||||
);
|
||||
const hasAnyAggregates = computed(() => hasPrimaryProducts.value || hasAddons.value);
|
||||
|
||||
const sortedPrimaryProducts = computed(() => {
|
||||
const list = Array.isArray(aggregates.value?.primary_products) ? [...aggregates.value!.primary_products] : [];
|
||||
return list.sort((a, b) => Number(b.quantity || 0) - Number(a.quantity || 0));
|
||||
});
|
||||
|
||||
const sortedAddons = computed(() => {
|
||||
const list = Array.isArray(aggregates.value?.addons) ? [...aggregates.value!.addons] : [];
|
||||
return list.sort((a, b) => Number(b.quantity || 0) - Number(a.quantity || 0));
|
||||
});
|
||||
|
||||
const formatQuantity = (value: any) => {
|
||||
const parsed = Number.parseInt(String(value ?? "0"), 10);
|
||||
return Number.isInteger(parsed) && parsed >= 0 ? parsed : 0;
|
||||
};
|
||||
|
||||
const formatCurrency = (value: any) => {
|
||||
const numeric = Number(value);
|
||||
if (!Number.isFinite(numeric)) {
|
||||
return "";
|
||||
}
|
||||
return SessionUser.functions.currency.toLocal(numeric);
|
||||
};
|
||||
|
||||
const heading = translate("invoicing_period.aggregates.heading", "Produktoversigt");
|
||||
const primaryHeading = translate("invoicing_period.aggregates.primary_products", "Primære produkter");
|
||||
const addonsHeading = translate("invoicing_period.aggregates.addons", "Tilvalg");
|
||||
const emptyLabel = translate("invoicing_period.aggregates.empty", "Ingen produkter");
|
||||
const loadingLabel = translate("invoicing_period.aggregates.loading", "Indlæser produktoversigt…");
|
||||
const totalLabel = translate("invoicing_period.aggregates.total", "i alt");
|
||||
const customerLabel = translate("invoicing_period.aggregates.for_customer", "for {name}", {
|
||||
name: String(props.customer?.customer_name || "").trim() || `#${props.customer?.customer_number ?? ""}`,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section
|
||||
class="product-aggregates-card"
|
||||
data-testid="invoicing-period-product-aggregates"
|
||||
:aria-label="heading"
|
||||
>
|
||||
<header class="product-aggregates-card__header">
|
||||
<div>
|
||||
<h3 class="product-aggregates-card__title">{{ heading }}</h3>
|
||||
<p class="product-aggregates-card__subtitle">{{ customerLabel }}</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="button is-small is-light product-aggregates-card__refresh"
|
||||
:aria-label="translate('invoicing_period.aggregates.refresh', 'Opdater produktoversigt')"
|
||||
:disabled="isLoading"
|
||||
data-testid="invoicing-period-product-aggregates-refresh"
|
||||
@click="refresh"
|
||||
>
|
||||
<span class="icon is-small">
|
||||
<i class="fas fa-sync-alt" :class="{ 'fa-spin': isLoading }"></i>
|
||||
</span>
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<p
|
||||
v-if="errorMessage"
|
||||
class="product-aggregates-card__notice"
|
||||
data-testid="invoicing-period-product-aggregates-notice"
|
||||
>
|
||||
{{ errorMessage }}
|
||||
</p>
|
||||
|
||||
<div v-if="isLoading && !hasAnyAggregates" class="product-aggregates-card__loading" role="status" data-testid="invoicing-period-product-aggregates-loading">
|
||||
<span class="icon is-small"><i class="fas fa-circle-notch fa-spin"></i></span>
|
||||
<span>{{ loadingLabel }}</span>
|
||||
</div>
|
||||
|
||||
<div v-else-if="!hasAnyAggregates" class="product-aggregates-card__empty" data-testid="invoicing-period-product-aggregates-empty">
|
||||
<span class="icon is-small has-text-grey"><i class="fas fa-box-open"></i></span>
|
||||
<span>{{ emptyLabel }}</span>
|
||||
</div>
|
||||
|
||||
<div v-else class="product-aggregates-card__sections">
|
||||
<div class="product-aggregates-card__section" data-testid="invoicing-period-product-aggregates-primary">
|
||||
<h4 class="product-aggregates-card__section-title">
|
||||
<span class="icon is-small"><i class="fas fa-soap"></i></span>
|
||||
<span>{{ primaryHeading }}</span>
|
||||
<span class="tag is-light is-rounded">{{ sortedPrimaryProducts.length }}</span>
|
||||
</h4>
|
||||
<ul v-if="hasPrimaryProducts" class="product-aggregates-card__list">
|
||||
<li
|
||||
v-for="item in sortedPrimaryProducts"
|
||||
:key="`primary-${item.product_id ?? item.product_name}`"
|
||||
class="product-aggregates-card__item"
|
||||
:data-testid="`invoicing-period-product-aggregates-primary-item-${item.product_id ?? item.product_name}`"
|
||||
>
|
||||
<span class="product-aggregates-card__item-name">{{ item.product_name }}</span>
|
||||
<span class="tag is-info is-light product-aggregates-card__qty">{{ formatQuantity(item.quantity) }}</span>
|
||||
<span
|
||||
v-if="formatCurrency(item.total_amount) !== ''"
|
||||
class="product-aggregates-card__amount has-text-grey"
|
||||
>
|
||||
{{ formatCurrency(item.total_amount) }}
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
<p v-else class="product-aggregates-card__section-empty">{{ emptyLabel }}</p>
|
||||
</div>
|
||||
|
||||
<div class="product-aggregates-card__section" data-testid="invoicing-period-product-aggregates-addons">
|
||||
<h4 class="product-aggregates-card__section-title">
|
||||
<span class="icon is-small"><i class="fas fa-puzzle-piece"></i></span>
|
||||
<span>{{ addonsHeading }}</span>
|
||||
<span class="tag is-light is-rounded">{{ sortedAddons.length }}</span>
|
||||
</h4>
|
||||
<ul v-if="hasAddons" class="product-aggregates-card__list">
|
||||
<li
|
||||
v-for="item in sortedAddons"
|
||||
:key="`addon-${item.product_id ?? item.product_name}`"
|
||||
class="product-aggregates-card__item"
|
||||
:data-testid="`invoicing-period-product-aggregates-addon-item-${item.product_id ?? item.product_name}`"
|
||||
>
|
||||
<span class="product-aggregates-card__item-name">{{ item.product_name }}</span>
|
||||
<span class="tag is-warning is-light product-aggregates-card__qty">{{ formatQuantity(item.quantity) }}</span>
|
||||
<span
|
||||
v-if="formatCurrency(item.total_amount) !== ''"
|
||||
class="product-aggregates-card__amount has-text-grey"
|
||||
>
|
||||
{{ formatCurrency(item.total_amount) }}
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
<p v-else class="product-aggregates-card__section-empty">{{ emptyLabel }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p v-if="hasAnyAggregates" class="product-aggregates-card__hint has-text-grey">
|
||||
<span class="icon is-small"><i class="fas fa-info-circle"></i></span>
|
||||
<span>{{ totalLabel }}: {{ sortedPrimaryProducts.length + sortedAddons.length }}</span>
|
||||
</p>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.product-aggregates-card {
|
||||
background: #f7f9fb;
|
||||
border: 1px solid #dfe3e8;
|
||||
border-radius: 8px;
|
||||
display: grid;
|
||||
gap: 0.6rem;
|
||||
margin-top: 0.75rem;
|
||||
padding: 0.85rem 1rem;
|
||||
}
|
||||
|
||||
.product-aggregates-card__header {
|
||||
align-items: start;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.product-aggregates-card__title {
|
||||
color: #263142;
|
||||
font-size: 0.95rem;
|
||||
font-weight: 700;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.product-aggregates-card__subtitle {
|
||||
color: #6b7280;
|
||||
font-size: 0.75rem;
|
||||
margin: 0.1rem 0 0;
|
||||
}
|
||||
|
||||
.product-aggregates-card__refresh {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.product-aggregates-card__notice {
|
||||
background: #fff7e0;
|
||||
border: 1px solid #f1d27b;
|
||||
border-radius: 6px;
|
||||
color: #7a5b00;
|
||||
font-size: 0.78rem;
|
||||
margin: 0;
|
||||
padding: 0.35rem 0.6rem;
|
||||
}
|
||||
|
||||
.product-aggregates-card__loading,
|
||||
.product-aggregates-card__empty {
|
||||
align-items: center;
|
||||
color: #536174;
|
||||
display: flex;
|
||||
gap: 0.4rem;
|
||||
padding: 0.35rem 0;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.product-aggregates-card__sections {
|
||||
display: grid;
|
||||
gap: 0.75rem;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.product-aggregates-card__section {
|
||||
background: #fff;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 6px;
|
||||
padding: 0.55rem 0.7rem;
|
||||
}
|
||||
|
||||
.product-aggregates-card__section-title {
|
||||
align-items: center;
|
||||
color: #263142;
|
||||
display: flex;
|
||||
font-size: 0.82rem;
|
||||
font-weight: 700;
|
||||
gap: 0.35rem;
|
||||
margin: 0 0 0.4rem;
|
||||
}
|
||||
|
||||
.product-aggregates-card__section-title .tag {
|
||||
font-size: 0.7rem;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.product-aggregates-card__list {
|
||||
display: grid;
|
||||
gap: 0.25rem;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.product-aggregates-card__item {
|
||||
align-items: center;
|
||||
display: grid;
|
||||
font-size: 0.82rem;
|
||||
gap: 0.4rem;
|
||||
grid-template-columns: minmax(0, 1fr) auto auto;
|
||||
}
|
||||
|
||||
.product-aggregates-card__item-name {
|
||||
color: #1f2937;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.product-aggregates-card__qty {
|
||||
border-radius: 999px;
|
||||
font-weight: 700;
|
||||
min-width: 1.8rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.product-aggregates-card__amount {
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.product-aggregates-card__section-empty {
|
||||
color: #6b7280;
|
||||
font-size: 0.8rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.product-aggregates-card__hint {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
font-size: 0.72rem;
|
||||
gap: 0.3rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 768px) {
|
||||
.product-aggregates-card__sections {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -109,6 +109,26 @@ const REVIEW_WORKSPACE_TRANSLATORS = {
|
||||
composer.t("invoicing_period.review_workspace.states.refreshing", params),
|
||||
"states.retained_error": (composer, params) =>
|
||||
composer.t("invoicing_period.review_workspace.states.retained_error", params),
|
||||
"aggregates.heading": (composer, params) =>
|
||||
composer.t("invoicing_period.review_workspace.aggregates.heading", params),
|
||||
"aggregates.primary_products": (composer, params) =>
|
||||
composer.t("invoicing_period.review_workspace.aggregates.primary_products", params),
|
||||
"aggregates.addons": (composer, params) =>
|
||||
composer.t("invoicing_period.review_workspace.aggregates.addons", params),
|
||||
"aggregates.empty": (composer, params) =>
|
||||
composer.t("invoicing_period.review_workspace.aggregates.empty", params),
|
||||
"aggregates.loading": (composer, params) =>
|
||||
composer.t("invoicing_period.review_workspace.aggregates.loading", params),
|
||||
"aggregates.error": (composer, params) =>
|
||||
composer.t("invoicing_period.review_workspace.aggregates.error", params),
|
||||
"aggregates.refresh": (composer, params) =>
|
||||
composer.t("invoicing_period.review_workspace.aggregates.refresh", params),
|
||||
"aggregates.total": (composer, params) =>
|
||||
composer.t("invoicing_period.review_workspace.aggregates.total", params),
|
||||
"aggregates.for_customer": (composer, params) =>
|
||||
composer.t("invoicing_period.review_workspace.aggregates.for_customer", params),
|
||||
"aggregates.using_mock_notice": (composer, params) =>
|
||||
composer.t("invoicing_period.review_workspace.aggregates.using_mock_notice", params),
|
||||
"toolbar.all_departments": (composer, params) =>
|
||||
composer.t("invoicing_period.review_workspace.toolbar.all_departments", params),
|
||||
"toolbar.all_invoice_states": (composer, params) =>
|
||||
|
||||
@@ -23,6 +23,7 @@ import InvoicingBillingPeriodFilters from "@/views/dashboards/superUserDashboard
|
||||
import InvoicingBillingPeriodCustomerAttributes from "@/views/dashboards/superUserDashboard/InvoicingBillingPeriod/displays/layout/InvoicingBillingPeriodCustomerAttributes.vue";
|
||||
import InvoicingPeriodFlagList from "@/views/dashboards/superUserDashboard/InvoicingBillingPeriod/components/InvoicingPeriodFlagList.vue";
|
||||
import InvoicingPeriodObjectTree from "@/views/dashboards/superUserDashboard/InvoicingBillingPeriod/components/InvoicingPeriodObjectTree.vue";
|
||||
import ProductAggregatesCard from "@/views/dashboards/superUserDashboard/InvoicingBillingPeriod/components/ProductAggregatesCard.vue";
|
||||
import PaginationNavigation from "@/components/displays/pagination/PaginationNavigation.vue";
|
||||
import {
|
||||
buildMultiMonthInvoiceContext,
|
||||
@@ -977,6 +978,10 @@ const getTransactionQueryParameters = () => {
|
||||
show_fixed_pricing: true,
|
||||
};
|
||||
};
|
||||
|
||||
// TRU-185: Backend product aggregate endpoint (TRU-182) is not yet merged.
|
||||
// Set to true once `/superuser/invoicing/period/customer-aggregates` is live.
|
||||
const isProductAggregatesEndpointAvailable = false;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -1608,6 +1613,12 @@ const getTransactionQueryParameters = () => {
|
||||
<span v-if="Number(reason.count || 0) > 1" class="tag is-light is-rounded">{{ reason.count }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
<ProductAggregatesCard
|
||||
:customer="selectedCustomer"
|
||||
:date-from="dates.computed.formattedStartDate.value"
|
||||
:date-to="dates.computed.formattedEndDate.value"
|
||||
:use-mock-data="!isProductAggregatesEndpointAvailable"
|
||||
/>
|
||||
<div
|
||||
v-if="selectedCustomer.expanded"
|
||||
class="period-review-detail__tree"
|
||||
|
||||
@@ -161,10 +161,14 @@ import {
|
||||
periodPaging,
|
||||
resetPeriodPagingState,
|
||||
} from "@/views/dashboards/superUserDashboard/InvoicingBillingPeriod/imports/InvoicingBillingPeriodImportPaging.js";
|
||||
import { createTestI18n } from "./helpers/mountWithApp.js";
|
||||
|
||||
const viewI18n = createTestI18n();
|
||||
|
||||
const mountView = () =>
|
||||
mount(InvoicingBillingPeriodViewAll, {
|
||||
global: {
|
||||
plugins: [viewI18n],
|
||||
stubs: {
|
||||
"b-tabs": {
|
||||
template: "<div data-testid='b-tabs-stub'><slot /></div>",
|
||||
|
||||
@@ -83,6 +83,7 @@ vi.mock("@/components/session/token/SessionUser.vue", () => ({
|
||||
},
|
||||
global: {
|
||||
language: {
|
||||
last_wash: "Last wash",
|
||||
nothing_left_to_show: "Nothing left to show",
|
||||
},
|
||||
},
|
||||
@@ -133,6 +134,7 @@ const messages = {
|
||||
make: "Make",
|
||||
model: "Model",
|
||||
no_plates_found: "No license plates found",
|
||||
never_washed: "Never washed",
|
||||
recent_scans: "Recent scans",
|
||||
recent_scans_helper: "Select a license plate to view vehicle details.",
|
||||
recent_scan_details_empty: "No vehicle details are available for this scan.",
|
||||
@@ -164,6 +166,9 @@ const scans = [
|
||||
customer_name: "Pleno Logistics",
|
||||
seen_before: true,
|
||||
barred: false,
|
||||
// TRU-78: enriched by the API so the landing page can show when
|
||||
// the plate was last washed (DHL pick-up use case).
|
||||
last_wash: "2026-04-07 17:12:33",
|
||||
},
|
||||
{
|
||||
id: 802,
|
||||
@@ -174,6 +179,22 @@ const scans = [
|
||||
customer_name: "",
|
||||
seen_before: false,
|
||||
barred: false,
|
||||
// TRU-78: explicit null means the API confirmed the plate has
|
||||
// never been washed.
|
||||
last_wash: null,
|
||||
},
|
||||
{
|
||||
id: 803,
|
||||
plate: "EF11111",
|
||||
plate_scanner_id: 3,
|
||||
created_at: "2026-04-08 08:30:00",
|
||||
customer_number: null,
|
||||
customer_name: "",
|
||||
seen_before: false,
|
||||
barred: false,
|
||||
// TRU-78: missing field should be treated as "never washed" too,
|
||||
// so older backends don't break the new UI.
|
||||
// (no `last_wash` key on purpose)
|
||||
},
|
||||
];
|
||||
|
||||
@@ -341,4 +362,59 @@ describe("PosLastScannedLicensePlatesV2", () => {
|
||||
"Vehicle details could not be loaded"
|
||||
);
|
||||
});
|
||||
|
||||
// TRU-78 / DRIFT 17: license plate scan should show "last washed" on the
|
||||
// landing page so the operator can see at a glance when a trailer was
|
||||
// last washed (DHL pick-up use case).
|
||||
it("renders the last washed timestamp when the scan has a last_wash value", async () => {
|
||||
const wrapper = mountWithApp(PosLastScannedLicensePlatesV2, { messages });
|
||||
|
||||
await vi.advanceTimersByTimeAsync(1000);
|
||||
paginationState.list.value = scans;
|
||||
await flushUi();
|
||||
|
||||
await wrapper.get('[data-testid="pos-recent-scan-row-801"]').trigger("click");
|
||||
await flushUi();
|
||||
|
||||
const lastWashField = wrapper.get('[data-testid="pos-recent-scan-detail-801-last-wash"]');
|
||||
expect(lastWashField.exists()).toBe(true);
|
||||
expect(lastWashField.text()).toContain("Last wash");
|
||||
// The MySQL DATETIME "2026-04-07 17:12:33" is rendered in the user's
|
||||
// locale. We accept both the raw DATETIME string (jsdom without full
|
||||
// Intl support) and the locale-formatted output (e.g. 04/07/2026 or
|
||||
// 2026-04-07 in browsers with Intl.DateTimeFormat).
|
||||
expect(lastWashField.text()).toMatch(/2026/);
|
||||
expect(lastWashField.text()).toMatch(/04[\/.\- ]07|07[\/.\- ]04|7[\/.\- ]4|2026-04-07/);
|
||||
expect(lastWashField.text()).toMatch(/17:12/);
|
||||
});
|
||||
|
||||
it("shows the 'never washed' message when the API confirms the plate has no last_wash", async () => {
|
||||
const wrapper = mountWithApp(PosLastScannedLicensePlatesV2, { messages });
|
||||
|
||||
await vi.advanceTimersByTimeAsync(1000);
|
||||
paginationState.list.value = scans;
|
||||
await flushUi();
|
||||
|
||||
await wrapper.get('[data-testid="pos-recent-scan-row-802"]').trigger("click");
|
||||
await flushUi();
|
||||
|
||||
const neverWashed = wrapper.get('[data-testid="pos-recent-scan-never-washed-802"]');
|
||||
expect(neverWashed.exists()).toBe(true);
|
||||
expect(neverWashed.text()).toContain("Never washed");
|
||||
});
|
||||
|
||||
it("falls back to 'never washed' when the scan has no last_wash key at all", async () => {
|
||||
const wrapper = mountWithApp(PosLastScannedLicensePlatesV2, { messages });
|
||||
|
||||
await vi.advanceTimersByTimeAsync(1000);
|
||||
paginationState.list.value = scans;
|
||||
await flushUi();
|
||||
|
||||
await wrapper.get('[data-testid="pos-recent-scan-row-803"]').trigger("click");
|
||||
await flushUi();
|
||||
|
||||
const neverWashed = wrapper.get('[data-testid="pos-recent-scan-never-washed-803"]');
|
||||
expect(neverWashed.exists()).toBe(true);
|
||||
expect(neverWashed.text()).toContain("Never washed");
|
||||
});
|
||||
});
|
||||
|
||||