#8277 createEntryControl #1370
|
@ -376,7 +376,7 @@ function getCaption(opt) {
|
||||||
>
|
>
|
||||||
<template #append>
|
<template #append>
|
||||||
<QIcon
|
<QIcon
|
||||||
v-show="isClearable && value"
|
v-show="isClearable && value != null && value !== ''"
|
||||||
name="close"
|
name="close"
|
||||||
@click="
|
@click="
|
||||||
() => {
|
() => {
|
||||||
|
@ -391,7 +391,7 @@ function getCaption(opt) {
|
||||||
<template v-for="(_, slotName) in $slots" #[slotName]="slotData" :key="slotName">
|
<template v-for="(_, slotName) in $slots" #[slotName]="slotData" :key="slotName">
|
||||||
<div v-if="slotName == 'append'">
|
<div v-if="slotName == 'append'">
|
||||||
<QIcon
|
<QIcon
|
||||||
v-show="isClearable && value"
|
v-show="isClearable && value != null && value !== ''"
|
||||||
name="close"
|
name="close"
|
||||||
@click.stop="
|
@click.stop="
|
||||||
() => {
|
() => {
|
||||||
|
@ -416,7 +416,7 @@ function getCaption(opt) {
|
||||||
<QItemLabel>
|
<QItemLabel>
|
||||||
{{ opt[optionLabel] }}
|
{{ opt[optionLabel] }}
|
||||||
</QItemLabel>
|
</QItemLabel>
|
||||||
<QItemLabel caption v-if="getCaption(opt)">
|
<QItemLabel caption v-if="getCaption(opt) !== false">
|
||||||
{{ `#${getCaption(opt)}` }}
|
{{ `#${getCaption(opt)}` }}
|
||||||
</QItemLabel>
|
</QItemLabel>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
|
|
|
@ -89,24 +89,26 @@ function cancel() {
|
||||||
<slot name="customHTML"></slot>
|
<slot name="customHTML"></slot>
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
<QCardActions align="right">
|
<QCardActions align="right">
|
||||||
<QBtn
|
<slot name="actions" :actions="{ confirm, cancel }">
|
||||||
:label="t('globals.cancel')"
|
<QBtn
|
||||||
color="primary"
|
:label="t('globals.cancel')"
|
||||||
:disable="isLoading"
|
color="primary"
|
||||||
flat
|
:disable="isLoading"
|
||||||
@click="cancel()"
|
flat
|
||||||
data-cy="VnConfirm_cancel"
|
@click="cancel()"
|
||||||
/>
|
data-cy="VnConfirm_cancel"
|
||||||
<QBtn
|
/>
|
||||||
:label="t('globals.confirm')"
|
<QBtn
|
||||||
:title="t('globals.confirm')"
|
:label="t('globals.confirm')"
|
||||||
color="primary"
|
:title="t('globals.confirm')"
|
||||||
:loading="isLoading"
|
color="primary"
|
||||||
@click="confirm()"
|
:loading="isLoading"
|
||||||
unelevated
|
@click="confirm()"
|
||||||
autofocus
|
unelevated
|
||||||
data-cy="VnConfirm_confirm"
|
autofocus
|
||||||
/>
|
data-cy="VnConfirm_confirm"
|
||||||
|
/>
|
||||||
|
</slot>
|
||||||
</QCardActions>
|
</QCardActions>
|
||||||
</QCard>
|
</QCard>
|
||||||
</QDialog>
|
</QDialog>
|
||||||
|
|
|
@ -346,6 +346,7 @@ globals:
|
||||||
parking: Parking
|
parking: Parking
|
||||||
vehicleList: Vehicles
|
vehicleList: Vehicles
|
||||||
vehicle: Vehicle
|
vehicle: Vehicle
|
||||||
|
entryPreAccount: Pre-account
|
||||||
unsavedPopup:
|
unsavedPopup:
|
||||||
title: Unsaved changes will be lost
|
title: Unsaved changes will be lost
|
||||||
subtitle: Are you sure exit without saving?
|
subtitle: Are you sure exit without saving?
|
||||||
|
|
|
@ -349,6 +349,7 @@ globals:
|
||||||
parking: Parking
|
parking: Parking
|
||||||
vehicleList: Vehículos
|
vehicleList: Vehículos
|
||||||
vehicle: Vehículo
|
vehicle: Vehículo
|
||||||
|
entryPreAccount: Precontabilizar
|
||||||
unsavedPopup:
|
unsavedPopup:
|
||||||
title: Los cambios que no haya guardado se perderán
|
title: Los cambios que no haya guardado se perderán
|
||||||
subtitle: ¿Seguro que quiere salir sin guardar?
|
subtitle: ¿Seguro que quiere salir sin guardar?
|
||||||
|
|
|
@ -0,0 +1,477 @@
|
||||||
|
<script setup>
|
||||||
|
import { ref, computed, markRaw, useTemplateRef, onBeforeMount, watch } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { toDate, toCurrency } from 'src/filters';
|
||||||
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
|
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||||
|
import FetchData from 'src/components/FetchData.vue';
|
||||||
|
import VnSelectSupplier from 'src/components/common/VnSelectSupplier.vue';
|
||||||
|
import EntryDescriptorProxy from './Card/EntryDescriptorProxy.vue';
|
||||||
|
import SupplierDescriptorProxy from '../Supplier/Card/SupplierDescriptorProxy.vue';
|
||||||
|
import VnInputNumber from 'src/components/common/VnInputNumber.vue';
|
||||||
|
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
|
||||||
|
import axios from 'axios';
|
||||||
|
import useNotify from 'src/composables/useNotify';
|
||||||
|
import VnConfirm from 'src/components/ui/VnConfirm.vue';
|
||||||
|
import VnDms from 'src/components/common/VnDms.vue';
|
||||||
|
import { useState } from 'src/composables/useState';
|
||||||
|
import { useQuasar } from 'quasar';
|
||||||
|
import InvoiceInDescriptorProxy from '../InvoiceIn/Card/InvoiceInDescriptorProxy.vue';
|
||||||
|
import { useStateStore } from 'src/stores/useStateStore';
|
||||||
|
import { downloadFile } from 'src/composables/downloadFile';
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
const quasar = useQuasar();
|
||||||
|
const { notify } = useNotify();
|
||||||
|
const user = useState().getUser();
|
||||||
|
const stateStore = useStateStore();
|
||||||
|
const updateDialog = ref();
|
||||||
|
const uploadDialog = ref();
|
||||||
|
let maxDays;
|
||||||
|
let defaultDays;
|
||||||
|
const dataKey = 'entryPreaccountingFilter';
|
||||||
|
const url = 'Entries/preAccountingFilter';
|
||||||
|
const arrayData = useArrayData(dataKey);
|
||||||
|
const daysAgo = ref();
|
||||||
|
const isBooked = ref();
|
||||||
|
const dmsData = ref();
|
||||||
|
const table = useTemplateRef('table');
|
||||||
|
const companies = ref([]);
|
||||||
|
const countries = ref([]);
|
||||||
|
const entryTypes = ref([]);
|
||||||
|
const supplierFiscalTypes = ref([]);
|
||||||
|
const warehouses = ref([]);
|
||||||
|
const defaultDmsDescription = ref();
|
||||||
|
const dmsTypeId = ref();
|
||||||
|
const selectedRows = ref([]);
|
||||||
|
const totalAmount = ref();
|
||||||
|
const totalSelectedAmount = computed(() => {
|
||||||
|
if (!selectedRows.value.length) return 0;
|
||||||
|
return selectedRows.value.reduce((acc, entry) => acc + entry.amount, 0);
|
||||||
|
});
|
||||||
|
let supplierRef;
|
||||||
|
let dmsFk;
|
||||||
|
const columns = computed(() => [
|
||||||
|
{
|
||||||
|
name: 'id',
|
||||||
|
label: t('entry.preAccount.id'),
|
||||||
|
isId: true,
|
||||||
|
chip: {
|
||||||
|
condition: () => true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'invoiceNumber',
|
||||||
|
label: t('entry.preAccount.invoiceNumber'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'company',
|
||||||
|
label: t('globals.company'),
|
||||||
|
columnFilter: {
|
||||||
|
component: 'select',
|
||||||
|
name: 'companyFk',
|
||||||
|
optionLabel: 'code',
|
||||||
|
options: companies.value,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'warehouse',
|
||||||
|
label: t('globals.warehouse'),
|
||||||
|
columnFilter: {
|
||||||
|
component: 'select',
|
||||||
|
name: 'warehouseInFk',
|
||||||
|
options: warehouses.value,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'gestDocFk',
|
||||||
|
label: t('entry.preAccount.gestDocFk'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'dmsType',
|
||||||
|
label: t('entry.preAccount.dmsType'),
|
||||||
|
columnFilter: {
|
||||||
|
component: 'select',
|
||||||
|
label: null,
|
||||||
|
name: 'dmsTypeFk',
|
||||||
|
url: 'DmsTypes',
|
||||||
|
fields: ['id', 'name'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'reference',
|
||||||
|
label: t('entry.preAccount.reference'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'shipped',
|
||||||
|
label: t('entry.preAccount.shipped'),
|
||||||
|
format: ({ shipped }, dashIfEmpty) => dashIfEmpty(toDate(shipped)),
|
||||||
|
columnFilter: {
|
||||||
|
component: 'date',
|
||||||
|
name: 'shipped',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'landed',
|
||||||
|
label: t('entry.preAccount.landed'),
|
||||||
|
format: ({ landed }, dashIfEmpty) => dashIfEmpty(toDate(landed)),
|
||||||
|
columnFilter: {
|
||||||
|
component: 'date',
|
||||||
|
name: 'landed',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'invoiceInFk',
|
||||||
|
label: t('entry.preAccount.invoiceInFk'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'supplier',
|
||||||
|
label: t('globals.supplier'),
|
||||||
|
format: (row) => row.supplier,
|
||||||
|
columnFilter: {
|
||||||
|
component: markRaw(VnSelectSupplier),
|
||||||
|
label: null,
|
||||||
|
name: 'supplierFk',
|
||||||
|
class: 'fit',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'country',
|
||||||
|
label: t('globals.country'),
|
||||||
|
columnFilter: {
|
||||||
|
component: 'select',
|
||||||
|
name: 'countryFk',
|
||||||
|
options: countries.value,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'description',
|
||||||
|
label: t('entry.preAccount.entryType'),
|
||||||
|
columnFilter: {
|
||||||
|
component: 'select',
|
||||||
|
label: null,
|
||||||
|
name: 'typeFk',
|
||||||
|
options: entryTypes.value,
|
||||||
|
optionLabel: 'description',
|
||||||
|
optionValue: 'code',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'payDem',
|
||||||
|
label: t('entry.preAccount.payDem'),
|
||||||
|
columnFilter: {
|
||||||
|
component: 'number',
|
||||||
|
name: 'payDem',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'fiscalCode',
|
||||||
|
label: t('entry.preAccount.fiscalCode'),
|
||||||
|
format: ({ fiscalCode }) => t(fiscalCode),
|
||||||
|
columnFilter: {
|
||||||
|
component: 'select',
|
||||||
|
name: 'fiscalCode',
|
||||||
|
options: supplierFiscalTypes.value,
|
||||||
|
optionLabel: 'locale',
|
||||||
|
optionValue: 'code',
|
||||||
|
sortBy: 'code',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'amount',
|
||||||
|
label: t('globals.amount'),
|
||||||
|
format: ({ amount }) => toCurrency(amount),
|
||||||
|
columnFilter: {
|
||||||
|
component: 'number',
|
||||||
|
name: 'amount',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'isAgricultural',
|
||||||
|
label: t('entry.preAccount.isAgricultural'),
|
||||||
|
component: 'checkbox',
|
||||||
|
isEditable: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'isBooked',
|
||||||
|
label: t('entry.preAccount.isBooked'),
|
||||||
|
component: 'checkbox',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'isReceived',
|
||||||
|
label: t('entry.preAccount.isReceived'),
|
||||||
|
component: 'checkbox',
|
||||||
|
isEditable: false,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
onBeforeMount(async () => {
|
||||||
|
const { data } = await axios.get('EntryConfigs/findOne', {
|
||||||
|
params: { filter: JSON.stringify({ fields: ['maxDays', 'defaultDays'] }) },
|
||||||
|
});
|
||||||
|
maxDays = data.maxDays;
|
||||||
|
defaultDays = data.defaultDays;
|
||||||
|
daysAgo.value = arrayData.store.userParams.daysAgo || defaultDays;
|
||||||
|
isBooked.value = arrayData.store.userParams.isBooked || false;
|
||||||
|
stateStore.leftDrawer = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(selectedRows, (nVal, oVal) => {
|
||||||
|
const lastRow = nVal.at(-1);
|
||||||
|
if (lastRow?.isBooked) selectedRows.value.pop();
|
||||||
|
if (nVal.length > oVal.length && lastRow.invoiceInFk)
|
||||||
|
quasar.dialog({
|
||||||
|
component: VnConfirm,
|
||||||
|
componentProps: { title: t('entry.preAccount.hasInvoice') },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function filterByDaysAgo(val) {
|
||||||
|
if (!val) val = defaultDays;
|
||||||
|
else if (val > maxDays) val = maxDays;
|
||||||
|
daysAgo.value = val;
|
||||||
|
arrayData.store.userParams.daysAgo = daysAgo.value;
|
||||||
|
table.value.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function preAccount() {
|
||||||
|
const entries = selectedRows.value;
|
||||||
|
const { companyFk, isAgricultural, landed } = entries.at(0);
|
||||||
|
try {
|
||||||
|
dmsFk = entries.find(({ gestDocFk }) => gestDocFk)?.gestDocFk;
|
||||||
|
if (isAgricultural) {
|
||||||
|
const year = new Date(landed).getFullYear();
|
||||||
|
supplierRef = (
|
||||||
|
await axios.get('InvoiceIns/getMaxRef', { params: { companyFk, year } })
|
||||||
|
).data;
|
||||||
|
return createInvoice();
|
||||||
|
} else if (dmsFk) {
|
||||||
|
supplierRef = (
|
||||||
|
await axios.get(`Dms/${dmsFk}`, {
|
||||||
|
params: { filter: JSON.stringify({ fields: ['reference'] }) },
|
||||||
|
})
|
||||||
|
).data?.reference;
|
||||||
|
updateDialog.value.show();
|
||||||
|
} else {
|
||||||
|
uploadFile();
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updateFile() {
|
||||||
|
await axios.post(`Dms/${dmsFk}/updateFile`, { dmsTypeId: dmsTypeId.value });
|
||||||
|
await createInvoice();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function uploadFile() {
|
||||||
|
const firstSelectedEntry = selectedRows.value.at(0);
|
||||||
|
const { supplier, companyFk, invoiceNumber } = firstSelectedEntry;
|
||||||
|
dmsData.value = {
|
||||||
|
dmsTypeFk: dmsTypeId.value,
|
||||||
|
warehouseFk: user.value.warehouseFk,
|
||||||
|
companyFk: companyFk,
|
||||||
|
description: supplier + defaultDmsDescription.value + invoiceNumber,
|
||||||
|
hasFile: false,
|
||||||
|
};
|
||||||
|
uploadDialog.value.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function afterUploadFile({ reference }, res) {
|
||||||
|
supplierRef = reference;
|
||||||
|
dmsFk = res.data[0].id;
|
||||||
|
await createInvoice();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function createInvoice() {
|
||||||
|
try {
|
||||||
|
await axios.post(`Entries/addInvoiceIn`, {
|
||||||
|
ids: selectedRows.value.map((entry) => entry.id),
|
||||||
|
supplierRef,
|
||||||
|
dmsFk,
|
||||||
|
});
|
||||||
|
notify(t('entry.preAccount.success'), 'positive');
|
||||||
|
} catch (e) {
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
|
supplierRef = null;
|
||||||
|
dmsFk = undefined;
|
||||||
|
selectedRows.value.length = 0;
|
||||||
|
table.value.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<FetchData
|
||||||
|
url="Countries"
|
||||||
|
:filter="{ fields: ['id', 'name'] }"
|
||||||
|
@on-fetch="(data) => (countries = data)"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
|
<FetchData
|
||||||
|
url="Companies"
|
||||||
|
:filter="{ fields: ['id', 'code'] }"
|
||||||
|
@on-fetch="(data) => (companies = data)"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
|
<FetchData
|
||||||
|
url="Warehouses"
|
||||||
|
:filter="{ fields: ['id', 'name'] }"
|
||||||
|
@on-fetch="(data) => (warehouses = data)"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
|
<FetchData
|
||||||
|
url="EntryTypes"
|
||||||
|
:filter="{ fields: ['code', 'description'] }"
|
||||||
|
@on-fetch="(data) => (entryTypes = data)"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
|
<FetchData
|
||||||
|
url="supplierFiscalTypes"
|
||||||
|
:filter="{ fields: ['code'] }"
|
||||||
|
@on-fetch="
|
||||||
|
(data) =>
|
||||||
|
(supplierFiscalTypes = data.map((x) => ({ locale: t(x.code), ...x })))
|
||||||
|
"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
|
<FetchData
|
||||||
|
url="InvoiceInConfigs/findOne"
|
||||||
|
:filter="{ fields: ['defaultDmsDescription'] }"
|
||||||
|
@on-fetch="(data) => (defaultDmsDescription = data?.defaultDmsDescription)"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
|
<FetchData
|
||||||
|
url="DmsTypes/findOne"
|
||||||
|
:filter="{ fields: ['id'] }"
|
||||||
|
:where="{ code: 'invoiceIn' }"
|
||||||
|
@on-fetch="(data) => (dmsTypeId = data?.id)"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
|
<VnSearchbar
|
||||||
|
:data-key
|
||||||
|
:url
|
||||||
|
:label="t('entry.preAccount.search')"
|
||||||
|
:info="t('entry.preAccount.searchInfo')"
|
||||||
|
:search-remove-params="false"
|
||||||
|
/>
|
||||||
|
<VnTable
|
||||||
|
v-model:selected="selectedRows"
|
||||||
|
:data-key
|
||||||
|
:columns
|
||||||
|
:url
|
||||||
|
:search-url="dataKey"
|
||||||
|
ref="table"
|
||||||
|
:disable-option="{ card: true }"
|
||||||
|
redirect="Entry"
|
||||||
|
:order="['landed DESC']"
|
||||||
|
:right-search="false"
|
||||||
|
:user-params="{ daysAgo, isBooked }"
|
||||||
|
:row-click="false"
|
||||||
|
:table="{ selection: 'multiple' }"
|
||||||
|
:limit="0"
|
||||||
|
:footer="true"
|
||||||
|
@on-fetch="
|
||||||
|
(data) => (totalAmount = data?.reduce((acc, entry) => acc + entry.amount, 0))
|
||||||
|
"
|
||||||
|
auto-load
|
||||||
|
>
|
||||||
|
<template #top-left>
|
||||||
|
<QBtn
|
||||||
|
data-cy="preAccount_btn"
|
||||||
|
icon="account_balance"
|
||||||
|
color="primary"
|
||||||
|
class="q-mr-sm"
|
||||||
|
:disable="!selectedRows.length"
|
||||||
|
@click="preAccount"
|
||||||
|
>
|
||||||
|
<QTooltip>{{ t('entry.preAccount.btn') }}</QTooltip>
|
||||||
|
</QBtn>
|
||||||
|
<VnInputNumber
|
||||||
|
v-model="daysAgo"
|
||||||
|
:label="$t('globals.daysAgo')"
|
||||||
|
dense
|
||||||
|
:step="1"
|
||||||
|
:decimal-places="0"
|
||||||
|
@update:model-value="filterByDaysAgo"
|
||||||
|
debounce="500"
|
||||||
|
:title="t('entry.preAccount.daysAgo')"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #column-id="{ row }">
|
||||||
|
<span class="link" @click.stop>
|
||||||
|
{{ row.id }}
|
||||||
|
<EntryDescriptorProxy :id="row.id" />
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
<template #column-company="{ row }">
|
||||||
|
<QBadge :color="row.color ?? 'transparent'" :label="row.company" />
|
||||||
|
</template>
|
||||||
|
<template #column-gestDocFk="{ row }">
|
||||||
|
<span class="link" @click.stop="downloadFile(row.gestDocFk)">
|
||||||
|
{{ row.gestDocFk }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
<template #column-supplier="{ row }">
|
||||||
|
<span class="link" @click.stop>
|
||||||
|
{{ row.supplier }}
|
||||||
|
<SupplierDescriptorProxy :id="row.supplierFk" />
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
<template #column-invoiceInFk="{ row }">
|
||||||
|
<span class="link" @click.stop>
|
||||||
|
{{ row.invoiceInFk }}
|
||||||
|
<InvoiceInDescriptorProxy :id="row.invoiceInFk" />
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
<template #column-footer-amount>
|
||||||
|
<div v-text="toCurrency(totalSelectedAmount)" />
|
||||||
|
<div v-text="toCurrency(totalAmount)" />
|
||||||
|
</template>
|
||||||
|
</VnTable>
|
||||||
|
<VnConfirm
|
||||||
|
ref="updateDialog"
|
||||||
|
:title="t('entry.preAccount.dialog.title')"
|
||||||
|
:message="t('entry.preAccount.dialog.message')"
|
||||||
|
>
|
||||||
|
<template #actions>
|
||||||
|
<QBtn
|
||||||
|
data-cy="updateFileYes"
|
||||||
|
:label="t('globals.yes')"
|
||||||
|
color="primary"
|
||||||
|
@click="updateFile"
|
||||||
|
autofocus
|
||||||
|
v-close-popup
|
||||||
|
/>
|
||||||
|
<QBtn
|
||||||
|
data-cy="updateFileNo"
|
||||||
|
:label="t('globals.no')"
|
||||||
|
color="primary"
|
||||||
|
flat
|
||||||
|
@click="uploadFile"
|
||||||
|
v-close-popup
|
||||||
|
/>
|
||||||
|
<QBtn :label="t('globals.cancel')" color="primary" flat v-close-popup />
|
||||||
|
</template>
|
||||||
|
</VnConfirm>
|
||||||
|
<QDialog ref="uploadDialog">
|
||||||
|
<VnDms
|
||||||
|
model="dms"
|
||||||
|
:form-initial-data="dmsData"
|
||||||
|
url="Dms/uploadFile"
|
||||||
|
@on-data-saved="afterUploadFile"
|
||||||
|
/>
|
||||||
|
</QDialog>
|
||||||
|
</template>
|
||||||
|
<i18n>
|
||||||
|
en:
|
||||||
|
IntraCommunity: Intra-community
|
||||||
|
NonCommunity: Non-community
|
||||||
|
CanaryIslands: Canary Islands
|
||||||
|
es:
|
||||||
|
IntraCommunity: Intracomunitaria
|
||||||
|
NonCommunity: Extracomunitaria
|
||||||
|
CanaryIsland: Islas Canarias
|
||||||
|
National: Nacional
|
||||||
|
</i18n>
|
|
@ -0,0 +1,63 @@
|
||||||
|
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||||
|
import { createWrapper } from 'app/test/vitest/helper';
|
||||||
|
import EntryPreAccount from '../EntryPreAccount.vue';
|
||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
|
describe('EntryPreAccount', () => {
|
||||||
|
let wrapper;
|
||||||
|
let vm;
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
vi.spyOn(axios, 'get').mockImplementation((url) => {
|
||||||
|
if (url == 'EntryConfigs/findOne')
|
||||||
|
return { data: { maxDays: 90, defaultDays: 30 } };
|
||||||
|
return { data: [] };
|
||||||
|
});
|
||||||
|
wrapper = createWrapper(EntryPreAccount);
|
||||||
|
vm = wrapper.vm;
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
vi.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('filterByDaysAgo()', () => {
|
||||||
|
it('should set daysAgo to defaultDays if no value is provided', () => {
|
||||||
|
vm.filterByDaysAgo();
|
||||||
|
expect(vm.daysAgo).toBe(vm.defaultDays);
|
||||||
|
expect(vm.arrayData.store.userParams.daysAgo).toBe(vm.defaultDays);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set daysAgo to maxDays if the value exceeds maxDays', () => {
|
||||||
|
vm.filterByDaysAgo(500);
|
||||||
|
expect(vm.daysAgo).toBe(vm.maxDays);
|
||||||
|
expect(vm.arrayData.store.userParams.daysAgo).toBe(vm.maxDays);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set daysAgo to the provided value if it is valid', () => {
|
||||||
|
vm.filterByDaysAgo(30);
|
||||||
|
expect(vm.daysAgo).toBe(30);
|
||||||
|
expect(vm.arrayData.store.userParams.daysAgo).toBe(30);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Dialog behavior when adding a new row', () => {
|
||||||
|
it('should open the dialog if the new row has invoiceInFk', async () => {
|
||||||
|
const dialogSpy = vi.spyOn(vm.quasar, 'dialog');
|
||||||
|
const selectedRows = [{ id: 1, invoiceInFk: 123 }];
|
||||||
|
vm.selectedRows = selectedRows;
|
||||||
|
await vm.$nextTick();
|
||||||
|
expect(dialogSpy).toHaveBeenCalledWith({
|
||||||
|
component: vm.VnConfirm,
|
||||||
|
componentProps: { title: vm.t('entry.preAccount.hasInvoice') },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not open the dialog if the new row does not have invoiceInFk', async () => {
|
||||||
|
const dialogSpy = vi.spyOn(vm.quasar, 'dialog');
|
||||||
|
vm.selectedRows = [{ id: 1, invoiceInFk: null }];
|
||||||
|
await vm.$nextTick();
|
||||||
|
expect(dialogSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -118,6 +118,33 @@ entry:
|
||||||
searchInfo: You can search by entry reference
|
searchInfo: You can search by entry reference
|
||||||
descriptorMenu:
|
descriptorMenu:
|
||||||
showEntryReport: Show entry report
|
showEntryReport: Show entry report
|
||||||
|
preAccount:
|
||||||
|
gestDocFk: Gestdoc
|
||||||
|
dmsType: Gestdoc type
|
||||||
|
invoiceNumber: Entry ref.
|
||||||
|
reference: Gestdoc ref.
|
||||||
|
shipped: Shipped
|
||||||
|
landed: Landed
|
||||||
|
id: Entry
|
||||||
|
invoiceInFk: Invoice in
|
||||||
|
supplierFk: Supplier
|
||||||
|
country: Country
|
||||||
|
description: Entry type
|
||||||
|
payDem: Payment term
|
||||||
|
isBooked: B
|
||||||
|
isReceived: R
|
||||||
|
entryType: Entry type
|
||||||
|
isAgricultural: Agricultural
|
||||||
|
fiscalCode: Account type
|
||||||
|
daysAgo: Max 365 days
|
||||||
|
search: Search
|
||||||
|
searchInfo: You can search by supplier name or nickname
|
||||||
|
btn: Pre-account
|
||||||
|
hasInvoice: This entry has already an invoice in
|
||||||
|
success: It has been successfully pre-accounted
|
||||||
|
dialog:
|
||||||
|
title: Pre-account entries
|
||||||
|
message: Do you want the invoice to inherit the entry document?
|
||||||
entryFilter:
|
entryFilter:
|
||||||
params:
|
params:
|
||||||
isExcludedFromAvailable: Excluded from available
|
isExcludedFromAvailable: Excluded from available
|
||||||
|
|
|
@ -69,6 +69,33 @@ entry:
|
||||||
observationType: Tipo de observación
|
observationType: Tipo de observación
|
||||||
search: Buscar entradas
|
search: Buscar entradas
|
||||||
searchInfo: Puedes buscar por referencia de entrada
|
searchInfo: Puedes buscar por referencia de entrada
|
||||||
|
preAccount:
|
||||||
|
gestDocFk: Gestdoc
|
||||||
|
dmsType: Tipo gestdoc
|
||||||
|
invoiceNumber: Ref. Entrada
|
||||||
|
reference: Ref. GestDoc
|
||||||
|
shipped: F. envío
|
||||||
|
landed: F. llegada
|
||||||
|
id: Entrada
|
||||||
|
invoiceInFk: Recibida
|
||||||
|
supplierFk: Proveedor
|
||||||
|
country: País
|
||||||
|
description: Tipo de Entrada
|
||||||
|
payDem: Plazo de pago
|
||||||
|
isBooked: C
|
||||||
|
isReceived: R
|
||||||
|
entryType: Tipo de entrada
|
||||||
|
isAgricultural: Agricultural
|
||||||
|
fiscalCode: Tipo de cuenta
|
||||||
|
daysAgo: Máximo 365 días
|
||||||
|
search: Buscar
|
||||||
|
searchInfo: Puedes buscar por nombre o alias de proveedor
|
||||||
|
btn: Precontabilizar
|
||||||
|
hasInvoice: Esta entrada ya tiene una f. recibida
|
||||||
|
success: Se ha precontabilizado correctamente
|
||||||
|
dialog:
|
||||||
|
title: Precontabilizar entradas
|
||||||
|
message: ¿Desea que la factura herede el documento de la entrada?
|
||||||
params:
|
params:
|
||||||
entryFk: Entrada
|
entryFk: Entrada
|
||||||
observationTypeFk: Tipo de observación
|
observationTypeFk: Tipo de observación
|
||||||
|
|
|
@ -85,6 +85,7 @@ export default {
|
||||||
'EntryLatestBuys',
|
'EntryLatestBuys',
|
||||||
'EntryStockBought',
|
'EntryStockBought',
|
||||||
'EntryWasteRecalc',
|
'EntryWasteRecalc',
|
||||||
|
'EntryPreAccount',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
component: RouterView,
|
component: RouterView,
|
||||||
|
@ -94,6 +95,7 @@ export default {
|
||||||
name: 'EntryMain',
|
name: 'EntryMain',
|
||||||
path: '',
|
path: '',
|
||||||
component: () => import('src/components/common/VnModule.vue'),
|
component: () => import('src/components/common/VnModule.vue'),
|
||||||
|
props: (route) => ({ leftDrawer: route.name !== 'EntryPreAccount' }),
|
||||||
redirect: { name: 'EntryIndexMain' },
|
redirect: { name: 'EntryIndexMain' },
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
|
@ -150,6 +152,15 @@ export default {
|
||||||
},
|
},
|
||||||
component: () => import('src/pages/Entry/EntryWasteRecalc.vue'),
|
component: () => import('src/pages/Entry/EntryWasteRecalc.vue'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'pre-account',
|
||||||
|
name: 'EntryPreAccount',
|
||||||
|
meta: {
|
||||||
|
title: 'entryPreAccount',
|
||||||
|
icon: 'account_balance',
|
||||||
|
},
|
||||||
|
component: () => import('src/pages/Entry/EntryPreAccount.vue'),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
/// <reference types="cypress" />
|
||||||
|
describe('Entry PreAccount Functionality', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.login('administrative');
|
||||||
|
cy.visit('/#/entry/pre-account');
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should pre-account without questions if it's agricultural", () => {
|
||||||
|
selectRowsByCol('id', [2]);
|
||||||
|
cy.dataCy('preAccount_btn').click();
|
||||||
|
cy.checkNotification('It has been successfully pre-accounted');
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should ask to upload a doc. if it's not agricultural and doesn't have doc. ", () => {
|
||||||
|
selectRowsByCol('id', [3]);
|
||||||
|
cy.dataCy('preAccount_btn').click();
|
||||||
|
cy.dataCy('Reference_input').type('{selectall}234343fh', { delay: 0 });
|
||||||
|
cy.dataCy('VnDms_inputFile').selectFile('test/cypress/fixtures/image.jpg', {
|
||||||
|
force: true,
|
||||||
|
});
|
||||||
|
cy.dataCy('FormModelPopup_save').click();
|
||||||
|
cy.checkNotification('It has been successfully pre-accounted');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should ask to inherit the doc. and open VnDms popup if user choose "no"', () => {
|
||||||
|
selectRowsByCol('id', [101]);
|
||||||
|
cy.dataCy('preAccount_btn').click();
|
||||||
|
cy.dataCy('updateFileNo').click();
|
||||||
|
cy.get('#formModel').should('be.visible');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should ask to inherit the doc. and open VnDms popup if user choose "yes" and pre-account', () => {
|
||||||
|
selectRowsByCol('id', [101]);
|
||||||
|
cy.dataCy('preAccount_btn').click();
|
||||||
|
cy.dataCy('updateFileYes').click();
|
||||||
|
cy.checkNotification('It has been successfully pre-accounted');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function selectRowsByCol(col = 'id', vals = []) {
|
||||||
|
for (const val of vals) {
|
||||||
|
const regex = new RegExp(`^\\s*(${val})\\s*$`);
|
||||||
|
cy.contains(`[data-col-field="${col}"]`, regex)
|
||||||
|
.parent()
|
||||||
|
.find('td > .q-checkbox')
|
||||||
|
.click();
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,7 +6,7 @@ describe('Item tax', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should modify the tax for Spain', () => {
|
it('should modify the tax for Spain', () => {
|
||||||
cy.dataCy('Class_select').eq(1).type('General VAT{enter}');
|
cy.dataCy('Class_select').eq(1).type('IVA General{enter}');
|
||||||
|
|||||||
cy.dataCy('crudModelDefaultSaveBtn').click();
|
cy.dataCy('crudModelDefaultSaveBtn').click();
|
||||||
cy.checkNotification('Data saved');
|
cy.checkNotification('Data saved');
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Los campos de la tabla taxClass me pidió Carlos Andrés que los copiara de producción.