Merge pull request '#333158 - hotfix packingType customerTicketList' (!1770) from hotfix_packingType_customerTicketList into master
gitea/salix-front/pipeline/head This commit looks good
Details
gitea/salix-front/pipeline/head This commit looks good
Details
Reviewed-on: #1770 Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
commit
645f0381f6
|
@ -15,7 +15,7 @@ import InvoiceOutDescriptorProxy from 'pages/InvoiceOut/Card/InvoiceOutDescripto
|
||||||
import RouteDescriptorProxy from 'src/pages/Route/Card/RouteDescriptorProxy.vue';
|
import RouteDescriptorProxy from 'src/pages/Route/Card/RouteDescriptorProxy.vue';
|
||||||
import VnTable from 'src/components/VnTable/VnTable.vue';
|
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||||
import CustomerDescriptorProxy from '../Card/CustomerDescriptorProxy.vue';
|
import CustomerDescriptorProxy from '../Card/CustomerDescriptorProxy.vue';
|
||||||
|
import { getItemPackagingType } from '../composables/getItemPackagingType.js';
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
@ -161,23 +161,6 @@ const setShippedColor = (date) => {
|
||||||
};
|
};
|
||||||
const rowClick = ({ id }) =>
|
const rowClick = ({ id }) =>
|
||||||
window.open(router.resolve({ params: { id }, name: 'TicketSummary' }).href, '_blank');
|
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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -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('-');
|
||||||
|
});
|
||||||
|
});
|
|
@ -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(', '));
|
||||||
|
}
|
Loading…
Reference in New Issue