Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into 8372-fixDoubleRequest

This commit is contained in:
Jorge Penadés 2025-02-07 16:19:50 +01:00
commit 705f3d7d62
31 changed files with 992 additions and 532 deletions

View File

@ -0,0 +1,2 @@
export const langs = ['en', 'es'];
export const decimalPlaces = 2;

View File

@ -41,7 +41,6 @@ const filteredItems = computed(() => {
return locale.includes(normalizedSearch); return locale.includes(normalizedSearch);
}); });
}); });
const filteredPinnedModules = computed(() => { const filteredPinnedModules = computed(() => {
if (!search.value) return pinnedModules.value; if (!search.value) return pinnedModules.value;
const normalizedSearch = search.value const normalizedSearch = search.value
@ -72,7 +71,7 @@ watch(
items.value = []; items.value = [];
getRoutes(); getRoutes();
}, },
{ deep: true } { deep: true },
); );
function findMatches(search, item) { function findMatches(search, item) {
@ -104,12 +103,22 @@ function addChildren(module, route, parent) {
} }
function getRoutes() { function getRoutes() {
if (props.source === 'main') { const handleRoutes = {
main: getMainRoutes,
card: getCardRoutes,
};
try {
handleRoutes[props.source]();
} catch (error) {
throw new Error(`Method is not defined`);
}
}
function getMainRoutes() {
const modules = Object.assign([], navigation.getModules().value); const modules = Object.assign([], navigation.getModules().value);
for (const item of modules) { for (const item of modules) {
const moduleDef = routes.find( const moduleDef = routes.find(
(route) => toLowerCamel(route.name) === item.module (route) => toLowerCamel(route.name) === item.module,
); );
if (!moduleDef) continue; if (!moduleDef) continue;
item.children = []; item.children = [];
@ -120,18 +129,15 @@ function getRoutes() {
items.value = modules; items.value = modules;
} }
if (props.source === 'card') { function getCardRoutes() {
const currentRoute = route.matched[1]; const currentRoute = route.matched[1];
const currentModule = toLowerCamel(currentRoute.name); const currentModule = toLowerCamel(currentRoute.name);
let moduleDef = routes.find( let moduleDef = routes.find((route) => toLowerCamel(route.name) === currentModule);
(route) => toLowerCamel(route.name) === currentModule
);
if (!moduleDef) return; if (!moduleDef) return;
if (!moduleDef?.menus) moduleDef = betaGetRoutes(); if (!moduleDef?.menus) moduleDef = betaGetRoutes();
addChildren(currentModule, moduleDef, items.value); addChildren(currentModule, moduleDef, items.value);
} }
}
function betaGetRoutes() { function betaGetRoutes() {
let menuRoute; let menuRoute;
@ -223,9 +229,16 @@ const searchModule = () => {
</template> </template>
<template v-for="(item, index) in filteredItems" :key="item.name"> <template v-for="(item, index) in filteredItems" :key="item.name">
<template <template
v-if="search ||item.children && !filteredPinnedModules.has(item.name)" v-if="
search ||
(item.children && !filteredPinnedModules.has(item.name))
"
>
<LeftMenuItem
:item="item"
group="modules"
:class="search && index === 0 ? 'searched' : ''"
> >
<LeftMenuItem :item="item" group="modules" :class="search && index === 0 ? 'searched' : ''">
<template #side> <template #side>
<QBtn <QBtn
v-if="item.isPinned === true" v-if="item.isPinned === true"

View File

@ -27,7 +27,7 @@ function columnName(col) {
</script> </script>
<template> <template>
<VnFilterPanel v-bind="$attrs" :search-button="true" :disable-submit-event="true"> <VnFilterPanel v-bind="$attrs" :search-button="true" :disable-submit-event="true">
<template #body="{ params, orders }"> <template #body="{ params, orders, searchFn }">
<div <div
class="row no-wrap flex-center" class="row no-wrap flex-center"
v-for="col of columns.filter((c) => c.columnFilter ?? true)" v-for="col of columns.filter((c) => c.columnFilter ?? true)"
@ -52,6 +52,7 @@ function columnName(col) {
<slot <slot
name="moreFilterPanel" name="moreFilterPanel"
:params="params" :params="params"
:search-fn="searchFn"
:orders="orders" :orders="orders"
:columns="columns" :columns="columns"
/> />

View File

@ -1,9 +1,12 @@
import { vi, describe, expect, it, beforeAll } from 'vitest'; import { vi, describe, expect, it, beforeAll, beforeEach, afterEach } from 'vitest';
import { createWrapper, axios } from 'app/test/vitest/helper'; import { createWrapper, axios } from 'app/test/vitest/helper';
import Leftmenu from 'components/LeftMenu.vue'; import Leftmenu from 'components/LeftMenu.vue';
import * as vueRouter from 'vue-router';
import { useNavigationStore } from 'src/stores/useNavigationStore'; import { useNavigationStore } from 'src/stores/useNavigationStore';
let vm;
let navigation;
vi.mock('src/router/modules', () => ({ vi.mock('src/router/modules', () => ({
default: [ default: [
{ {
@ -21,6 +24,16 @@ vi.mock('src/router/modules', () => ({
{ {
path: '', path: '',
name: 'CustomerMain', name: 'CustomerMain',
meta: {
menu: 'Customer',
menuChildren: [
{
name: 'CustomerCreditContracts',
title: 'creditContracts',
icon: 'vn:solunion',
},
],
},
children: [ children: [
{ {
path: 'list', path: 'list',
@ -28,6 +41,13 @@ vi.mock('src/router/modules', () => ({
meta: { meta: {
title: 'list', title: 'list',
icon: 'view_list', icon: 'view_list',
menuChildren: [
{
name: 'CustomerCreditContracts',
title: 'creditContracts',
icon: 'vn:solunion',
},
],
}, },
}, },
{ {
@ -44,20 +64,59 @@ vi.mock('src/router/modules', () => ({
}, },
], ],
})); }));
vi.spyOn(vueRouter, 'useRoute').mockReturnValue({
describe('Leftmenu', () => { matched: [
let vm; {
let navigation; path: '/',
beforeAll(() => { redirect: {
name: 'Dashboard',
},
name: 'Main',
meta: {},
props: {
default: false,
},
children: [
{
path: '/dashboard',
name: 'Dashboard',
meta: {
title: 'dashboard',
icon: 'dashboard',
},
},
],
},
{
path: '/customer',
redirect: {
name: 'CustomerMain',
},
name: 'Customer',
meta: {
title: 'customers',
icon: 'vn:client',
moduleName: 'Customer',
keyBinding: 'c',
menu: 'customer',
},
},
],
query: {},
params: {},
meta: { moduleName: 'mockName' },
path: 'mockName/1',
name: 'Customer',
});
function mount(source = 'main') {
vi.spyOn(axios, 'get').mockResolvedValue({ vi.spyOn(axios, 'get').mockResolvedValue({
data: [], data: [],
}); });
const wrapper = createWrapper(Leftmenu, {
vm = createWrapper(Leftmenu, {
propsData: { propsData: {
source: 'main', source,
}, },
}).vm; });
navigation = useNavigationStore(); navigation = useNavigationStore();
navigation.fetchPinned = vi.fn().mockReturnValue(Promise.resolve(true)); navigation.fetchPinned = vi.fn().mockReturnValue(Promise.resolve(true));
@ -71,24 +130,259 @@ describe('Leftmenu', () => {
}, },
], ],
}); });
return wrapper;
}
describe('getRoutes', () => {
afterEach(() => vi.clearAllMocks());
const getRoutes = vi.fn().mockImplementation((props, getMethodA, getMethodB) => {
const handleRoutes = {
methodA: getMethodA,
methodB: getMethodB,
};
try {
handleRoutes[props.source]();
} catch (error) {
throw Error('Method not defined');
}
}); });
it('should return a proper formated object with two child items', async () => { const getMethodA = vi.fn();
const expectedMenuItem = [ const getMethodB = vi.fn();
{ const fn = (props) => getRoutes(props, getMethodA, getMethodB);
children: null,
name: 'CustomerList', it('should call getMethodB when source is card', () => {
title: 'globals.pageTitles.list', let props = { source: 'methodB' };
icon: 'view_list', fn(props);
},
{ expect(getMethodB).toHaveBeenCalled();
children: null, expect(getMethodA).not.toHaveBeenCalled();
name: 'CustomerCreate', });
title: 'globals.pageTitles.createCustomer', it('should call getMethodA when source is main', () => {
icon: 'vn:addperson', let props = { source: 'methodA' };
}, fn(props);
expect(getMethodA).toHaveBeenCalled();
expect(getMethodB).not.toHaveBeenCalled();
});
it('should call getMethodA when source is not exists or undefined', () => {
let props = { source: 'methodC' };
expect(() => fn(props)).toThrowError('Method not defined');
expect(getMethodA).not.toHaveBeenCalled();
expect(getMethodB).not.toHaveBeenCalled();
});
});
describe('Leftmenu as card', () => {
beforeAll(() => {
vm = mount('card').vm;
});
it('should get routes for card source', async () => {
vm.getRoutes();
});
});
describe('Leftmenu as main', () => {
beforeEach(() => {
vm = mount().vm;
});
it('should initialize with default props', () => {
expect(vm.source).toBe('main');
});
it('should filter items based on search input', async () => {
vm.search = 'cust';
await vm.$nextTick();
expect(vm.filteredItems[0].name).toEqual('customer');
expect(vm.filteredItems[0].module).toEqual('customer');
});
it('should filter items based on search input', async () => {
vm.search = 'Rou';
await vm.$nextTick();
expect(vm.filteredItems).toEqual([]);
});
it('should return pinned items', () => {
vm.items = [
{ name: 'Item 1', isPinned: false },
{ name: 'Item 2', isPinned: true },
]; ];
const firstMenuItem = vm.items[0]; expect(vm.pinnedModules).toEqual(
expect(firstMenuItem.children).toEqual(expect.arrayContaining(expectedMenuItem)); new Map([['Item 2', { name: 'Item 2', isPinned: true }]]),
);
});
it('should find matches in routes', () => {
const search = 'child1';
const item = {
children: [
{ name: 'child1', children: [] },
{ name: 'child2', children: [] },
],
};
const matches = vm.findMatches(search, item);
expect(matches).toEqual([{ name: 'child1', children: [] }]);
});
it('should not proceed if event is already prevented', async () => {
const item = { module: 'testModule', isPinned: false };
const event = {
preventDefault: vi.fn(),
stopPropagation: vi.fn(),
defaultPrevented: true,
};
await vm.togglePinned(item, event);
expect(event.preventDefault).not.toHaveBeenCalled();
expect(event.stopPropagation).not.toHaveBeenCalled();
});
it('should call quasar.notify with success message', async () => {
const item = { module: 'testModule', isPinned: false };
const event = {
preventDefault: vi.fn(),
stopPropagation: vi.fn(),
defaultPrevented: false,
};
const response = { data: { id: 1 } };
vi.spyOn(axios, 'post').mockResolvedValue(response);
vi.spyOn(vm.quasar, 'notify');
await vm.togglePinned(item, event);
expect(vm.quasar.notify).toHaveBeenCalledWith({
message: 'Data saved',
type: 'positive',
});
});
it('should handle a single matched route with a menu', () => {
const route = {
matched: [{ meta: { menu: 'customer' } }],
};
const result = vm.betaGetRoutes();
expect(result.meta.menu).toEqual(route.matched[0].meta.menu);
});
it('should get routes for main source', () => {
vm.props.source = 'main';
vm.getRoutes();
expect(navigation.getModules).toHaveBeenCalled();
});
it('should find direct child matches', () => {
const search = 'child1';
const item = {
children: [{ name: 'child1' }, { name: 'child2' }],
};
const result = vm.findMatches(search, item);
expect(result).toEqual([{ name: 'child1' }]);
});
it('should find nested child matches', () => {
const search = 'child3';
const item = {
children: [
{ name: 'child1' },
{
name: 'child2',
children: [{ name: 'child3' }],
},
],
};
const result = vm.findMatches(search, item);
expect(result).toEqual([{ name: 'child3' }]);
});
});
describe('normalize', () => {
beforeAll(() => {
vm = mount('card').vm;
});
it('should normalize and lowercase text', () => {
const input = 'ÁÉÍÓÚáéíóú';
const expected = 'aeiouaeiou';
expect(vm.normalize(input)).toBe(expected);
});
it('should handle empty string', () => {
const input = '';
const expected = '';
expect(vm.normalize(input)).toBe(expected);
});
it('should handle text without diacritics', () => {
const input = 'hello';
const expected = 'hello';
expect(vm.normalize(input)).toBe(expected);
});
it('should handle mixed text', () => {
const input = 'Héllo Wórld!';
const expected = 'hello world!';
expect(vm.normalize(input)).toBe(expected);
});
});
describe('addChildren', () => {
const module = 'testModule';
beforeEach(() => {
vm = mount().vm;
vi.clearAllMocks();
});
it('should add menu items to parent if matches are found', () => {
const parent = 'testParent';
const route = {
meta: {
menu: 'testMenu',
},
children: [{ name: 'child1' }, { name: 'child2' }],
};
vm.addChildren(module, route, parent);
expect(navigation.addMenuItem).toHaveBeenCalled();
});
it('should handle routes with no meta menu', () => {
const route = {
meta: {},
menus: {},
};
const parent = [];
vm.addChildren(module, route, parent);
expect(navigation.addMenuItem).toHaveBeenCalled();
});
it('should handle empty parent array', () => {
const parent = [];
const route = {
meta: {
menu: 'child11',
},
children: [
{
name: 'child1',
meta: {
menuChildren: [
{
name: 'CustomerCreditContracts',
title: 'creditContracts',
icon: 'vn:solunion',
},
],
},
},
],
};
vm.addChildren(module, route, parent);
expect(navigation.addMenuItem).toHaveBeenCalled();
}); });
}); });

View File

@ -106,7 +106,14 @@ function checkIsMain() {
:data-key="dataKey" :data-key="dataKey"
:array-data="arrayData" :array-data="arrayData"
:columns="columns" :columns="columns"
>
<template #moreFilterPanel="{ params, orders, searchFn }">
<slot
name="moreFilterPanel"
v-bind="{ params, orders, searchFn }"
/> />
</template>
</VnTableFilter>
</slot> </slot>
</template> </template>
</RightAdvancedMenu> </RightAdvancedMenu>

View File

@ -171,7 +171,8 @@ onMounted(() => {
}); });
const arrayDataKey = const arrayDataKey =
$props.dataKey ?? ($props.url?.length > 0 ? $props.url : $attrs.name ?? $attrs.label); $props.dataKey ??
($props.url?.length > 0 ? $props.url : ($attrs.name ?? $attrs.label));
const arrayData = useArrayData(arrayDataKey, { const arrayData = useArrayData(arrayDataKey, {
url: $props.url, url: $props.url,
@ -220,7 +221,7 @@ async function fetchFilter(val) {
optionFilterValue.value ?? optionFilterValue.value ??
(new RegExp(/\d/g).test(val) (new RegExp(/\d/g).test(val)
? optionValue.value ? optionValue.value
: optionFilter.value ?? optionLabel.value); : (optionFilter.value ?? optionLabel.value));
let defaultWhere = {}; let defaultWhere = {};
if ($props.filterOptions.length) { if ($props.filterOptions.length) {
@ -239,7 +240,7 @@ async function fetchFilter(val) {
const { data } = await arrayData.applyFilter( const { data } = await arrayData.applyFilter(
{ filter: filterOptions }, { filter: filterOptions },
{ updateRouter: false } { updateRouter: false },
); );
setOptions(data); setOptions(data);
return data; return data;
@ -272,7 +273,7 @@ async function filterHandler(val, update) {
ref.setOptionIndex(-1); ref.setOptionIndex(-1);
ref.moveOptionSelection(1, true); ref.moveOptionSelection(1, true);
} }
} },
); );
} }
@ -308,7 +309,7 @@ function handleKeyDown(event) {
if (inputValue) { if (inputValue) {
const matchingOption = myOptions.value.find( const matchingOption = myOptions.value.find(
(option) => (option) =>
option[optionLabel.value].toLowerCase() === inputValue.toLowerCase() option[optionLabel.value].toLowerCase() === inputValue.toLowerCase(),
); );
if (matchingOption) { if (matchingOption) {
@ -320,11 +321,11 @@ function handleKeyDown(event) {
} }
const focusableElements = document.querySelectorAll( const focusableElements = document.querySelectorAll(
'a:not([disabled]), button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), details:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled])' 'a:not([disabled]), button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), details:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled])',
); );
const currentIndex = Array.prototype.indexOf.call( const currentIndex = Array.prototype.indexOf.call(
focusableElements, focusableElements,
event.target event.target,
); );
if (currentIndex >= 0 && currentIndex < focusableElements.length - 1) { if (currentIndex >= 0 && currentIndex < focusableElements.length - 1) {
focusableElements[currentIndex + 1].focus(); focusableElements[currentIndex + 1].focus();

View File

@ -1,9 +1,7 @@
<script setup> <script setup>
import { computed } from 'vue';
import VnSelect from 'components/common/VnSelect.vue'; import VnSelect from 'components/common/VnSelect.vue';
const model = defineModel({ type: [String, Number, Object] }); const model = defineModel({ type: [String, Number, Object] });
const url = 'Suppliers';
</script> </script>
<template> <template>
@ -11,10 +9,11 @@ const url = 'Suppliers';
:label="$t('globals.supplier')" :label="$t('globals.supplier')"
v-bind="$attrs" v-bind="$attrs"
v-model="model" v-model="model"
:url="url" url="Suppliers"
option-value="id" option-value="id"
option-label="nickname" option-label="nickname"
:fields="['id', 'name', 'nickname', 'nif']" :fields="['id', 'name', 'nickname', 'nif']"
:filter-options="['id', 'name', 'nickname', 'nif']"
sort-by="name ASC" sort-by="name ASC"
> >
<template #option="scope"> <template #option="scope">

View File

@ -635,6 +635,8 @@ wagon:
name: Name name: Name
supplier: supplier:
search: Search supplier
searchInfo: Search supplier by id or name
list: list:
payMethod: Pay method payMethod: Pay method
account: Account account: Account

View File

@ -352,7 +352,7 @@ globals:
from: Desde from: Desde
to: Hasta to: Hasta
supplierFk: Proveedor supplierFk: Proveedor
supplierRef: Ref. proveedor supplierRef: Nº factura
serial: Serie serial: Serie
amount: Importe amount: Importe
awbCode: AWB awbCode: AWB
@ -644,6 +644,8 @@ wagon:
volume: Volumen volume: Volumen
name: Nombre name: Nombre
supplier: supplier:
search: Buscar proveedor
searchInfo: Buscar proveedor por id o nombre
list: list:
payMethod: Método de pago payMethod: Método de pago
account: Cuenta account: Cuenta
@ -651,6 +653,7 @@ supplier:
tableVisibleColumns: tableVisibleColumns:
nif: NIF/CIF nif: NIF/CIF
account: Cuenta account: Cuenta
summary: summary:
responsible: Responsable responsible: Responsable
verified: Verificado verified: Verificado

View File

@ -1,12 +1,12 @@
<script setup> <script setup>
import { Dark, Quasar } from 'quasar'; import { Dark, Quasar } from 'quasar';
import { computed } from 'vue'; import { computed, onMounted } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { localeEquivalence } from 'src/i18n/index'; import { localeEquivalence } from 'src/i18n/index';
import quasarLang from 'src/utils/quasarLang'; import quasarLang from 'src/utils/quasarLang';
import { langs } from 'src/boot/defaults/constants.js';
const { t, locale } = useI18n(); const { t, locale } = useI18n();
const userLocale = computed({ const userLocale = computed({
get() { get() {
return locale.value; return locale.value;
@ -28,7 +28,6 @@ const darkMode = computed({
Dark.set(value); Dark.set(value);
}, },
}); });
const langs = ['en', 'es'];
</script> </script>
<template> <template>

View File

@ -119,7 +119,7 @@ const openSendEmailDialog = async () => {
openConfirmationModal( openConfirmationModal(
t('The consumption report will be sent'), t('The consumption report will be sent'),
t('Please, confirm'), t('Please, confirm'),
() => sendCampaignMetricsEmail({ address: arrayData.store.data.email }) () => sendCampaignMetricsEmail({ address: arrayData.store.data.email }),
); );
}; };
const sendCampaignMetricsEmail = ({ address }) => { const sendCampaignMetricsEmail = ({ address }) => {

View File

@ -125,7 +125,7 @@ function deleteFile(dmsFk) {
<VnInput <VnInput
clearable clearable
clear-icon="close" clear-icon="close"
:label="t('Supplier ref')" :label="t('invoiceIn.supplierRef')"
v-model="data.supplierRef" v-model="data.supplierRef"
/> />
</VnRow> </VnRow>
@ -310,7 +310,6 @@ function deleteFile(dmsFk) {
supplierFk: Supplier supplierFk: Supplier
es: es:
supplierFk: Proveedor supplierFk: Proveedor
Supplier ref: Ref. proveedor
Expedition date: Fecha expedición Expedition date: Fecha expedición
Operation date: Fecha operación Operation date: Fecha operación
Undeductible VAT: Iva no deducible Undeductible VAT: Iva no deducible

View File

@ -186,7 +186,7 @@ const createInvoiceInCorrection = async () => {
clickable clickable
@click="book(entityId)" @click="book(entityId)"
> >
<QItemSection>{{ t('invoiceIn.descriptorMenu.toBook') }}</QItemSection> <QItemSection>{{ t('invoiceIn.descriptorMenu.book') }}</QItemSection>
</QItem> </QItem>
</template> </template>
</InvoiceInToBook> </InvoiceInToBook>
@ -197,7 +197,7 @@ const createInvoiceInCorrection = async () => {
@click="triggerMenu('unbook')" @click="triggerMenu('unbook')"
> >
<QItemSection> <QItemSection>
{{ t('invoiceIn.descriptorMenu.toUnbook') }} {{ t('invoiceIn.descriptorMenu.unbook') }}
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem <QItem

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref, computed } from 'vue'; import { ref, computed, onBeforeMount } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import axios from 'axios'; import axios from 'axios';
@ -12,6 +12,7 @@ import VnSelect from 'src/components/common/VnSelect.vue';
import useNotify from 'src/composables/useNotify.js'; import useNotify from 'src/composables/useNotify.js';
import VnInputDate from 'src/components/common/VnInputDate.vue'; import VnInputDate from 'src/components/common/VnInputDate.vue';
import VnInputNumber from 'src/components/common/VnInputNumber.vue'; import VnInputNumber from 'src/components/common/VnInputNumber.vue';
import { toCurrency } from 'filters/index';
const route = useRoute(); const route = useRoute();
const { notify } = useNotify(); const { notify } = useNotify();
@ -26,7 +27,7 @@ const invoiceInFormRef = ref();
const invoiceId = +route.params.id; const invoiceId = +route.params.id;
const filter = { where: { invoiceInFk: invoiceId } }; const filter = { where: { invoiceInFk: invoiceId } };
const areRows = ref(false); const areRows = ref(false);
const totals = ref();
const columns = computed(() => [ const columns = computed(() => [
{ {
name: 'duedate', name: 'duedate',
@ -66,6 +67,8 @@ const columns = computed(() => [
}, },
]); ]);
const totalAmount = computed(() => getTotal(invoiceInFormRef.value.formData, 'amount'));
const isNotEuro = (code) => code != 'EUR'; const isNotEuro = (code) => code != 'EUR';
async function insert() { async function insert() {
@ -73,6 +76,10 @@ async function insert() {
await invoiceInFormRef.value.reload(); await invoiceInFormRef.value.reload();
notify(t('globals.dataSaved'), 'positive'); notify(t('globals.dataSaved'), 'positive');
} }
onBeforeMount(async () => {
totals.value = (await axios.get(`InvoiceIns/${invoiceId}/getTotals`)).data;
});
</script> </script>
<template> <template>
<FetchData <FetchData
@ -153,7 +160,7 @@ async function insert() {
<QTd /> <QTd />
<QTd /> <QTd />
<QTd> <QTd>
{{ getTotal(rows, 'amount', { currency: 'default' }) }} {{ toCurrency(totalAmount) }}
</QTd> </QTd>
<QTd> <QTd>
<template v-if="isNotEuro(invoiceIn.currency.code)"> <template v-if="isNotEuro(invoiceIn.currency.code)">
@ -235,7 +242,16 @@ async function insert() {
v-shortcut="'+'" v-shortcut="'+'"
size="lg" size="lg"
round round
@click="!areRows ? insert() : invoiceInFormRef.insert()" @click="
() => {
if (!areRows) insert();
else
invoiceInFormRef.insert({
amount: (totals.totalTaxableBase - totalAmount).toFixed(2),
invoiceInFk: invoiceId,
});
}
"
/> />
</QPageSticky> </QPageSticky>
</template> </template>

View File

@ -193,7 +193,7 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`;
<InvoiceIntoBook> <InvoiceIntoBook>
<template #content="{ book }"> <template #content="{ book }">
<QBtn <QBtn
:label="t('To book')" :label="t('Book')"
color="orange-11" color="orange-11"
text-color="black" text-color="black"
@click="book(entityId)" @click="book(entityId)"
@ -224,10 +224,7 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`;
</span> </span>
</template> </template>
</VnLv> </VnLv>
<VnLv <VnLv :label="t('invoiceIn.supplierRef')" :value="entity.supplierRef" />
:label="t('invoiceIn.list.supplierRef')"
:value="entity.supplierRef"
/>
<VnLv <VnLv
:label="t('invoiceIn.summary.currency')" :label="t('invoiceIn.summary.currency')"
:value="entity.currency?.code" :value="entity.currency?.code"
@ -357,7 +354,7 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`;
entity.totals.totalTaxableBaseForeignValue && entity.totals.totalTaxableBaseForeignValue &&
toCurrency( toCurrency(
entity.totals.totalTaxableBaseForeignValue, entity.totals.totalTaxableBaseForeignValue,
currency currency,
) )
}}</QTd> }}</QTd>
</QTr> </QTr>
@ -392,7 +389,7 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`;
entity.totals.totalDueDayForeignValue && entity.totals.totalDueDayForeignValue &&
toCurrency( toCurrency(
entity.totals.totalDueDayForeignValue, entity.totals.totalDueDayForeignValue,
currency currency,
) )
}} }}
</QTd> </QTd>
@ -472,5 +469,5 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`;
Search invoice: Buscar factura recibida Search invoice: Buscar factura recibida
You can search by invoice reference: Puedes buscar por referencia de la factura You can search by invoice reference: Puedes buscar por referencia de la factura
Totals: Totales Totals: Totales
To book: Contabilizar Book: Contabilizar
</i18n> </i18n>

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref, computed } from 'vue'; import { ref, computed, nextTick } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useArrayData } from 'src/composables/useArrayData'; import { useArrayData } from 'src/composables/useArrayData';
@ -25,7 +25,6 @@ const sageTaxTypes = ref([]);
const sageTransactionTypes = ref([]); const sageTransactionTypes = ref([]);
const rowsSelected = ref([]); const rowsSelected = ref([]);
const invoiceInFormRef = ref(); const invoiceInFormRef = ref();
const expenseRef = ref();
defineProps({ defineProps({
actionIcon: { actionIcon: {
@ -97,6 +96,20 @@ const columns = computed(() => [
}, },
]); ]);
const taxableBaseTotal = computed(() => {
return getTotal(invoiceInFormRef.value.formData, 'taxableBase');
});
const taxRateTotal = computed(() => {
return getTotal(invoiceInFormRef.value.formData, null, {
cb: taxRate,
});
});
const combinedTotal = computed(() => {
return +taxableBaseTotal.value + +taxRateTotal.value;
});
const filter = { const filter = {
fields: [ fields: [
'id', 'id',
@ -125,7 +138,7 @@ function taxRate(invoiceInTax) {
return ((taxTypeSage / 100) * taxableBase).toFixed(2); return ((taxTypeSage / 100) * taxableBase).toFixed(2);
} }
function autocompleteExpense(evt, row, col) { function autocompleteExpense(evt, row, col, ref) {
const val = evt.target.value; const val = evt.target.value;
if (!val) return; if (!val) return;
@ -134,22 +147,17 @@ function autocompleteExpense(evt, row, col) {
({ id }) => id == useAccountShortToStandard(param), ({ id }) => id == useAccountShortToStandard(param),
); );
expenseRef.value.vnSelectDialogRef.vnSelectRef.toggleOption(lookup); ref.vnSelectDialogRef.vnSelectRef.toggleOption(lookup);
} }
const taxableBaseTotal = computed(() => { function setCursor(ref) {
return getTotal(invoiceInFormRef.value.formData, 'taxableBase'); nextTick(() => {
}); const select = ref.vnSelectDialogRef
? ref.vnSelectDialogRef.vnSelectRef
const taxRateTotal = computed(() => { : ref.vnSelectRef;
return getTotal(invoiceInFormRef.value.formData, null, { select.$el.querySelector('input').setSelectionRange(0, 0);
cb: taxRate,
});
});
const combinedTotal = computed(() => {
return +taxableBaseTotal.value + +taxRateTotal.value;
}); });
}
</script> </script>
<template> <template>
<FetchData <FetchData
@ -187,14 +195,24 @@ const combinedTotal = computed(() => {
<template #body-cell-expense="{ row, col }"> <template #body-cell-expense="{ row, col }">
<QTd> <QTd>
<VnSelectDialog <VnSelectDialog
ref="expenseRef" :ref="`expenseRef-${row.$index}`"
v-model="row[col.model]" v-model="row[col.model]"
:options="col.options" :options="col.options"
:option-value="col.optionValue" :option-value="col.optionValue"
:option-label="col.optionLabel" :option-label="col.optionLabel"
:filter-options="['id', 'name']" :filter-options="['id', 'name']"
:tooltip="t('Create a new expense')" :tooltip="t('Create a new expense')"
@keydown.tab="autocompleteExpense($event, row, col)" @keydown.tab="
autocompleteExpense(
$event,
row,
col,
$refs[`expenseRef-${row.$index}`],
)
"
@update:model-value="
setCursor($refs[`expenseRef-${row.$index}`])
"
> >
<template #option="scope"> <template #option="scope">
<QItem v-bind="scope.itemProps"> <QItem v-bind="scope.itemProps">
@ -210,7 +228,7 @@ const combinedTotal = computed(() => {
</QTd> </QTd>
</template> </template>
<template #body-cell-taxablebase="{ row }"> <template #body-cell-taxablebase="{ row }">
<QTd> <QTd shrink>
<VnInputNumber <VnInputNumber
clear-icon="close" clear-icon="close"
v-model="row.taxableBase" v-model="row.taxableBase"
@ -221,12 +239,16 @@ const combinedTotal = computed(() => {
<template #body-cell-sageiva="{ row, col }"> <template #body-cell-sageiva="{ row, col }">
<QTd> <QTd>
<VnSelect <VnSelect
:ref="`sageivaRef-${row.$index}`"
v-model="row[col.model]" v-model="row[col.model]"
:options="col.options" :options="col.options"
:option-value="col.optionValue" :option-value="col.optionValue"
:option-label="col.optionLabel" :option-label="col.optionLabel"
:filter-options="['id', 'vat']" :filter-options="['id', 'vat']"
data-cy="vat-sageiva" data-cy="vat-sageiva"
@update:model-value="
setCursor($refs[`sageivaRef-${row.$index}`])
"
> >
<template #option="scope"> <template #option="scope">
<QItem v-bind="scope.itemProps"> <QItem v-bind="scope.itemProps">
@ -244,11 +266,15 @@ const combinedTotal = computed(() => {
<template #body-cell-sagetransaction="{ row, col }"> <template #body-cell-sagetransaction="{ row, col }">
<QTd> <QTd>
<VnSelect <VnSelect
:ref="`sagetransactionRef-${row.$index}`"
v-model="row[col.model]" v-model="row[col.model]"
:options="col.options" :options="col.options"
:option-value="col.optionValue" :option-value="col.optionValue"
:option-label="col.optionLabel" :option-label="col.optionLabel"
:filter-options="['id', 'transaction']" :filter-options="['id', 'transaction']"
@update:model-value="
setCursor($refs[`sagetransactionRef-${row.$index}`])
"
> >
<template #option="scope"> <template #option="scope">
<QItem v-bind="scope.itemProps"> <QItem v-bind="scope.itemProps">
@ -266,7 +292,7 @@ const combinedTotal = computed(() => {
</QTd> </QTd>
</template> </template>
<template #body-cell-foreignvalue="{ row }"> <template #body-cell-foreignvalue="{ row }">
<QTd> <QTd shrink>
<VnInputNumber <VnInputNumber
:class="{ :class="{
'no-pointer-events': !isNotEuro(currency), 'no-pointer-events': !isNotEuro(currency),

View File

@ -56,7 +56,7 @@ const cols = computed(() => [
{ {
align: 'left', align: 'left',
name: 'supplierRef', name: 'supplierRef',
label: t('invoiceIn.list.supplierRef'), label: t('invoiceIn.supplierRef'),
}, },
{ {
align: 'left', align: 'left',
@ -177,7 +177,7 @@ const cols = computed(() => [
:required="true" :required="true"
/> />
<VnInput <VnInput
:label="t('invoiceIn.list.supplierRef')" :label="t('invoiceIn.supplierRef')"
v-model="data.supplierRef" v-model="data.supplierRef"
/> />
<VnSelect <VnSelect

View File

@ -4,6 +4,7 @@ import { useQuasar } from 'quasar';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import VnConfirm from 'src/components/ui/VnConfirm.vue'; import VnConfirm from 'src/components/ui/VnConfirm.vue';
import { useArrayData } from 'src/composables/useArrayData'; import { useArrayData } from 'src/composables/useArrayData';
import qs from 'qs';
const { notify, dialog } = useQuasar(); const { notify, dialog } = useQuasar();
const { t } = useI18n(); const { t } = useI18n();
@ -12,29 +13,51 @@ defineExpose({ checkToBook });
const { store } = useArrayData(); const { store } = useArrayData();
async function checkToBook(id) { async function checkToBook(id) {
let directBooking = true; let messages = [];
const hasProblemWithTax = (
await axios.get('InvoiceInTaxes/count', {
params: {
where: JSON.stringify({
invoiceInFk: id,
or: [{ taxTypeSageFk: null }, { transactionTypeSageFk: null }],
}),
},
})
).data?.count;
if (hasProblemWithTax)
messages.push(t('The VAT and Transaction fields have not been informed'));
const { data: totals } = await axios.get(`InvoiceIns/${id}/getTotals`); const { data: totals } = await axios.get(`InvoiceIns/${id}/getTotals`);
const taxableBaseNotEqualDueDay = totals.totalDueDay != totals.totalTaxableBase; const taxableBaseNotEqualDueDay = totals.totalDueDay != totals.totalTaxableBase;
const vatNotEqualDueDay = totals.totalDueDay != totals.totalVat; const vatNotEqualDueDay = totals.totalDueDay != totals.totalVat;
if (taxableBaseNotEqualDueDay && vatNotEqualDueDay) directBooking = false; if (taxableBaseNotEqualDueDay && vatNotEqualDueDay)
messages.push(t('The sum of the taxable bases does not match the due dates'));
const { data: dueDaysCount } = await axios.get('InvoiceInDueDays/count', { const dueDaysCount = (
where: { await axios.get('InvoiceInDueDays/count', {
params: {
where: JSON.stringify({
invoiceInFk: id, invoiceInFk: id,
dueDated: { gte: Date.vnNew() }, dueDated: { gte: Date.vnNew() },
}),
}, },
}); })
).data?.count;
if (dueDaysCount) directBooking = false; if (dueDaysCount) messages.push(t('Some due dates are less than or equal to today'));
if (directBooking) return toBook(id);
if (!messages.length) toBook(id);
else
dialog({ dialog({
component: VnConfirm, component: VnConfirm,
componentProps: { title: t('Are you sure you want to book this invoice?') }, componentProps: {
}).onOk(async () => await toBook(id)); title: t('Are you sure you want to book this invoice?'),
message: messages.reduce((acc, msg) => `${acc}<p>${msg}</p>`, ''),
},
}).onOk(() => toBook(id));
} }
async function toBook(id) { async function toBook(id) {
@ -59,4 +82,7 @@ async function toBook(id) {
es: es:
Are you sure you want to book this invoice?: ¿Estás seguro de querer asentar esta factura? Are you sure you want to book this invoice?: ¿Estás seguro de querer asentar esta factura?
It was not able to book the invoice: No se pudo contabilizar la factura It was not able to book the invoice: No se pudo contabilizar la factura
Some due dates are less than or equal to today: Algún vencimiento tiene una fecha menor o igual que hoy
The sum of the taxable bases does not match the due dates: La suma de las bases imponibles no coincide con la de los vencimientos
The VAT and Transaction fields have not been informed: No se han informado los campos de iva y/o transacción
</i18n> </i18n>

View File

@ -3,10 +3,10 @@ invoiceIn:
searchInfo: Search incoming invoices by ID or supplier fiscal name searchInfo: Search incoming invoices by ID or supplier fiscal name
serial: Serial serial: Serial
isBooked: Is booked isBooked: Is booked
supplierRef: Invoice nº
list: list:
ref: Reference ref: Reference
supplier: Supplier supplier: Supplier
supplierRef: Supplier ref.
file: File file: File
issued: Issued issued: Issued
dueDated: Due dated dueDated: Due dated
@ -19,8 +19,6 @@ invoiceIn:
unbook: Unbook unbook: Unbook
delete: Delete delete: Delete
clone: Clone clone: Clone
toBook: To book
toUnbook: To unbook
deleteInvoice: Delete invoice deleteInvoice: Delete invoice
invoiceDeleted: invoice deleted invoiceDeleted: invoice deleted
cloneInvoice: Clone invoice cloneInvoice: Clone invoice
@ -70,4 +68,3 @@ invoiceIn:
isBooked: Is booked isBooked: Is booked
account: Ledger account account: Ledger account
correctingFk: Rectificative correctingFk: Rectificative

View File

@ -3,10 +3,10 @@ invoiceIn:
searchInfo: Buscar facturas recibidas por ID o nombre fiscal del proveedor searchInfo: Buscar facturas recibidas por ID o nombre fiscal del proveedor
serial: Serie serial: Serie
isBooked: Contabilizada isBooked: Contabilizada
supplierRef: Nº factura
list: list:
ref: Referencia ref: Referencia
supplier: Proveedor supplier: Proveedor
supplierRef: Ref. proveedor
issued: F. emisión issued: F. emisión
dueDated: F. vencimiento dueDated: F. vencimiento
file: Fichero file: Fichero
@ -15,12 +15,10 @@ invoiceIn:
descriptor: descriptor:
ticketList: Listado de tickets ticketList: Listado de tickets
descriptorMenu: descriptorMenu:
book: Asentar book: Contabilizar
unbook: Desasentar unbook: Descontabilizar
delete: Eliminar delete: Eliminar
clone: Clonar clone: Clonar
toBook: Contabilizar
toUnbook: Descontabilizar
deleteInvoice: Eliminar factura deleteInvoice: Eliminar factura
invoiceDeleted: Factura eliminada invoiceDeleted: Factura eliminada
cloneInvoice: Clonar factura cloneInvoice: Clonar factura
@ -68,4 +66,3 @@ invoiceIn:
isBooked: Contabilizada isBooked: Contabilizada
account: Cuenta contable account: Cuenta contable
correctingFk: Rectificativa correctingFk: Rectificativa

View File

@ -65,10 +65,19 @@ const columns = computed(() => [
name: 'name', name: 'name',
...defaultColumnAttrs, ...defaultColumnAttrs,
create: true, create: true,
columnFilter: {
component: 'select',
attrs: {
url: 'Items',
fields: ['id', 'name', 'subName'],
optionLabel: 'name',
optionValue: 'name',
uppercase: false,
},
},
}, },
{ {
label: t('item.fixedPrice.groupingPrice'), label: t('item.fixedPrice.groupingPrice'),
field: 'rate2',
name: 'rate2', name: 'rate2',
...defaultColumnAttrs, ...defaultColumnAttrs,
component: 'input', component: 'input',
@ -76,7 +85,6 @@ const columns = computed(() => [
}, },
{ {
label: t('item.fixedPrice.packingPrice'), label: t('item.fixedPrice.packingPrice'),
field: 'rate3',
name: 'rate3', name: 'rate3',
...defaultColumnAttrs, ...defaultColumnAttrs,
component: 'input', component: 'input',
@ -85,7 +93,6 @@ const columns = computed(() => [
{ {
label: t('item.fixedPrice.minPrice'), label: t('item.fixedPrice.minPrice'),
field: 'minPrice',
name: 'minPrice', name: 'minPrice',
...defaultColumnAttrs, ...defaultColumnAttrs,
component: 'input', component: 'input',
@ -108,7 +115,6 @@ const columns = computed(() => [
}, },
{ {
label: t('item.fixedPrice.ended'), label: t('item.fixedPrice.ended'),
field: 'ended',
name: 'ended', name: 'ended',
...defaultColumnAttrs, ...defaultColumnAttrs,
columnField: { columnField: {
@ -124,7 +130,6 @@ const columns = computed(() => [
{ {
label: t('globals.warehouse'), label: t('globals.warehouse'),
field: 'warehouseFk',
name: 'warehouseFk', name: 'warehouseFk',
...defaultColumnAttrs, ...defaultColumnAttrs,
columnClass: 'shrink', columnClass: 'shrink',
@ -415,7 +420,6 @@ function handleOnDataSave({ CrudModelRef }) {
'row-key': 'id', 'row-key': 'id',
selection: 'multiple', selection: 'multiple',
}" }"
:use-model="true"
v-model:selected="rowsSelected" v-model:selected="rowsSelected"
:create-as-dialog="false" :create-as-dialog="false"
:create="{ :create="{

View File

@ -6,7 +6,7 @@ import VehicleFilter from '../VehicleFilter.js';
<template> <template>
<VnCardBeta <VnCardBeta
data-key="Vehicle" data-key="Vehicle"
base-url="Vehicles" url="Vehicles"
:filter="VehicleFilter" :filter="VehicleFilter"
:descriptor="VehicleDescriptor" :descriptor="VehicleDescriptor"
/> />

View File

@ -136,7 +136,7 @@ const columns = computed(() => [
/> />
<FetchData <FetchData
url="Countries" url="Countries"
:filter="{ fields: ['code'] }" :filter="{ fields: ['name', 'code'] }"
@on-fetch="(data) => (countries = data)" @on-fetch="(data) => (countries = data)"
auto-load auto-load
/> />
@ -209,7 +209,7 @@ const columns = computed(() => [
v-model="data.countryCodeFk" v-model="data.countryCodeFk"
:label="$t('globals.country')" :label="$t('globals.country')"
option-value="code" option-value="code"
option-label="code" option-label="name"
:options="countries" :options="countries"
/> />
<VnInput <VnInput

View File

@ -1,19 +1,13 @@
<script setup> <script setup>
import VnCard from 'components/common/VnCard.vue';
import SupplierDescriptor from './SupplierDescriptor.vue'; import SupplierDescriptor from './SupplierDescriptor.vue';
import VnCardBeta from 'src/components/common/VnCardBeta.vue';
import filter from './SupplierFilter.js'; import filter from './SupplierFilter.js';
</script> </script>
<template> <template>
<VnCard <VnCardBeta
data-key="Supplier" data-key="Supplier"
url="Suppliers" url="Suppliers"
:filter="filter"
:descriptor="SupplierDescriptor" :descriptor="SupplierDescriptor"
search-data-key="SupplierList" :filter="filter"
:searchbar-props="{
url: 'Suppliers/filter',
searchUrl: 'table',
label: 'Search suppliers',
}"
/> />
</template> </template>

View File

@ -16,6 +16,7 @@ import axios from 'axios';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
import { useArrayData } from 'composables/useArrayData'; import { useArrayData } from 'composables/useArrayData';
import RightMenu from 'src/components/common/RightMenu.vue';
const state = useState(); const state = useState();
const stateStore = useStateStore(); const stateStore = useStateStore();
@ -173,10 +174,11 @@ onMounted(async () => {
</div> </div>
</div> </div>
</Teleport> </Teleport>
<QPage class="column items-center q-pa-md"> <RightMenu>
<Teleport to="#right-panel" v-if="stateStore.isHeaderMounted()"> <template #right-panel>
<SupplierConsumptionFilter data-key="SupplierConsumption" /> <SupplierConsumptionFilter data-key="SupplierConsumption" />
</Teleport> </template>
</RightMenu>
<QTable <QTable
:rows="rows" :rows="rows"
row-key="id" row-key="id"
@ -225,7 +227,6 @@ onMounted(async () => {
</QTr> </QTr>
</template> </template>
</QTable> </QTable>
</QPage>
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@ -2,14 +2,15 @@
import { computed, ref } from 'vue'; import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import VnTable from 'components/VnTable/VnTable.vue'; import VnTable from 'components/VnTable/VnTable.vue';
import VnSearchbar from 'components/ui/VnSearchbar.vue'; import VnSection from 'src/components/common/VnSection.vue';
import RightMenu from 'src/components/common/RightMenu.vue';
import SupplierListFilter from './SupplierListFilter.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import FetchData from 'src/components/FetchData.vue';
const { t } = useI18n(); const { t } = useI18n();
const tableRef = ref(); const tableRef = ref();
const dataKey = 'SupplierList';
const provincesOptions = ref([]);
const columns = computed(() => [ const columns = computed(() => [
{ {
align: 'left', align: 'left',
@ -104,19 +105,26 @@ const columns = computed(() => [
}, },
]); ]);
</script> </script>
<template> <template>
<VnSearchbar data-key="SuppliersList" :limit="20" :label="t('Search suppliers')" /> <FetchData
<RightMenu> url="Provinces"
<template #right-panel> :filter="{ fields: ['id', 'name'], order: 'name ASC' }"
<SupplierListFilter data-key="SuppliersList" /> @on-fetch="(data) => (provincesOptions = data)"
</template> auto-load
</RightMenu> />
<VnSection
:data-key="dataKey"
:columns="columns"
prefix="supplier"
:array-data-props="{
url: 'Suppliers/filter',
order: 'id ASC',
}"
>
<template #body>
<VnTable <VnTable
ref="tableRef" ref="tableRef"
data-key="SuppliersList" :data-key="dataKey"
url="Suppliers/filter"
redirect="supplier"
:create="{ :create="{
urlCreate: 'Suppliers/newSupplier', urlCreate: 'Suppliers/newSupplier',
title: t('Create Supplier'), title: t('Create Supplier'),
@ -124,19 +132,36 @@ const columns = computed(() => [
formInitialData: {}, formInitialData: {},
mapper: (data) => { mapper: (data) => {
data.name = data.socialName; data.name = data.socialName;
delete data.socialName;
return data; return data;
}, },
}" }"
:right-search="false"
order="id ASC"
:columns="columns" :columns="columns"
redirect="supplier"
:right-search="false"
> >
<template #more-create-dialog="{ data }"> <template #more-create-dialog="{ data }">
<VnInput :label="t('globals.name')" v-model="data.socialName" :uppercase="true" /> <VnInput
:label="t('globals.name')"
v-model="data.socialName"
:uppercase="true"
/>
</template> </template>
</VnTable> </VnTable>
</template> </template>
<template #moreFilterPanel="{ params, searchFn }">
<VnSelect
:label="t('globals.params.provinceFk')"
v-model="params.provinceFk"
@update:model-value="searchFn()"
:options="provincesOptions"
filled
dense
class="q-px-sm q-pr-lg"
/>
</template>
</VnSection>
</template>
<i18n> <i18n>
es: es:

View File

@ -1,122 +0,0 @@
<script setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import VnInput from 'src/components/common/VnInput.vue';
import FetchData from 'components/FetchData.vue';
const props = defineProps({
dataKey: {
type: String,
required: true,
},
});
const { t } = useI18n();
const provincesOptions = ref([]);
const countriesOptions = ref([]);
</script>
<template>
<FetchData
url="Provinces"
:filter="{ fields: ['id', 'name'], order: 'name ASC'}"
@on-fetch="(data) => (provincesOptions = data)"
auto-load
/>
<FetchData
url="countries"
:filter="{ fields: ['id', 'name'], order: 'name ASC'}"
@on-fetch="(data) => (countriesOptions = data)"
auto-load
/>
<VnFilterPanel
:data-key="props.dataKey"
:search-button="true"
:unremovable-params="['supplierFk']"
>
<template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs">
<strong>{{ t(`params.${tag.label}`) }}: </strong>
<span>{{ formatFn(tag.value) }}</span>
</div>
</template>
<template #body="{ params, searchFn }">
<QItem>
<QItemSection>
<VnInput
v-model="params.search"
:label="t('params.search')"
is-outlined
/>
</QItemSection>
</QItem>
<QItem>
<QItemSection>
<VnInput
v-model="params.nickname"
:label="t('params.nickname')"
is-outlined
/>
</QItemSection>
</QItem>
<QItem>
<QItemSection>
<VnInput v-model="params.nif" :label="t('params.nif')" is-outlined />
</QItemSection>
</QItem>
<QItem>
<QItemSection>
<VnSelect
:label="t('params.provinceFk')"
v-model="params.provinceFk"
@update:model-value="searchFn()"
:options="provincesOptions"
option-value="id"
option-label="name"
hide-selected
dense
outlined
rounded
/>
</QItemSection>
</QItem>
<QItem>
<QItemSection>
<VnSelect
:label="t('params.countryFk')"
v-model="params.countryFk"
@update:model-value="searchFn()"
:options="countriesOptions"
option-value="id"
option-label="name"
hide-selected
dense
outlined
rounded
/>
</QItemSection>
</QItem>
</template>
</VnFilterPanel>
</template>
<i18n>
en:
params:
search: General search
nickname: Alias
nif: Tax number
provinceFk: Province
countryFk: Country
es:
params:
search: Búsqueda general
nickname: Alias
nif: NIF/CIF
provinceFk: Provincia
countryFk: País
</i18n>

View File

@ -376,6 +376,30 @@ onMounted(async () => {
</template> </template>
<template #body-cell-problems="{ row }"> <template #body-cell-problems="{ row }">
<QTd class="q-gutter-x-xs"> <QTd class="q-gutter-x-xs">
<QIcon
v-if="row.futureAgencyFk !== row.agencyFk && row.agencyFk"
color="primary"
name="vn:agency-term"
size="xs"
class="q-mr-xs"
>
<QTooltip class="column">
<span>
{{
t('advanceTickets.originAgency', {
agency: row.futureAgency,
})
}}
</span>
<span>
{{
t('advanceTickets.destinationAgency', {
agency: row.agency,
})
}}
</span>
</QTooltip>
</QIcon>
<QIcon <QIcon
v-if="row.isTaxDataChecked === 0" v-if="row.isTaxDataChecked === 0"
color="primary" color="primary"

View File

@ -107,7 +107,10 @@ export default defineRouter(function (/* { store, ssrContext } */) {
'Failed to fetch dynamically imported module', 'Failed to fetch dynamically imported module',
'Importing a module script failed', 'Importing a module script failed',
]; ];
state.set('error', errorMessages.some(message.includes)); state.set(
'error',
errorMessages.some((error) => message.startsWith(error)),
);
}); });
return Router; return Router;
}); });

View File

@ -1,19 +1,12 @@
import { RouterView } from 'vue-router'; import { RouterView } from 'vue-router';
export default { const supplierCard = {
path: '/supplier', name: 'SupplierCard',
name: 'Supplier', path: ':id',
component: () => import('src/pages/Supplier/Card/SupplierCard.vue'),
redirect: { name: 'SupplierSummary' },
meta: { meta: {
title: 'suppliers', menu: [
icon: 'vn:supplier',
moduleName: 'Supplier',
keyBinding: 'p',
},
component: RouterView,
redirect: { name: 'SupplierMain' },
menus: {
main: ['SupplierList'],
card: [
'SupplierBasicData', 'SupplierBasicData',
'SupplierFiscalData', 'SupplierFiscalData',
'SupplierBillingData', 'SupplierBillingData',
@ -27,38 +20,6 @@ export default {
'SupplierDms', 'SupplierDms',
], ],
}, },
children: [
{
path: '',
name: 'SupplierMain',
component: () => import('src/components/common/VnModule.vue'),
redirect: { name: 'SupplierList' },
children: [
{
path: 'list',
name: 'SupplierList',
meta: {
title: 'list',
icon: 'view_list',
},
component: () => import('src/pages/Supplier/SupplierList.vue'),
},
{
path: 'create',
name: 'SupplierCreate',
meta: {
title: 'supplierCreate',
icon: 'add',
},
component: () => import('src/pages/Supplier/SupplierCreate.vue'),
},
],
},
{
name: 'SupplierCard',
path: ':id',
component: () => import('src/pages/Supplier/Card/SupplierCard.vue'),
redirect: { name: 'SupplierSummary' },
children: [ children: [
{ {
name: 'SupplierSummary', name: 'SupplierSummary',
@ -67,8 +28,7 @@ export default {
title: 'summary', title: 'summary',
icon: 'launch', icon: 'launch',
}, },
component: () => component: () => import('src/pages/Supplier/Card/SupplierSummary.vue'),
import('src/pages/Supplier/Card/SupplierSummary.vue'),
}, },
{ {
path: 'basic-data', path: 'basic-data',
@ -77,8 +37,7 @@ export default {
title: 'basicData', title: 'basicData',
icon: 'vn:settings', icon: 'vn:settings',
}, },
component: () => component: () => import('src/pages/Supplier/Card/SupplierBasicData.vue'),
import('src/pages/Supplier/Card/SupplierBasicData.vue'),
}, },
{ {
path: 'fiscal-data', path: 'fiscal-data',
@ -87,8 +46,7 @@ export default {
title: 'fiscalData', title: 'fiscalData',
icon: 'vn:dfiscales', icon: 'vn:dfiscales',
}, },
component: () => component: () => import('src/pages/Supplier/Card/SupplierFiscalData.vue'),
import('src/pages/Supplier/Card/SupplierFiscalData.vue'),
}, },
{ {
path: 'billing-data', path: 'billing-data',
@ -97,8 +55,7 @@ export default {
title: 'billingData', title: 'billingData',
icon: 'vn:payment', icon: 'vn:payment',
}, },
component: () => component: () => import('src/pages/Supplier/Card/SupplierBillingData.vue'),
import('src/pages/Supplier/Card/SupplierBillingData.vue'),
}, },
{ {
path: 'log', path: 'log',
@ -116,8 +73,7 @@ export default {
title: 'accounts', title: 'accounts',
icon: 'vn:credit', icon: 'vn:credit',
}, },
component: () => component: () => import('src/pages/Supplier/Card/SupplierAccounts.vue'),
import('src/pages/Supplier/Card/SupplierAccounts.vue'),
}, },
{ {
path: 'contact', path: 'contact',
@ -126,8 +82,7 @@ export default {
title: 'contacts', title: 'contacts',
icon: 'contact_phone', icon: 'contact_phone',
}, },
component: () => component: () => import('src/pages/Supplier/Card/SupplierContacts.vue'),
import('src/pages/Supplier/Card/SupplierContacts.vue'),
}, },
{ {
path: 'address', path: 'address',
@ -136,8 +91,7 @@ export default {
title: 'addresses', title: 'addresses',
icon: 'vn:delivery', icon: 'vn:delivery',
}, },
component: () => component: () => import('src/pages/Supplier/Card/SupplierAddresses.vue'),
import('src/pages/Supplier/Card/SupplierAddresses.vue'),
}, },
{ {
path: 'address/create', path: 'address/create',
@ -152,8 +106,7 @@ export default {
title: 'balance', title: 'balance',
icon: 'balance', icon: 'balance',
}, },
component: () => component: () => import('src/pages/Supplier/Card/SupplierBalance.vue'),
import('src/pages/Supplier/Card/SupplierBalance.vue'),
}, },
{ {
path: 'consumption', path: 'consumption',
@ -162,8 +115,7 @@ export default {
title: 'consumption', title: 'consumption',
icon: 'show_chart', icon: 'show_chart',
}, },
component: () => component: () => import('src/pages/Supplier/Card/SupplierConsumption.vue'),
import('src/pages/Supplier/Card/SupplierConsumption.vue'),
}, },
{ {
path: 'agency-term', path: 'agency-term',
@ -172,8 +124,7 @@ export default {
title: 'agencyTerm', title: 'agencyTerm',
icon: 'vn:agency-term', icon: 'vn:agency-term',
}, },
component: () => component: () => import('src/pages/Supplier/Card/SupplierAgencyTerm.vue'),
import('src/pages/Supplier/Card/SupplierAgencyTerm.vue'),
}, },
{ {
path: 'dms', path: 'dms',
@ -191,6 +142,54 @@ export default {
import('src/pages/Supplier/Card/SupplierAgencyTermCreate.vue'), import('src/pages/Supplier/Card/SupplierAgencyTermCreate.vue'),
}, },
], ],
};
export default {
name: 'Supplier',
path: '/supplier',
meta: {
title: 'suppliers',
icon: 'vn:supplier',
moduleName: 'Supplier',
keyBinding: 'p',
menu: ['SupplierList'],
},
component: RouterView,
redirect: { name: 'SupplierMain' },
children: [
{
path: '',
name: 'SupplierMain',
component: () => import('src/components/common/VnModule.vue'),
redirect: { name: 'SupplierIndexMain' },
children: [
{
path: '',
name: 'SupplierIndexMain',
redirect: { name: 'SupplierList' },
component: () => import('src/pages/Supplier/SupplierList.vue'),
children: [
{
path: 'list',
name: 'SupplierList',
meta: {
title: 'list',
icon: 'view_list',
},
},
supplierCard,
],
},
{
path: 'create',
name: 'SupplierCreate',
meta: {
title: 'supplierCreate',
icon: 'add',
},
component: () => import('src/pages/Supplier/SupplierCreate.vue'),
},
],
}, },
], ],
}; };

View File

@ -0,0 +1,153 @@
import { setActivePinia, createPinia } from 'pinia';
import { describe, beforeEach, afterEach, it, expect, vi, beforeAll } from 'vitest';
import { useNavigationStore } from '../useNavigationStore';
import axios from 'axios';
let store;
vi.mock('src/router/modules', () => [
{ name: 'Item', meta: {} },
{ name: 'Shelving', meta: {} },
{ name: 'Order', meta: {} },
]);
vi.mock('src/filters', () => ({
toLowerCamel: vi.fn((name) => name.toLowerCase()),
}));
const modulesMock = [
{
name: 'Item',
children: null,
title: 'globals.pageTitles.undefined',
icon: undefined,
module: 'item',
isPinned: true,
},
{
name: 'Shelving',
children: null,
title: 'globals.pageTitles.undefined',
icon: undefined,
module: 'shelving',
isPinned: false,
},
{
name: 'Order',
children: null,
title: 'globals.pageTitles.undefined',
icon: undefined,
module: 'order',
isPinned: false,
},
];
const pinnedModulesMock = [
{
name: 'Item',
children: null,
title: 'globals.pageTitles.undefined',
icon: undefined,
module: 'item',
isPinned: true,
},
];
describe('useNavigationStore', () => {
beforeEach(() => {
setActivePinia(createPinia());
vi.spyOn(axios, 'get').mockResolvedValue({ data: true });
store = useNavigationStore();
store.getModules = vi.fn().mockReturnValue({
value: modulesMock,
});
store.getPinnedModules = vi.fn().mockReturnValue({
value: pinnedModulesMock,
});
});
afterEach(() => {
vi.clearAllMocks();
});
it('should return modules with correct structure', () => {
const store = useNavigationStore();
const modules = store.getModules();
expect(modules.value).toEqual(modulesMock);
});
it('should return pinned modules', () => {
const store = useNavigationStore();
const pinnedModules = store.getPinnedModules();
expect(pinnedModules.value).toEqual(pinnedModulesMock);
});
it('should toggle pinned modules', () => {
const store = useNavigationStore();
store.togglePinned('item');
store.togglePinned('shelving');
expect(store.pinnedModules).toEqual(['item', 'shelving']);
store.togglePinned('item');
expect(store.pinnedModules).toEqual(['shelving']);
});
it('should fetch pinned modules', async () => {
vi.spyOn(axios, 'get').mockResolvedValue({
data: [{ id: 1, workerFk: 9, moduleFk: 'order', position: 1 }],
});
const store = useNavigationStore();
await store.fetchPinned();
expect(store.pinnedModules).toEqual(['order']);
});
it('should add menu item correctly', () => {
const store = useNavigationStore();
const module = 'customer';
const parent = [];
const route = {
name: 'customer',
title: 'Customer',
icon: 'customer',
meta: {
keyBinding: 'ctrl+shift+c',
name: 'customer',
title: 'Customer',
icon: 'customer',
menu: 'customer',
menuChildren: [{ name: 'customer', title: 'Customer', icon: 'customer' }],
},
};
const result = store.addMenuItem(module, route, parent);
const expectedItem = {
children: [
{
icon: 'customer',
name: 'customer',
title: 'globals.pageTitles.Customer',
},
],
icon: 'customer',
keyBinding: 'ctrl+shift+c',
name: 'customer',
title: 'globals.pageTitles.Customer',
};
expect(result).toEqual(expectedItem);
expect(parent.length).toBe(1);
expect(parent).toEqual([expectedItem]);
});
it('should not add menu item if condition is not met', () => {
const store = useNavigationStore();
const module = 'testModule';
const route = { meta: { hidden: true, menuchildren: {} } };
const parent = [];
const result = store.addMenuItem(module, route, parent);
expect(result).toBeUndefined();
expect(parent.length).toBe(0);
});
});