0
0
Fork 0

fix: refs #7553 fix conflicts

This commit is contained in:
Jon Elias 2024-09-10 11:47:38 +02:00
commit e7a89138ba
60 changed files with 1292 additions and 1044 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "salix-front", "name": "salix-front",
"version": "24.36.0", "version": "24.40.0",
"description": "Salix frontend", "description": "Salix frontend",
"productName": "Salix", "productName": "Salix",
"author": "Verdnatura", "author": "Verdnatura",

View File

@ -9,16 +9,16 @@ export default {
const keyBindingMap = routes const keyBindingMap = routes
.filter((route) => route.meta.keyBinding) .filter((route) => route.meta.keyBinding)
.reduce((map, route) => { .reduce((map, route) => {
map[route.meta.keyBinding.toLowerCase()] = route.path; map['Key' + route.meta.keyBinding.toUpperCase()] = route.path;
return map; return map;
}, {}); }, {});
const handleKeyDown = (event) => { const handleKeyDown = (event) => {
const { ctrlKey, altKey, key } = event; const { ctrlKey, altKey, code } = event;
if (ctrlKey && altKey && keyBindingMap[key] && !isNotified) { if (ctrlKey && altKey && keyBindingMap[code] && !isNotified) {
event.preventDefault(); event.preventDefault();
router.push(keyBindingMap[key]); router.push(keyBindingMap[code]);
isNotified = true; isNotified = true;
} }
}; };

View File

@ -0,0 +1,50 @@
<script setup>
import { useI18n } from 'vue-i18n';
import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue';
import FormModelPopup from './FormModelPopup.vue';
const emit = defineEmits(['onDataSaved']);
const { t } = useI18n();
</script>
<template>
<FormModelPopup
url-create="Expenses"
model="Expense"
:title="t('New expense')"
:form-initial-data="{ id: null, isWithheld: false, name: null }"
@on-data-saved="emit('onDataSaved', $event)"
>
<template #form-inputs="{ data, validate }">
<VnRow>
<VnInput
:label="`${t('globals.code')}`"
v-model="data.id"
:required="true"
:rules="validate('expense.code')"
/>
<QCheckbox
dense
size="sm"
:label="`${t('It\'s a withholding')}`"
v-model="data.isWithheld"
:rules="validate('expense.isWithheld')"
/>
</VnRow>
<VnRow>
<VnInput
:label="`${t('globals.description')}`"
v-model="data.name"
:required="true"
:rules="validate('expense.description')"
/>
</VnRow>
</template>
</FormModelPopup>
</template>
<i18n>
es:
New expense: Nuevo gasto
It's a withholding: Es una retención
</i18n>

View File

@ -189,11 +189,11 @@ async function saveChanges(data) {
}); });
} }
async function insert() { async function insert(pushData = $props.dataRequired) {
const $index = formData.value.length const $index = formData.value.length
? formData.value[formData.value.length - 1].$index + 1 ? formData.value[formData.value.length - 1].$index + 1
: 0; : 0;
formData.value.push(Object.assign({ $index }, $props.dataRequired)); formData.value.push(Object.assign({ $index }, pushData));
hasChanges.value = true; hasChanges.value = true;
} }

View File

@ -159,8 +159,8 @@ const removeTag = (index, params, search) => {
/> />
<VnFilterPanel <VnFilterPanel
:data-key="props.dataKey" :data-key="props.dataKey"
:expr-builder="exprBuilder" :expr-builder="props.exprBuilder"
:custom-tags="customTags" :custom-tags="props.customTags"
> >
<template #tags="{ tag, formatFn }"> <template #tags="{ tag, formatFn }">
<strong v-if="tag.label === 'categoryFk'"> <strong v-if="tag.label === 'categoryFk'">

View File

@ -1,6 +1,6 @@
<script setup> <script setup>
import axios from 'axios'; import axios from 'axios';
import { onMounted, ref, reactive } from 'vue'; import { onMounted, watch, ref, reactive } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { QSeparator, useQuasar } from 'quasar'; import { QSeparator, useQuasar } from 'quasar';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
@ -29,6 +29,15 @@ onMounted(async () => {
getRoutes(); getRoutes();
}); });
watch(
() => route.matched,
() => {
items.value = [];
getRoutes();
},
{ deep: true }
);
function findMatches(search, item) { function findMatches(search, item) {
const matches = []; const matches = [];
function findRoute(search, item) { function findRoute(search, item) {

View File

@ -33,7 +33,12 @@ const itemComputed = computed(() => {
<QItemSection avatar v-if="!itemComputed.icon"> <QItemSection avatar v-if="!itemComputed.icon">
<QIcon name="disabled_by_default" /> <QIcon name="disabled_by_default" />
</QItemSection> </QItemSection>
<QItemSection>{{ t(itemComputed.title) }}</QItemSection> <QItemSection>
{{ t(itemComputed.title) }}
<QTooltip>
{{ 'Ctrl + Alt + ' + item.keyBinding.toUpperCase() }}
</QTooltip>
</QItemSection>
<QItemSection side> <QItemSection side>
<slot name="side" :item="itemComputed" /> <slot name="side" :item="itemComputed" />
</QItemSection> </QItemSection>

View File

@ -33,6 +33,7 @@ const invoiceCorrectionTypesOptions = ref([]);
const refund = async () => { const refund = async () => {
const params = { const params = {
id: invoiceParams.id, id: invoiceParams.id,
withWarehouse: invoiceParams.inheritWarehouse,
cplusRectificationTypeFk: invoiceParams.cplusRectificationTypeFk, cplusRectificationTypeFk: invoiceParams.cplusRectificationTypeFk,
siiTypeInvoiceOutFk: invoiceParams.siiTypeInvoiceOutFk, siiTypeInvoiceOutFk: invoiceParams.siiTypeInvoiceOutFk,
invoiceCorrectionTypeFk: invoiceParams.invoiceCorrectionTypeFk, invoiceCorrectionTypeFk: invoiceParams.invoiceCorrectionTypeFk,

View File

@ -49,9 +49,9 @@ const $props = defineProps({
type: Object, type: Object,
default: null, default: null,
}, },
bottom: { createAsDialog: {
type: Object, type: Boolean,
default: null, default: true,
}, },
cardClass: { cardClass: {
type: String, type: String,
@ -89,6 +89,10 @@ const $props = defineProps({
type: Object, type: Object,
default: () => ({}), default: () => ({}),
}, },
crudModel: {
type: Object,
default: () => ({}),
},
tableHeight: { tableHeight: {
type: String, type: String,
default: '90vh', default: '90vh',
@ -288,10 +292,17 @@ function parseOrder(urlOrders) {
const emit = defineEmits(['onFetch', 'update:selected', 'saveChanges']); const emit = defineEmits(['onFetch', 'update:selected', 'saveChanges']);
defineExpose({ defineExpose({
create: createForm,
reload, reload,
redirect: redirectFn, redirect: redirectFn,
selected, selected,
CrudModelRef,
}); });
function handleOnDataSaved(_, res) {
if (_.onDataSaved) _.onDataSaved(this);
else $props.create.onDataSaved(_);
}
</script> </script>
<template> <template>
<QDrawer <QDrawer
@ -378,6 +389,7 @@ defineExpose({
@virtual-scroll=" @virtual-scroll="
(event) => (event) =>
event.index > rows.length - 2 && event.index > rows.length - 2 &&
($props.crudModel?.paginate ?? true) &&
CrudModelRef.vnPaginateRef.paginate() CrudModelRef.vnPaginateRef.paginate()
" "
@row-click="(_, row) => rowClickFunction && rowClickFunction(row)" @row-click="(_, row) => rowClickFunction && rowClickFunction(row)"
@ -493,6 +505,7 @@ defineExpose({
> >
<QBtn <QBtn
v-for="(btn, index) of col.actions" v-for="(btn, index) of col.actions"
v-show="btn.show ? btn.show(row) : true"
:key="index" :key="index"
:title="btn.title" :title="btn.title"
:icon="btn.icon" :icon="btn.icon"
@ -630,8 +643,17 @@ defineExpose({
</QTable> </QTable>
</template> </template>
</CrudModel> </CrudModel>
<QPageSticky v-if="create" :offset="[20, 20]" style="z-index: 2"> <QPageSticky :offset="[20, 20]" style="z-index: 2">
<QBtn @click="showForm = !showForm" color="primary" fab icon="add" shortcut="+" /> <QBtn
@click="
() =>
createAsDialog ? (showForm = !showForm) : handleOnDataSaved(create)
"
color="primary"
fab
icon="add"
shortcut="+"
/>
<QTooltip> <QTooltip>
{{ createForm.title }} {{ createForm.title }}
</QTooltip> </QTooltip>

View File

@ -135,6 +135,7 @@ const columns = computed(() => [
field: 'hasFile', field: 'hasFile',
label: t('globals.original'), label: t('globals.original'),
name: 'hasFile', name: 'hasFile',
toolTip: t('The documentation is available in paper form'),
component: QCheckbox, component: QCheckbox,
props: (prop) => ({ props: (prop) => ({
disable: true, disable: true,
@ -297,6 +298,14 @@ defineExpose({
row-key="clientFk" row-key="clientFk"
:grid="$q.screen.lt.sm" :grid="$q.screen.lt.sm"
> >
<template #header="props">
<QTr :props="props" class="bg">
<QTh v-for="col in props.cols" :key="col.name" :props="props">
<QTooltip v-if="col.toolTip">{{ col.toolTip }}</QTooltip
>{{ col.label }}
</QTh>
</QTr>
</template>
<template #body-cell="props"> <template #body-cell="props">
<QTd :props="props"> <QTd :props="props">
<QTr :props="props"> <QTr :props="props">
@ -397,8 +406,10 @@ defineExpose({
<i18n> <i18n>
en: en:
contentTypesInfo: Allowed file types {allowedContentTypes} contentTypesInfo: Allowed file types {allowedContentTypes}
The documentation is available in paper form: The documentation is available in paper form
es: es:
contentTypesInfo: Tipos de archivo permitidos {allowedContentTypes} contentTypesInfo: Tipos de archivo permitidos {allowedContentTypes}
Generate identifier for original file: Generar identificador para archivo original Generate identifier for original file: Generar identificador para archivo original
Upload file: Subir fichero Upload file: Subir fichero
the documentation is available in paper form: Se tiene la documentación en papel
</i18n> </i18n>

View File

@ -92,7 +92,6 @@ const mixinRules = [
<slot name="prepend" /> <slot name="prepend" />
</template> </template>
<template #append> <template #append>
<slot name="append" v-if="$slots.append && !$attrs.disabled" />
<QIcon <QIcon
name="close" name="close"
size="xs" size="xs"
@ -104,6 +103,7 @@ const mixinRules = [
} }
" "
></QIcon> ></QIcon>
<slot name="append" v-if="$slots.append && !$attrs.disabled" />
<QIcon v-if="info" name="info"> <QIcon v-if="info" name="info">
<QTooltip max-width="350px"> <QTooltip max-width="350px">
{{ info }} {{ info }}
@ -119,3 +119,8 @@ const mixinRules = [
es: es:
inputMin: Debe ser mayor a {value} inputMin: Debe ser mayor a {value}
</i18n> </i18n>
<style lang="scss">
.q-field__append {
padding-inline: 0;
}
</style>

View File

@ -9,6 +9,10 @@ const $props = defineProps({
type: Boolean, type: Boolean,
default: false, default: false,
}, },
showEvent: {
type: Boolean,
default: true,
},
}); });
const { t } = useI18n(); const { t } = useI18n();
@ -94,6 +98,7 @@ watch(
:class="{ required: $attrs.required }" :class="{ required: $attrs.required }"
:rules="$attrs.required ? [requiredFieldRule] : null" :rules="$attrs.required ? [requiredFieldRule] : null"
:clearable="false" :clearable="false"
@click="isPopupOpen = true"
> >
<template #append> <template #append>
<QIcon <QIcon
@ -111,6 +116,7 @@ watch(
" "
/> />
<QIcon <QIcon
v-if="showEvent"
name="event" name="event"
class="cursor-pointer" class="cursor-pointer"
@click="isPopupOpen = !isPopupOpen" @click="isPopupOpen = !isPopupOpen"
@ -130,6 +136,7 @@ watch(
v-model="popupDate" v-model="popupDate"
:landscape="true" :landscape="true"
:today-btn="true" :today-btn="true"
:options="$attrs.options"
@update:model-value=" @update:model-value="
(date) => { (date) => {
formattedDate = date; formattedDate = date;

View File

@ -14,6 +14,7 @@ import VnJsonValue from '../common/VnJsonValue.vue';
import FetchData from '../FetchData.vue'; import FetchData from '../FetchData.vue';
import VnSelect from './VnSelect.vue'; import VnSelect from './VnSelect.vue';
import VnUserLink from '../ui/VnUserLink.vue'; import VnUserLink from '../ui/VnUserLink.vue';
import VnPaginate from '../ui/VnPaginate.vue';
const stateStore = useStateStore(); const stateStore = useStateStore();
const validationsStore = useValidator(); const validationsStore = useValidator();
@ -66,9 +67,10 @@ const filter = {
}, },
}, },
], ],
where: { and: [{ originFk: route.params.id }] },
}; };
const workers = ref(); const paginate = ref();
const actions = ref(); const actions = ref();
const changeInput = ref(); const changeInput = ref();
const searchInput = ref(); const searchInput = ref();
@ -235,9 +237,7 @@ async function openPointRecord(id, modelLog) {
const locale = validations[modelLog.model]?.locale || {}; const locale = validations[modelLog.model]?.locale || {};
pointRecord.value = parseProps(propNames, locale, data); pointRecord.value = parseProps(propNames, locale, data);
} }
async function setLogTree() { async function setLogTree(data) {
filter.where = { and: [{ originFk: route.params.id }] };
const { data } = await getLogs(filter);
logTree.value = getLogTree(data); logTree.value = getLogTree(data);
} }
@ -266,15 +266,7 @@ async function applyFilter() {
filter.where.and.push(selectedFilters.value); filter.where.and.push(selectedFilters.value);
} }
const { data } = await getLogs(filter); paginate.value.fetch(filter);
logTree.value = getLogTree(data);
}
async function getLogs(filter) {
return axios.get(props.url ?? `${props.model}Logs`, {
params: { filter: JSON.stringify(filter) },
});
} }
function setDate(type) { function setDate(type) {
@ -377,8 +369,6 @@ async function clearFilter() {
await applyFilter(); await applyFilter();
} }
setLogTree();
onUnmounted(() => { onUnmounted(() => {
stateStore.rightDrawer = false; stateStore.rightDrawer = false;
}); });
@ -391,16 +381,6 @@ watch(
); );
</script> </script>
<template> <template>
<FetchData
:url="`${props.model}Logs/${route.params.id}/editors`"
:filter="{
fields: ['id', 'nickname', 'name', 'image'],
order: 'nickname',
limit: 30,
}"
@on-fetch="(data) => (workers = data)"
auto-load
/>
<FetchData <FetchData
:url="`${props.model}Logs/${route.params.id}/models`" :url="`${props.model}Logs/${route.params.id}/models`"
:filter="{ order: ['changedModel'] }" :filter="{ order: ['changedModel'] }"
@ -418,6 +398,16 @@ watch(
" "
auto-load auto-load
/> />
<VnPaginate
ref="paginate"
:data-key="`${model}Log`"
:url="`${model}Logs`"
:filter="filter"
:skeleton="false"
auto-load
@on-fetch="setLogTree"
>
<template #body>
<div <div
class="column items-center logs origin-log q-mt-md" class="column items-center logs origin-log q-mt-md"
v-for="(originLog, originLogIndex) in logTree" v-for="(originLog, originLogIndex) in logTree"
@ -465,8 +455,10 @@ watch(
size="md" size="md"
class="model-name q-mr-xs text-white" class="model-name q-mr-xs text-white"
v-if=" v-if="
!(modelLog.changedModel && modelLog.changedModelId) && !(
modelLog.model modelLog.changedModel &&
modelLog.changedModelId
) && modelLog.model
" "
:style="{ :style="{
backgroundColor: useColor(modelLog.model), backgroundColor: useColor(modelLog.model),
@ -540,7 +532,9 @@ watch(
> >
{{ modelLog.modelI18n }} {{ modelLog.modelI18n }}
<span v-if="modelLog.id" <span v-if="modelLog.id"
>#{{ modelLog.id }}</span >#{{
modelLog.id
}}</span
> >
</div> </div>
<QCardSection <QCardSection
@ -555,12 +549,18 @@ watch(
> >
<span <span
class="json-field q-mr-xs text-grey" class="json-field q-mr-xs text-grey"
:title="value.name" :title="
value.name
"
> >
{{ value.nameI18n }}: {{
value.nameI18n
}}:
</span> </span>
<VnJsonValue <VnJsonValue
:value="value.val.val" :value="
value.val.val
"
/> />
</QItem> </QItem>
</QCardSection> </QCardSection>
@ -572,7 +572,11 @@ watch(
:class="actionsClass[log.action]" :class="actionsClass[log.action]"
:name="actionsIcon[log.action]" :name="actionsIcon[log.action]"
:title=" :title="
t(`actions.${actionsText[log.action]}`) t(
`actions.${
actionsText[log.action]
}`
)
" "
/> />
</div> </div>
@ -592,17 +596,27 @@ watch(
@click="log.expand = !log.expand" @click="log.expand = !log.expand"
/> />
<span v-if="log.props.length" class="attributes"> <span v-if="log.props.length" class="attributes">
<span v-if="!log.expand" class="q-pa-none text-grey"> <span
v-if="!log.expand"
class="q-pa-none text-grey"
>
<span <span
v-for="(prop, propIndex) in log.props" v-for="(prop, propIndex) in log.props"
:key="propIndex" :key="propIndex"
class="basic-json" class="basic-json"
> >
<span class="json-field" :title="prop.name"> <span
class="json-field"
:title="prop.name"
>
{{ prop.nameI18n }}: {{ prop.nameI18n }}:
</span> </span>
<VnJsonValue :value="prop.val.val" /> <VnJsonValue :value="prop.val.val" />
<span v-if="propIndex < log.props.length - 1" <span
v-if="
propIndex <
log.props.length - 1
"
>,&nbsp; >,&nbsp;
</span> </span>
</span> </span>
@ -612,28 +626,44 @@ watch(
class="expanded-json column q-pa-none" class="expanded-json column q-pa-none"
> >
<div <div
v-for="(prop, prop2Index) in log.props" v-for="(
prop, prop2Index
) in log.props"
:key="prop2Index" :key="prop2Index"
class="q-pa-none text-grey" class="q-pa-none text-grey"
> >
<span class="json-field" :title="prop.name"> <span
class="json-field"
:title="prop.name"
>
{{ prop.nameI18n }}: {{ prop.nameI18n }}:
</span> </span>
<VnJsonValue :value="prop.val.val" /> <VnJsonValue :value="prop.val.val" />
<span v-if="prop.val.id" class="id-value"> <span
v-if="prop.val.id"
class="id-value"
>
#{{ prop.val.id }} #{{ prop.val.id }}
</span> </span>
<span v-if="log.action == 'update'"> <span v-if="log.action == 'update'">
<VnJsonValue :value="prop.old.val" /> <VnJsonValue
<span v-if="prop.old.id" class="id-value"> :value="prop.old.val"
/>
<span
v-if="prop.old.id"
class="id-value"
>
#{{ prop.old.id }} #{{ prop.old.id }}
</span> </span>
</span> </span>
</div> </div>
</span> </span>
</span> </span>
<span v-if="!log.props.length" class="description"> <span
v-if="!log.props.length"
class="description"
>
{{ log.description }} {{ log.description }}
</span> </span>
</QCardSection> </QCardSection>
@ -643,6 +673,8 @@ watch(
</QList> </QList>
</div> </div>
</div> </div>
</template>
</VnPaginate>
<Teleport to="#right-panel" v-if="stateStore.isHeaderMounted()"> <Teleport to="#right-panel" v-if="stateStore.isHeaderMounted()">
<QList dense> <QList dense>
<QSeparator /> <QSeparator />
@ -691,17 +723,16 @@ watch(
</QOptionGroup> </QOptionGroup>
</QItem> </QItem>
<QItem class="q-mt-sm"> <QItem class="q-mt-sm">
<QItemSection v-if="!workers"> <QItemSection v-if="userRadio !== null">
<QSkeleton type="QInput" class="full-width" />
</QItemSection>
<QItemSection v-if="workers && userRadio !== null">
<VnSelect <VnSelect
class="full-width" class="full-width"
:label="t('globals.user')" :label="t('globals.user')"
v-model="userSelect" v-model="userSelect"
option-label="name" option-label="name"
option-value="id" option-value="id"
:options="workers" :url="`${model}Logs/${$route.params.id}/editors`"
:fields="['id', 'nickname', 'name', 'image']"
sort-by="nickname"
@update:model-value="selectFilter('userSelect')" @update:model-value="selectFilter('userSelect')"
hide-selected hide-selected
> >

View File

@ -1,3 +1,6 @@
<script setup>
defineProps({ wrap: { type: Boolean, default: false } });
</script>
<template> <template>
<div class="vn-row q-gutter-md q-mb-md"> <div class="vn-row q-gutter-md q-mb-md">
<slot /> <slot />
@ -15,7 +18,9 @@
} }
@media screen and (max-width: 800px) { @media screen and (max-width: 800px) {
.vn-row { .vn-row {
&:not(.wrap) {
flex-direction: column; flex-direction: column;
} }
} }
}
</style> </style>

View File

@ -0,0 +1,10 @@
import { toCurrency } from 'src/filters';
export function getTotal(rows, key, opts = {}) {
const { currency, cb } = opts;
const total = rows.reduce((acc, row) => acc + +(cb ? cb(row) : row[key] || 0), 0);
return currency
? toCurrency(total, currency == 'default' ? undefined : currency)
: total;
}

View File

@ -40,6 +40,8 @@ globals:
noChanges: No changes to save noChanges: No changes to save
changesToSave: You have changes pending to save changesToSave: You have changes pending to save
confirmRemove: You are about to delete this row. Are you sure? confirmRemove: You are about to delete this row. Are you sure?
rowWillBeRemoved: This row will be removed
sureToContinue: Are you sure you want to continue?
rowAdded: Row added rowAdded: Row added
rowRemoved: Row removed rowRemoved: Row removed
pleaseWait: Please wait... pleaseWait: Please wait...
@ -84,7 +86,7 @@ globals:
description: Description description: Description
id: Id id: Id
order: Order order: Order
original: Original original: Phys. Doc
file: File file: File
selectFile: Select a file selectFile: Select a file
copyClipboard: Copy on clipboard copyClipboard: Copy on clipboard
@ -261,6 +263,7 @@ globals:
clientsActionsMonitor: Clients and actions clientsActionsMonitor: Clients and actions
serial: Serial serial: Serial
medical: Mutual medical: Mutual
supplier: Supplier
created: Created created: Created
worker: Worker worker: Worker
now: Now now: Now
@ -760,56 +763,6 @@ parking:
searchBar: searchBar:
info: You can search by parking code info: You can search by parking code
label: Search parking... label: Search parking...
invoiceIn:
list:
ref: Reference
supplier: Supplier
supplierRef: Supplier ref.
serialNumber: Serial number
serial: Serial
file: File
issued: Issued
isBooked: Is booked
awb: AWB
amount: Amount
card:
issued: Issued
amount: Amount
client: Client
company: Company
customerCard: Customer card
ticketList: Ticket List
vat: Vat
dueDay: Due day
intrastat: Intrastat
summary:
supplier: Supplier
supplierRef: Supplier ref.
currency: Currency
docNumber: Doc number
issued: Expedition date
operated: Operation date
bookEntried: Entry date
bookedDate: Booked date
sage: Sage withholding
vat: Undeductible VAT
company: Company
booked: Booked
expense: Expense
taxableBase: Taxable base
rate: Rate
sageVat: Sage vat
sageTransaction: Sage transaction
dueDay: Date
bank: Bank
amount: Amount
foreignValue: Foreign value
dueTotal: Due day
noMatch: Do not match
code: Code
net: Net
stems: Stems
country: Country
order: order:
field: field:
salesPersonFk: Sales Person salesPersonFk: Sales Person
@ -1305,6 +1258,7 @@ components:
active: Is active active: Is active
visible: Is visible visible: Is visible
floramondo: Is floramondo floramondo: Is floramondo
showBadDates: Show future items
userPanel: userPanel:
copyToken: Token copied to clipboard copyToken: Token copied to clipboard
settings: Settings settings: Settings

View File

@ -39,6 +39,8 @@ globals:
noChanges: Sin cambios que guardar noChanges: Sin cambios que guardar
changesToSave: Tienes cambios pendientes de guardar changesToSave: Tienes cambios pendientes de guardar
confirmRemove: Vas a eliminar este registro. ¿Continuar? confirmRemove: Vas a eliminar este registro. ¿Continuar?
rowWillBeRemoved: Esta linea se eliminará
sureToContinue: ¿Seguro que quieres continuar?
rowAdded: Fila añadida rowAdded: Fila añadida
rowRemoved: Fila eliminada rowRemoved: Fila eliminada
pleaseWait: Por favor espera... pleaseWait: Por favor espera...
@ -86,7 +88,7 @@ globals:
description: Descripción description: Descripción
id: Id id: Id
order: Orden order: Orden
original: Original original: Doc. física
file: Fichero file: Fichero
selectFile: Seleccione un fichero selectFile: Seleccione un fichero
copyClipboard: Copiar en portapapeles copyClipboard: Copiar en portapapeles
@ -265,6 +267,7 @@ globals:
clientsActionsMonitor: Clientes y acciones clientsActionsMonitor: Clientes y acciones
serial: Facturas por serie serial: Facturas por serie
medical: Mutua medical: Mutua
supplier: Proveedor
created: Fecha creación created: Fecha creación
worker: Trabajador worker: Trabajador
now: Ahora now: Ahora
@ -806,54 +809,6 @@ parking:
searchBar: searchBar:
info: Puedes buscar por código de parking info: Puedes buscar por código de parking
label: Buscar parking... label: Buscar parking...
invoiceIn:
list:
ref: Referencia
supplier: Proveedor
supplierRef: Ref. proveedor
serialNumber: Num. serie
shortIssued: F. emisión
serial: Serie
file: Fichero
issued: Fecha emisión
isBooked: Conciliada
awb: AWB
amount: Importe
card:
issued: Fecha emisión
amount: Importe
client: Cliente
company: Empresa
customerCard: Ficha del cliente
ticketList: Listado de tickets
vat: Iva
dueDay: Fecha de vencimiento
summary:
supplier: Proveedor
supplierRef: Ref. proveedor
currency: Divisa
docNumber: Número documento
issued: Fecha de expedición
operated: Fecha operación
bookEntried: Fecha asiento
bookedDate: Fecha contable
sage: Retención sage
vat: Iva no deducible
company: Empresa
booked: Contabilizada
expense: Gasto
taxableBase: Base imp.
rate: Tasa
sageTransaction: Sage transación
dueDay: Fecha
bank: Caja
amount: Importe
foreignValue: Divisa
dueTotal: Vencimiento
code: Código
net: Neto
stems: Tallos
country: País
department: department:
pageTitles: pageTitles:
basicData: Basic data basicData: Basic data
@ -1285,6 +1240,7 @@ components:
active: Activo active: Activo
visible: Visible visible: Visible
floramondo: Floramondo floramondo: Floramondo
showBadDates: Ver items a futuro
userPanel: userPanel:
copyToken: Token copiado al portapapeles copyToken: Token copiado al portapapeles
settings: Configuración settings: Configuración

View File

@ -27,15 +27,15 @@ const filter = {
order: 'created DESC', order: 'created DESC',
}; };
const urlPath = 'AccessTokens'; const urlPath = 'VnTokens';
const refresh = () => paginateRef.value.fetch(); const refresh = () => paginateRef.value.fetch();
const navigate = (id) => router.push({ name: 'AccountSummary', params: { id } }); const navigate = (id) => router.push({ name: 'AccountSummary', params: { id } });
const killSession = async (id) => { const killSession = async ({ userId, created }) => {
try { try {
await axios.delete(`${urlPath}/${id}`); await axios.post(`${urlPath}/killSession`, { userId, created });
paginateRef.value.fetch(); paginateRef.value.fetch();
notify(t('Session killed'), 'positive'); notify(t('Session killed'), 'positive');
} catch (error) { } catch (error) {
@ -84,7 +84,7 @@ const killSession = async (id) => {
openConfirmationModal( openConfirmationModal(
t('Session will be killed'), t('Session will be killed'),
t('Are you sure you want to continue?'), t('Are you sure you want to continue?'),
() => killSession(row.id) () => killSession(row)
) )
" "
outline outline

View File

@ -4,6 +4,7 @@ import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import axios from 'axios'; import axios from 'axios';
import { usePrintService } from 'composables/usePrintService';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
@ -27,7 +28,7 @@ const router = useRouter();
const state = useState(); const state = useState();
const user = state.getUser(); const user = state.getUser();
const stateStore = useStateStore(); const stateStore = useStateStore();
const { sendEmail } = usePrintService();
const client = ref({}); const client = ref({});
const hasChanged = ref(false); const hasChanged = ref(false);
const isLoading = ref(false); const isLoading = ref(false);
@ -156,22 +157,33 @@ const onSubmit = async () => {
} }
}; };
const onDataSaved = async ({ const getSamples = async () => {
addressId, try {
companyFk, const filter = { where: { id: initialData.typeFk } };
companyId, let { data } = await axios.get('Samples', {
from, params: { filter: JSON.stringify(filter) },
recipient,
replyTo,
}) => {
await axios.post(`Clients/${route.params.id}/incoterms-authorization-email`, {
addressId,
companyFk,
companyId,
from,
recipient,
replyTo,
}); });
return data[0];
} catch (error) {
notify('errors.create', 'negative');
}
};
getSamples();
const onDataSaved = async () => {
try {
const params = {
recipientId: initialData.recipientId,
recipient: initialData.recipient,
replyTo: initialData.replyTo,
};
setParams(params);
const samplesData = await getSamples();
const path = `${samplesData.model}/${route.params.id}/${samplesData.code}-email`;
await sendEmail(path, params);
} catch (error) {
notify('errors.create', 'negative');
}
toCustomerSamples(); toCustomerSamples();
}; };

View File

@ -55,6 +55,15 @@ const pinnedModules = computed(() => navigation.getPinnedModules());
> >
<div class="text-center text-primary button-text"> <div class="text-center text-primary button-text">
{{ t(item.title) }} {{ t(item.title) }}
<div v-if="item.keyBinding">
{{ '(' + item.keyBinding + ')' }}
<QTooltip>
{{
'Ctrl + Alt + ' +
item.keyBinding.toUpperCase()
}}
</QTooltip>
</div>
</div> </div>
</QBtn> </QBtn>
</div> </div>

View File

@ -26,7 +26,6 @@ const { notify } = useNotify();
const rowsSelected = ref([]); const rowsSelected = ref([]);
const entryBuysPaginateRef = ref(null); const entryBuysPaginateRef = ref(null);
const packagingsOptions = ref(null);
const originalRowDataCopy = ref(null); const originalRowDataCopy = ref(null);
const getInputEvents = (colField, props) => { const getInputEvents = (colField, props) => {
@ -66,7 +65,10 @@ const tableColumnComponents = computed(() => ({
'map-options': true, 'map-options': true,
'use-input': true, 'use-input': true,
'hide-selected': true, 'hide-selected': true,
options: packagingsOptions.value, url: 'Packagings',
fields: ['id'],
where: { freightItemFk: true },
'sort-by': 'id ASC',
dense: true, dense: true,
}, },
event: getInputEvents, event: getInputEvents,
@ -304,13 +306,6 @@ const lockIconType = (groupingMode, mode) => {
</script> </script>
<template> <template>
<FetchData
ref="expensesRef"
url="Packagings"
:filter="{ fields: ['id'], where: { freightItemFk: true }, order: 'id ASC' }"
auto-load
@on-fetch="(data) => (packagingsOptions = data)"
/>
<VnSubToolbar> <VnSubToolbar>
<template #st-actions> <template #st-actions>
<QBtnGroup push style="column-gap: 10px"> <QBtnGroup push style="column-gap: 10px">

View File

@ -223,6 +223,10 @@ async function onSubmit() {
autofocus autofocus
/> />
</VnRow> </VnRow>
<VnRow>
<VnInputDate :label="t('Entry date')" v-model="data.bookEntried" />
<VnInputDate :label="t('Accounted date')" v-model="data.booked" />
</VnRow>
<VnRow> <VnRow>
<VnSelect <VnSelect
:label="t('Undeductible VAT')" :label="t('Undeductible VAT')"
@ -285,10 +289,6 @@ async function onSubmit() {
</template> </template>
</VnInput> </VnInput>
</VnRow> </VnRow>
<VnRow>
<VnInputDate :label="t('Entry date')" v-model="data.bookEntried" />
<VnInputDate :label="t('Accounted date')" v-model="data.booked" />
</VnRow>
<VnRow> <VnRow>
<VnSelect <VnSelect
:label="t('Currency')" :label="t('Currency')"

View File

@ -3,6 +3,8 @@ import VnCard from 'components/common/VnCard.vue';
import InvoiceInDescriptor from './InvoiceInDescriptor.vue'; import InvoiceInDescriptor from './InvoiceInDescriptor.vue';
import InvoiceInFilter from '../InvoiceInFilter.vue'; import InvoiceInFilter from '../InvoiceInFilter.vue';
import InvoiceInSearchbar from '../InvoiceInSearchbar.vue'; import InvoiceInSearchbar from '../InvoiceInSearchbar.vue';
import { onBeforeRouteUpdate } from 'vue-router';
import { setRectificative } from '../composables/setRectificative';
const filter = { const filter = {
include: [ include: [
@ -20,6 +22,8 @@ const filter = {
{ relation: 'currency' }, { relation: 'currency' },
], ],
}; };
onBeforeRouteUpdate(async (to) => await setRectificative(to));
</script> </script>
<template> <template>
<VnCard <VnCard

View File

@ -356,10 +356,7 @@ const createInvoiceInCorrection = async () => {
<template #body="{ entity }"> <template #body="{ entity }">
<VnLv :label="t('invoiceIn.card.issued')" :value="toDate(entity.issued)" /> <VnLv :label="t('invoiceIn.card.issued')" :value="toDate(entity.issued)" />
<VnLv :label="t('invoiceIn.summary.booked')" :value="toDate(entity.booked)" /> <VnLv :label="t('invoiceIn.summary.booked')" :value="toDate(entity.booked)" />
<VnLv <VnLv :label="t('invoiceIn.card.amount')" :value="toCurrency(totalAmount)" />
:label="t('invoiceIn.card.amount')"
:value="toCurrency(totalAmount, entity.currency?.code)"
/>
<VnLv :label="t('invoiceIn.summary.supplier')"> <VnLv :label="t('invoiceIn.summary.supplier')">
<template #value> <template #value>
<span class="link"> <span class="link">

View File

@ -5,10 +5,10 @@ import { useI18n } from 'vue-i18n';
import axios from 'axios'; import axios from 'axios';
import { toDate } from 'src/filters'; import { toDate } from 'src/filters';
import { useArrayData } from 'src/composables/useArrayData'; import { useArrayData } from 'src/composables/useArrayData';
import { getTotal } from 'src/composables/getTotal';
import CrudModel from 'src/components/CrudModel.vue'; import CrudModel from 'src/components/CrudModel.vue';
import FetchData from 'src/components/FetchData.vue'; import FetchData from 'src/components/FetchData.vue';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import { toCurrency } from 'src/filters';
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';
@ -72,7 +72,6 @@ async function insert() {
await invoiceInFormRef.value.reload(); await invoiceInFormRef.value.reload();
notify(t('globals.dataSaved'), 'positive'); notify(t('globals.dataSaved'), 'positive');
} }
const getTotalAmount = (rows) => rows.reduce((acc, { amount }) => acc + +amount, 0);
</script> </script>
<template> <template>
<FetchData <FetchData
@ -155,9 +154,17 @@ const getTotalAmount = (rows) => rows.reduce((acc, { amount }) => acc + +amount,
<QTd /> <QTd />
<QTd /> <QTd />
<QTd> <QTd>
{{ toCurrency(getTotalAmount(rows), currency) }} {{ getTotal(rows, 'amount', { currency: 'default' }) }}
</QTd>
<QTd>
<template v-if="isNotEuro(invoiceIn.currency.code)">
{{
getTotal(rows, 'foreignValue', {
currency: invoiceIn.currency.code,
})
}}
</template>
</QTd> </QTd>
<QTd />
</QTr> </QTr>
</template> </template>
<template #item="props"> <template #item="props">

View File

@ -2,18 +2,15 @@
import { computed, ref } from 'vue'; import { computed, ref } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { toCurrency } from 'src/filters'; import { getTotal } from 'src/composables/getTotal';
import CrudModel from 'src/components/CrudModel.vue'; import CrudModel from 'src/components/CrudModel.vue';
import FetchData from 'src/components/FetchData.vue'; import FetchData from 'src/components/FetchData.vue';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import { useArrayData } from 'src/composables/useArrayData';
import VnInputNumber from 'src/components/common/VnInputNumber.vue'; import VnInputNumber from 'src/components/common/VnInputNumber.vue';
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
const arrayData = useArrayData();
const currency = computed(() => arrayData.store.data?.currency?.code);
const invoceInIntrastat = ref([]); const invoceInIntrastat = ref([]);
const rowsSelected = ref([]); const rowsSelected = ref([]);
const countries = ref([]); const countries = ref([]);
@ -72,9 +69,6 @@ const columns = computed(() => [
}, },
]); ]);
const getTotal = (data, key) =>
data.reduce((acc, cur) => acc + +String(cur[key] || 0).replace(',', '.'), 0);
const formatOpt = (row, { model, options }, prop) => { const formatOpt = (row, { model, options }, prop) => {
const obj = row[model]; const obj = row[model];
const option = options.find(({ id }) => id == obj); const option = options.find(({ id }) => id == obj);
@ -154,7 +148,7 @@ const formatOpt = (row, { model, options }, prop) => {
<QTd /> <QTd />
<QTd /> <QTd />
<QTd> <QTd>
{{ toCurrency(getTotal(rows, 'amount'), currency) }} {{ getTotal(rows, 'amount', { currency: 'default' }) }}
</QTd> </QTd>
<QTd> <QTd>
{{ getTotal(rows, 'net') }} {{ getTotal(rows, 'net') }}

View File

@ -35,7 +35,7 @@ const vatColumns = ref([
name: 'landed', name: 'landed',
label: 'invoiceIn.summary.taxableBase', label: 'invoiceIn.summary.taxableBase',
field: (row) => row.taxableBase, field: (row) => row.taxableBase,
format: (value) => toCurrency(value, currency.value), format: (value) => toCurrency(value),
sortable: true, sortable: true,
align: 'left', align: 'left',
}, },
@ -64,7 +64,7 @@ const vatColumns = ref([
name: 'rate', name: 'rate',
label: 'invoiceIn.summary.rate', label: 'invoiceIn.summary.rate',
field: (row) => taxRate(row.taxableBase, row.taxTypeSage?.rate), field: (row) => taxRate(row.taxableBase, row.taxTypeSage?.rate),
format: (value) => toCurrency(value, currency.value), format: (value) => toCurrency(value),
sortable: true, sortable: true,
align: 'left', align: 'left',
}, },
@ -72,7 +72,7 @@ const vatColumns = ref([
name: 'currency', name: 'currency',
label: 'invoiceIn.summary.currency', label: 'invoiceIn.summary.currency',
field: (row) => row.foreignValue, field: (row) => row.foreignValue,
format: (value) => value, format: (val) => val && toCurrency(val, currency.value),
sortable: true, sortable: true,
align: 'left', align: 'left',
}, },
@ -97,7 +97,7 @@ const dueDayColumns = ref([
name: 'amount', name: 'amount',
label: 'invoiceIn.summary.amount', label: 'invoiceIn.summary.amount',
field: (row) => row.amount, field: (row) => row.amount,
format: (value) => toCurrency(value, currency.value), format: (value) => toCurrency(value),
sortable: true, sortable: true,
align: 'left', align: 'left',
}, },
@ -105,7 +105,7 @@ const dueDayColumns = ref([
name: 'landed', name: 'landed',
label: 'invoiceIn.summary.foreignValue', label: 'invoiceIn.summary.foreignValue',
field: (row) => row.foreignValue, field: (row) => row.foreignValue,
format: (value) => value, format: (val) => val && toCurrency(val, currency.value),
sortable: true, sortable: true,
align: 'left', align: 'left',
}, },
@ -124,7 +124,7 @@ const intrastatColumns = ref([
{ {
name: 'amount', name: 'amount',
label: 'invoiceIn.summary.amount', label: 'invoiceIn.summary.amount',
field: (row) => toCurrency(row.amount, currency.value), field: (row) => toCurrency(row.amount),
sortable: true, sortable: true,
align: 'left', align: 'left',
}, },
@ -179,7 +179,6 @@ const getTotalTax = (tax) =>
const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`; const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`;
</script> </script>
<template> <template>
<CardSummary <CardSummary
data-key="InvoiceInSummary" data-key="InvoiceInSummary"
@ -229,10 +228,7 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`;
:label="t('invoiceIn.summary.currency')" :label="t('invoiceIn.summary.currency')"
:value="entity.currency?.code" :value="entity.currency?.code"
/> />
<VnLv <VnLv :label="t('invoiceIn.serial')" :value="`${entity.serial}`" />
:label="t('invoiceIn.summary.docNumber')"
:value="`${entity.serial}/${entity.serialNumber}`"
/>
</QCard> </QCard>
<QCard class="vn-one"> <QCard class="vn-one">
<QCardSection class="q-pa-none"> <QCardSection class="q-pa-none">
@ -293,12 +289,9 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`;
<QCardSection class="q-pa-none"> <QCardSection class="q-pa-none">
<VnLv <VnLv
:label="t('invoiceIn.summary.taxableBase')" :label="t('invoiceIn.summary.taxableBase')"
:value="toCurrency(entity.totals.totalTaxableBase, currency)" :value="toCurrency(entity.totals.totalTaxableBase)"
/>
<VnLv
label="Total"
:value="toCurrency(entity.totals.totalVat, currency)"
/> />
<VnLv label="Total" :value="toCurrency(entity.totals.totalVat)" />
<VnLv :label="t('invoiceIn.summary.dueTotal')"> <VnLv :label="t('invoiceIn.summary.dueTotal')">
<template #value> <template #value>
<QChip <QChip
@ -311,7 +304,7 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`;
: t('invoiceIn.summary.dueTotal') : t('invoiceIn.summary.dueTotal')
" "
> >
{{ toCurrency(entity.totals.totalDueDay, currency) }} {{ toCurrency(entity.totals.totalDueDay) }}
</QChip> </QChip>
</template> </template>
</VnLv> </VnLv>
@ -350,15 +343,17 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`;
<template #bottom-row> <template #bottom-row>
<QTr class="bg"> <QTr class="bg">
<QTd></QTd> <QTd></QTd>
<QTd>{{ toCurrency(entity.totals.totalTaxableBase) }}</QTd>
<QTd></QTd>
<QTd></QTd>
<QTd>{{ toCurrency(getTotalTax(entity.invoiceInTax)) }}</QTd>
<QTd>{{ <QTd>{{
toCurrency(entity.totals.totalTaxableBase, currency) entity.totals.totalTaxableBaseForeignValue &&
toCurrency(
entity.totals.totalTaxableBaseForeignValue,
currency
)
}}</QTd> }}</QTd>
<QTd></QTd>
<QTd></QTd>
<QTd>{{
toCurrency(getTotalTax(entity.invoiceInTax, currency))
}}</QTd>
<QTd></QTd>
</QTr> </QTr>
</template> </template>
</QTable> </QTable>
@ -384,9 +379,17 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`;
<QTd></QTd> <QTd></QTd>
<QTd></QTd> <QTd></QTd>
<QTd> <QTd>
{{ toCurrency(entity.totals.totalDueDay, currency) }} {{ toCurrency(entity.totals.totalDueDay) }}
</QTd>
<QTd>
{{
entity.totals.totalDueDayForeignValue &&
toCurrency(
entity.totals.totalDueDayForeignValue,
currency
)
}}
</QTd> </QTd>
<QTd></QTd>
</QTr> </QTr>
</template> </template>
</QTable> </QTable>
@ -421,7 +424,7 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`;
<template #bottom-row> <template #bottom-row>
<QTr class="bg"> <QTr class="bg">
<QTd></QTd> <QTd></QTd>
<QTd>{{ toCurrency(intrastatTotals.amount, currency) }}</QTd> <QTd>{{ toCurrency(intrastatTotals.amount) }}</QTd>
<QTd>{{ intrastatTotals.net }}</QTd> <QTd>{{ intrastatTotals.net }}</QTd>
<QTd>{{ intrastatTotals.stems }}</QTd> <QTd>{{ intrastatTotals.stems }}</QTd>
<QTd></QTd> <QTd></QTd>

View File

@ -2,18 +2,17 @@
import { ref, computed } from 'vue'; import { ref, computed } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useQuasar } from 'quasar';
import axios from 'axios';
import { useArrayData } from 'src/composables/useArrayData'; import { useArrayData } from 'src/composables/useArrayData';
import { getTotal } from 'src/composables/getTotal';
import { toCurrency } from 'src/filters'; import { toCurrency } from 'src/filters';
import FetchData from 'src/components/FetchData.vue'; import FetchData from 'src/components/FetchData.vue';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import CrudModel from 'src/components/CrudModel.vue'; import CrudModel from 'src/components/CrudModel.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnInputNumber from 'src/components/common/VnInputNumber.vue'; import VnInputNumber from 'src/components/common/VnInputNumber.vue';
import VnSelectDialog from 'src/components/common/VnSelectDialog.vue';
import CreateNewExpenseForm from 'src/components/CreateNewExpenseForm.vue';
const { t } = useI18n(); const { t } = useI18n();
const quasar = useQuasar();
const arrayData = useArrayData(); const arrayData = useArrayData();
const invoiceIn = computed(() => arrayData.store.data); const invoiceIn = computed(() => arrayData.store.data);
@ -23,15 +22,7 @@ const expenses = ref([]);
const sageTaxTypes = ref([]); const sageTaxTypes = ref([]);
const sageTransactionTypes = ref([]); const sageTransactionTypes = ref([]);
const rowsSelected = ref([]); const rowsSelected = ref([]);
const newExpense = ref({
code: undefined,
isWithheld: false,
description: undefined,
});
const invoiceInFormRef = ref(); const invoiceInFormRef = ref();
const expensesRef = ref();
const newExpenseRef = ref();
defineProps({ defineProps({
actionIcon: { actionIcon: {
@ -56,7 +47,7 @@ const columns = computed(() => [
{ {
name: 'taxablebase', name: 'taxablebase',
label: t('Taxable base'), label: t('Taxable base'),
field: (row) => toCurrency(row.taxableBase, currency.value), field: (row) => row.taxableBase,
model: 'taxableBase', model: 'taxableBase',
sortable: true, sortable: true,
tabIndex: 2, tabIndex: 2,
@ -91,7 +82,7 @@ const columns = computed(() => [
label: t('Rate'), label: t('Rate'),
sortable: true, sortable: true,
tabIndex: 5, tabIndex: 5,
field: (row) => toCurrency(taxRate(row, row.taxTypeSageFk), currency.value), field: (row) => taxRate(row, row.taxTypeSageFk),
align: 'left', align: 'left',
}, },
{ {
@ -132,40 +123,6 @@ function taxRate(invoiceInTax) {
return (taxTypeSage / 100) * taxableBase; return (taxTypeSage / 100) * taxableBase;
} }
async function addExpense() {
try {
if (!newExpense.value.code) throw new Error(t(`The code can't be empty`));
if (isNaN(newExpense.value.code))
throw new Error(t(`The code have to be a number`));
if (!newExpense.value.description)
throw new Error(t(`The description can't be empty`));
const data = [
{
id: newExpense.value.code,
isWithheld: newExpense.value.isWithheld,
name: newExpense.value.description,
},
];
await axios.post(`Expenses`, data);
await expensesRef.value.fetch();
quasar.notify({
type: 'positive',
message: t('globals.dataSaved'),
});
newExpenseRef.value.hide();
} catch (error) {
quasar.notify({
type: 'negative',
message: t(`${error.message}`),
});
}
}
const getTotalTaxableBase = (rows) =>
rows.reduce((acc, { taxableBase }) => acc + +(taxableBase || 0), 0);
const getTotalRate = (rows) => rows.reduce((acc, cur) => acc + +taxRate(cur), 0);
const formatOpt = (row, { model, options }, prop) => { const formatOpt = (row, { model, options }, prop) => {
const obj = row[model]; const obj = row[model];
const option = options.find(({ id }) => id == obj); const option = options.find(({ id }) => id == obj);
@ -207,37 +164,25 @@ const formatOpt = (row, { model, options }, prop) => {
> >
<template #body-cell-expense="{ row, col }"> <template #body-cell-expense="{ row, col }">
<QTd> <QTd>
<VnSelect <VnSelectDialog
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')"
> >
<template #option="scope"> <template #option="scope">
<QItem v-bind="scope.itemProps"> <QItem v-bind="scope.itemProps">
{{ `${scope.opt.id}: ${scope.opt.name}` }} {{ `${scope.opt.id}: ${scope.opt.name}` }}
</QItem> </QItem>
</template> </template>
<template #append> <template #form>
<QIcon <CreateNewExpenseForm
name="close" @on-data-saved="$refs.expensesRef.fetch()"
@click.stop="value = null"
class="cursor-pointer"
size="xs"
/> />
<QIcon
@click.stop.prevent="newExpenseRef.show()"
:name="actionIcon"
size="xs"
class="default-icon"
>
<QTooltip>
{{ t('Create expense') }}
</QTooltip>
</QIcon>
</template> </template>
</VnSelect> </VnSelectDialog>
</QTd> </QTd>
</template> </template>
<template #body-cell-taxablebase="{ row }"> <template #body-cell-taxablebase="{ row }">
@ -325,12 +270,24 @@ const formatOpt = (row, { model, options }, prop) => {
<QTd /> <QTd />
<QTd /> <QTd />
<QTd> <QTd>
{{ toCurrency(getTotalTaxableBase(rows), currency) }} {{ getTotal(rows, 'taxableBase', { currency: 'default' }) }}
</QTd> </QTd>
<QTd /> <QTd />
<QTd /> <QTd />
<QTd> {{ toCurrency(getTotalRate(rows), currency) }}</QTd> <QTd>
<QTd /> {{
getTotal(rows, null, { cb: taxRate, currency: 'default' })
}}</QTd
>
<QTd>
<template v-if="isNotEuro(invoiceIn.currency.code)">
{{
getTotal(rows, 'foreignValue', {
currency: invoiceIn.currency.code,
})
}}
</template>
</QTd>
</QTr> </QTr>
</template> </template>
<template #item="props"> <template #item="props">
@ -342,7 +299,7 @@ const formatOpt = (row, { model, options }, prop) => {
<QSeparator /> <QSeparator />
<QList> <QList>
<QItem> <QItem>
<VnSelect <VnSelectDialog
:label="t('Expense')" :label="t('Expense')"
class="full-width" class="full-width"
v-model="props.row['expenseFk']" v-model="props.row['expenseFk']"
@ -350,13 +307,17 @@ const formatOpt = (row, { model, options }, prop) => {
option-value="id" option-value="id"
option-label="name" option-label="name"
:filter-options="['id', 'name']" :filter-options="['id', 'name']"
:tooltip="t('Create a new expense')"
> >
<template #option="scope"> <template #option="scope">
<QItem v-bind="scope.itemProps"> <QItem v-bind="scope.itemProps">
{{ `${scope.opt.id}: ${scope.opt.name}` }} {{ `${scope.opt.id}: ${scope.opt.name}` }}
</QItem> </QItem>
</template> </template>
</VnSelect> <template #form>
<CreateNewExpenseForm />
</template>
</VnSelectDialog>
</QItem> </QItem>
<QItem> <QItem>
<VnInputNumber <VnInputNumber
@ -439,44 +400,6 @@ const formatOpt = (row, { model, options }, prop) => {
</QTable> </QTable>
</template> </template>
</CrudModel> </CrudModel>
<QDialog ref="newExpenseRef">
<QCard>
<QCardSection class="q-pb-none">
<QItem class="q-pa-none">
<span class="text-primary text-h6 full-width">
<QIcon name="edit" class="q-mr-xs" />
{{ t('New expense') }}
</span>
<QBtn icon="close" flat round dense v-close-popup />
</QItem>
</QCardSection>
<QCardSection class="q-pt-none">
<QItem>
<VnInput
:label="`${t('Code')}*`"
v-model="newExpense.code"
:required="true"
/>
<QCheckbox
dense
size="sm"
:label="`${t('It\'s a withholding')}`"
v-model="newExpense.isWithheld"
/>
</QItem>
<QItem>
<VnInput
:label="`${t('Descripction')}*`"
v-model="newExpense.description"
/>
</QItem>
</QCardSection>
<QCardActions class="justify-end">
<QBtn flat :label="t('globals.close')" color="primary" v-close-popup />
<QBtn :label="t('globals.save')" color="primary" @click="addExpense" />
</QCardActions>
</QCard>
</QDialog>
<QPageSticky position="bottom-right" :offset="[25, 25]"> <QPageSticky position="bottom-right" :offset="[25, 25]">
<QBtn <QBtn
color="primary" color="primary"
@ -484,7 +407,9 @@ const formatOpt = (row, { model, options }, prop) => {
size="lg" size="lg"
round round
@click="invoiceInFormRef.insert()" @click="invoiceInFormRef.insert()"
/> >
<QTooltip>{{ t('Add tax') }}</QTooltip>
</QBtn>
</QPageSticky> </QPageSticky>
</template> </template>
@ -524,18 +449,11 @@ const formatOpt = (row, { model, options }, prop) => {
<i18n> <i18n>
es: es:
Expense: Gasto Expense: Gasto
Create expense: Crear gasto Create a new expense: Crear nuevo gasto
Add tax: Crear gasto Add tax: Crear gasto
Taxable base: Base imp. Taxable base: Base imp.
Sage tax: Sage iva Sage tax: Sage iva
Sage transaction: Sage transacción Sage transaction: Sage transacción
Rate: Tasa Rate: Tasa
Foreign value: Divisa Foreign value: Divisa
New expense: Nuevo gasto
Code: Código
It's a withholding: Es una retención
Descripction: Descripción
The code can't be empty: El código no puede estar vacío
The description can't be empty: La descripción no puede estar vacía
The code have to be a number: El código debe ser un número.
</i18n> </i18n>

View File

@ -28,6 +28,16 @@ const activities = ref([]);
</div> </div>
</template> </template>
<template #body="{ params, searchFn }"> <template #body="{ params, searchFn }">
<QItem>
<QItemSection>
<VnInputDate :label="t('From')" v-model="params.from" is-outlined />
</QItemSection>
</QItem>
<QItem>
<QItemSection>
<VnInputDate :label="t('To')" v-model="params.to" is-outlined />
</QItemSection>
</QItem>
<QItem> <QItem>
<QItemSection> <QItemSection>
<VnSelect <VnSelect
@ -64,16 +74,6 @@ const activities = ref([]);
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem>
<QItemSection>
<VnInput
:label="t('params.serialNumber')"
v-model="params.serialNumber"
is-outlined
lazy-rules
/>
</QItemSection>
</QItem>
<QItem> <QItem>
<QItemSection> <QItemSection>
<VnInput <VnInput
@ -84,15 +84,6 @@ const activities = ref([]);
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem>
<QItemSection>
<VnInputDate
:label="t('Issued')"
v-model="params.issued"
is-outlined
/>
</QItemSection>
</QItem>
<QItem> <QItem>
<QItemSection> <QItemSection>
<VnInput <VnInput
@ -140,22 +131,6 @@ const activities = ref([]);
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
<QExpansionItem :label="t('More options')" expand-separator>
<QItem>
<QItemSection>
<VnInputDate
:label="t('From')"
v-model="params.from"
is-outlined
/>
</QItemSection>
</QItem>
<QItem>
<QItemSection>
<VnInputDate :label="t('To')" v-model="params.to" is-outlined />
</QItemSection>
</QItem>
</QExpansionItem>
</template> </template>
</VnFilterPanel> </VnFilterPanel>
</template> </template>
@ -179,6 +154,7 @@ en:
correctedFk: Rectified correctedFk: Rectified
issued: Issued issued: Issued
to: To to: To
from: From
awbCode: AWB awbCode: AWB
correctingFk: Rectificative correctingFk: Rectificative
supplierActivityFk: Supplier activity supplierActivityFk: Supplier activity
@ -201,6 +177,8 @@ es:
correctedFk: Rectificada correctedFk: Rectificada
correctingFk: Rectificativa correctingFk: Rectificativa
supplierActivityFk: Actividad proveedor supplierActivityFk: Actividad proveedor
from: Desde
to: Hasta
From: Desde From: Desde
To: Hasta To: Hasta
Amount: Importe Amount: Importe

View File

@ -47,12 +47,6 @@ const cols = computed(() => [
name: 'supplierRef', name: 'supplierRef',
label: t('invoiceIn.list.supplierRef'), label: t('invoiceIn.list.supplierRef'),
}, },
{
align: 'left',
name: 'serialNumber',
label: t('invoiceIn.list.serialNumber'),
},
{ {
align: 'left', align: 'left',
name: 'serial', name: 'serial',
@ -141,7 +135,7 @@ const cols = computed(() => [
v-model="data.supplierFk" v-model="data.supplierFk"
url="Suppliers" url="Suppliers"
:fields="['id', 'nickname']" :fields="['id', 'nickname']"
:label="t('Supplier')" :label="t('globals.supplier')"
option-value="id" option-value="id"
option-label="nickname" option-label="nickname"
:filter-options="['id', 'name']" :filter-options="['id', 'name']"
@ -162,7 +156,7 @@ const cols = computed(() => [
/> />
<VnSelect <VnSelect
url="Companies" url="Companies"
:label="t('Company')" :label="t('globals.company')"
:fields="['id', 'code']" :fields="['id', 'code']"
v-model="data.companyFk" v-model="data.companyFk"
option-value="id" option-value="id"

View File

@ -0,0 +1,14 @@
import axios from 'axios';
export async function setRectificative(route) {
const card = route.matched.find((route) => route.name === 'InvoiceInCard');
const corrective = card.children.find(
(route) => route.name === 'InvoiceInCorrective'
);
corrective.meta.hidden = !(
await axios.get('InvoiceInCorrections', {
params: { filter: { where: { correctingFk: route.params.id } } },
})
).data.length;
}

View File

@ -0,0 +1,49 @@
invoiceIn:
serial: Serial
list:
ref: Reference
supplier: Supplier
supplierRef: Supplier ref.
serial: Serial
file: File
issued: Issued
isBooked: Is booked
awb: AWB
amount: Amount
card:
issued: Issued
amount: Amount
client: Client
company: Company
customerCard: Customer card
ticketList: Ticket List
vat: Vat
dueDay: Due day
intrastat: Intrastat
summary:
supplier: Supplier
supplierRef: Supplier ref.
currency: Currency
issued: Expedition date
operated: Operation date
bookEntried: Entry date
bookedDate: Booked date
sage: Sage withholding
vat: Undeductible VAT
company: Company
booked: Booked
expense: Expense
taxableBase: Taxable base
rate: Rate
sageVat: Sage vat
sageTransaction: Sage transaction
dueDay: Date
bank: Bank
amount: Amount
foreignValue: Foreign value
dueTotal: Due day
noMatch: Do not match
code: Code
net: Net
stems: Stems
country: Country

View File

@ -0,0 +1,47 @@
invoiceIn:
serial: Serie
list:
ref: Referencia
supplier: Proveedor
supplierRef: Ref. proveedor
shortIssued: F. emisión
file: Fichero
issued: Fecha emisión
isBooked: Conciliada
awb: AWB
amount: Importe
card:
issued: Fecha emisión
amount: Importe
client: Cliente
company: Empresa
customerCard: Ficha del cliente
ticketList: Listado de tickets
vat: Iva
dueDay: Fecha de vencimiento
summary:
supplier: Proveedor
supplierRef: Ref. proveedor
currency: Divisa
docNumber: Número documento
issued: Fecha de expedición
operated: Fecha operación
bookEntried: Fecha asiento
bookedDate: Fecha contable
sage: Retención sage
vat: Iva no deducible
company: Empresa
booked: Contabilizada
expense: Gasto
taxableBase: Base imp.
rate: Tasa
sageTransaction: Sage transación
dueDay: Fecha
bank: Caja
amount: Importe
foreignValue: Divisa
dueTotal: Vencimiento
code: Código
net: Neto
stems: Tallos
country: País

View File

@ -10,8 +10,6 @@ import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.v
import VnConfirm from 'components/ui/VnConfirm.vue'; import VnConfirm from 'components/ui/VnConfirm.vue';
import RegularizeStockForm from 'components/RegularizeStockForm.vue'; import RegularizeStockForm from 'components/RegularizeStockForm.vue';
import ItemDescriptorImage from 'src/pages/Item/Card/ItemDescriptorImage.vue'; import ItemDescriptorImage from 'src/pages/Item/Card/ItemDescriptorImage.vue';
import { useState } from 'src/composables/useState';
import useCardDescription from 'src/composables/useCardDescription'; import useCardDescription from 'src/composables/useCardDescription';
import { getUrl } from 'src/composables/getUrl'; import { getUrl } from 'src/composables/getUrl';
import axios from 'axios'; import axios from 'axios';
@ -35,58 +33,69 @@ const $props = defineProps({
type: Number, type: Number,
default: null, default: null,
}, },
warehouseFk: {
type: Number,
default: null,
},
}); });
const quasar = useQuasar(); const quasar = useQuasar();
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const { t } = useI18n(); const { t } = useI18n();
const state = useState(); const warehouseConfig = ref(null);
const user = state.getUser();
const entityId = computed(() => { const entityId = computed(() => {
return $props.id || route.params.id; return $props.id || route.params.id;
}); });
const regularizeStockFormDialog = ref(null); const regularizeStockFormDialog = ref(null);
const available = ref(null); const available = ref(null);
const visible = ref(null); const visible = ref(null);
const _warehouseFk = ref(null);
const salixUrl = ref(); const salixUrl = ref();
const warehouseFk = computed({
get() {
return _warehouseFk.value;
},
set(val) {
_warehouseFk.value = val;
if (val) updateStock();
},
});
onMounted(async () => { onMounted(async () => {
warehouseFk.value = user.value.warehouseFk;
salixUrl.value = await getUrl(''); salixUrl.value = await getUrl('');
await getItemConfigs();
await updateStock();
}); });
const data = ref(useCardDescription()); const data = ref(useCardDescription());
const setData = (entity) => { const setData = async (entity) => {
try {
if (!entity) return; if (!entity) return;
data.value = useCardDescription(entity.name, entity.id); data.value = useCardDescription(entity.name, entity.id);
await updateStock();
} catch (err) {
console.error('Error item');
}
}; };
const getItemConfigs = async () => {
try {
const { data } = await axios.get('ItemConfigs/findOne');
if (!data) return;
return (warehouseConfig.value = data.warehouseFk);
} catch (err) {
console.error('Error item');
}
};
const updateStock = async () => { const updateStock = async () => {
try { try {
available.value = null; available.value = null;
visible.value = null; visible.value = null;
const params = { const params = {
warehouseFk: warehouseFk.value, warehouseFk: $props.warehouseFk,
dated: $props.dated, dated: $props.dated,
}; };
await getItemConfigs();
if (!params.warehouseFk) {
params.warehouseFk = warehouseConfig.value;
}
const { data } = await axios.get(`Items/${entityId.value}/getVisibleAvailable`, { const { data } = await axios.get(`Items/${entityId.value}/getVisibleAvailable`, {
params, params,
}); });
available.value = data.available; available.value = data.available;
visible.value = data.visible; visible.value = data.visible;
} catch (err) { } catch (err) {

View File

@ -47,8 +47,11 @@ const getWarehouseName = async (warehouseFk) => {
const filter = { const filter = {
where: { id: warehouseFk }, where: { id: warehouseFk },
}; };
const { data } = await axios.get('Warehouses/findOne', {
const { data } = await axios.get('Warehouses/findOne', { filter }); params: {
filter: JSON.stringify(filter),
},
});
if (!data) return; if (!data) return;
warehouseName.value = data.name; warehouseName.value = data.name;
}; };

View File

@ -15,6 +15,10 @@ const $props = defineProps({
type: Number, type: Number,
default: null, default: null,
}, },
warehouseFk: {
type: Number,
default: null,
},
}); });
</script> </script>
@ -26,6 +30,7 @@ const $props = defineProps({
:summary="ItemSummary" :summary="ItemSummary"
:dated="dated" :dated="dated"
:sale-fk="saleFk" :sale-fk="saleFk"
:warehouse-fk="warehouseFk"
/> />
</QPopupProxy> </QPopupProxy>
</template> </template>

View File

@ -1,196 +1,190 @@
<script setup> <script setup>
import { onMounted, ref, reactive, computed, onUnmounted, watch } from 'vue'; import { onMounted, ref, reactive, onUnmounted, nextTick, computed } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import FetchData from 'components/FetchData.vue';
import FetchedTags from 'components/ui/FetchedTags.vue'; import FetchedTags from 'components/ui/FetchedTags.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 VnSelect from 'src/components/common/VnSelect.vue';
import VnInputDate from 'src/components/common/VnInputDate.vue'; import VnInputDate from 'src/components/common/VnInputDate.vue';
import EditTableCellValueForm from 'src/components/EditTableCellValueForm.vue'; import EditTableCellValueForm from 'src/components/EditTableCellValueForm.vue';
import ItemFixedPriceFilter from './ItemFixedPriceFilter.vue'; import ItemFixedPriceFilter from './ItemFixedPriceFilter.vue';
import { useQuasar } from 'quasar';
import ItemDescriptorProxy from './Card/ItemDescriptorProxy.vue'; import ItemDescriptorProxy from './Card/ItemDescriptorProxy.vue';
import { tMobile } from 'src/composables/tMobile';
import VnConfirm from 'components/ui/VnConfirm.vue';
import FetchData from 'src/components/FetchData.vue';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
import { dashIfEmpty } from 'src/filters'; import { toDate } from 'src/filters';
import { useVnConfirm } from 'composables/useVnConfirm'; import { useVnConfirm } from 'composables/useVnConfirm';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
import { toCurrency } from 'filters/index';
import useNotify from 'src/composables/useNotify.js'; import useNotify from 'src/composables/useNotify.js';
import axios from 'axios'; import axios from 'axios';
import { useArrayData } from 'composables/useArrayData';
import { isLower, isBigger } from 'src/filters/date.js'; import { isLower, isBigger } from 'src/filters/date.js';
import RightMenu from 'src/components/common/RightMenu.vue'; import RightMenu from 'src/components/common/RightMenu.vue';
import VnTable from 'src/components/VnTable/VnTable.vue';
import { QCheckbox } from 'quasar';
const quasar = useQuasar();
const stateStore = useStateStore(); const stateStore = useStateStore();
const { t } = useI18n(); const { t } = useI18n();
const { openConfirmationModal } = useVnConfirm(); const { openConfirmationModal } = useVnConfirm();
const state = useState(); const state = useState();
const { notify } = useNotify(); const { notify } = useNotify();
const tableRef = ref();
const editTableCellDialogRef = ref(null); const editTableCellDialogRef = ref(null);
const user = state.getUser(); const user = state.getUser();
const fixedPrices = ref([]); const fixedPrices = ref([]);
const fixedPricesOriginalData = ref([]);
const warehousesOptions = ref([]); const warehousesOptions = ref([]);
const rowsSelected = ref([]); const rowsSelected = ref([]);
const exprBuilder = (param, value) => { const itemFixedPriceFilterRef = ref();
switch (param) {
case 'name':
return { 'i.name': { like: `%${value}%` } };
case 'itemFk':
case 'warehouseFk':
case 'rate2':
case 'rate3':
param = `fp.${param}`;
return { [param]: value };
case 'minPrice':
param = `i.${param}`;
return { [param]: value };
}
};
const params = reactive({}); const params = reactive({});
const arrayData = useArrayData('ItemFixedPrices', {
url: 'FixedPrices/filter',
userParams: params,
order: ['name ASC', 'itemFk'],
exprBuilder: exprBuilder,
});
const store = arrayData.store;
const fetchFixedPrices = async () => {
await arrayData.fetch({ append: false });
};
const onFixedPricesFetched = (data) => {
fixedPrices.value = data;
// el objetivo de guardar una copia de las rows es evitar guardar cambios si la data no cambió al disparar los eventos
fixedPricesOriginalData.value = JSON.parse(JSON.stringify(data));
};
watch(
() => store.data,
(data) => onFixedPricesFetched(data)
);
const applyColumnFilter = async (col) => {
try {
const paramKey = col.columnFilter?.filterParamKey || col.field;
params[paramKey] = col.columnFilter.filterValue;
await arrayData.addFilter({ params });
} catch (err) {
console.error('Error applying column filter', err);
}
};
const getColumnInputEvents = (col) => {
return col.columnFilter.type === 'select'
? { 'update:modelValue': () => applyColumnFilter(col) }
: {
'keyup.enter': () => applyColumnFilter(col),
};
};
const defaultColumnFilter = {
component: VnInput,
type: 'text',
filterValue: null,
event: getColumnInputEvents,
attrs: {
dense: true,
},
};
const defaultColumnAttrs = { const defaultColumnAttrs = {
align: 'left', align: 'left',
sortable: true, sortable: true,
}; };
onMounted(async () => {
stateStore.rightDrawer = true;
params.warehouseFk = user.value.warehouseFk;
});
onUnmounted(() => (stateStore.rightDrawer = false));
const columns = computed(() => [ const columns = computed(() => [
{ {
label: t('item.fixedPrice.itemId'), label: t('item.fixedPrice.itemId'),
name: 'itemId', name: 'itemId',
field: 'itemFk',
...defaultColumnAttrs, ...defaultColumnAttrs,
columnFilter: { isId: true,
...defaultColumnFilter, cardVisible: true,
columnField: {
component: 'input',
type: 'number',
}, },
columnClass: 'shrink',
}, },
{ {
label: t('globals.description'), label: t('globals.name'),
field: 'name', field: 'name',
name: 'description', name: 'description',
...defaultColumnAttrs, ...defaultColumnAttrs,
columnFilter: { create: true,
...defaultColumnFilter, cardVisible: true,
},
}, },
{ {
label: t('item.fixedPrice.groupingPrice'), label: t('item.fixedPrice.groupingPrice'),
field: 'rate2', field: 'rate2',
name: 'groupingPrice', name: 'rate2',
...defaultColumnAttrs, ...defaultColumnAttrs,
columnFilter: { cardVisible: true,
...defaultColumnFilter, columnField: {
class: 'expand',
component: 'input',
type: 'number',
},
columnFilter: {
class: 'expand',
component: 'input',
type: 'number',
}, },
format: (val) => toCurrency(val),
}, },
{ {
label: t('item.fixedPrice.packingPrice'), label: t('item.fixedPrice.packingPrice'),
field: 'rate3', field: 'rate3',
name: 'packingPrice', name: 'rate3',
...defaultColumnAttrs, ...defaultColumnAttrs,
columnFilter: { cardVisible: true,
...defaultColumnFilter, columnField: {
class: 'expand',
component: 'input',
type: 'number',
},
columnFilter: {
class: 'expand',
component: 'input',
type: 'number',
}, },
format: (val) => dashIfEmpty(val),
}, },
{ {
label: t('item.fixedPrice.minPrice'), label: t('item.fixedPrice.minPrice'),
field: 'minPrice', field: 'minPrice',
columnClass: 'shrink',
name: 'minPrice', name: 'minPrice',
...defaultColumnAttrs, ...defaultColumnAttrs,
cardVisible: true,
columnField: {
class: 'expand',
component: 'input',
type: 'number',
},
columnFilter: { columnFilter: {
...defaultColumnFilter, class: 'expand',
component: 'input',
type: 'number',
}, },
}, },
{ {
label: t('item.fixedPrice.started'), label: t('item.fixedPrice.started'),
field: 'started', field: 'started',
name: 'started', name: 'started',
format: ({ started }) => toDate(started),
cardVisible: true,
...defaultColumnAttrs, ...defaultColumnAttrs,
columnFilter: null, columnField: {
component: 'date',
class: 'shrink',
},
columnFilter: {
component: 'date',
},
columnClass: 'expand',
}, },
{ {
label: t('item.fixedPrice.ended'), label: t('item.fixedPrice.ended'),
field: 'ended', field: 'ended',
name: 'ended', name: 'ended',
...defaultColumnAttrs, ...defaultColumnAttrs,
columnFilter: null, cardVisible: true,
columnField: {
component: 'date',
class: 'shrink',
},
columnFilter: {
component: 'date',
},
columnClass: 'expand',
format: (row) => toDate(row.ended),
}, },
{ {
label: t('item.fixedPrice.warehouse'), label: t('item.fixedPrice.warehouse'),
field: 'warehouseFk', field: 'warehouseFk',
name: 'warehouse', name: 'warehouseFk',
...defaultColumnAttrs, ...defaultColumnAttrs,
columnClass: 'shrink',
columnFilter: { columnFilter: {
component: VnSelect, component: 'select',
type: 'select', },
filterValue: null, columnField: {
event: getColumnInputEvents, component: 'select',
class: 'expand',
},
attrs: { attrs: {
options: warehousesOptions.value, options: warehousesOptions,
'option-value': 'id',
'option-label': 'name',
dense: true,
}, },
}, },
{
align: 'right',
name: 'tableActions',
actions: [
{
title: t('delete'),
icon: 'delete',
action: (row) => confirmRemove(row),
isPrimary: true,
},
],
}, },
{ name: 'deleteAction', align: 'center' },
]); ]);
const editTableFieldsOptions = [ const editTableFieldsOptions = [
@ -218,15 +212,6 @@ const editTableFieldsOptions = [
type: 'number', type: 'number',
}, },
}, },
{
field: 'hasMinPrice',
label: t('item.fixedPrice.hasMinPrice'),
component: 'checkbox',
attrs: {
'false-value': 0,
'true-value': 1,
},
},
{ {
field: 'started', field: 'started',
label: t('item.fixedPrice.started'), label: t('item.fixedPrice.started'),
@ -248,7 +233,6 @@ const editTableFieldsOptions = [
}, },
}, },
]; ];
const getRowUpdateInputEvents = (props, resetMinPrice, inputType = 'text') => { const getRowUpdateInputEvents = (props, resetMinPrice, inputType = 'text') => {
return inputType === 'text' return inputType === 'text'
? { ? {
@ -258,91 +242,6 @@ const getRowUpdateInputEvents = (props, resetMinPrice, inputType = 'text') => {
: { 'update:modelValue': () => upsertPrice(props, resetMinPrice) }; : { 'update:modelValue': () => upsertPrice(props, resetMinPrice) };
}; };
const validations = (row, rowIndex, col) => {
const isNew = !row.id;
// Si la row no tiene id significa que fue agregada con addRow y no se ha guardado en la base de datos
// Si isNew es falso no se checkea si el valor es igual a la original
if (!isNew)
if (fixedPricesOriginalData.value[rowIndex][col.field] == row[col.field])
return false;
const requiredFields = ['itemFk', 'started', 'ended', 'rate2', 'rate3'];
return requiredFields.every(
(field) => row[field] !== null && row[field] !== undefined
);
};
const upsertPrice = async ({ row, col, rowIndex }, resetMinPrice = false) => {
if (!validations(row, rowIndex, col)) return;
try {
if (resetMinPrice) row.hasMinPrice = 0;
const { data } = await axios.patch('FixedPrices/upsertFixedPrice', row);
row = data;
fixedPricesOriginalData.value[rowIndex][col.field] = row[col.field];
} catch (err) {
console.error('Error editing price', err);
}
};
const addRow = () => {
if (!fixedPrices.value || fixedPrices.value.length === 0) {
fixedPrices.value = [];
const today = Date.vnNew();
const millisecsInDay = 86400000;
const daysInWeek = 7;
const nextWeek = new Date(today.getTime() + daysInWeek * millisecsInDay);
const newPrice = {
started: today,
ended: nextWeek,
hasMinPrice: 0,
};
fixedPricesOriginalData.value.push({ ...newPrice });
fixedPrices.value.push({ ...newPrice });
return;
}
const lastItemCopy = JSON.parse(
JSON.stringify(fixedPrices.value[fixedPrices.value.length - 1])
);
delete lastItemCopy.id;
fixedPricesOriginalData.value.push(lastItemCopy);
fixedPrices.value.push(lastItemCopy);
};
const openEditTableCellDialog = () => {
editTableCellDialogRef.value.show();
};
const onEditCellDataSaved = async () => {
rowsSelected.value = [];
await fetchFixedPrices();
};
const onWarehousesFetched = (data) => {
warehousesOptions.value = data;
// Actualiza las 'options' del elemento con field 'warehouseFk' en 'editTableFieldsOptions'.
const warehouseField = editTableFieldsOptions.find(
(field) => field.field === 'warehouseFk'
);
warehouseField.attrs.options = data;
};
const removePrice = async (id, rowIndex) => {
try {
await axios.delete(`FixedPrices/${id}`);
fixedPrices.value.splice(rowIndex, 1);
fixedPricesOriginalData.value.splice(rowIndex, 1);
notify(t('globals.dataSaved'), 'positive');
} catch (err) {
console.error('Error removing price', err);
}
};
const updateMinPrice = async (value, props) => { const updateMinPrice = async (value, props) => {
// El checkbox hasMinPrice se encuentra en la misma columna que el input hasMinPrice // El checkbox hasMinPrice se encuentra en la misma columna que el input hasMinPrice
// Por lo tanto le mandamos otro objeto con las mismas propiedades pero con el campo 'field' cambiado // Por lo tanto le mandamos otro objeto con las mismas propiedades pero con el campo 'field' cambiado
@ -354,64 +253,248 @@ const updateMinPrice = async (value, props) => {
}); });
}; };
onMounted(async () => { const upsertPrice = async (props, resetMinPrice = false) => {
stateStore.rightDrawer = true; try {
params.warehouseFk = user.value.warehouseFk; const { row } = props;
await fetchFixedPrices(); if (tableRef.value.CrudModelRef.getChanges().updates.length > 0) {
if (resetMinPrice) row.hasMinPrice = 0;
await upsertFixedPrice(row);
}
} catch (err) {
console.error('Error editing price', err);
}
};
async function upsertFixedPrice(row) {
try {
const { data } = await axios.patch('FixedPrices/upsertFixedPrice', row);
return data;
} catch (err) {
console.error('Error editing price', err);
}
}
async function saveOnRowChange(row) {
if (rowsSelected.value.length > 1) return;
if (rowsSelected.value[0]?.id === row.id) return;
else if (rowsSelected.value.length === 1) await upsertPrice(rowsSelected.value[0]);
rowsSelected.value = [row];
}
function checkLastVisibleRow() {
let lastVisibleRow = null;
getTableRows().forEach((row, index) => {
const rect = row.getBoundingClientRect();
if (rect.top >= 0 && rect.bottom <= window.innerHeight) {
lastVisibleRow = index;
}
}); });
onUnmounted(() => (stateStore.rightDrawer = false)); return lastVisibleRow;
}
const addRow = (original = null) => {
let copy = null;
if (!original) {
const today = Date.vnNew();
const millisecsInDay = 86400000;
const daysInWeek = 7;
const nextWeek = new Date(today.getTime() + daysInWeek * millisecsInDay);
copy = {
id: 0,
started: today,
ended: nextWeek,
hasMinPrice: 0,
$index: 0,
};
} else
copy = {
$index: original.$index - 1,
itemFk: original.itemFk,
name: original.name,
subName: original.subName,
value5: original.value5,
value6: original.value6,
value7: original.value7,
value8: original.value8,
value9: original.value9,
value10: original.value10,
warehouseFk: original.warehouseFk,
rate2: original.rate2,
rate3: original.rate3,
hasMinPrice: original.hasMinPrice,
minPrice: original.minPrice,
started: Date.vnNew(),
ended: Date.vnNew(),
};
return { original, copy };
};
const getTableRows = () =>
document.getElementsByClassName('q-table')[0].querySelectorAll('tr.cursor-pointer');
function highlightNewRow({ $index: index }) {
const row = getTableRows()[index];
if (row) {
row.classList.add('highlight');
setTimeout(() => {
row.classList.remove('highlight');
}, 3000); // Duración de la animación en milisegundos
}
}
const openEditTableCellDialog = () => {
editTableCellDialogRef.value.show();
};
const onEditCellDataSaved = async () => {
rowsSelected.value = [];
tableRef.value.reload();
};
const removeFuturePrice = async () => {
try {
rowsSelected.value.forEach(({ id }) => {
const rowIndex = fixedPrices.value.findIndex(({ id }) => id === id);
removePrice(id, rowIndex);
});
} catch (err) {
console.error('Error removing price', err);
}
};
function confirmRemove(item, isFuture) {
const promise = async () =>
isFuture ? removeFuturePrice(item.id) : removePrice(item.id);
quasar.dialog({
component: VnConfirm,
componentProps: {
title: t('globals.rowWillBeRemoved'),
message: t('globals.confirmDeletion'),
promise,
},
});
}
const removePrice = async (id) => {
try {
await axios.delete(`FixedPrices/${id}`);
notify(t('globals.dataSaved'), 'positive');
tableRef.value.reload({});
} catch (err) {
console.error('Error removing price', err);
}
};
const dateStyle = (date) =>
date
? {
'bg-color': 'warning',
'is-outlined': true,
}
: {};
function handleOnDataSave({ CrudModelRef }) {
const { original, copy } = addRow(CrudModelRef.formData[checkLastVisibleRow()]);
if (original) {
CrudModelRef.formData.splice(original?.$index ?? 0, 0, copy);
} else {
CrudModelRef.insert(copy);
}
nextTick(() => {
highlightNewRow(original ?? { $index: 0 });
});
}
</script> </script>
<template> <template>
<FetchData <FetchData
url="Warehouses" @on-fetch="(data) => (warehousesOptions = data)"
:filter="{ order: ['name'] }"
auto-load auto-load
@on-fetch="(data) => onWarehousesFetched(data)" url="Warehouses"
:filter="{ fields: ['id', 'name'], order: 'name ASC', limit: 30 }"
/> />
<RightMenu> <RightMenu>
<template #right-panel> <template #right-panel>
<ItemFixedPriceFilter <ItemFixedPriceFilter
data-key="ItemFixedPrices" data-key="ItemFixedPrices"
:warehouses-options="warehousesOptions" ref="itemFixedPriceFilterRef"
/> />
</template> </template>
</RightMenu> </RightMenu>
<QPage class="column items-center q-pa-md"> <VnSubToolbar>
<QTable <template #st-data>
:rows="fixedPrices" <QBtn
:columns="columns" v-if="rowsSelected.length"
row-key="id" @click="openEditTableCellDialog()"
selection="multiple" color="primary"
v-model:selected="rowsSelected" icon="edit"
:pagination="{ rowsPerPage: 0 }"
class="full-width q-mt-md"
:no-data-label="t('globals.noResults')"
> >
<template #top-row="{ cols }"> <QTooltip>
<QTr> {{ t('Edit fixed price(s)') }}
<QTd /> </QTooltip>
<QTd </QBtn>
v-for="(col, index) in cols" <QBtn
:key="index" :label="tMobile('globals.remove')"
style="max-width: 100px" color="primary"
> icon="delete"
<component flat
:is="col.columnFilter.component" @click="(row) => confirmRemove(row, true)"
v-if="col.columnFilter" :title="t('globals.remove')"
v-model="col.columnFilter.filterValue" v-if="rowsSelected.length"
v-bind="col.columnFilter.attrs"
v-on="col.columnFilter.event(col)"
dense
/> />
</QTd> </template>
</QTr> </VnSubToolbar>
<QPage>
<VnTable
@on-fetch="
(data) =>
data.forEach((item) => {
item.hasMinPrice = `${item.hasMinPrice !== 0}`;
})
"
:default-remove="false"
:default-reset="false"
:default-save="false"
data-key="ItemFixedPrices"
url="FixedPrices/filter"
:order="['itemFk ASC']"
save-url="FixedPrices/crud"
:user-params="{ warehouseFk: user.warehouseFk }"
ref="tableRef"
dense
:columns="columns"
default-mode="table"
auto-load
:is-editable="true"
:right-search="false"
:table="{
'row-key': 'id',
selection: 'multiple',
}"
:crud-model="{
paginate: false,
}"
v-model:selected="rowsSelected"
:row-click="saveOnRowChange"
:create-as-dialog="false"
:create="{
onDataSaved: handleOnDataSave,
}"
:use-model="true"
:disable-option="{ card: true }"
>
<template #header-selection="scope">
<QCheckbox v-model="scope.selected" />
</template>
<template #body-selection="scope">
{{ scope }}
<QCheckbox flat v-model="scope.selected" />
</template> </template>
<template #body-cell-itemId="props"> <template #column-itemId="props">
<QTd>
<VnSelect <VnSelect
style="max-width: 100px"
url="Items/withName" url="Items/withName"
hide-selected hide-selected
option-label="id" option-label="id"
@ -428,87 +511,74 @@ onUnmounted(() => (stateStore.rightDrawer = false));
</QItem> </QItem>
</template> </template>
</VnSelect> </VnSelect>
</QTd>
</template> </template>
<template #body-cell-description="{ row }"> <template #column-description="{ row }">
<QTd class="col">
<span class="link"> <span class="link">
{{ row.name }} {{ row.name }}
</span> </span>
<span class="subName">{{ row.subName }}</span>
<ItemDescriptorProxy :id="row.itemFk" /> <ItemDescriptorProxy :id="row.itemFk" />
<FetchedTags :item="row" /> <FetchedTags style="width: max-content; max-width: 220px" :item="row" />
</QTd>
</template> </template>
<template #body-cell-groupingPrice="props"> <template #column-rate2="props">
<QTd class="col">
<VnInput <VnInput
mask="###.##"
v-model.number="props.row.rate2" v-model.number="props.row.rate2"
v-on="getRowUpdateInputEvents(props)" v-on="getRowUpdateInputEvents(props)"
> >
<template #append></template> <template #append></template>
</VnInput> </VnInput>
</QTd>
</template> </template>
<template #body-cell-packingPrice="props"> <template #column-rate3="props">
<QTd class="col">
<VnInput <VnInput
mask="###.##"
v-model.number="props.row.rate3" v-model.number="props.row.rate3"
v-on="getRowUpdateInputEvents(props)" v-on="getRowUpdateInputEvents(props)"
> >
<template #append></template> <template #append></template>
</VnInput> </VnInput>
</QTd>
</template> </template>
<template #body-cell-minPrice="props"> <template #column-minPrice="props">
<QTd class="col"> <QTd class="col">
<div class="row"> <div class="row" style="width: 115px">
<QCheckbox <QCheckbox
class="col"
:model-value="props.row.hasMinPrice" :model-value="props.row.hasMinPrice"
@update:model-value="updateMinPrice($event, props)" @update:model-value="updateMinPrice($event, props)"
:false-value="0" :false-value="'false'"
:true-value="1" :true-value="'true'"
:toggle-indeterminate="false"
/> />
<VnInput <VnInput
class="col" class="col"
:disable="!props.row.hasMinPrice" :disable="props.row.hasMinPrice === 1"
v-model.number="props.row.minPrice" v-model.number="props.row.minPrice"
v-on="getRowUpdateInputEvents(props)" v-on="getRowUpdateInputEvents(props)"
type="number" >
/> <template #append></template>
</VnInput>
</div> </div>
</QTd> </QTd>
</template> </template>
<template #body-cell-started="props"> <template #column-started="props">
<QTd class="col" style="min-width: 160px">
<VnInputDate <VnInputDate
class="vnInputDate"
:show-event="true"
v-model="props.row.started" v-model="props.row.started"
v-on="getRowUpdateInputEvents(props, false, 'date')" v-on="getRowUpdateInputEvents(props, false, 'date')"
v-bind=" v-bind="dateStyle(isBigger(props.row.started))"
isBigger(props.row.started)
? { 'bg-color': 'warning', 'is-outlined': true }
: {}
"
/> />
</QTd>
</template> </template>
<template #body-cell-ended="props"> <template #column-ended="props">
<QTd class="col" style="min-width: 150px">
<VnInputDate <VnInputDate
class="vnInputDate"
:show-event="true"
v-model="props.row.ended" v-model="props.row.ended"
v-on="getRowUpdateInputEvents(props, false, 'date')" v-on="getRowUpdateInputEvents(props, false, 'date')"
v-bind=" v-bind="dateStyle(isLower(props.row.ended))"
isLower(props.row.ended)
? { 'bg-color': 'warning', 'is-outlined': true }
: {}
"
/> />
</QTd>
</template> </template>
<template #body-cell-warehouse="props"> <template #column-warehouseFk="props">
<QTd class="col">
<VnSelect <VnSelect
style="max-width: 150px"
:options="warehousesOptions" :options="warehousesOptions"
hide-selected hide-selected
option-label="name" option-label="name"
@ -516,10 +586,8 @@ onUnmounted(() => (stateStore.rightDrawer = false));
v-model="props.row.warehouseFk" v-model="props.row.warehouseFk"
v-on="getRowUpdateInputEvents(props, false, 'select')" v-on="getRowUpdateInputEvents(props, false, 'select')"
/> />
</QTd>
</template> </template>
<template #body-cell-deleteAction="{ row, rowIndex }"> <template #column-deleteAction="{ row, rowIndex }">
<QTd class="col">
<QIcon <QIcon
name="delete" name="delete"
size="sm" size="sm"
@ -527,40 +595,19 @@ onUnmounted(() => (stateStore.rightDrawer = false));
color="primary" color="primary"
@click.stop=" @click.stop="
openConfirmationModal( openConfirmationModal(
t('This row will be removed'), t('globals.rowWillBeRemoved'),
t('Do you want to clone this item?'), t('Do you want to clone this item?'),
() => removePrice(row.id, rowIndex) () => removePrice(row.id, rowIndex)
) )
" "
> >
<QTooltip class="text-no-wrap"> <QTooltip class="text-no-wrap">
{{ t('Delete') }} {{ t('globals.delete') }}
</QTooltip> </QTooltip>
</QIcon> </QIcon>
</QTd>
</template> </template>
<template #bottom-row> </VnTable>
<QTd align="center">
<QIcon
@click.stop="addRow()"
class="fill-icon-on-hover"
color="primary"
name="add_circle"
size="sm"
>
<QTooltip>
{{ t('Add fixed price') }}
</QTooltip>
</QIcon>
</QTd>
</template>
</QTable>
<QPageSticky v-if="rowsSelected.length" :offset="[20, 20]">
<QBtn @click="openEditTableCellDialog()" color="primary" fab icon="edit" />
<QTooltip>
{{ t('Edit fixed price(s)') }}
</QTooltip>
</QPageSticky>
<QDialog ref="editTableCellDialogRef"> <QDialog ref="editTableCellDialogRef">
<EditTableCellValueForm <EditTableCellValueForm
edit-url="FixedPrices/editFixedPrice" edit-url="FixedPrices/editFixedPrice"
@ -571,12 +618,56 @@ onUnmounted(() => (stateStore.rightDrawer = false));
</QDialog> </QDialog>
</QPage> </QPage>
</template> </template>
<style lang="scss">
.q-table th,
.q-table td {
padding-inline: 5px !important;
// text-align: -webkit-right;
}
.q-table tbody td {
max-width: none;
.q-td.col {
& .vnInputDate {
min-width: 90px;
}
& div.row {
& .q-checkbox {
& .q-checkbox__inner {
position: relative !important;
&.q-checkbox__inner--truthy {
color: var(--q-primary);
}
}
}
}
}
}
.q-field__after,
.q-field__append {
padding: 0;
}
tbody tr.highlight .q-td {
animation: highlight-animation 4s ease-in-out;
}
@keyframes highlight-animation {
0% {
background-color: $primary-light;
}
100% {
background-color: transparent;
}
}
.subName {
margin-left: 5%;
font-size: 0.75rem;
text-transform: uppercase;
color: var(--vn-label-color);
}
</style>
<i18n> <i18n>
es: es:
Add fixed price: Añadir precio fijado Add fixed price: Añadir precio fijado
Edit fixed price(s): Editar precio(s) fijado(s) Edit fixed price(s): Editar precio(s) fijado(s)
This row will be removed: Esta linea se eliminará
Are you sure you want to continue?: ¿Seguro que quieres continuar?
Delete: Eliminar
</i18n> </i18n>

View File

@ -9,18 +9,29 @@ import ItemsFilterPanel from 'src/components/ItemsFilterPanel.vue';
const { t } = useI18n(); const { t } = useI18n();
defineProps({ const props = defineProps({
dataKey: { dataKey: {
type: String, type: String,
required: true, required: true,
}, },
warehousesOptions: {
type: Array,
default: () => [],
},
}); });
const itemTypeWorkersOptions = ref([]); const itemTypeWorkersOptions = ref([]);
const exprBuilder = (param, value) => {
switch (param) {
case 'name':
return { 'i.name': { like: `%${value}%` } };
case 'itemFk':
case 'warehouseFk':
case 'rate2':
case 'rate3':
param = `fp.${param}`;
return { [param]: value };
case 'minPrice':
param = `i.${param}`;
return { [param]: value };
}
};
</script> </script>
<template> <template>
@ -31,7 +42,7 @@ const itemTypeWorkersOptions = ref([]);
:filter="{ fields: ['id', 'nickname'], order: 'nickname ASC', limit: 30 }" :filter="{ fields: ['id', 'nickname'], order: 'nickname ASC', limit: 30 }"
@on-fetch="(data) => (itemTypeWorkersOptions = data)" @on-fetch="(data) => (itemTypeWorkersOptions = data)"
/> />
<ItemsFilterPanel :data-key="dataKey" :custom-tags="['tags']"> <ItemsFilterPanel :data-key="props.dataKey" :custom-tags="['tags']">
<template #body="{ params, searchFn }"> <template #body="{ params, searchFn }">
<QItem class="q-my-md"> <QItem class="q-my-md">
<QItemSection> <QItemSection>
@ -52,9 +63,11 @@ const itemTypeWorkersOptions = ref([]);
<QItem class="q-my-md"> <QItem class="q-my-md">
<QItemSection> <QItemSection>
<VnSelect <VnSelect
url="Warehouses"
auto-load
:filter="{ fields: ['id', 'name'], order: 'name ASC', limit: 30 }"
:label="t('components.itemsFilterPanel.warehouseFk')" :label="t('components.itemsFilterPanel.warehouseFk')"
v-model="params.warehouseFk" v-model="params.warehouseFk"
:options="warehousesOptions"
option-label="name" option-label="name"
option-value="id" option-value="id"
dense dense
@ -93,8 +106,15 @@ const itemTypeWorkersOptions = ref([]);
toggle-indeterminate toggle-indeterminate
@update:model-value="searchFn()" @update:model-value="searchFn()"
/> />
</QItemSection>
<QItemSection> <QCheckbox
v-model="params.showBadDates"
:label="t(`components.itemsFilterPanel.showBadDates`)"
toggle-indeterminate
@update:model-value="searchFn()"
>
</QCheckbox>
<QCheckbox <QCheckbox
:label="t('components.itemsFilterPanel.hasMinPrice')" :label="t('components.itemsFilterPanel.hasMinPrice')"
v-model="params.hasMinPrice" v-model="params.hasMinPrice"

View File

@ -23,7 +23,7 @@ function confirmRemove() {
.dialog({ .dialog({
component: VnConfirm, component: VnConfirm,
componentProps: { componentProps: {
title: t('confirmDeletion'), title: t('globals.confirmDeletion'),
message: t('confirmDeletionMessage'), message: t('confirmDeletionMessage'),
promise: remove, promise: remove,
}, },
@ -52,12 +52,10 @@ async function remove() {
<i18n> <i18n>
en: en:
deleteOrder: Delete order deleteOrder: Delete order
confirmDeletion: Confirm deletion
confirmDeletionMessage: Are you sure you want to delete this order? confirmDeletionMessage: Are you sure you want to delete this order?
es: es:
deleteOrder: Eliminar pedido deleteOrder: Eliminar pedido
confirmDeletion: Confirmar eliminación
confirmDeletionMessage: Seguro que quieres eliminar este pedido? confirmDeletionMessage: Seguro que quieres eliminar este pedido?
</i18n> </i18n>

View File

@ -426,7 +426,11 @@ function toTicketUrl(section) {
<QTd> <QTd>
<QBtn class="link" flat> <QBtn class="link" flat>
{{ props.row.itemFk }} {{ props.row.itemFk }}
<ItemDescriptorProxy :id="props.row.itemFk" /> <ItemDescriptorProxy
:id="props.row.itemFk"
:sale-fk="props.row.id"
:warehouse-fk="ticket.warehouseFk"
/>
</QBtn> </QBtn>
</QTd> </QTd>
<QTd> <QTd>

View File

@ -1,12 +1,11 @@
<script setup> <script setup>
import { computed, ref, watch } from 'vue'; import { computed, ref } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import CardDescriptor from 'src/components/ui/CardDescriptor.vue'; import CardDescriptor from 'src/components/ui/CardDescriptor.vue';
import VnLv from 'src/components/ui/VnLv.vue'; import VnLv from 'src/components/ui/VnLv.vue';
import VnLinkPhone from 'src/components/ui/VnLinkPhone.vue'; import VnLinkPhone from 'src/components/ui/VnLinkPhone.vue';
import WorkerChangePasswordForm from 'src/pages/Worker/Card/WorkerChangePasswordForm.vue'; import WorkerChangePasswordForm from 'src/pages/Worker/Card/WorkerChangePasswordForm.vue';
import useCardDescription from 'src/composables/useCardDescription';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
import axios from 'axios'; import axios from 'axios';
import VnImg from 'src/components/ui/VnImg.vue'; import VnImg from 'src/components/ui/VnImg.vue';
@ -39,18 +38,6 @@ const entityId = computed(() => {
const worker = ref(); const worker = ref();
const workerExcluded = ref(false); const workerExcluded = ref(false);
const sip = ref(null);
watch(
() => [worker.value?.sip?.extension, state.get('extension')],
([newWorkerSip, newStateExtension], [oldWorkerSip, oldStateExtension]) => {
if (newStateExtension !== oldStateExtension || sip.value === oldStateExtension) {
sip.value = newStateExtension;
} else if (newWorkerSip !== oldWorkerSip && sip.value !== newStateExtension) {
sip.value = newWorkerSip;
}
}
);
const getIsExcluded = async () => { const getIsExcluded = async () => {
try { try {
const { data } = await axios.get( const { data } = await axios.get(
@ -176,10 +163,10 @@ const refetch = async () => await cardDescriptorRef.value.getData();
<VnLinkPhone :phone-number="entity.phone" /> <VnLinkPhone :phone-number="entity.phone" />
</template> </template>
</VnLv> </VnLv>
<VnLv :value="sip"> <VnLv :value="worker?.sip?.extension">
<template #label> <template #label>
{{ t('worker.summary.sipExtension') }} {{ t('worker.summary.sipExtension') }}
<VnLinkPhone v-if="sip" :phone-number="sip" /> <VnLinkPhone :phone-number="worker?.sip?.extension" />
</template> </template>
</VnLv> </VnLv>
</template> </template>

View File

@ -7,6 +7,7 @@ export default {
title: 'suppliers', title: 'suppliers',
icon: 'vn:supplier', icon: 'vn:supplier',
moduleName: 'Supplier', moduleName: 'Supplier',
keyBinding: 'p',
}, },
component: RouterView, component: RouterView,
redirect: { name: 'SupplierMain' }, redirect: { name: 'SupplierMain' },

View File

@ -7,6 +7,7 @@ export default {
title: 'users', title: 'users',
icon: 'face', icon: 'face',
moduleName: 'Account', moduleName: 'Account',
keyBinding: 'u',
}, },
component: RouterView, component: RouterView,
redirect: { name: 'AccountMain' }, redirect: { name: 'AccountMain' },

View File

@ -7,6 +7,7 @@ export default {
title: 'claims', title: 'claims',
icon: 'vn:claims', icon: 'vn:claims',
moduleName: 'Claim', moduleName: 'Claim',
keyBinding: 'r',
}, },
component: RouterView, component: RouterView,
redirect: { name: 'ClaimMain' }, redirect: { name: 'ClaimMain' },

View File

@ -7,6 +7,7 @@ export default {
title: 'customers', title: 'customers',
icon: 'vn:client', icon: 'vn:client',
moduleName: 'Customer', moduleName: 'Customer',
keyBinding: 'c',
}, },
component: RouterView, component: RouterView,
redirect: { name: 'CustomerMain' }, redirect: { name: 'CustomerMain' },

View File

@ -7,6 +7,7 @@ export default {
title: 'entries', title: 'entries',
icon: 'vn:entry', icon: 'vn:entry',
moduleName: 'Entry', moduleName: 'Entry',
keyBinding: 'e',
}, },
component: RouterView, component: RouterView,
redirect: { name: 'EntryMain' }, redirect: { name: 'EntryMain' },

View File

@ -1,5 +1,5 @@
import { RouterView } from 'vue-router'; import { RouterView } from 'vue-router';
import { setRectificative } from 'src/pages/InvoiceIn/composables/setRectificative';
export default { export default {
path: '/invoice-in', path: '/invoice-in',
name: 'InvoiceIn', name: 'InvoiceIn',
@ -63,6 +63,10 @@ export default {
path: ':id', path: ':id',
component: () => import('src/pages/InvoiceIn/Card/InvoiceInCard.vue'), component: () => import('src/pages/InvoiceIn/Card/InvoiceInCard.vue'),
redirect: { name: 'InvoiceInSummary' }, redirect: { name: 'InvoiceInSummary' },
beforeEnter: async (to, from, next) => {
await setRectificative(to);
next();
},
children: [ children: [
{ {
name: 'InvoiceInSummary', name: 'InvoiceInSummary',

View File

@ -7,6 +7,7 @@ export default {
title: 'items', title: 'items',
icon: 'vn:item', icon: 'vn:item',
moduleName: 'Item', moduleName: 'Item',
keyBinding: 'a',
}, },
component: RouterView, component: RouterView,
redirect: { name: 'ItemMain' }, redirect: { name: 'ItemMain' },

View File

@ -7,6 +7,7 @@ export default {
title: 'monitors', title: 'monitors',
icon: 'grid_view', icon: 'grid_view',
moduleName: 'Monitor', moduleName: 'Monitor',
keyBinding: 'm',
}, },
component: RouterView, component: RouterView,
redirect: { name: 'MonitorMain' }, redirect: { name: 'MonitorMain' },

View File

@ -7,6 +7,7 @@ export default {
title: 'order', title: 'order',
icon: 'vn:basket', icon: 'vn:basket',
moduleName: 'Order', moduleName: 'Order',
keyBinding: 'o',
}, },
component: RouterView, component: RouterView,
redirect: { name: 'OrderMain' }, redirect: { name: 'OrderMain' },

View File

@ -7,7 +7,6 @@ export default {
title: 'routes', title: 'routes',
icon: 'vn:delivery', icon: 'vn:delivery',
moduleName: 'Route', moduleName: 'Route',
keyBinding: 'r',
}, },
component: RouterView, component: RouterView,
redirect: { name: 'RouteMain' }, redirect: { name: 'RouteMain' },

View File

@ -7,6 +7,7 @@ export default {
title: 'tickets', title: 'tickets',
icon: 'vn:ticket', icon: 'vn:ticket',
moduleName: 'Ticket', moduleName: 'Ticket',
keyBinding: 't',
}, },
component: RouterView, component: RouterView,
redirect: { name: 'TicketMain' }, redirect: { name: 'TicketMain' },

View File

@ -7,6 +7,7 @@ export default {
title: 'workers', title: 'workers',
icon: 'vn:worker', icon: 'vn:worker',
moduleName: 'Worker', moduleName: 'Worker',
keyBinding: 'w',
}, },
component: RouterView, component: RouterView,
redirect: { name: 'WorkerMain' }, redirect: { name: 'WorkerMain' },

View File

@ -7,6 +7,7 @@ export default {
title: 'zones', title: 'zones',
icon: 'vn:zone', icon: 'vn:zone',
moduleName: 'Zone', moduleName: 'Zone',
keyBinding: 'z',
}, },
component: RouterView, component: RouterView,
redirect: { name: 'ZoneMain' }, redirect: { name: 'ZoneMain' },

View File

@ -56,6 +56,7 @@ export const useNavigationStore = defineStore('navigationStore', () => {
function addMenuItem(module, route, parent) { function addMenuItem(module, route, parent) {
const { meta } = route; const { meta } = route;
let { menuChildren = null } = meta; let { menuChildren = null } = meta;
if (meta.hidden) return;
if (menuChildren) if (menuChildren)
menuChildren = menuChildren.map(({ name, title, icon }) => ({ menuChildren = menuChildren.map(({ name, title, icon }) => ({
name, name,
@ -72,6 +73,7 @@ export const useNavigationStore = defineStore('navigationStore', () => {
if (meta) { if (meta) {
item.title = `globals.pageTitles.${meta.title}`; item.title = `globals.pageTitles.${meta.title}`;
item.icon = meta.icon; item.icon = meta.icon;
item.keyBinding = meta.keyBinding;
} }
parent.push(item); parent.push(item);

View File

@ -36,8 +36,7 @@ describe('InvoiceInBasicData', () => {
}); });
it('should throw an error creating a new dms if a file is not attached', () => { it('should throw an error creating a new dms if a file is not attached', () => {
cy.get(formInputs).eq(5).click(); cy.get(formInputs).eq(7).type('{selectall}{backspace}');
cy.get(formInputs).eq(5).type('{selectall}{backspace}');
cy.get(documentBtns).eq(0).click(); cy.get(documentBtns).eq(0).click();
cy.get(dialogActionBtns).eq(1).click(); cy.get(dialogActionBtns).eq(1).click();
cy.get('.q-notification__message').should( cy.get('.q-notification__message').should(

View File

@ -3,13 +3,14 @@ describe('InvoiceInVat', () => {
const thirdRow = 'tbody > :nth-child(3)'; const thirdRow = 'tbody > :nth-child(3)';
const firstLineVat = 'tbody > :nth-child(1) > :nth-child(4)'; const firstLineVat = 'tbody > :nth-child(1) > :nth-child(4)';
const dialogInputs = '.q-dialog label input'; const dialogInputs = '.q-dialog label input';
const dialogBtns = '.q-dialog button'; const addBtn = 'tbody tr:nth-child(1) td:nth-child(2) .--add-icon';
const acrossInput = 'tbody tr:nth-child(1) td:nth-child(2) .default-icon';
const randomInt = Math.floor(Math.random() * 100); const randomInt = Math.floor(Math.random() * 100);
beforeEach(() => { beforeEach(() => {
cy.login('developer'); cy.login('developer');
cy.visit(`/#/invoice-in/1/vat`); cy.visit(`/#/invoice-in/1/vat`);
cy.intercept('GET', '/api/InvoiceIns/1/getTotals').as('lastCall');
cy.wait('@lastCall');
}); });
it('should edit the sage iva', () => { it('should edit the sage iva', () => {
@ -26,22 +27,15 @@ describe('InvoiceInVat', () => {
}); });
it('should remove the first line', () => { it('should remove the first line', () => {
cy.removeRow(2); cy.removeRow(1);
});
it('should throw an error if there are fields undefined', () => {
cy.get(acrossInput).click();
cy.get(dialogBtns).eq(2).click();
cy.get('.q-notification__message').should('have.text', "The code can't be empty");
}); });
it('should correctly handle expense addition', () => { it('should correctly handle expense addition', () => {
cy.get(acrossInput).click(); cy.get(addBtn).click();
cy.get(dialogInputs).eq(0).type(randomInt); cy.get(dialogInputs).eq(0).type(randomInt);
cy.get(dialogInputs).eq(1).click();
cy.get(dialogInputs).eq(1).type('This is a dummy expense'); cy.get(dialogInputs).eq(1).type('This is a dummy expense');
cy.get(dialogBtns).eq(2).click(); cy.get('button[type="submit"]').click();
cy.get('.q-notification__message').should('have.text', 'Data saved'); cy.get('.q-notification__message').should('have.text', 'Data created');
}); });
}); });

View File

@ -9,6 +9,7 @@ describe('Ticket descriptor', () => {
cy.login('developer'); cy.login('developer');
cy.visit(`/#/ticket/${ticketId}/summary`); cy.visit(`/#/ticket/${ticketId}/summary`);
cy.waitForElement('.q-page', 7000);
}); });
it('should clone the ticket without warehouse', () => { it('should clone the ticket without warehouse', () => {

View File

@ -0,0 +1,33 @@
/// <reference types="cypress" />
describe('VnShortcuts', () => {
const modules = {
item: 'a',
customer: 'c',
ticket: 't',
claim: 'r',
worker: 'w',
monitor: 'm',
order: 'o',
supplier: 'p',
entry: 'e',
zone: 'z',
account: 'u',
};
beforeEach(() => {
cy.login('developer');
cy.visit('/');
});
for (const [module, shortcut] of Object.entries(modules)) {
it(`should visit ${module} module`, () => {
cy.get('body').trigger('keydown', {
ctrlKey: true,
altKey: true,
code: `Key${shortcut.toUpperCase()}`,
});
cy.url().should('include', module);
});
}
});

View File

@ -3,6 +3,7 @@ describe('WagonTypeCreate', () => {
cy.viewport(1920, 1080); cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit('/#/wagon/type/create'); cy.visit('/#/wagon/type/create');
cy.waitForElement('.q-page', 6000);
}); });
function chooseColor(color) { function chooseColor(color) {