forked from verdnatura/salix-front
Reviewed-on: verdnatura/salix-front#674 Reviewed-by: Javier Segarra <jsegarra@verdnatura.es>
This commit is contained in:
commit
1b8a72175c
|
@ -0,0 +1,173 @@
|
||||||
|
<script setup>
|
||||||
|
import { ref, reactive } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
import { useDialogPluginComponent } from 'quasar';
|
||||||
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
|
import FetchData from 'components/FetchData.vue';
|
||||||
|
import VnSelect from 'components/common/VnSelect.vue';
|
||||||
|
import FormPopup from './FormPopup.vue';
|
||||||
|
import axios from 'axios';
|
||||||
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
|
|
||||||
|
const $props = defineProps({
|
||||||
|
invoiceOutData: {
|
||||||
|
type: Object,
|
||||||
|
default: () => {},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const { dialogRef } = useDialogPluginComponent();
|
||||||
|
const { t } = useI18n();
|
||||||
|
const router = useRouter();
|
||||||
|
const { notify } = useNotify();
|
||||||
|
|
||||||
|
const rectificativeTypeOptions = ref([]);
|
||||||
|
const siiTypeInvoiceOutsOptions = ref([]);
|
||||||
|
const inheritWarehouse = ref(true);
|
||||||
|
const invoiceParams = reactive({
|
||||||
|
id: $props.invoiceOutData?.id,
|
||||||
|
});
|
||||||
|
const invoiceCorrectionTypesOptions = ref([]);
|
||||||
|
|
||||||
|
const refund = async () => {
|
||||||
|
const params = {
|
||||||
|
id: invoiceParams.id,
|
||||||
|
cplusRectificationTypeFk: invoiceParams.cplusRectificationTypeFk,
|
||||||
|
siiTypeInvoiceOutFk: invoiceParams.siiTypeInvoiceOutFk,
|
||||||
|
invoiceCorrectionTypeFk: invoiceParams.invoiceCorrectionTypeFk,
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { data } = await axios.post('InvoiceOuts/refundAndInvoice', params);
|
||||||
|
notify(t('Refunded invoice'), 'positive');
|
||||||
|
const [id] = data?.refundId || [];
|
||||||
|
if (id) router.push({ name: 'InvoiceOutSummary', params: { id } });
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error refunding invoice', err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<FetchData
|
||||||
|
url="CplusRectificationTypes"
|
||||||
|
:filter="{ order: 'description' }"
|
||||||
|
@on-fetch="
|
||||||
|
(data) => (
|
||||||
|
(rectificativeTypeOptions = data),
|
||||||
|
(invoiceParams.cplusRectificationTypeFk = data.filter(
|
||||||
|
(type) => type.description == 'I – Por diferencias'
|
||||||
|
)[0].id)
|
||||||
|
)
|
||||||
|
"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
|
<FetchData
|
||||||
|
url="SiiTypeInvoiceOuts"
|
||||||
|
:filter="{ where: { code: { like: 'R%' } } }"
|
||||||
|
@on-fetch="
|
||||||
|
(data) => (
|
||||||
|
(siiTypeInvoiceOutsOptions = data),
|
||||||
|
(invoiceParams.siiTypeInvoiceOutFk = data.filter(
|
||||||
|
(type) => type.code == 'R4'
|
||||||
|
)[0].id)
|
||||||
|
)
|
||||||
|
"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
|
<FetchData
|
||||||
|
url="InvoiceCorrectionTypes"
|
||||||
|
@on-fetch="(data) => (invoiceCorrectionTypesOptions = data)"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
|
|
||||||
|
<QDialog ref="dialogRef">
|
||||||
|
<FormPopup
|
||||||
|
@on-submit="refund()"
|
||||||
|
:custom-submit-button-label="t('Accept')"
|
||||||
|
:default-cancel-button="false"
|
||||||
|
>
|
||||||
|
<template #form-inputs>
|
||||||
|
<VnRow>
|
||||||
|
<VnSelect
|
||||||
|
:label="t('Rectificative type')"
|
||||||
|
:options="rectificativeTypeOptions"
|
||||||
|
hide-selected
|
||||||
|
option-label="description"
|
||||||
|
option-value="id"
|
||||||
|
v-model="invoiceParams.cplusRectificationTypeFk"
|
||||||
|
:required="true"
|
||||||
|
/>
|
||||||
|
</VnRow>
|
||||||
|
<VnRow>
|
||||||
|
<VnSelect
|
||||||
|
:label="t('Class')"
|
||||||
|
:options="siiTypeInvoiceOutsOptions"
|
||||||
|
hide-selected
|
||||||
|
option-label="description"
|
||||||
|
option-value="id"
|
||||||
|
v-model="invoiceParams.siiTypeInvoiceOutFk"
|
||||||
|
:required="true"
|
||||||
|
>
|
||||||
|
<template #option="scope">
|
||||||
|
<QItem v-bind="scope.itemProps">
|
||||||
|
<QItemSection>
|
||||||
|
<QItemLabel>
|
||||||
|
{{ scope.opt?.code }} -
|
||||||
|
{{ scope.opt?.description }}
|
||||||
|
</QItemLabel>
|
||||||
|
</QItemSection>
|
||||||
|
</QItem>
|
||||||
|
</template>
|
||||||
|
</VnSelect>
|
||||||
|
</VnRow>
|
||||||
|
|
||||||
|
<VnRow>
|
||||||
|
<VnSelect
|
||||||
|
:label="t('Type')"
|
||||||
|
:options="invoiceCorrectionTypesOptions"
|
||||||
|
hide-selected
|
||||||
|
option-label="description"
|
||||||
|
option-value="id"
|
||||||
|
v-model="invoiceParams.invoiceCorrectionTypeFk"
|
||||||
|
:required="true"
|
||||||
|
/> </VnRow
|
||||||
|
><VnRow>
|
||||||
|
<div>
|
||||||
|
<QCheckbox
|
||||||
|
:label="t('Inherit warehouse')"
|
||||||
|
v-model="inheritWarehouse"
|
||||||
|
/>
|
||||||
|
<QIcon name="info" class="cursor-info q-ml-sm" size="sm">
|
||||||
|
<QTooltip>{{ t('Inherit warehouse tooltip') }}</QTooltip>
|
||||||
|
</QIcon>
|
||||||
|
</div>
|
||||||
|
</VnRow>
|
||||||
|
</template>
|
||||||
|
</FormPopup>
|
||||||
|
</QDialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<i18n>
|
||||||
|
en:
|
||||||
|
Refund invoice: Refund invoice
|
||||||
|
Rectificative type: Rectificative type
|
||||||
|
Class: Class
|
||||||
|
Type: Type
|
||||||
|
Refunded invoice: Refunded invoice
|
||||||
|
Inherit warehouse: Inherit the warehouse
|
||||||
|
Inherit warehouse tooltip: Select this option to inherit the warehouse when refunding the invoice
|
||||||
|
Accept: Accept
|
||||||
|
Error refunding invoice: Error refunding invoice
|
||||||
|
es:
|
||||||
|
Refund invoice: Abonar factura
|
||||||
|
Rectificative type: Tipo rectificativa
|
||||||
|
Class: Clase
|
||||||
|
Type: Tipo
|
||||||
|
Refunded invoice: Factura abonada
|
||||||
|
Inherit warehouse: Heredar el almacén
|
||||||
|
Inherit warehouse tooltip: Seleccione esta opción para heredar el almacén al abonar la factura.
|
||||||
|
Accept: Aceptar
|
||||||
|
Error refunding invoice: Error abonando factura
|
||||||
|
</i18n>
|
|
@ -2,13 +2,12 @@
|
||||||
import { ref, reactive } from 'vue';
|
import { ref, reactive } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar, useDialogPluginComponent } from 'quasar';
|
||||||
import VnConfirm from 'components/ui/VnConfirm.vue';
|
import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
import FetchData from 'components/FetchData.vue';
|
import FetchData from 'components/FetchData.vue';
|
||||||
import VnSelect from 'components/common/VnSelect.vue';
|
import VnSelect from 'components/common/VnSelect.vue';
|
||||||
import FormPopup from './FormPopup.vue';
|
import FormPopup from './FormPopup.vue';
|
||||||
import { useDialogPluginComponent } from 'quasar';
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
|
|
||||||
|
@ -18,19 +17,19 @@ const $props = defineProps({
|
||||||
default: () => {},
|
default: () => {},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const { dialogRef } = useDialogPluginComponent();
|
const { dialogRef } = useDialogPluginComponent();
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
const checked = ref(true);
|
|
||||||
const transferInvoiceParams = reactive({
|
|
||||||
id: $props.invoiceOutData?.id,
|
|
||||||
refFk: $props.invoiceOutData?.ref,
|
|
||||||
});
|
|
||||||
|
|
||||||
const rectificativeTypeOptions = ref([]);
|
const rectificativeTypeOptions = ref([]);
|
||||||
const siiTypeInvoiceOutsOptions = ref([]);
|
const siiTypeInvoiceOutsOptions = ref([]);
|
||||||
|
const checked = ref(true);
|
||||||
|
const transferInvoiceParams = reactive({
|
||||||
|
id: $props.invoiceOutData?.id,
|
||||||
|
});
|
||||||
const invoiceCorrectionTypesOptions = ref([]);
|
const invoiceCorrectionTypesOptions = ref([]);
|
||||||
|
|
||||||
const selectedClient = (client) => {
|
const selectedClient = (client) => {
|
||||||
|
@ -44,10 +43,9 @@ const makeInvoice = async () => {
|
||||||
const params = {
|
const params = {
|
||||||
id: transferInvoiceParams.id,
|
id: transferInvoiceParams.id,
|
||||||
cplusRectificationTypeFk: transferInvoiceParams.cplusRectificationTypeFk,
|
cplusRectificationTypeFk: transferInvoiceParams.cplusRectificationTypeFk,
|
||||||
|
siiTypeInvoiceOutFk: transferInvoiceParams.siiTypeInvoiceOutFk,
|
||||||
invoiceCorrectionTypeFk: transferInvoiceParams.invoiceCorrectionTypeFk,
|
invoiceCorrectionTypeFk: transferInvoiceParams.invoiceCorrectionTypeFk,
|
||||||
newClientFk: transferInvoiceParams.newClientFk,
|
newClientFk: transferInvoiceParams.newClientFk,
|
||||||
refFk: transferInvoiceParams.refFk,
|
|
||||||
siiTypeInvoiceOutFk: transferInvoiceParams.siiTypeInvoiceOutFk,
|
|
||||||
makeInvoice: checked.value,
|
makeInvoice: checked.value,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,7 +72,7 @@ const makeInvoice = async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await axios.post('InvoiceOuts/transferInvoice', params);
|
const { data } = await axios.post('InvoiceOuts/transfer', params);
|
||||||
notify(t('Transferred invoice'), 'positive');
|
notify(t('Transferred invoice'), 'positive');
|
||||||
const id = data?.[0];
|
const id = data?.[0];
|
||||||
if (id) router.push({ name: 'InvoiceOutSummary', params: { id } });
|
if (id) router.push({ name: 'InvoiceOutSummary', params: { id } });
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { useRouter } from 'vue-router';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
|
|
||||||
import TransferInvoiceForm from 'src/components/TransferInvoiceForm.vue';
|
import TransferInvoiceForm from 'src/components/TransferInvoiceForm.vue';
|
||||||
|
import RefundInvoiceForm from 'src/components/RefundInvoiceForm.vue';
|
||||||
import SendEmailDialog from 'components/common/SendEmailDialog.vue';
|
import SendEmailDialog from 'components/common/SendEmailDialog.vue';
|
||||||
|
|
||||||
import useNotify from 'src/composables/useNotify';
|
import useNotify from 'src/composables/useNotify';
|
||||||
|
@ -141,6 +142,15 @@ const showTransferInvoiceForm = async () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const showRefundInvoiceForm = () => {
|
||||||
|
quasar.dialog({
|
||||||
|
component: RefundInvoiceForm,
|
||||||
|
componentProps: {
|
||||||
|
invoiceOutData: $props.invoiceOutData,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -229,10 +239,13 @@ const showTransferInvoiceForm = async () => {
|
||||||
<QMenu anchor="top end" self="top start">
|
<QMenu anchor="top end" self="top start">
|
||||||
<QList>
|
<QList>
|
||||||
<QItem v-ripple clickable @click="refundInvoice(true)">
|
<QItem v-ripple clickable @click="refundInvoice(true)">
|
||||||
<QItemSection>{{ t('With warehouse') }}</QItemSection>
|
<QItemSection>{{ t('With warehouse, no invoice') }}</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem v-ripple clickable @click="refundInvoice(false)">
|
<QItem v-ripple clickable @click="refundInvoice(false)">
|
||||||
<QItemSection>{{ t('Without warehouse') }}</QItemSection>
|
<QItemSection>{{ t('Without warehouse, no invoice') }}</QItemSection>
|
||||||
|
</QItem>
|
||||||
|
<QItem v-ripple clickable @click="showRefundInvoiceForm()">
|
||||||
|
<QItemSection>{{ t('Invoiced') }}</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
</QList>
|
</QList>
|
||||||
</QMenu>
|
</QMenu>
|
||||||
|
@ -255,8 +268,9 @@ es:
|
||||||
As CSV: como CSV
|
As CSV: como CSV
|
||||||
Send PDF: Enviar PDF
|
Send PDF: Enviar PDF
|
||||||
Send CSV: Enviar CSV
|
Send CSV: Enviar CSV
|
||||||
With warehouse: Con almacén
|
With warehouse, no invoice: Con almacén, sin factura
|
||||||
Without warehouse: Sin almacén
|
Without warehouse, no invoice: Sin almacén, sin factura
|
||||||
|
Invoiced: Facturado
|
||||||
InvoiceOut deleted: Factura eliminada
|
InvoiceOut deleted: Factura eliminada
|
||||||
Confirm deletion: Confirmar eliminación
|
Confirm deletion: Confirmar eliminación
|
||||||
Are you sure you want to delete this invoice?: Estas seguro de eliminar esta factura?
|
Are you sure you want to delete this invoice?: Estas seguro de eliminar esta factura?
|
||||||
|
|
Loading…
Reference in New Issue