forked from verdnatura/salix-front
Merge branch 'dev' into plus_key_shortcut
This commit is contained in:
commit
6321ed4ee2
|
@ -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 { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { useQuasar, useDialogPluginComponent } from 'quasar';
|
||||
import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||
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 { useDialogPluginComponent } from 'quasar';
|
||||
import axios from 'axios';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
|
||||
|
@ -18,19 +17,19 @@ const $props = defineProps({
|
|||
default: () => {},
|
||||
},
|
||||
});
|
||||
|
||||
const { dialogRef } = useDialogPluginComponent();
|
||||
const quasar = useQuasar();
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
const { notify } = useNotify();
|
||||
const checked = ref(true);
|
||||
const transferInvoiceParams = reactive({
|
||||
id: $props.invoiceOutData?.id,
|
||||
refFk: $props.invoiceOutData?.ref,
|
||||
});
|
||||
|
||||
const rectificativeTypeOptions = ref([]);
|
||||
const siiTypeInvoiceOutsOptions = ref([]);
|
||||
const checked = ref(true);
|
||||
const transferInvoiceParams = reactive({
|
||||
id: $props.invoiceOutData?.id,
|
||||
});
|
||||
const invoiceCorrectionTypesOptions = ref([]);
|
||||
|
||||
const selectedClient = (client) => {
|
||||
|
@ -44,10 +43,9 @@ const makeInvoice = async () => {
|
|||
const params = {
|
||||
id: transferInvoiceParams.id,
|
||||
cplusRectificationTypeFk: transferInvoiceParams.cplusRectificationTypeFk,
|
||||
siiTypeInvoiceOutFk: transferInvoiceParams.siiTypeInvoiceOutFk,
|
||||
invoiceCorrectionTypeFk: transferInvoiceParams.invoiceCorrectionTypeFk,
|
||||
newClientFk: transferInvoiceParams.newClientFk,
|
||||
refFk: transferInvoiceParams.refFk,
|
||||
siiTypeInvoiceOutFk: transferInvoiceParams.siiTypeInvoiceOutFk,
|
||||
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');
|
||||
const id = data?.[0];
|
||||
if (id) router.push({ name: 'InvoiceOutSummary', params: { id } });
|
||||
|
|
|
@ -5,6 +5,7 @@ import { useRouter } from 'vue-router';
|
|||
import { useQuasar } from 'quasar';
|
||||
|
||||
import TransferInvoiceForm from 'src/components/TransferInvoiceForm.vue';
|
||||
import RefundInvoiceForm from 'src/components/RefundInvoiceForm.vue';
|
||||
import SendEmailDialog from 'components/common/SendEmailDialog.vue';
|
||||
|
||||
import useNotify from 'src/composables/useNotify';
|
||||
|
@ -141,6 +142,15 @@ const showTransferInvoiceForm = async () => {
|
|||
},
|
||||
});
|
||||
};
|
||||
|
||||
const showRefundInvoiceForm = () => {
|
||||
quasar.dialog({
|
||||
component: RefundInvoiceForm,
|
||||
componentProps: {
|
||||
invoiceOutData: $props.invoiceOutData,
|
||||
},
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -229,10 +239,13 @@ const showTransferInvoiceForm = async () => {
|
|||
<QMenu anchor="top end" self="top start">
|
||||
<QList>
|
||||
<QItem v-ripple clickable @click="refundInvoice(true)">
|
||||
<QItemSection>{{ t('With warehouse') }}</QItemSection>
|
||||
<QItemSection>{{ t('With warehouse, no invoice') }}</QItemSection>
|
||||
</QItem>
|
||||
<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>
|
||||
</QList>
|
||||
</QMenu>
|
||||
|
@ -255,8 +268,9 @@ es:
|
|||
As CSV: como CSV
|
||||
Send PDF: Enviar PDF
|
||||
Send CSV: Enviar CSV
|
||||
With warehouse: Con almacén
|
||||
Without warehouse: Sin almacén
|
||||
With warehouse, no invoice: Con almacén, sin factura
|
||||
Without warehouse, no invoice: Sin almacén, sin factura
|
||||
Invoiced: Facturado
|
||||
InvoiceOut deleted: Factura eliminada
|
||||
Confirm deletion: Confirmar eliminación
|
||||
Are you sure you want to delete this invoice?: Estas seguro de eliminar esta factura?
|
||||
|
|
Loading…
Reference in New Issue