Compare commits

..

9 Commits

Author SHA1 Message Date
Pau Rovira 35914be54a Merge branch 'dev' into 8406-crudModelUpdate
gitea/salix-front/pipeline/pr-dev This commit is unstable Details
2025-04-17 11:31:28 +00:00
Pau Rovira 0fa1b6ee9d Merge branch 'dev' into 8406-crudModelUpdate
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details
2025-04-17 08:40:11 +00:00
Pau Rovira d838d9b55a feat: refs #8406 "add" button on a bottom bar in CrudModel
gitea/salix-front/pipeline/pr-dev This commit looks good Details
2025-04-16 14:58:18 +02:00
Pau Rovira 36d306e827 Merge branch 'dev' into 8406-crudModelUpdate
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details
2025-04-14 11:38:13 +00:00
Pau Rovira 5703798781 fix: refs #8406 fixed front test
gitea/salix-front/pipeline/pr-dev This commit is unstable Details
2025-04-03 09:56:46 +02:00
Pau Rovira c075f39576 Merge branch 'dev' into 8406-crudModelUpdate
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details
2025-04-03 06:52:24 +00:00
Pau Rovira 87c1c16d26 feat: refs #8406 added new insertion with tabulation
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details
2025-04-03 08:38:03 +02:00
Pau Rovira 5b42e97d83 Merge branch 'dev' into 8406-crudModelUpdate
gitea/salix-front/pipeline/pr-dev This commit is unstable Details
2025-03-24 10:07:01 +00:00
Pau Rovira e874375276 feat: refs #8406 upgraded CrudModel 2025-03-24 11:05:36 +01:00
29 changed files with 180 additions and 713 deletions

View File

@ -1,6 +1,6 @@
<script setup>
import axios from 'axios';
import { computed, ref, useAttrs, watch } from 'vue';
import { computed, ref, useAttrs, watch, nextTick } from 'vue';
import { useRouter, onBeforeRouteLeave } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { useQuasar } from 'quasar';
@ -42,7 +42,15 @@ const $props = defineProps({
},
dataRequired: {
type: Object,
default: () => {},
default: () => ({}),
},
dataDefault: {
type: Object,
default: () => ({}),
},
insertOnLoad: {
type: Boolean,
default: false,
},
defaultSave: {
type: Boolean,
@ -56,6 +64,10 @@ const $props = defineProps({
type: Boolean,
default: true,
},
defaultAdd: {
type: Boolean,
default: false,
},
selected: {
type: Object,
default: null,
@ -86,7 +98,10 @@ const vnPaginateRef = ref();
const formData = ref();
const saveButtonRef = ref(null);
const watchChanges = ref();
let isNotEqual = ref(false);
let isLastRowEmpty = ref(false);
const formUrl = computed(() => $props.url);
const rowsContainer = ref(null);
const emit = defineEmits(['onFetch', 'update:selected', 'saveChanges']);
@ -122,9 +137,13 @@ async function fetch(data) {
const rows = keyData ? data[keyData] : data;
resetData(rows);
emit('onFetch', rows);
if ($props.insertOnLoad) {
await insert();
}
return rows;
}
function resetData(data) {
if (!data) return;
if (data && Array.isArray(data)) {
@ -135,9 +154,16 @@ function resetData(data) {
formData.value = JSON.parse(JSON.stringify(data));
if (watchChanges.value) watchChanges.value(); //destroy watcher
watchChanges.value = watch(formData, () => (hasChanges.value = true), { deep: true });
}
watchChanges.value = watch(formData, (nVal) => {
hasChanges.value = false;
const filteredNewData = nVal.filter(row => !isRowEmpty(row) || row[$props.primaryKey]);
const filteredOriginal = originalData.value.filter(row => row[$props.primaryKey]);
const changes = getDifferences(filteredOriginal, filteredNewData);
hasChanges.value = !isEmpty(changes);
}, { deep: true });
}
async function reset() {
await fetch(originalData.value);
hasChanges.value = false;
@ -165,7 +191,9 @@ async function onSubmit() {
});
}
isLoading.value = true;
await saveChanges($props.saveFn ? formData.value : null);
}
async function onSubmitAndGo() {
@ -203,14 +231,32 @@ async function saveChanges(data) {
});
}
async function insert(pushData = $props.dataRequired) {
const $index = formData.value.length
? formData.value[formData.value.length - 1].$index + 1
: 0;
formData.value.push(Object.assign({ $index }, pushData));
hasChanges.value = true;
async function insert(pushData = { ...$props.dataRequired, ...$props.dataDefault }) {
formData.value = formData.value.filter(row => !isRowEmpty(row));
const lastRow = formData.value.at(-1);
const isLastRowEmpty = lastRow ? isRowEmpty(lastRow) : false;
if (formData.value.length > 0 && isLastRowEmpty) return;
const $index = formData.value.length ? formData.value.at(-1).$index + 1 : 0;
const nRow = Object.assign({ $index }, pushData);
formData.value.push(nRow);
const hasChange = Object.keys(nRow).some(key => !isChange(nRow, key));
if (hasChange) hasChanges.value = true;
}
function isRowEmpty(row) {
return Object.keys(row).every(key => isChange(row, key));
}
function isChange(row,key){
return !row[key] || key == '$index' || Object.hasOwn($props.dataRequired || {}, key);
}
async function remove(data) {
if (!data.length)
return quasar.notify({
@ -227,10 +273,8 @@ async function remove(data) {
newData = newData.filter(
(form) => !preRemove.some((index) => index == form.$index),
);
const changes = getChanges();
if (!changes.creates?.length && !changes.updates?.length)
hasChanges.value = false;
fetch(newData);
formData.value = newData;
hasChanges.value = JSON.stringify(removeIndexField(formData.value)) !== JSON.stringify(removeIndexField(originalData.value));
}
if (ids.length) {
quasar
@ -248,9 +292,8 @@ async function remove(data) {
newData = newData.filter((form) => !ids.some((id) => id == form[pk]));
fetch(newData);
});
} else {
reset();
}
emit('update:selected', []);
}
@ -261,7 +304,7 @@ function getChanges() {
const pk = $props.primaryKey;
for (const [i, row] of formData.value.entries()) {
if (!row[pk]) {
creates.push(row);
creates.push(Object.assign(row, { ...$props.dataRequired }));
} else if (originalData.value[i]) {
const data = getDifferences(originalData.value[i], row);
if (!isEmpty(data)) {
@ -287,6 +330,40 @@ function isEmpty(obj) {
return !Object.keys(obj).length;
}
function removeIndexField(data) {
if (Array.isArray(data)) {
return data.map(({ $index, ...rest }) => rest);
} else if (typeof data === 'object' && data !== null) {
const { $index, ...rest } = data;
return rest;
}
}
async function handleTab(event) {
if (event.target.classList.contains('q-checkbox__input') ||
event.target.type === 'checkbox' ||
event.target.closest('.q-checkbox')) {
return;
}
const focusableElements = rowsContainer.value?.querySelectorAll(
'input:not([type="checkbox"]), select, textarea, [tabindex]:not([tabindex="-1"]):not(.q-checkbox__input), .q-field__native'
);
if (!focusableElements || focusableElements.length === 0) return;
const lastElement = focusableElements[focusableElements.length - 1];
if (event.target === lastElement) {
event.preventDefault();
await insert();
await nextTick();
const newElements = rowsContainer.value.querySelectorAll('input:not([type="checkbox"]), select, textarea, [tabindex]:not([tabindex="-1"]):not(.q-checkbox__input)');
if (newElements.length > focusableElements.length) {
newElements[newElements.length - 1].focus();
}
}
}
async function reload(params) {
const data = await vnPaginateRef.value.fetch(params);
fetch(data);
@ -312,12 +389,14 @@ watch(formUrl, async () => {
v-bind="$attrs"
>
<template #body v-if="formData">
<div ref="rowsContainer" @keydown.tab="handleTab">
<slot
name="body"
:rows="formData"
:validate="validate"
:filter="filter"
></slot>
</div>
</template>
</VnPaginate>
<Teleport to="#st-actions" v-if="stateStore?.isSubToolbarShown() && hasSubToolbar">
@ -397,4 +476,16 @@ watch(formUrl, async () => {
:label="t && t('globals.pleaseWait')"
color="primary"
/>
<div class=" bottomButton" v-if="defaultAdd">
<QBtn
@click="insert()"
class="cursor-pointer fill-icon"
color="primary"
icon="add_circle"
size="md"
round
flat
v-shortcut="'+'"
/>
</div>
</template>

View File

@ -663,6 +663,7 @@ const rowCtrlClickFunction = computed(() => {
:class="$attrs['class'] ?? 'q-px-md'"
:limit="$attrs['limit'] ?? 100"
ref="CrudModelRef"
:insert-on-load="crudModel.insertOnLoad"
@on-fetch="(...args) => emit('onFetch', ...args)"
:search-url="searchUrl"
:disable-infinite-scroll="isTableMode"

View File

@ -193,11 +193,11 @@ describe('CrudModel', () => {
});
it('should set originalData and formatData with data and generate watchChanges', async () => {
data = {
data = [{
name: 'Tony',
lastName: 'Stark',
age: 42,
};
}];
vm.resetData(data);

View File

@ -186,7 +186,7 @@ onMounted(() => {
if ($props.focusOnMount) setTimeout(() => vnSelectRef.value.showPopup(), 300);
});
const someIsLoading = computed(() => isLoading.value || !!arrayData?.isLoading?.value);
const someIsLoading = computed(() => isLoading.value || arrayData?.isLoading?.value);
function findKeyInOptions() {
if (!$props.options) return;
return filter($props.modelValue, $props.options)?.length;
@ -376,7 +376,7 @@ function getCaption(opt) {
>
<template #append>
<QIcon
v-show="isClearable && value != null && value !== ''"
v-show="isClearable && value"
name="close"
@click="
() => {
@ -391,7 +391,7 @@ function getCaption(opt) {
<template v-for="(_, slotName) in $slots" #[slotName]="slotData" :key="slotName">
<div v-if="slotName == 'append'">
<QIcon
v-show="isClearable && value != null && value !== ''"
v-show="isClearable && value"
name="close"
@click.stop="
() => {
@ -416,7 +416,7 @@ function getCaption(opt) {
<QItemLabel>
{{ opt[optionLabel] }}
</QItemLabel>
<QItemLabel caption v-if="getCaption(opt) !== false">
<QItemLabel caption v-if="getCaption(opt)">
{{ `#${getCaption(opt)}` }}
</QItemLabel>
</QItemSection>

View File

@ -89,7 +89,6 @@ function cancel() {
<slot name="customHTML"></slot>
</QCardSection>
<QCardActions align="right">
<slot name="actions" :actions="{ confirm, cancel }">
<QBtn
:label="t('globals.cancel')"
color="primary"
@ -108,7 +107,6 @@ function cancel() {
autofocus
data-cy="VnConfirm_confirm"
/>
</slot>
</QCardActions>
</QCard>
</QDialog>

View File

@ -1,4 +1,4 @@
import { onMounted, computed, ref } from 'vue';
import { onMounted, computed } from 'vue';
import { useRouter, useRoute } from 'vue-router';
import axios from 'axios';
import { useArrayDataStore } from 'stores/useArrayDataStore';
@ -346,7 +346,7 @@ export function useArrayData(key, userOptions) {
}
const totalRows = computed(() => (store.data && store.data.length) || 0);
const isLoading = ref(store.isLoading || false);
const isLoading = computed(() => store.isLoading || false);
return {
fetch,

View File

@ -346,7 +346,6 @@ globals:
parking: Parking
vehicleList: Vehicles
vehicle: Vehicle
entryPreAccount: Pre-account
unsavedPopup:
title: Unsaved changes will be lost
subtitle: Are you sure exit without saving?

View File

@ -349,7 +349,6 @@ globals:
parking: Parking
vehicleList: Vehículos
vehicle: Vehículo
entryPreAccount: Precontabilizar
unsavedPopup:
title: Los cambios que no haya guardado se perderán
subtitle: ¿Seguro que quiere salir sin guardar?

View File

@ -138,6 +138,8 @@ const columns = computed(() => [
:filter="developmentsFilter"
ref="claimDevelopmentForm"
:data-required="{ claimFk: route.params.id }"
:defaultAdd="true"
:insert-on-load="true"
v-model:selected="selected"
@save-changes="$router.push(`/claim/${route.params.id}/action`)"
:default-save="false"

View File

@ -1,477 +0,0 @@
<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>

View File

@ -1,63 +0,0 @@
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();
});
});
});

View File

@ -118,33 +118,6 @@ entry:
searchInfo: You can search by entry reference
descriptorMenu:
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:
params:
isExcludedFromAvailable: Excluded from available

View File

@ -69,33 +69,6 @@ entry:
observationType: Tipo de observación
search: Buscar entradas
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:
entryFk: Entrada
observationTypeFk: Tipo de observación

View File

@ -89,6 +89,8 @@ onBeforeMount(async () => await setTaxableBase());
data-key="InvoiceInDueDays"
url="InvoiceInDueDays"
:filter="filter"
:insert-on-load="true"
:default-add="true"
auto-load
:data-required="{ invoiceInFk: invoiceId }"
v-model:selected="rowsSelected"

View File

@ -89,7 +89,9 @@ const columns = computed(() => [
url="InvoiceInIntrastats"
auto-load
:data-required="{ invoiceInFk: invoiceInId }"
:default-add="true"
:filter="filter"
:insert-on-load="true"
v-model:selected="rowsSelected"
@on-fetch="(data) => (invoceInIntrastat = data)"
>

View File

@ -187,6 +187,8 @@ function setCursor(ref) {
url="InvoiceInTaxes"
:filter="filter"
:data-required="{ invoiceInFk: $route.params.id }"
:default-add="true"
:insert-on-load="true"
auto-load
v-model:selected="rowsSelected"
:go-to="`/invoice-in/${$route.params.id}/due-day`"

View File

@ -51,6 +51,7 @@ const submit = async (rows) => {
<CrudModel
:data-required="{ itemFk: route.params.id }"
:default-remove="false"
:insert-on-load="true"
:filter="{
fields: ['id', 'itemFk', 'code'],
where: { itemFk: route.params.id },

View File

@ -76,15 +76,22 @@ const insertTag = (rows) => {
model="ItemTags"
url="ItemTags"
:data-required="{
$index: undefined,
itemFk: route.params.id,
priority: undefined,
tag: {
isFree: undefined,
isFree: true,
value: undefined,
name: undefined,
},
}"
:data-default="{
tag: {
isFree: true,
value: undefined,
name: undefined,
},
tagFk: undefined,
priority: undefined,
}"
:default-remove="false"
:user-filter="{

View File

@ -24,10 +24,10 @@ const crudModelFilter = reactive({
where: { ticketFk: route.params.id },
});
const crudModelRequiredData = computed(() => ({
const crudModelDefaultData = computed(() => ({
created: Date.vnNew(),
packagingFk: null,
quantity: 0,
created: Date.vnNew(),
ticketFk: route.params.id,
}));
@ -59,7 +59,7 @@ watch(
url="TicketPackagings"
model="TicketPackagings"
:filter="crudModelFilter"
:data-required="crudModelRequiredData"
:data-default="crudModelDefaultData"
:default-remove="false"
auto-load
style="max-width: 800px"

View File

@ -719,6 +719,7 @@ watch(
:create-as-dialog="false"
:crud-model="{
disableInfiniteScroll: true,
insertOnLoad: false,
}"
:default-remove="false"
:default-reset="false"

View File

@ -181,6 +181,7 @@ function beforeSave(data) {
model="TicketService"
:filter="crudModelFilter"
:data-required="crudModelRequiredData"
:default-add="true"
auto-load
v-model:selected="selected"
:order="['description ASC']"

View File

@ -181,6 +181,7 @@ const setUserParams = (params) => {
:create="false"
:crud-model="{
disableInfiniteScroll: true,
insertOnLoad: false,
}"
:table="{
'row-key': 'itemFk',

View File

@ -99,6 +99,10 @@ const columns = computed(() => [
workerFk: entityId,
},
}"
:crud-model="{
insertOnLoad: false,
}"
order="paymentDate DESC"
:columns="columns"
auto-load

View File

@ -128,6 +128,9 @@ const columns = computed(() => [
workerFk: entityId,
},
}"
:crud-model="{
insertOnLoad: false,
}"
order="id DESC"
:columns="columns"
auto-load

View File

@ -109,6 +109,9 @@ const columns = [
workerFk: entityId,
},
}"
:crud-model="{
insertOnLoad: false,
}"
order="date DESC"
:columns="columns"
auto-load

View File

@ -170,6 +170,9 @@ function isSigned(row) {
'row-key': 'deviceProductionFk',
selection: 'multiple',
}"
:crud-model="{
insertOnLoad: false,
}"
:table-filter="{ hiddenTags: ['userFk'] }"
>
<template #moreBeforeActions>

View File

@ -85,7 +85,6 @@ export default {
'EntryLatestBuys',
'EntryStockBought',
'EntryWasteRecalc',
'EntryPreAccount',
],
},
component: RouterView,
@ -95,7 +94,6 @@ export default {
name: 'EntryMain',
path: '',
component: () => import('src/components/common/VnModule.vue'),
props: (route) => ({ leftDrawer: route.name !== 'EntryPreAccount' }),
redirect: { name: 'EntryIndexMain' },
children: [
{
@ -152,15 +150,6 @@ export default {
},
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'),
},
],
},
],

View File

@ -1,48 +0,0 @@
/// <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();
}
}

View File

@ -6,7 +6,7 @@ describe('Item tax', () => {
});
it('should modify the tax for Spain', () => {
cy.dataCy('Class_select').eq(1).type('IVA General{enter}');
cy.dataCy('Class_select').eq(1).type('General VAT{enter}');
cy.dataCy('crudModelDefaultSaveBtn').click();
cy.checkNotification('Data saved');
});