feat: refs #8277 add confirmation dialog for pre-accounting entries and update localization
gitea/salix-front/pipeline/pr-dev This commit is unstable
Details
gitea/salix-front/pipeline/pr-dev This commit is unstable
Details
This commit is contained in:
parent
6fd7e6e875
commit
a1840f14df
|
@ -89,24 +89,26 @@ function cancel() {
|
|||
<slot name="customHTML"></slot>
|
||||
</QCardSection>
|
||||
<QCardActions align="right">
|
||||
<QBtn
|
||||
:label="t('globals.cancel')"
|
||||
color="primary"
|
||||
:disable="isLoading"
|
||||
flat
|
||||
@click="cancel()"
|
||||
data-cy="VnConfirm_cancel"
|
||||
/>
|
||||
<QBtn
|
||||
:label="t('globals.confirm')"
|
||||
:title="t('globals.confirm')"
|
||||
color="primary"
|
||||
:loading="isLoading"
|
||||
@click="confirm()"
|
||||
unelevated
|
||||
autofocus
|
||||
data-cy="VnConfirm_confirm"
|
||||
/>
|
||||
<slot name="actions" :actions="{ confirm, cancel }">
|
||||
<QBtn
|
||||
:label="t('globals.cancel')"
|
||||
color="primary"
|
||||
:disable="isLoading"
|
||||
flat
|
||||
@click="cancel()"
|
||||
data-cy="VnConfirm_cancel"
|
||||
/>
|
||||
<QBtn
|
||||
:label="t('globals.confirm')"
|
||||
:title="t('globals.confirm')"
|
||||
color="primary"
|
||||
:loading="isLoading"
|
||||
@click="confirm()"
|
||||
unelevated
|
||||
autofocus
|
||||
data-cy="VnConfirm_confirm"
|
||||
/>
|
||||
</slot>
|
||||
</QCardActions>
|
||||
</QCard>
|
||||
</QDialog>
|
||||
|
|
|
@ -12,15 +12,21 @@ import VnInputNumber from 'src/components/common/VnInputNumber.vue';
|
|||
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
|
||||
import axios from 'axios';
|
||||
import useNotify from 'src/composables/useNotify';
|
||||
import VnConfirm from 'src/components/ui/VnConfirm.vue';
|
||||
import VnDms from 'src/components/common/VnDms.vue';
|
||||
import { date } from 'quasar';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { notify } = useNotify();
|
||||
const dialog = ref();
|
||||
const dmsDialog = ref();
|
||||
const MAXDAYS = 365;
|
||||
const DEFAULTDAYS = 60;
|
||||
const dataKey = 'entryControl';
|
||||
const url = 'Entries/control';
|
||||
const arrayData = useArrayData(dataKey);
|
||||
const daysAgo = ref();
|
||||
const dmsData = ref();
|
||||
const table = useTemplateRef('table');
|
||||
const companies = ref([]);
|
||||
const countries = ref([]);
|
||||
|
@ -28,6 +34,8 @@ const entryTypes = ref([]);
|
|||
const entryAccounts = ref([]);
|
||||
const warehouses = ref([]);
|
||||
const selectedRows = ref([]);
|
||||
let selectedGestDoc;
|
||||
let supplierRef;
|
||||
const columns = computed(() => [
|
||||
{
|
||||
name: 'id',
|
||||
|
@ -207,57 +215,89 @@ function filterByDaysAgo(val) {
|
|||
async function preAccount() {
|
||||
let selectedAgri;
|
||||
const entries = selectedRows.value;
|
||||
|
||||
|
||||
for (const i in entries) {
|
||||
const { supplierFk, companyFk, isAgricultural } = entries[i];
|
||||
const nextEntry = entries[+i + 1];
|
||||
|
||||
// Is It agricultural?
|
||||
if (!selectedAgri && isAgricultural) selectedAgri = entries[i];
|
||||
if (!nextEntry) return;
|
||||
// Has It gestDoc?
|
||||
if (!selectedGestDoc && entries[i].gestDocFk) selectedGestDoc = entries[i];
|
||||
// Is It same supplier and company?
|
||||
if (!nextEntry) break;
|
||||
else if (nextEntry.supplierFk !== supplierFk || nextEntry.companyFk !== companyFk)
|
||||
return notify('Entries must have the same supplier and company', 'negative');
|
||||
|
||||
}
|
||||
|
||||
// Check if it is agricultural
|
||||
if(selectedAgri){
|
||||
const supplierYearRef = new Date(selectedAgri.landed).getFullYear();
|
||||
// If It's agricultural, get the supplierRef
|
||||
if (selectedAgri) {
|
||||
const year = new Date(selectedAgri.landed).getFullYear();
|
||||
supplierRef = (
|
||||
await axios.get('InvoiceIns/getMaxRef', {
|
||||
params: { companyFk: selectedAgri.companyFk, year },
|
||||
})
|
||||
).data?.supplierRef;
|
||||
|
||||
return createInvoice(true);
|
||||
} else if (selectedGestDoc) {
|
||||
// If There's a allocated file for an entry? Ask to (update/updlod) the file
|
||||
dialog.value.show();
|
||||
} else {
|
||||
// If There's no gestDoc, upload the file
|
||||
uploadFile();
|
||||
}
|
||||
|
||||
/* If vIsFarmer Then
|
||||
vSupplierRef = Nz(db.getValueV("SELECT IFNULL(MAX(CAST(ii.supplierRef AS UNSIGNED)) + 1, YEAR('" & vnNow() & "') * 1000 + 1) " & _
|
||||
"FROM vn.invoiceIn ii " & _
|
||||
"JOIN vn.supplier s ON s.id = ii.supplierFk " & _
|
||||
"JOIN vn.invoiceInConfig iic ON iic.sageFarmerWithholdingFk = s.withholdingSageFk " & _
|
||||
"WHERE ii.companyFk = # " & _
|
||||
"AND YEAR(ii.issued) = # " & _
|
||||
"AND supplierRef LIKE CONCAT('%',YEAR(ii.issued),'%') ", _
|
||||
rs("empresa_id"), _
|
||||
vYearSupplierRef), 0)
|
||||
|
||||
If vSupplierRef = 0 Then
|
||||
vSupplierRef = vYearSupplierRef & "001"
|
||||
End If
|
||||
|
||||
Else
|
||||
vSupplierRef = db.getValueV("SELECT reference FROM vn.dms WHERE id = #", Nz(Me.gestdoc_id, 0))
|
||||
End If */
|
||||
|
||||
// no es agricultural
|
||||
// check if has gestdoc
|
||||
// Yes, ask for inherit gestdoc or not
|
||||
// No, open VNDms popup con los argumentos del codigo access
|
||||
|
||||
// Generar factura
|
||||
// Cabecera,
|
||||
// ..........................................
|
||||
// lineas...<
|
||||
// lineas...
|
||||
// Actualizar entradas (contabilizada, numero de factura) MAS TARDE
|
||||
|
||||
// await axios.post('Entries/preAccount', {
|
||||
// ids: selectedRows.value.map((row) => row.id),
|
||||
// });
|
||||
}
|
||||
|
||||
async function updateFile() {
|
||||
await axios.post(`Dms/${selectedGestDoc.gestDocFk}/updateFile`, { dmsTypeId: 1 });
|
||||
}
|
||||
|
||||
async function uploadFile() {
|
||||
const firstSelectedEntry = selectedRows.value.at(0);
|
||||
const { supplier, warehouseInFk, companyFk, invoiceNumber } = firstSelectedEntry;
|
||||
dmsData.value = {
|
||||
dmsTypeFk: 1,
|
||||
warehouseFk: warehouseInFk,
|
||||
companyFk: companyFk,
|
||||
description: supplier + '.Fact: ' + invoiceNumber,
|
||||
reference: invoiceNumber,
|
||||
};
|
||||
dmsDialog.value.show();
|
||||
}
|
||||
|
||||
async function createInvoice(isAgricultural) {
|
||||
const {
|
||||
supplierFk,
|
||||
landed,
|
||||
shipped,
|
||||
companyFk,
|
||||
currencyFk,
|
||||
gestDocFk: docFk,
|
||||
} = selectedRows.value.at(0);
|
||||
const lastDay = new Date(landed.getFullYear(), landed.getMonth() + 1, 0).getDate();
|
||||
const issued = isAgricultural ? lastDay : shipped;
|
||||
const siiTrascendencyInvoiceInFk = isAgricultural ? 2 : 1;
|
||||
await axios.post('InvoiceIns', {
|
||||
supplierFk,
|
||||
supplierRef,
|
||||
issued,
|
||||
companyFk,
|
||||
docFk,
|
||||
currencyFk,
|
||||
siiTrascendencyInvoiceInFk,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
|
@ -347,4 +387,28 @@ End If */
|
|||
</span>
|
||||
</template>
|
||||
</VnTable>
|
||||
<VnConfirm
|
||||
ref="dialog"
|
||||
:title="t('entry.control.dialog.title')"
|
||||
:message="t('entry.control.dialog.message')"
|
||||
>
|
||||
<template #actions>
|
||||
<QBtn
|
||||
:label="t('globals.yes')"
|
||||
color="primary"
|
||||
@click="updateFile"
|
||||
autofocus
|
||||
/>
|
||||
<QBtn :label="t('globals.no')" color="primary" flat @click="uploadFile" />
|
||||
<QBtn :label="t('globals.cancel')" color="primary" flat v-close-popup />
|
||||
</template>
|
||||
</VnConfirm>
|
||||
<QDialog ref="dmsDialog">
|
||||
<VnDms
|
||||
model="dms"
|
||||
:form-initial-data="dmsData"
|
||||
url="Dms/uploadFile"
|
||||
@data-saved="dmsData = null"
|
||||
/>
|
||||
</QDialog>
|
||||
</template>
|
||||
|
|
|
@ -140,6 +140,9 @@ entry:
|
|||
search: Search
|
||||
searchInfo: You can search by supplier name or nickname
|
||||
preAccount: Pre-account
|
||||
dialog:
|
||||
title: Pre-account entries
|
||||
message: Do you want the invoice to inherit the entry document?
|
||||
entryFilter:
|
||||
params:
|
||||
isExcludedFromAvailable: Excluded from available
|
||||
|
|
|
@ -91,6 +91,9 @@ entry:
|
|||
search: Buscar
|
||||
searchInfo: Puedes buscar por nombre o alias de proveedor
|
||||
preAccount: Precontabilizar
|
||||
dialog:
|
||||
title: Precontabilizar entradas
|
||||
message: ¿Desea que la factura herede el documento de la entrada?
|
||||
params:
|
||||
entryFk: Entrada
|
||||
observationTypeFk: Tipo de observación
|
||||
|
|
Loading…
Reference in New Issue