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>
</QIcon>
<QIcon
v-if="row.hasRounding"
color="primary"
name="sync_problem"
size="xs"
>
<QTooltip>
{{ t('ticketList.rounding') }}
</QTooltip>
</QIcon>
</span>
</template>
<template #column-id="{ row }">

View File

@ -1,7 +1,8 @@
<script setup>
import { ref, computed } from 'vue';
import { ref, computed, onMounted } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import axios from 'axios';
import CustomerDescriptorProxy from 'pages/Customer/Card/CustomerDescriptorProxy.vue';
import CardDescriptor from 'components/ui/CardDescriptor.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 { toDateTimeFormat } from 'src/filters/date';
onMounted(async () => await getTicketData());
const $props = defineProps({
id: {
type: Number,
@ -24,6 +27,8 @@ const { t } = useI18n();
const entityId = computed(() => {
return $props.id || route.params.id;
});
const sales = ref({});
const rounding = ref();
const filter = {
include: [
@ -102,6 +107,34 @@ const data = ref(useCardDescription());
function ticketFilter(ticket) {
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>
<template>
@ -112,6 +145,7 @@ function ticketFilter(ticket) {
:title="data.title"
:subtitle="data.subtitle"
data-key="ticketData"
@on-fetch="getTicketData"
>
<template #menu="{ entity }">
<TicketDescriptorMenu :ticket="entity" />
@ -197,6 +231,18 @@ function ticketFilter(ticket) {
>
<QTooltip>{{ t('This ticket is deleted') }}</QTooltip>
</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>
</template>
<template #actions="{ entity }">

View File

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

View File

@ -38,9 +38,11 @@ const ticket = computed(() => summaryRef.value?.entity);
const editableStates = ref([]);
const ticketUrl = ref();
const grafanaUrl = 'https://grafana.verdnatura.es';
const roundingName = ref();
onMounted(async () => {
ticketUrl.value = (await getUrl('ticket/')) + entityId.value + '/';
getTicketData();
});
function formattedAddress() {
@ -101,6 +103,27 @@ function getNoteValue(description) {
function toTicketUrl(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>
<template>
@ -407,6 +430,16 @@ function toTicketUrl(section) {
{{ t('ticket.summary.hasComponentLack') }}
</QTooltip>
</QIcon>
<QIcon
v-if="props.row.hasRounding"
color="primary"
name="sync_problem"
size="xs"
>
<QTooltip>
{{ t('ticketList.rounding') }}
</QTooltip>
</QIcon>
</QTd>
<QTd>
<QBtn class="link" flat>

View File

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

View File

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

View File

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