Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix-front into dev
gitea/salix-front/pipeline/head This commit looks good
Details
gitea/salix-front/pipeline/head This commit looks good
Details
This commit is contained in:
commit
23669e118f
|
@ -132,8 +132,7 @@ const card = toRef(props, 'item');
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
white-space: nowrap;
|
||||
width: 192px;
|
||||
|
||||
p {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ const detailsColumns = ref([
|
|||
{
|
||||
name: 'item',
|
||||
label: 'claim.item',
|
||||
field: (row) => row.sale.itemFk,
|
||||
field: (row) => dashIfEmpty(row.sale.itemFk),
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
|
@ -67,13 +67,13 @@ const detailsColumns = ref([
|
|||
{
|
||||
name: 'quantity',
|
||||
label: 'claim.quantity',
|
||||
field: (row) => row.sale.quantity,
|
||||
field: (row) => dashIfEmpty(row.sale.quantity),
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
name: 'claimed',
|
||||
label: 'claim.claimed',
|
||||
field: (row) => row.quantity,
|
||||
field: (row) => dashIfEmpty(row.quantity),
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ const detailsColumns = ref([
|
|||
{
|
||||
name: 'price',
|
||||
label: 'claim.price',
|
||||
field: (row) => row.sale.price,
|
||||
field: (row) => dashIfEmpty(row.sale.price),
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
|
@ -337,23 +337,16 @@ function claimUrl(section) {
|
|||
</QTh>
|
||||
</QTr>
|
||||
</template>
|
||||
<template #body="props">
|
||||
<QTr :props="props">
|
||||
<QTd v-for="col in props.cols" :key="col.name" :props="props">
|
||||
<template v-if="col.name === 'description'">
|
||||
<span class="link">{{
|
||||
dashIfEmpty(col.field(props.row))
|
||||
}}</span>
|
||||
<ItemDescriptorProxy
|
||||
:id="props.row.sale.itemFk"
|
||||
:sale-fk="props.row.saleFk"
|
||||
/>
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ dashIfEmpty(col.field(props.row)) }}
|
||||
</template>
|
||||
</QTd>
|
||||
</QTr>
|
||||
<template #body-cell-description="props">
|
||||
<QTd :props="props">
|
||||
<span class="link">
|
||||
{{ props.value }}
|
||||
</span>
|
||||
<ItemDescriptorProxy
|
||||
:id="props.row.sale.itemFk"
|
||||
:sale-fk="props.row.saleFk"
|
||||
/>
|
||||
</QTd>
|
||||
</template>
|
||||
</QTable>
|
||||
</QCard>
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
|
||||
import { dashIfEmpty, toCurrency, toDate } from 'src/filters';
|
||||
import { useQuasar } from 'quasar';
|
||||
|
||||
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
||||
import ModalCloseContract from 'src/pages/Customer/components/ModalCloseContract.vue';
|
||||
import { toDate } from 'src/filters';
|
||||
import CustomerCreditContractsCreate from '../components/CustomerCreditContractsCreate.vue';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
|
@ -16,6 +17,7 @@ const quasar = useQuasar();
|
|||
|
||||
const vnPaginateRef = ref(null);
|
||||
const showQPageSticky = ref(true);
|
||||
const showForm = ref();
|
||||
|
||||
const filter = {
|
||||
order: 'finished ASC, started DESC',
|
||||
|
@ -36,25 +38,21 @@ const fetch = (data) => {
|
|||
data.forEach((element) => {
|
||||
if (!element.finished) {
|
||||
showQPageSticky.value = false;
|
||||
return;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const toCustomerCreditContractsCreate = () => {
|
||||
router.push({ name: 'CustomerCreditContractsCreate' });
|
||||
};
|
||||
|
||||
const openDialog = (item) => {
|
||||
quasar.dialog({
|
||||
component: ModalCloseContract,
|
||||
componentProps: {
|
||||
id: item.id,
|
||||
promise: updateData,
|
||||
promise: async () => {
|
||||
await updateData();
|
||||
showQPageSticky.value = true;
|
||||
},
|
||||
},
|
||||
});
|
||||
updateData();
|
||||
showQPageSticky.value = true;
|
||||
};
|
||||
|
||||
const openViewCredit = (credit) => {
|
||||
|
@ -66,14 +64,14 @@ const openViewCredit = (credit) => {
|
|||
});
|
||||
};
|
||||
|
||||
const updateData = () => {
|
||||
vnPaginateRef.value?.fetch();
|
||||
const updateData = async () => {
|
||||
await vnPaginateRef.value?.fetch();
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="full-width flex justify-center">
|
||||
<QCard class="card-width q-pa-lg">
|
||||
<section class="row justify-center">
|
||||
<QCard class="q-pa-lg" style="width: 70%">
|
||||
<VnPaginate
|
||||
:user-filter="filter"
|
||||
@on-fetch="fetch"
|
||||
|
@ -84,100 +82,84 @@ const updateData = () => {
|
|||
url="CreditClassifications"
|
||||
>
|
||||
<template #body="{ rows }">
|
||||
<div v-if="rows.length">
|
||||
<div v-if="rows.length" class="q-gutter-y-md">
|
||||
<QCard
|
||||
v-for="(item, index) in rows"
|
||||
:key="index"
|
||||
:class="{
|
||||
'customer-card': true,
|
||||
'q-mb-md': index < rows.length - 1,
|
||||
'is-active': !item.finished,
|
||||
}"
|
||||
:class="{ disabled: item.finished }"
|
||||
>
|
||||
<QCardSection
|
||||
class="full-width flex justify-between q-py-none"
|
||||
class="full-width"
|
||||
:class="{ 'row justify-between': $q.screen.gt.md }"
|
||||
>
|
||||
<div class="width-state flex">
|
||||
<div
|
||||
class="flex items-center cursor-pointer q-mr-md"
|
||||
v-if="!item.finished"
|
||||
<div class="width-state row no-wrap">
|
||||
<QIcon
|
||||
:style="{
|
||||
visibility: item.finished
|
||||
? 'hidden'
|
||||
: 'visible',
|
||||
}"
|
||||
@click.stop="openDialog(item)"
|
||||
color="primary"
|
||||
name="lock"
|
||||
data-cy="closeBtn"
|
||||
size="md"
|
||||
class="fill-icon q-px-md"
|
||||
>
|
||||
<QIcon
|
||||
@click.stop="openDialog(item)"
|
||||
color="primary"
|
||||
name="lock"
|
||||
size="md"
|
||||
class="fill-icon"
|
||||
>
|
||||
<QTooltip>{{ t('Close contract') }}</QTooltip>
|
||||
</QIcon>
|
||||
</div>
|
||||
<QTooltip>{{ t('Close contract') }}</QTooltip>
|
||||
</QIcon>
|
||||
|
||||
<div>
|
||||
<div class="flex q-mb-xs">
|
||||
<div class="q-mr-sm color-vn-label">
|
||||
{{ t('Since') }}:
|
||||
</div>
|
||||
<div class="text-weight-bold">
|
||||
{{ toDate(item.started) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<div class="q-mr-sm color-vn-label">
|
||||
{{ t('To') }}:
|
||||
</div>
|
||||
<div class="text-weight-bold">
|
||||
{{ toDate(item.finished) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<VnLv
|
||||
:label="t('Since')"
|
||||
:value="toDate(item.started)"
|
||||
/>
|
||||
<VnLv
|
||||
:label="t('To')"
|
||||
:value="toDate(item.finished)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<QSeparator vertical />
|
||||
|
||||
<div class="width-data flex">
|
||||
<div class="column width-data">
|
||||
<div
|
||||
class="full-width flex justify-between items-center"
|
||||
class="column"
|
||||
v-if="item?.insurances.length"
|
||||
v-for="insurance in item.insurances"
|
||||
:key="insurance.id"
|
||||
>
|
||||
<div class="flex">
|
||||
<div class="color-vn-label q-mr-xs">
|
||||
{{ t('Credit') }}:
|
||||
</div>
|
||||
<div class="text-weight-bold">
|
||||
{{ item.insurances[0].credit }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<div class="color-vn-label q-mr-xs">
|
||||
{{ t('Grade') }}:
|
||||
</div>
|
||||
<div class="text-weight-bold">
|
||||
{{ item.insurances[0].grade || '-' }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<div class="color-vn-label q-mr-xs">
|
||||
{{ t('Date') }}:
|
||||
</div>
|
||||
<div class="text-weight-bold">
|
||||
{{ toDate(item.insurances[0].created) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center cursor-pointer">
|
||||
<QIcon
|
||||
@click.stop="openViewCredit(item)"
|
||||
color="primary"
|
||||
name="preview"
|
||||
size="md"
|
||||
>
|
||||
<QTooltip>{{
|
||||
t('View credits')
|
||||
}}</QTooltip>
|
||||
</QIcon>
|
||||
<div
|
||||
:class="{
|
||||
'row q-gutter-x-md': $q.screen.gt.sm,
|
||||
}"
|
||||
class="q-mb-sm"
|
||||
>
|
||||
<VnLv
|
||||
:label="t('Credit')"
|
||||
:value="toCurrency(insurance.credit)"
|
||||
/>
|
||||
<VnLv
|
||||
:label="t('Grade')"
|
||||
:value="dashIfEmpty(insurance.grade)"
|
||||
/>
|
||||
<VnLv
|
||||
:label="t('Date')"
|
||||
:value="toDate(insurance.created)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<QBtn
|
||||
@click.stop="openViewCredit(item)"
|
||||
icon="preview"
|
||||
size="md"
|
||||
:title="t('View credits')"
|
||||
data-cy="viewBtn"
|
||||
color="primary"
|
||||
flat
|
||||
/>
|
||||
</QCardSection>
|
||||
</QCard>
|
||||
</div>
|
||||
|
@ -187,11 +169,12 @@ const updateData = () => {
|
|||
</template>
|
||||
</VnPaginate>
|
||||
</QCard>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<QPageSticky :offset="[18, 18]" v-if="showQPageSticky">
|
||||
<QBtn
|
||||
@click.stop="toCustomerCreditContractsCreate()"
|
||||
data-cy="createBtn"
|
||||
@click.stop="showForm = !showForm"
|
||||
color="primary"
|
||||
fab
|
||||
icon="add"
|
||||
|
@ -201,24 +184,25 @@ const updateData = () => {
|
|||
{{ t('New contract') }}
|
||||
</QTooltip>
|
||||
</QPageSticky>
|
||||
|
||||
<QDialog v-model="showForm">
|
||||
<CustomerCreditContractsCreate @on-data-saved="updateData()" />
|
||||
</QDialog>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.customer-card {
|
||||
border: 2px solid var(--vn-light-gray);
|
||||
border-radius: 10px;
|
||||
padding: 10px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.is-active {
|
||||
background-color: var(--vn-light-gray);
|
||||
}
|
||||
.width-state {
|
||||
width: 30%;
|
||||
}
|
||||
.width-data {
|
||||
width: 65%;
|
||||
width: 50%;
|
||||
}
|
||||
::v-deep(.label) {
|
||||
margin-right: 5px;
|
||||
}
|
||||
::v-deep(.label)::after {
|
||||
content: ':';
|
||||
color: var(--vn-label-color);
|
||||
}
|
||||
</style>
|
||||
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
<script setup>
|
||||
import { computed, onBeforeMount, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import { toCurrency, toDate } from 'src/filters';
|
||||
|
||||
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||
import axios from 'axios';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const create = ref(null);
|
||||
const tableRef = ref();
|
||||
const columns = computed(() => [
|
||||
{
|
||||
align: 'left',
|
||||
field: 'created',
|
||||
format: ({ created }) => toDate(created),
|
||||
label: t('Created'),
|
||||
name: 'created',
|
||||
create: true,
|
||||
columnCreate: {
|
||||
component: 'date',
|
||||
},
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: 'grade',
|
||||
label: t('Grade'),
|
||||
name: 'grade',
|
||||
create: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
format: ({ credit }) => toCurrency(credit),
|
||||
label: t('Credit'),
|
||||
name: 'credit',
|
||||
create: true,
|
||||
},
|
||||
]);
|
||||
|
||||
onBeforeMount(async () => {
|
||||
const query = `CreditClassifications/findOne?filter=${encodeURIComponent(
|
||||
JSON.stringify({
|
||||
fields: ['finished'],
|
||||
where: { id: route.params.creditId },
|
||||
}),
|
||||
)}`;
|
||||
const { data } = await axios(query);
|
||||
create.value = data.finished
|
||||
? false
|
||||
: {
|
||||
urlCreate: 'CreditInsurances',
|
||||
title: t('Create Insurance'),
|
||||
onDataSaved: () => tableRef.value.reload(),
|
||||
formInitialData: {
|
||||
created: Date.vnNew(),
|
||||
creditClassificationFk: route.params.creditId,
|
||||
},
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnTable
|
||||
v-if="create != null"
|
||||
url="CreditInsurances"
|
||||
ref="tableRef"
|
||||
data-key="creditInsurances"
|
||||
:filter="{
|
||||
where: {
|
||||
creditClassificationFk: `${route.params.creditId}`,
|
||||
},
|
||||
order: 'created DESC',
|
||||
}"
|
||||
:columns="columns"
|
||||
:right-search="false"
|
||||
:is-editable="false"
|
||||
:use-model="true"
|
||||
:column-search="false"
|
||||
:disable-option="{ card: true }"
|
||||
:create
|
||||
auto-load
|
||||
/>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
es:
|
||||
Created: Fecha creación
|
||||
Grade: Grade
|
||||
Credit: Crédito
|
||||
</i18n>
|
|
@ -26,6 +26,7 @@ const columns = computed(() => [
|
|||
url: 'Clients',
|
||||
fields: ['id', 'socialName'],
|
||||
optionLabel: 'socialName',
|
||||
optionValue: 'socialName',
|
||||
},
|
||||
},
|
||||
columnClass: 'expand',
|
||||
|
@ -37,8 +38,11 @@ const columns = computed(() => [
|
|||
name: 'city',
|
||||
columnFilter: {
|
||||
component: 'select',
|
||||
inWhere: true,
|
||||
attrs: {
|
||||
url: 'Towns',
|
||||
optionValue: 'name',
|
||||
optionLabel: 'name',
|
||||
},
|
||||
},
|
||||
cardVisible: true,
|
||||
|
@ -94,7 +98,7 @@ const columns = computed(() => [
|
|||
</VnSubToolbar>
|
||||
<VnTable
|
||||
:data-key="dataKey"
|
||||
url="Clients/filter"
|
||||
url="Clients/extendedListFilter"
|
||||
:table="{
|
||||
'row-key': 'id',
|
||||
selection: 'multiple',
|
||||
|
|
|
@ -3,44 +3,29 @@ import { reactive, computed } from 'vue';
|
|||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
|
||||
import FormModel from 'components/FormModel.vue';
|
||||
import VnRow from 'components/ui/VnRow.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
||||
import FormModelPopup from 'src/components/FormModelPopup.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const routeId = computed(() => route.params.id);
|
||||
const router = useRouter();
|
||||
|
||||
const initialData = reactive({
|
||||
started: Date.vnNew(),
|
||||
clientFk: routeId.value,
|
||||
});
|
||||
|
||||
const toCustomerCreditContracts = () => {
|
||||
router.push({ name: 'CustomerCreditContracts' });
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FormModel
|
||||
<FormModelPopup
|
||||
v-on="$attrs"
|
||||
:form-initial-data="initialData"
|
||||
:observe-form-changes="false"
|
||||
url-create="creditClassifications/createWithInsurance"
|
||||
@on-data-saved="toCustomerCreditContracts()"
|
||||
>
|
||||
<template #moreActions>
|
||||
<QBtn
|
||||
:label="t('globals.cancel')"
|
||||
@click="toCustomerCreditContracts"
|
||||
color="primary"
|
||||
flat
|
||||
icon="close"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template #form="{ data }">
|
||||
<template #form-inputs="{ data }">
|
||||
<VnRow>
|
||||
<div class="col">
|
||||
<VnInput
|
||||
|
@ -63,7 +48,7 @@ const toCustomerCreditContracts = () => {
|
|||
</div>
|
||||
</VnRow>
|
||||
</template>
|
||||
</FormModel>
|
||||
</FormModelPopup>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import { toCurrency, toDate } from 'src/filters';
|
||||
|
||||
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
|
||||
const filter = {
|
||||
where: {
|
||||
creditClassificationFk: `${route.params.creditId}`,
|
||||
},
|
||||
limit: 20,
|
||||
};
|
||||
const columns = computed(() => [
|
||||
{
|
||||
align: 'left',
|
||||
field: 'created',
|
||||
format: ({ created }) => toDate(created),
|
||||
label: t('Created'),
|
||||
name: 'created',
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: 'grade',
|
||||
label: t('Grade'),
|
||||
name: 'grade',
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
format: ({ credit }) => toCurrency(credit),
|
||||
label: t('Credit'),
|
||||
name: 'credit',
|
||||
},
|
||||
]);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnTable
|
||||
url="CreditInsurances"
|
||||
ref="tableRef"
|
||||
data-key="creditInsurances"
|
||||
:filter="filter"
|
||||
:columns="columns"
|
||||
:right-search="false"
|
||||
:is-editable="false"
|
||||
:use-model="true"
|
||||
:column-search="false"
|
||||
:disable-option="{ card: true }"
|
||||
auto-load
|
||||
></VnTable>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
es:
|
||||
Created: Fecha creación
|
||||
Grade: Grade
|
||||
Credit: Crédito
|
||||
</i18n>
|
|
@ -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>
|
||||
|
|
|
@ -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(', '));
|
||||
}
|
|
@ -8,7 +8,6 @@ import VnRow from 'components/ui/VnRow.vue';
|
|||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
||||
import VnInputTime from 'components/common/VnInputTime.vue';
|
||||
|
||||
import axios from 'axios';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
|
@ -59,11 +58,25 @@ const zoneWhere = computed(() => {
|
|||
});
|
||||
|
||||
async function getLanded(params) {
|
||||
getDate(`Agencies/getLanded`, params);
|
||||
const data = await getDate(`Agencies/getLanded`, params);
|
||||
formData.value.landed = data.landed;
|
||||
const shippedDate = new Date(params.shipped);
|
||||
const landedDate = new Date(data.hour);
|
||||
shippedDate.setHours(
|
||||
landedDate.getHours(),
|
||||
landedDate.getMinutes(),
|
||||
landedDate.getSeconds(),
|
||||
);
|
||||
formData.value.shipped = shippedDate.toISOString();
|
||||
}
|
||||
|
||||
async function getShipped(params) {
|
||||
getDate(`Agencies/getShipped`, params);
|
||||
const data = await getDate(`Agencies/getShipped`, params);
|
||||
formData.value.landed = params.landed;
|
||||
const [hours, minutes, seconds] = data.hour.split(':').map(Number);
|
||||
let shippedDate = new Date(data.shipped);
|
||||
shippedDate.setHours(hours, minutes, seconds);
|
||||
formData.value.shipped = shippedDate.toISOString();
|
||||
}
|
||||
|
||||
async function getDate(query, params) {
|
||||
|
@ -75,15 +88,8 @@ async function getDate(query, params) {
|
|||
if (!data) return notify(t('basicData.noDeliveryZoneAvailable'), 'negative');
|
||||
|
||||
formData.value.zoneFk = data.zoneFk;
|
||||
formData.value.landed = data.landed;
|
||||
const shippedDate = new Date(params.shipped);
|
||||
const landedDate = new Date(data.hour);
|
||||
shippedDate.setHours(
|
||||
landedDate.getHours(),
|
||||
landedDate.getMinutes(),
|
||||
landedDate.getSeconds(),
|
||||
);
|
||||
formData.value.shipped = shippedDate.toISOString();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
const onChangeZone = async (zoneId) => {
|
||||
|
@ -273,8 +279,6 @@ async function getZone(options) {
|
|||
<VnSelect
|
||||
:label="t('ticketList.client')"
|
||||
v-model="clientId"
|
||||
option-value="id"
|
||||
option-label="name"
|
||||
url="Clients"
|
||||
:fields="['id', 'name']"
|
||||
sort-by="id"
|
||||
|
@ -309,16 +313,31 @@ async function getZone(options) {
|
|||
<VnSelect
|
||||
:label="t('basicData.address')"
|
||||
v-model="addressId"
|
||||
option-value="id"
|
||||
option-label="nickname"
|
||||
:options="addresses"
|
||||
hide-selected
|
||||
map-options
|
||||
:required="true"
|
||||
:sort-by="['isActive DESC']"
|
||||
:rules="validate('basicData.address')"
|
||||
>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
<QItem
|
||||
v-bind="scope.itemProps"
|
||||
:class="{ disabled: !scope.opt.isActive }"
|
||||
>
|
||||
<QItemSection style="min-width: min-content" avatar>
|
||||
<QIcon
|
||||
v-if="
|
||||
scope.opt.isActive &&
|
||||
formData.client.defaultAddressFk === scope.opt.id
|
||||
"
|
||||
size="sm"
|
||||
color="grey"
|
||||
name="star"
|
||||
class="fill-icon"
|
||||
/>
|
||||
</QItemSection>
|
||||
<QItemSection>
|
||||
<QItemLabel
|
||||
:class="{
|
||||
|
@ -344,6 +363,9 @@ async function getZone(options) {
|
|||
{{ scope.opt?.agencyMode?.name }}</span
|
||||
>
|
||||
</QItemLabel>
|
||||
<QItemLabel caption>
|
||||
{{ `#${scope.opt?.id}` }}
|
||||
</QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
|
@ -425,14 +447,6 @@ async function getZone(options) {
|
|||
:rules="validate('ticketList.shipped')"
|
||||
@update:model-value="setShipped"
|
||||
/>
|
||||
<VnInputTime
|
||||
:label="t('basicData.shippedHour')"
|
||||
v-model="formData.shipped"
|
||||
:required="true"
|
||||
:rules="validate('basicData.shippedHour')"
|
||||
disabled
|
||||
@update:model-value="setShipped"
|
||||
/>
|
||||
<VnInputDate
|
||||
:label="t('basicData.landed')"
|
||||
v-model="formData.landed"
|
||||
|
|
|
@ -20,6 +20,7 @@ export default {
|
|||
'isFreezed',
|
||||
'isTaxDataChecked',
|
||||
'hasElectronicInvoice',
|
||||
'defaultAddressFk',
|
||||
'credit',
|
||||
],
|
||||
include: [
|
||||
|
|
|
@ -582,7 +582,7 @@ function setReference(data) {
|
|||
hide-selected
|
||||
required
|
||||
@update:model-value="() => onClientSelected(data)"
|
||||
:sort-by="'id ASC'"
|
||||
:sort-by="['id ASC']"
|
||||
>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
|
@ -608,7 +608,7 @@ function setReference(data) {
|
|||
map-options
|
||||
required
|
||||
:disable="!data.clientId"
|
||||
:sort-by="'isActive DESC'"
|
||||
:sort-by="['isActive DESC']"
|
||||
@update:model-value="() => fetchAvailableAgencies(data)"
|
||||
>
|
||||
<template #option="scope">
|
||||
|
|
|
@ -13,6 +13,8 @@ export default {
|
|||
'daysInForward',
|
||||
'availabled',
|
||||
'awbFk',
|
||||
'isDelivered',
|
||||
'isReceived',
|
||||
],
|
||||
include: [
|
||||
{
|
||||
|
|
|
@ -182,6 +182,7 @@ const columns = computed(() => [
|
|||
align: 'left',
|
||||
showValue: false,
|
||||
sortable: true,
|
||||
style: 'max-width: 200px;',
|
||||
},
|
||||
{
|
||||
label: t('globals.packages'),
|
||||
|
@ -206,6 +207,7 @@ const columns = computed(() => [
|
|||
align: 'left',
|
||||
showValue: false,
|
||||
sortable: true,
|
||||
style: 'max-width: 75px;',
|
||||
},
|
||||
{
|
||||
label: t('extraCommunity.physicKg'),
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -89,7 +89,7 @@ watch(
|
|||
v-model="formData.geoFk"
|
||||
url="Postcodes/location"
|
||||
:fields="['geoFk', 'code', 'townFk', 'countryFk']"
|
||||
:sort-by="'code ASC'"
|
||||
:sort-by="['code ASC']"
|
||||
option-value="geoFk"
|
||||
option-label="code"
|
||||
:filter-options="['code']"
|
||||
|
|
|
@ -225,7 +225,7 @@ const customerCard = {
|
|||
name: 'CustomerCreditContractsInsurance',
|
||||
component: () =>
|
||||
import(
|
||||
'src/pages/Customer/components/CustomerCreditContractsInsurance.vue'
|
||||
'src/pages/Customer/Card/CustomerCreditContractsInsurance.vue'
|
||||
),
|
||||
},
|
||||
],
|
||||
|
|
|
@ -7,7 +7,28 @@ describe('Client credit contracts', () => {
|
|||
timeout: 5000,
|
||||
});
|
||||
});
|
||||
it('Should load layout', () => {
|
||||
cy.get('.q-page').should('be.visible');
|
||||
it('Should add a new contract and an additional credit', () => {
|
||||
cy.dataCy('createBtn').click();
|
||||
cy.dataCy('Credit_input').type(123);
|
||||
cy.dataCy('Grade_input').type(9);
|
||||
cy.dataCy('FormModelPopup_save').click();
|
||||
cy.checkNotification('Data created');
|
||||
cy.dataCy('createBtn').should('not.exist');
|
||||
});
|
||||
|
||||
it('Should add an additional credit', () => {
|
||||
cy.dataCy('viewBtn').eq(0).click();
|
||||
cy.get('.q-page-sticky > div').click();
|
||||
cy.dataCy('Credit_input').type(321);
|
||||
cy.dataCy('Grade_input').type(89);
|
||||
cy.dataCy('FormModelPopup_save').click();
|
||||
cy.checkNotification('Data created');
|
||||
});
|
||||
|
||||
it('Should close a contract', () => {
|
||||
cy.dataCy('closeBtn').eq(0).click();
|
||||
cy.get('.q-btn--unelevated').click();
|
||||
cy.checkNotification('Data saved');
|
||||
cy.dataCy('createBtn').should('exist');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue