Merge branch 'dev' into 6321_negative_tickets

This commit is contained in:
Javier Segarra 2025-01-30 00:08:58 +01:00
parent 07ad4b1655
commit 31d829ac05
14 changed files with 96 additions and 137 deletions

View File

@ -14,8 +14,8 @@ export default defineConfig({
downloadsFolder: 'test/cypress/downloads',
video: false,
specPattern: 'test/cypress/integration/**/*.spec.js',
experimentalRunAllSpecs: true,
watchForFileChanges: true,
experimentalRunAllSpecs: false,
watchForFileChanges: false,
reporter: 'cypress-mochawesome-reporter',
reporterOptions: {
charts: true,

View File

@ -30,7 +30,6 @@ export default configure(function (/* ctx */) {
// --> boot files are part of "main.js"
// https://v2.quasar.dev/quasar-cli/boot-files
boot: ['i18n', 'axios', 'vnDate', 'validations', 'quasar', 'quasar.defaults'],
importStrategy: 'auto',
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#css
css: ['app.scss'],

View File

@ -334,8 +334,8 @@ function handleKeyDown(event) {
}
function getCaption(opt) {
if (optionCaption.value === false && typeof optionCaption.value !== 'string') return;
return '' + (opt[optionCaption.value] || opt[optionValue.value]);
if (optionCaption.value === false) return;
return opt[optionCaption.value] || opt[optionValue.value];
}
</script>

View File

@ -273,6 +273,7 @@ input::-webkit-inner-spin-button {
}
td {
font-size: 11pt;
border-top: 1px solid var(--vn-page-color);
border-collapse: collapse;
}
}

View File

@ -105,37 +105,25 @@ const columns = computed(() => [
{
align: 'left',
sortable: true,
label: t('proposal.tag5'),
label: t('item.list.color'),
name: 'tag5',
field: 'value5',
// format: (val) => val,
style: "color: 'red'",
columnClass: 'expand',
},
{
align: 'left',
sortable: true,
label: t('proposal.tag6'),
label: t('item.list.stems'),
name: 'tag6',
field: 'value6',
// format: (val) => val,
attrs: ({ model }) => {
return {
style: `color: var(--vn-label-color)`,
};
},
style: (row) => `color: var(--vn-label-color)`,
columnClass: 'expand',
},
{
align: 'left',
sortable: true,
label: t('proposal.tag7'),
label: t('item.list.producer'),
name: 'tag7',
field: 'value7',
// format: (val) => val,
style: "color: 'red'",
columnClass: 'expand',
},

View File

@ -130,6 +130,7 @@ item:
origin: Orig.
userName: Buyer
weight: Weight
color: Color
weightByPiece: Weight/stem
stemMultiplier: Multiplier
producer: Producer

View File

@ -135,6 +135,7 @@ item:
size: Medida
origin: Orig.
weight: Peso
color: Color
weightByPiece: Peso/tallo
userName: Comprador
stemMultiplier: Multiplicador

View File

@ -34,7 +34,6 @@ const $props = defineProps({
onMounted(() => (_transfer.value = $props.transfer));
const { t } = useI18n();
const QPopupProxyRef = ref(null);
const transferFormRef = ref(null);
const _transfer = ref();
const splitDate = ref(Date.vnNew());
@ -110,13 +109,9 @@ const splitSelectedRows = async () => {
></QBtn>
<VnInputDate :label="$t('New date')" v-model="splitDate"></VnInputDate>
</div>
<div v-else>
<QSeparator class="q-my-lg" color="primary" />
<QCard
v-if="!$props.split"
class="full-width q-px-md"
style="display: flex; width: 80vw"
>
{{ ticket }}- {{ transfer }}
<QCard class="full-width q-px-md" style="display: flex; width: 80vw">
<QTable
:rows="transfer.sales"
:columns="transferLinesColumns"
@ -175,6 +170,7 @@ const splitSelectedRows = async () => {
</template>
</QTable>
</QCard>
</div>
</QPopupProxy>
</template>
<style lang="scss">
@ -186,6 +182,4 @@ const splitSelectedRows = async () => {
es:
Sales to transfer: Líneas a transferir
Destination ticket: Ticket destinatario
Transfer to ticket: Transferir a ticket
New ticket: Nuevo ticket
</i18n>

View File

@ -1,8 +1,9 @@
import axios from 'axios';
import notifyResults from 'src/utils/notifyResults';
export default async function (data) {
const reducedData = data.reduce((acc, item) => {
const existing = acc.find((obj) => obj.ticketFk === item.id);
const existing = acc.find(({ ticketFk }) => ticketFk === item.id);
if (existing) {
existing.sales.push(item.saleFk);
} else {
@ -11,29 +12,11 @@ export default async function (data) {
return acc;
}, []);
console.log(reducedData);
const promises = reducedData.map((params) => axios.post(`Tickets/split`, params));
const results = await Promise.allSettled(promises);
// results.forEach((result, index) => {
// if (result.status === 'fulfilled') {
// console.log(`Promise ${index + 1} fulfilled:`, result.value.data);
// // Mostrar notificación de éxito
// Notify.create({
// type: 'positive',
// message: `Operación ${index + 1} completada con éxito.`,
// });
// } else {
// console.error(`Promise ${index + 1} rejected:`, result.reason);
// // Mostrar notificación de error
// Notify.create({
// type: 'negative',
// message: `Operación ${index + 1} fallida: ${result.reason.message}`,
// });
// }
// });
notifyResults(results, 'ticketFk');
return results;
}

View File

@ -4,7 +4,6 @@ import { useI18n } from 'vue-i18n';
import ChangeQuantityDialog from './components/ChangeQuantityDialog.vue';
import ChangeStateDialog from './components/ChangeStateDialog.vue';
import ChangeItemDialog from './components/ChangeItemDialog.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import TicketTransfer from '../Card/TicketTransfer.vue';
import FetchData from 'src/components/FetchData.vue';
import { useStateStore } from 'stores/useStateStore';
@ -167,7 +166,6 @@ const filterTable = { stateFk: 0, warehouseFk: useState().getUser().value.wareho
<TicketTransfer
ref="transferFormRef"
split="true"
class="full-width"
:ticket="selectedRows"
:transfer="{
sales: selectedRows,
@ -175,7 +173,11 @@ const filterTable = { stateFk: 0, warehouseFk: useState().getUser().value.wareho
}"
></TicketTransfer>
</QBtn>
<QBtn color="primary" @click="showProposalDialog = true">
<QBtn
color="primary"
@click="showProposalDialog = true"
:disable="selectedRows.length < 1"
>
<QIcon
name="import_export"
class="rotate-90"

View File

@ -1,12 +1,10 @@
<script setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import axios from 'axios';
import VnSelect from 'src/components/common/VnSelect.vue';
import handlePromiseResults from './notifyResults';
import notifyResults from 'src/utils/notifyResults';
const emit = defineEmits(['update-item']);
const { t } = useI18n();
const showChangeItemDialog = ref(false);
const newItem = ref(null);
const $props = defineProps({
@ -27,7 +25,7 @@ const updateItem = async () => {
}),
);
const result = await Promise.allSettled(rowsToUpdate);
handlePromiseResults(result, 'saleFk');
notifyResults(result, 'saleFk');
emit('update-item', newItem.value);
} catch (err) {
console.error('Error updating item:', err);
@ -40,7 +38,7 @@ const updateItem = async () => {
<QCard class="q-pa-sm">
<QCardSection class="row items-center justify-center column items-stretch">
{{ showChangeItemDialog }}
<span>{{ t('negative.detail.modal.changeItem.title') }}</span>
<span>{{ $t('negative.detail.modal.changeItem.title') }}</span>
<VnSelect
url="Items/WithName"
:fields="['id', 'name']"
@ -53,9 +51,9 @@ const updateItem = async () => {
</VnSelect>
</QCardSection>
<QCardActions align="right">
<QBtn :label="t('globals.cancel')" color="primary" flat v-close-popup />
<QBtn :label="$t('globals.cancel')" color="primary" flat v-close-popup />
<QBtn
:label="t('globals.confirm')"
:label="$t('globals.confirm')"
color="primary"
:disable="!newItem"
@click="updateItem"

View File

@ -1,11 +1,9 @@
<script setup>
import { ref, defineEmits } from 'vue';
import { useI18n } from 'vue-i18n';
import axios from 'axios';
import VnInput from 'src/components/common/VnInput.vue';
import handlePromiseResults from './notifyResults';
import notifyResults from 'src/utils/notifyResults';
const { t } = useI18n();
const showChangeQuantityDialog = ref(false);
const newQuantity = ref(null);
const $props = defineProps({
@ -26,7 +24,7 @@ const updateQuantity = async () => {
);
const result = await Promise.allSettled(rowsToUpdate);
handlePromiseResults(result, 'saleFk');
notifyResults(result, 'saleFk');
emit('update-quantity', newQuantity.value);
} catch (err) {
@ -38,18 +36,18 @@ const updateQuantity = async () => {
<template>
<QCard class="q-pa-sm">
<QCardSection class="row items-center justify-center column items-stretch">
<span>{{ t('negative.detail.modal.changeQuantity.title') }}</span>
<span>{{ $t('negative.detail.modal.changeQuantity.title') }}</span>
<VnInput
type="number"
:min="0"
:label="t('negative.detail.modal.changeQuantity.placeholder')"
:label="$t('negative.detail.modal.changeQuantity.placeholder')"
v-model="newQuantity"
/>
</QCardSection>
<QCardActions align="right">
<QBtn :label="t('globals.cancel')" color="primary" flat v-close-popup />
<QBtn :label="$t('globals.cancel')" color="primary" flat v-close-popup />
<QBtn
:label="t('globals.confirm')"
:label="$t('globals.confirm')"
color="primary"
:disable="!newQuantity || newQuantity < 0"
@click="updateQuantity"

View File

@ -1,14 +1,12 @@
<script setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import axios from 'axios';
import VnSelect from 'src/components/common/VnSelect.vue';
import FetchData from 'components/FetchData.vue';
import handlePromiseResults from './notifyResults';
import notifyResults from 'src/utils/notifyResults';
const emit = defineEmits(['update-state']);
const editableStates = ref([]);
const { t } = useI18n();
const showChangeStateDialog = ref(false);
const newState = ref(null);
const $props = defineProps({
@ -27,7 +25,7 @@ const updateState = async () => {
}),
);
const result = await Promise.allSettled(rowsToUpdate);
handlePromiseResults(result, 'ticketFk');
notifyResults(result, 'ticketFk');
emit('update-state', newState.value);
} catch (err) {
@ -44,9 +42,9 @@ const updateState = async () => {
/>
<QCard class="q-pa-sm">
<QCardSection class="row items-center justify-center column items-stretch">
<span>{{ t('negative.detail.modal.changeState.title') }}</span>
<span>{{ $t('negative.detail.modal.changeState.title') }}</span>
<VnSelect
:label="t('negative.detail.modal.changeState.placeholder')"
:label="$t('negative.detail.modal.changeState.placeholder')"
v-model="newState"
:options="editableStates"
option-label="name"
@ -54,9 +52,9 @@ const updateState = async () => {
/>
</QCardSection>
<QCardActions align="right">
<QBtn :label="t('globals.cancel')" color="primary" flat v-close-popup />
<QBtn :label="$t('globals.cancel')" color="primary" flat v-close-popup />
<QBtn
:label="t('globals.confirm')"
:label="$t('globals.confirm')"
color="primary"
:disable="!newState"
@click="updateState"

View File

@ -4,16 +4,12 @@ export default function (results, key) {
results.forEach((result, index) => {
if (result.status === 'fulfilled') {
const data = JSON.parse(result.value.config.data);
console.log(`Promise ${index + 1} fulfilled:`, result.value);
// Mostrar notificación de éxito
Notify.create({
type: 'positive',
message: `Operación (${index + 1}) ${data[key]} completada con éxito.`,
});
} else {
const data = JSON.parse(result.reason.config.data);
console.error(`Promise ${index + 1} rejected:`, result.reason);
// Mostrar notificación de error
Notify.create({
type: 'negative',
message: `Operación (${index + 1}) ${data[key]} fallida: ${result.reason.message}`,