feat: refs #6242 added rounding field
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jon Elias 2024-09-25 14:05:35 +02:00
parent 4ff068aa8a
commit fdf6fd2bba
7 changed files with 128 additions and 7 deletions

View File

@ -416,6 +416,16 @@ const openTab = (id) =>
> >
<QTooltip>{{ $t('salesTicketsTable.tooLittle') }}</QTooltip> <QTooltip>{{ $t('salesTicketsTable.tooLittle') }}</QTooltip>
</QIcon> </QIcon>
<QIcon
v-if="row.hasRounding"
color="primary"
name="sync_problem"
size="xs"
>
<QTooltip>
{{ t('ticketList.rounding') }}
</QTooltip>
</QIcon>
</span> </span>
</template> </template>
<template #column-id="{ row }"> <template #column-id="{ row }">

View File

@ -1,7 +1,8 @@
<script setup> <script setup>
import { ref, computed } from 'vue'; import { ref, computed, onMounted } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import axios from 'axios';
import CustomerDescriptorProxy from 'pages/Customer/Card/CustomerDescriptorProxy.vue'; import CustomerDescriptorProxy from 'pages/Customer/Card/CustomerDescriptorProxy.vue';
import CardDescriptor from 'components/ui/CardDescriptor.vue'; import CardDescriptor from 'components/ui/CardDescriptor.vue';
import TicketDescriptorMenu from './TicketDescriptorMenu.vue'; import TicketDescriptorMenu from './TicketDescriptorMenu.vue';
@ -10,6 +11,8 @@ import useCardDescription from 'src/composables/useCardDescription';
import VnUserLink from 'src/components/ui/VnUserLink.vue'; import VnUserLink from 'src/components/ui/VnUserLink.vue';
import { toDateTimeFormat } from 'src/filters/date'; import { toDateTimeFormat } from 'src/filters/date';
onMounted(async () => await getTicketData());
const $props = defineProps({ const $props = defineProps({
id: { id: {
type: Number, type: Number,
@ -24,6 +27,8 @@ const { t } = useI18n();
const entityId = computed(() => { const entityId = computed(() => {
return $props.id || route.params.id; return $props.id || route.params.id;
}); });
const sales = ref({});
const rounding = ref();
const filter = { const filter = {
include: [ include: [
@ -102,6 +107,34 @@ const data = ref(useCardDescription());
function ticketFilter(ticket) { function ticketFilter(ticket) {
return JSON.stringify({ clientFk: ticket.clientFk }); return JSON.stringify({ clientFk: ticket.clientFk });
} }
const getTicketData = async () => {
const { data } = await axios.get(`tickets/filter`, {
params: { id: entityId.value },
});
rounding.value = data[0]?.hasRounding;
getSales();
};
const getSales = async () => {
const { data } = await axios.get(`Tickets/${route.params.id}/getSales`);
if (data) {
sales.value = data;
await sales.value.map((sale) => {
return {
...sale,
hasRounding: false,
};
});
await sales.value.forEach((sale) => {
if (rounding?.value?.includes(sale.concept)) {
sale.hasRounding = true;
}
});
}
};
</script> </script>
<template> <template>
@ -112,6 +145,7 @@ function ticketFilter(ticket) {
:title="data.title" :title="data.title"
:subtitle="data.subtitle" :subtitle="data.subtitle"
data-key="ticketData" data-key="ticketData"
@on-fetch="getTicketData"
> >
<template #menu="{ entity }"> <template #menu="{ entity }">
<TicketDescriptorMenu :ticket="entity" /> <TicketDescriptorMenu :ticket="entity" />
@ -197,6 +231,18 @@ function ticketFilter(ticket) {
> >
<QTooltip>{{ t('This ticket is deleted') }}</QTooltip> <QTooltip>{{ t('This ticket is deleted') }}</QTooltip>
</QIcon> </QIcon>
<div v-for="sale in sales" :key="sale.id">
<QIcon
v-if="sale?.hasRounding"
color="primary"
name="sync_problem"
size="xs"
>
<QTooltip>
{{ t('ticketList.rounding') }}
</QTooltip>
</QIcon>
</div>
</QCardActions> </QCardActions>
</template> </template>
<template #actions="{ entity }"> <template #actions="{ entity }">

View File

@ -50,12 +50,17 @@ const transfer = ref({
sales: [], sales: [],
}); });
const tableRef = ref([]); const tableRef = ref([]);
const roundingName = ref();
watch( watch(
() => route.params.id, () => route.params.id,
async () => await getSales() async () => await getSales()
); );
onMounted(async () => {
getTicketData();
});
const columns = computed(() => [ const columns = computed(() => [
{ {
align: 'left', align: 'left',
@ -157,8 +162,19 @@ const getConfig = async () => {
}; };
const onSalesFetched = (salesData) => { const onSalesFetched = (salesData) => {
sales.value = salesData; sales.value = salesData.map((sale) => {
for (let sale of salesData) sale.amount = getSaleTotal(sale); return {
...sale,
amount: getSaleTotal(sale),
hasRounding: false,
};
});
sales.value.forEach((sale) => {
if (roundingName?.value?.includes(sale.concept)) {
sale.hasRounding = true;
}
});
}; };
const getSales = async () => { const getSales = async () => {
@ -179,6 +195,14 @@ const getSaleTotal = (sale) => {
return price - discount; return price - discount;
}; };
const getTicketData = async () => {
const { data } = await axios.get(`tickets/filter`, {
params: { id: route.params.id },
});
roundingName.value = data[0]?.hasRounding;
};
const resetChanges = async () => { const resetChanges = async () => {
arrayData.fetch({ append: false }); arrayData.fetch({ append: false });
getSales(); getSales();
@ -611,7 +635,7 @@ watch(
<VnTable <VnTable
ref="tableRef" ref="tableRef"
data-key="TicketSales" data-key="TicketSales"
:url="`Tickets/${route.params.id}/getSales`" :data="sales"
:columns="columns" :columns="columns"
v-model:selected="selectedRows" v-model:selected="selectedRows"
:bottom="true" :bottom="true"
@ -634,6 +658,7 @@ watch(
:default-reset="false" :default-reset="false"
:default-save="false" :default-save="false"
:disabled-attr="isTicketEditable" :disabled-attr="isTicketEditable"
@request-success="getSales"
> >
<template #column-statusIcons="{ row }"> <template #column-statusIcons="{ row }">
<router-link <router-link
@ -677,6 +702,11 @@ watch(
{{ t('ticketSale.hasComponentLack') }} {{ t('ticketSale.hasComponentLack') }}
</QTooltip> </QTooltip>
</QIcon> </QIcon>
<QIcon v-if="row.hasRounding" color="primary" name="sync_problem" size="xs">
<QTooltip>
{{ t('ticketList.rounding') }}
</QTooltip>
</QIcon>
</template> </template>
<template #column-image="{ row }"> <template #column-image="{ row }">
<div class="image-wrapper"> <div class="image-wrapper">

View File

@ -38,9 +38,11 @@ const ticket = computed(() => summaryRef.value?.entity);
const editableStates = ref([]); const editableStates = ref([]);
const ticketUrl = ref(); const ticketUrl = ref();
const grafanaUrl = 'https://grafana.verdnatura.es'; const grafanaUrl = 'https://grafana.verdnatura.es';
const roundingName = ref();
onMounted(async () => { onMounted(async () => {
ticketUrl.value = (await getUrl('ticket/')) + entityId.value + '/'; ticketUrl.value = (await getUrl('ticket/')) + entityId.value + '/';
getTicketData();
}); });
function formattedAddress() { function formattedAddress() {
@ -101,6 +103,27 @@ function getNoteValue(description) {
function toTicketUrl(section) { function toTicketUrl(section) {
return '#/ticket/' + entityId.value + '/' + section; return '#/ticket/' + entityId.value + '/' + section;
} }
const getTicketData = async () => {
const { data } = await axios.get(`tickets/filter`, {
params: { id: entityId.value },
});
if (data) {
roundingName.value = data[0]?.hasRounding;
ticket.value.sales.map((sale) => {
return {
...sale,
hasRounding: false,
};
});
ticket.value.sales.forEach((sale) => {
if (roundingName?.value?.includes(sale.concept)) {
sale.hasRounding = true;
}
});
}
};
</script> </script>
<template> <template>
@ -407,6 +430,16 @@ function toTicketUrl(section) {
{{ t('ticket.summary.hasComponentLack') }} {{ t('ticket.summary.hasComponentLack') }}
</QTooltip> </QTooltip>
</QIcon> </QIcon>
<QIcon
v-if="props.row.hasRounding"
color="primary"
name="sync_problem"
size="xs"
>
<QTooltip>
{{ t('ticketList.rounding') }}
</QTooltip>
</QIcon>
</QTd> </QTd>
<QTd> <QTd>
<QBtn class="link" flat> <QBtn class="link" flat>

View File

@ -541,14 +541,14 @@ function setReference(data) {
size="xs" size="xs"
> >
<QTooltip> <QTooltip>
{{ t('Rounding') }} {{ t('ticketList.rounding') }}
</QTooltip> </QTooltip>
</QIcon> </QIcon>
</div> </div>
</template> </template>
<template #column-salesPersonFk="{ row }"> <template #column-salesPersonFk="{ row }">
<span class="link" @click.stop> <span class="link" @click.stop>
{{ row.salesPerson }} {{ row.userName }}
<CustomerDescriptorProxy :id="row.salesPersonFk" /> <CustomerDescriptorProxy :id="row.salesPersonFk" />
</span> </span>
</template> </template>

View File

@ -272,3 +272,4 @@ ticketList:
toLines: Go to lines toLines: Go to lines
addressNickname: Address nickname addressNickname: Address nickname
ref: Reference ref: Reference
rounding: Rounding

View File

@ -86,7 +86,7 @@ weeklyTickets:
search: Buscar por tickets programados search: Buscar por tickets programados
searchInfo: Buscar tickets programados por el identificador o el identificador del cliente searchInfo: Buscar tickets programados por el identificador o el identificador del cliente
advanceTickets: advanceTickets:
preparation: Preparación preparation: Preparación
origin: Origen origin: Origen
destination: Destinatario destination: Destinatario
originAgency: 'Agencia origen: {agency}' originAgency: 'Agencia origen: {agency}'
@ -275,3 +275,4 @@ ticketList:
toLines: Ir a lineas toLines: Ir a lineas
addressNickname: Alias consignatario addressNickname: Alias consignatario
ref: Referencia ref: Referencia
rounding: Redondeo