0
0
Fork 0

feat: refs #7893 Added waste recalc section

This commit is contained in:
Guillermo Bonet 2024-10-07 10:03:05 +02:00
parent ed5cf137b0
commit 4f3e7e2630
4 changed files with 104 additions and 1 deletions

View File

@ -105,6 +105,7 @@ globals:
campaign: Campaign
weight: Weight
error: Ups! Something went wrong
recalc: Recalculate
pageTitles:
logIn: Login
addressEdit: Update address
@ -275,6 +276,7 @@ globals:
serial: Serial
medical: Mutual
RouteExtendedList: Router
wasteRecalc: Waste recaclulate
supplier: Supplier
created: Created
worker: Worker
@ -465,6 +467,10 @@ entry:
landing: Landing
isExcludedFromAvailable: Es inventory
isRaid: Raid
wasteRecalc:
dateRequired: The date fields are required
dateIncoherent: The "from" date cannot be later than the "to" date
recalcOk: The wastes were successfully recalculated
ticket:
pageTitles:
tickets: Tickets

View File

@ -107,6 +107,7 @@ globals:
campaign: Campaña
weight: Peso
error: ¡Ups! Algo salió mal
recalc: Recalcular
pageTitles:
logIn: Inicio de sesión
addressEdit: Modificar consignatario
@ -279,6 +280,7 @@ globals:
clientsActionsMonitor: Clientes y acciones
serial: Facturas por serie
medical: Mutua
wasteRecalc: Recalcular mermas
supplier: Proveedor
created: Fecha creación
worker: Trabajador
@ -467,6 +469,10 @@ entry:
landing: Llegada
isExcludedFromAvailable: Es inventario
isRaid: Redada
wasteRecalc:
dateRequired: Los campos de tipo fecha son obligatorios
dateIncoherent: La fecha "desde" no puede ser superior a la fecha "hasta"
recalcOk: Se han recalculado las mermas correctamente
ticket:
pageTitles:
tickets: Tickets

View File

@ -0,0 +1,76 @@
<script setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import VnInputDate from 'components/common/VnInputDate.vue';
import useNotify from 'src/composables/useNotify.js';
import axios from 'axios';
const { t } = useI18n();
const isLoading = ref(false);
const dateFrom = ref();
const dateTo = ref();
const recalc = async () => {
const { notify } = useNotify();
if (!dateFrom.value || !dateTo.value) {
notify('entry.wasteRecalc.dateRequired', 'negative');
return;
}
const from = new Date(dateFrom.value);
const to = new Date(dateTo.value);
if (from > to) {
notify('entry.wasteRecalc.dateIncoherent', 'negative');
return;
}
const params = {
schema: 'bs',
params: [from, to],
};
try {
isLoading.value = true;
await axios.post('Applications/waste_addSales/execute-proc', params);
notify('entry.wasteRecalc.recalcOk', 'positive');
} catch (err) {
console.error('Error in execution:', err);
notify('entry.wasteRecalc.recalcOk', 'negative');
} finally {
isLoading.value = false;
}
};
</script>
<template>
<div class="q-pa-lg row justify-center">
<QCard class="bg-light" style="width: 300px">
<QCardSection>
<VnInputDate
class="q-mb-lg"
v-model="dateFrom"
:label="t('globals.from')"
rounded
dense
/>
<VnInputDate
class="q-mb-lg"
v-model="dateTo"
:label="t('globals.to')"
rounded
dense
/>
<QBtn
color="primary"
text-color="white"
:label="t('globals.recalc')"
icon="Calculate"
:loading="isLoading"
:disable="isLoading"
@click="recalc()"
/>
</QCardSection>
</QCard>
</div>
</template>

View File

@ -12,7 +12,13 @@ export default {
component: RouterView,
redirect: { name: 'EntryMain' },
menus: {
main: ['EntryList', 'MyEntries', 'EntryLatestBuys', 'EntryStockBought'],
main: [
'EntryList',
'MyEntries',
'EntryLatestBuys',
'EntryStockBought',
'EntryWasteRecalc',
],
card: ['EntryBasicData', 'EntryBuys', 'EntryNotes', 'EntryDms', 'EntryLog'],
},
children: [
@ -67,6 +73,15 @@ export default {
},
component: () => import('src/pages/Entry/EntryStockBought.vue'),
},
{
path: 'waste-recalc',
name: 'EntryWasteRecalc',
meta: {
title: 'wasteRecalc',
icon: 'compost',
},
component: () => import('src/pages/Entry/EntryWasteRecalc.vue'),
},
],
},
{