feat: refs #7346 add seriaType option #626

Merged
jgallego merged 7 commits from 7346-invoiceOutMultilple into dev 2024-08-23 09:08:53 +00:00
9 changed files with 60 additions and 31 deletions

View File

@ -103,10 +103,6 @@ select:-webkit-autofill {
border-radius: 8px; border-radius: 8px;
} }
.card-width {
width: 770px;
}
.vn-card-list { .vn-card-list {
width: 100%; width: 100%;
max-width: 60em; max-width: 60em;

View File

@ -690,6 +690,7 @@ invoiceOut:
chooseValidClient: Choose a valid client chooseValidClient: Choose a valid client
chooseValidCompany: Choose a valid company chooseValidCompany: Choose a valid company
chooseValidPrinter: Choose a valid printer chooseValidPrinter: Choose a valid printer
chooseValidSerialType: Choose a serial type
fillDates: Invoice date and the max date should be filled fillDates: Invoice date and the max date should be filled
invoiceDateLessThanMaxDate: Invoice date can not be less than max date invoiceDateLessThanMaxDate: Invoice date can not be less than max date
invoiceWithFutureDate: Exists an invoice with a future date invoiceWithFutureDate: Exists an invoice with a future date

View File

@ -696,6 +696,7 @@ invoiceOut:
chooseValidClient: Selecciona un cliente válido chooseValidClient: Selecciona un cliente válido
chooseValidCompany: Selecciona una empresa válida chooseValidCompany: Selecciona una empresa válida
chooseValidPrinter: Selecciona una impresora válida chooseValidPrinter: Selecciona una impresora válida
chooseValidSerialType: Selecciona una tipo de serie válida
fillDates: La fecha de la factura y la fecha máxima deben estar completas fillDates: La fecha de la factura y la fecha máxima deben estar completas
invoiceDateLessThanMaxDate: La fecha de la factura no puede ser menor que la fecha máxima invoiceDateLessThanMaxDate: La fecha de la factura no puede ser menor que la fecha máxima
invoiceWithFutureDate: Existe una factura con una fecha futura invoiceWithFutureDate: Existe una factura con una fecha futura

View File

@ -222,7 +222,7 @@ const showTransferInvoiceForm = async () => {
<QItemSection>{{ t('Generate PDF invoice') }}</QItemSection> <QItemSection>{{ t('Generate PDF invoice') }}</QItemSection>
</QItem> </QItem>
<QItem v-ripple clickable> <QItem v-ripple clickable>
<QItemSection>{{ t('Refund...') }}</QItemSection> <QItemSection>{{ t('Refund') }}</QItemSection>
<QItemSection side> <QItemSection side>
<QIcon name="keyboard_arrow_right" /> <QIcon name="keyboard_arrow_right" />
</QItemSection> </QItemSection>
@ -250,7 +250,7 @@ es:
Delete invoice: Eliminar factura Delete invoice: Eliminar factura
Book invoice: Asentar factura Book invoice: Asentar factura
Generate PDF invoice: Generar PDF factura Generate PDF invoice: Generar PDF factura
Refund...: Abono Refund: Abono
As PDF: como PDF As PDF: como PDF
As CSV: como CSV As CSV: como CSV
Send PDF: Enviar PDF Send PDF: Enviar PDF

View File

@ -94,11 +94,13 @@ const selectCustomerId = (id) => {
}; };
const statusText = computed(() => { const statusText = computed(() => {
return status.value === 'invoicing' const baseStatus = t(`status.${status.value}`);
? `${t(`status.${status.value}`)} ${ const clientId =
addresses.value[getAddressNumber.value]?.clientId status.value === 'invoicing'
}` ? addresses.value[getAddressNumber.value]?.clientId || ''
: t(`status.${status.value}`); : '';
return clientId ? `${baseStatus} ${clientId}`.trim() : baseStatus;
}); });
onMounted(() => (stateStore.rightDrawer = true)); onMounted(() => (stateStore.rightDrawer = true));

View File

@ -20,21 +20,27 @@ const { initialDataLoading, formInitialData, invoicing, status } =
const { makeInvoice, setStatusValue } = invoiceOutGlobalStore; const { makeInvoice, setStatusValue } = invoiceOutGlobalStore;
const clientsToInvoice = ref('all'); const clientsToInvoice = ref('all');
const companiesOptions = ref([]); const companiesOptions = ref([]);
const printersOptions = ref([]); const printersOptions = ref([]);
const clientsOptions = ref([]); const clientsOptions = ref([]);
const serialTypesOptions = ref([]);
const handleInvoiceOutSerialsFetch = (data) => {
serialTypesOptions.value = Array.from(
new Set(data.map((item) => item.type).filter((type) => type))

variable === null es lo mismo que hacer !variable

Por otra parte

    serialTypesOptions.value = Array.from(
        new Set(data.map((item) => item.type).filter((type) => type))
    );
};

variable === null es lo mismo que hacer !variable Por otra parte ``` serialTypesOptions.value = Array.from( new Set(data.map((item) => item.type).filter((type) => type)) ); }; ```
);
jsegarra marked this conversation as resolved Outdated

Para tener una condición con 4 condiciones que siguen el mismo criterio, propondria usar el método "every"

Para tener una condición con 4 condiciones que siguen el mismo criterio, propondria usar el método "every"
};
const formData = ref({}); const formData = ref({});
const optionsInitialData = computed(() => { const optionsInitialData = computed(() => {
return ( const optionsArrays = [
companiesOptions.value.length > 0 && companiesOptions.value,
printersOptions.value.length > 0 && printersOptions.value,
clientsOptions.value.length > 0 clientsOptions.value,
); serialTypesOptions.value,
];
return optionsArrays.every((arr) => arr.length > 0);
}); });
const getStatus = computed({ const getStatus = computed({
@ -60,7 +66,11 @@ onMounted(async () => {
/> />
<FetchData url="Printers" @on-fetch="(data) => (printersOptions = data)" auto-load /> <FetchData url="Printers" @on-fetch="(data) => (printersOptions = data)" auto-load />
<FetchData url="Clients" @on-fetch="(data) => (clientsOptions = data)" auto-load /> <FetchData url="Clients" @on-fetch="(data) => (clientsOptions = data)" auto-load />
<FetchData
url="invoiceOutSerials"
@on-fetch="handleInvoiceOutSerialsFetch"
auto-load
/>
<QForm <QForm
v-if="!initialDataLoading && optionsInitialData" v-if="!initialDataLoading && optionsInitialData"
@submit="makeInvoice(formData, clientsToInvoice)" @submit="makeInvoice(formData, clientsToInvoice)"
@ -95,6 +105,17 @@ onMounted(async () => {
outlined outlined
rounded rounded
/> />
<VnSelect
:label="t('invoiceOutSerialType')"
v-model="formData.serialType"
:options="serialTypesOptions"

Si printas la variable serialTypesOptions, te sale algo asi: [ { "code": "A", "description": "Global nacional", "isTaxed": true, "isCEE": false, "taxAreaFk": "NATIONAL" } ]

Type no aparece por ningún lado

Si printas la variable serialTypesOptions, te sale algo asi: [ { "code": "A", "description": "Global nacional", "isTaxed": true, "isCEE": false, "taxAreaFk": "NATIONAL" } ] Type no aparece por ningún lado

creo que eso se debe a que no lo has probado descargando también el back de la 7346

creo que eso se debe a que no lo has probado descargando también el back de la 7346

Puede ser.
Lo pruebo con esa rama

Puede ser. Lo pruebo con esa rama
option-value="type"
option-label="type"
hide-selected
dense
outlined
rounded
/>
<VnInputDate <VnInputDate
v-model="formData.invoiceDate" v-model="formData.invoiceDate"
:label="t('invoiceDate')" :label="t('invoiceDate')"
@ -168,6 +189,7 @@ en:
printer: Printer printer: Printer
invoiceOut: Invoice out invoiceOut: Invoice out
client: Client client: Client
invoiceOutSerialType: Serial Type
stop: Stop stop: Stop
es: es:
@ -179,5 +201,6 @@ es:
printer: Impresora printer: Impresora
invoiceOut: Facturar invoiceOut: Facturar
client: Cliente client: Cliente
invoiceOutSerialType: Tipo de Serie
stop: Parar stop: Parar
</i18n> </i18n>

View File

@ -198,7 +198,7 @@ watchEffect(selectedRows);
:url="`${MODEL}/filter`" :url="`${MODEL}/filter`"
:create="{ :create="{
urlCreate: 'InvoiceOuts/createManualInvoice', urlCreate: 'InvoiceOuts/createManualInvoice',
title: t('Create Manual Invoice'), title: t('Create manual invoice'),
onDataSaved: ({ id }) => tableRef.redirect(id), onDataSaved: ({ id }) => tableRef.redirect(id),
formInitialData: { formInitialData: {
active: true, active: true,
@ -275,10 +275,12 @@ en:
fileAllowed: Successful download of CSV file fileAllowed: Successful download of CSV file
youCanSearchByInvoiceReference: You can search by invoice reference youCanSearchByInvoiceReference: You can search by invoice reference
createInvoice: Make invoice createInvoice: Make invoice
Create manual invoice: Create manual invoice
es: es:
searchInvoice: Buscar factura emitida searchInvoice: Buscar factura emitida
fileDenied: El navegador denegó la descarga de archivos... fileDenied: El navegador denegó la descarga de archivos...
fileAllowed: Descarga exitosa de archivo CSV fileAllowed: Descarga exitosa de archivo CSV
youCanSearchByInvoiceReference: Puedes buscar por referencia de la factura youCanSearchByInvoiceReference: Puedes buscar por referencia de la factura
createInvoice: Crear factura createInvoice: Crear factura
Create manual invoice: Crear factura manual
</i18n> </i18n>

View File

@ -244,7 +244,7 @@ const createRefund = async (withWarehouse) => {
</QItem> </QItem>
<QItem clickable v-ripple> <QItem clickable v-ripple>
<QItemSection> <QItemSection>
<QItemLabel>{{ t('Refund...') }}</QItemLabel> <QItemLabel>{{ t('Refund') }}</QItemLabel>
</QItemSection> </QItemSection>
<QItemSection side> <QItemSection side>
<QIcon name="keyboard_arrow_right" /> <QIcon name="keyboard_arrow_right" />
@ -279,7 +279,7 @@ es:
Add claim: Crear reclamación Add claim: Crear reclamación
Mark as reserved: Marcar como reservado Mark as reserved: Marcar como reservado
Unmark as reserved: Desmarcar como reservado Unmark as reserved: Desmarcar como reservado
Refund...: Abono... Refund: Abono
with warehouse: con almacén with warehouse: con almacén
without warehouse: sin almacén without warehouse: sin almacén
Claim out of time: Reclamación fuera de plazo Claim out of time: Reclamación fuera de plazo

View File

@ -19,6 +19,7 @@ export const useInvoiceOutGlobalStore = defineStore({
maxShipped: null, maxShipped: null,
clientId: null, clientId: null,
printer: null, printer: null,
serialType: null,
}, },
addresses: [], addresses: [],
minInvoicingDate: null, minInvoicingDate: null,
@ -100,6 +101,7 @@ export const useInvoiceOutGlobalStore = defineStore({
maxShipped: new Date(formData.maxShipped), maxShipped: new Date(formData.maxShipped),
clientId: formData.clientId ? formData.clientId : null, clientId: formData.clientId ? formData.clientId : null,
companyFk: formData.companyFk, companyFk: formData.companyFk,
serialType: formData.serialType,
}; };
this.validateMakeInvoceParams(params, clientsToInvoice); this.validateMakeInvoceParams(params, clientsToInvoice);
@ -152,7 +154,13 @@ export const useInvoiceOutGlobalStore = defineStore({
); );
throw new Error('Invoice date in the future'); throw new Error('Invoice date in the future');
} }
if (!params.serialType) {
notify(
'invoiceOut.globalInvoices.errors.chooseValidSerialType',
'negative'
);
throw new Error('Invalid Serial Type');
}
if (!params.companyFk) { if (!params.companyFk) {
notify('invoiceOut.globalInvoices.errors.chooseValidCompany', 'negative'); notify('invoiceOut.globalInvoices.errors.chooseValidCompany', 'negative');
throw new Error('Invalid company'); throw new Error('Invalid company');
@ -180,6 +188,7 @@ export const useInvoiceOutGlobalStore = defineStore({
invoiceDate: new Date(formData.invoiceDate), invoiceDate: new Date(formData.invoiceDate),
maxShipped: new Date(formData.maxShipped), maxShipped: new Date(formData.maxShipped),
companyFk: formData.companyFk, companyFk: formData.companyFk,
serialType: formData.serialType,
}; };
this.status = 'invoicing'; this.status = 'invoicing';
@ -191,12 +200,7 @@ export const useInvoiceOutGlobalStore = defineStore({
this.addressIndex++; this.addressIndex++;
this.isInvoicing = false; this.isInvoicing = false;
} catch (err) { } catch (err) {
if ( if (err?.response?.status >= 400 && err?.response?.status < 500) {
err &&
err.response &&
err.response.status >= 400 &&
err.response.status < 500
) {
this.invoiceClientError(address, err.response?.data?.error?.message); this.invoiceClientError(address, err.response?.data?.error?.message);
return; return;
} else { } else {
@ -243,7 +247,7 @@ export const useInvoiceOutGlobalStore = defineStore({
params, params,
}); });
if (data.data && data.data.error) throw new Error(); if (data?.data?.error) throw new Error();
const status = exportFile('negativeBases.csv', data, { const status = exportFile('negativeBases.csv', data, {
encoding: 'windows-1252', encoding: 'windows-1252',