Merge branch 'master' of https://gitea.verdnatura.es/verdnatura/salix-front into test
gitea/salix-front/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2025-05-05 07:45:16 +02:00
commit cf487b5a0d
5 changed files with 51 additions and 19 deletions

View File

@ -15,7 +15,7 @@ import InvoiceOutDescriptorProxy from 'pages/InvoiceOut/Card/InvoiceOutDescripto
import RouteDescriptorProxy from 'src/pages/Route/Card/RouteDescriptorProxy.vue';
import VnTable from 'src/components/VnTable/VnTable.vue';
import CustomerDescriptorProxy from '../Card/CustomerDescriptorProxy.vue';
import { getItemPackagingType } from '../composables/getItemPackagingType.js';
const { t } = useI18n();
const route = useRoute();
const router = useRouter();
@ -161,23 +161,6 @@ const setShippedColor = (date) => {
};
const rowClick = ({ id }) =>
window.open(router.resolve({ params: { id }, name: 'TicketSummary' }).href, '_blank');
const getItemPackagingType = (ticketSales) => {
if (!ticketSales?.length) return '-';
const packagingTypes = ticketSales.reduce((types, sale) => {
const { itemPackingTypeFk } = sale.item;
if (
!types.includes(itemPackingTypeFk) &&
(itemPackingTypeFk === 'H' || itemPackingTypeFk === 'V')
) {
types.push(itemPackingTypeFk);
}
return types;
}, []);
return dashIfEmpty(packagingTypes.join(', ') || '-');
};
</script>
<template>

View File

@ -0,0 +1,36 @@
import { describe, it, expect } from 'vitest';
import { getItemPackagingType } from '../getItemPackagingType';
describe('getItemPackagingType', () => {
it('should return "-" if ticketSales is null or undefined', () => {
expect(getItemPackagingType(null)).toBe('-');
expect(getItemPackagingType(undefined)).toBe('-');
});
it('should return "-" if ticketSales does not have a length property', () => {
const ticketSales = { someKey: 'someValue' }; // No tiene propiedad length
expect(getItemPackagingType(ticketSales)).toBe('-');
});
it('should return unique packaging types as a comma-separated string', () => {
const ticketSales = [
{ item: { itemPackingTypeFk: 'H' } },
{ item: { itemPackingTypeFk: 'V' } },
{ item: { itemPackingTypeFk: 'H' } },
];
expect(getItemPackagingType(ticketSales)).toBe('H, V');
});
it('should return unique packaging types as a comma-separated string', () => {
const ticketSales = [
{ item: { itemPackingTypeFk: 'H' } },
{ item: { itemPackingTypeFk: 'V' } },
{ item: { itemPackingTypeFk: 'H' } },
{ item: { itemPackingTypeFk: 'A' } },
];
expect(getItemPackagingType(ticketSales)).toBe('H, V, A');
});
it('should return "-" if ticketSales is an empty array', () => {
expect(getItemPackagingType([])).toBe('-');
});
});

View File

@ -0,0 +1,11 @@
import { dashIfEmpty } from 'src/filters';
export function getItemPackagingType(ticketSales) {
if (!ticketSales?.length) return '-';
const packagingTypes = Array.from(
new Set(ticketSales.map(({ item: { itemPackingTypeFk } }) => itemPackingTypeFk)),
);
return dashIfEmpty(packagingTypes.join(', '));
}

View File

@ -13,6 +13,8 @@ export default {
'daysInForward',
'availabled',
'awbFk',
'isDelivered',
'isReceived',
],
include: [
{

View File

@ -408,7 +408,7 @@ const isUnsatisfied = async (reason) => {
const resendEmail = async () => {
const params = {
recipient: worker.value[0]?.user?.emailUser?.email,
recipient: worker.value?.user?.emailUser?.email,
week: selectedWeekNumber.value,
year: selectedDateYear.value,
workerId: Number(route.params.id),