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;
}
.card-width {
width: 770px;
}
.vn-card-list {
width: 100%;
max-width: 60em;

View File

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

View File

@ -696,6 +696,7 @@ invoiceOut:
chooseValidClient: Selecciona un cliente válido
chooseValidCompany: Selecciona una empresa 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
invoiceDateLessThanMaxDate: La fecha de la factura no puede ser menor que la fecha máxima
invoiceWithFutureDate: Existe una factura con una fecha futura

View File

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

View File

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

View File

@ -20,21 +20,27 @@ const { initialDataLoading, formInitialData, invoicing, status } =
const { makeInvoice, setStatusValue } = invoiceOutGlobalStore;
const clientsToInvoice = ref('all');
const companiesOptions = ref([]);
const printersOptions = ref([]);
const clientsOptions = ref([]);
const serialTypesOptions = ref([]);
const handleInvoiceOutSerialsFetch = (data) => {
serialTypesOptions.value = Array.from(
new Set(data.map((item) => item.type).filter((type) => type))
);
};
const formData = ref({});
const optionsInitialData = computed(() => {
return (
companiesOptions.value.length > 0 &&
printersOptions.value.length > 0 &&
clientsOptions.value.length > 0
);
const optionsArrays = [
companiesOptions.value,
printersOptions.value,
clientsOptions.value,
serialTypesOptions.value,
];
return optionsArrays.every((arr) => arr.length > 0);
});
const getStatus = computed({
@ -60,7 +66,11 @@ onMounted(async () => {
/>
<FetchData url="Printers" @on-fetch="(data) => (printersOptions = data)" auto-load />
<FetchData url="Clients" @on-fetch="(data) => (clientsOptions = data)" auto-load />
<FetchData
url="invoiceOutSerials"
@on-fetch="handleInvoiceOutSerialsFetch"
auto-load
/>
<QForm
v-if="!initialDataLoading && optionsInitialData"
@submit="makeInvoice(formData, clientsToInvoice)"
@ -95,6 +105,17 @@ onMounted(async () => {
outlined
rounded
/>
<VnSelect
:label="t('invoiceOutSerialType')"
v-model="formData.serialType"
:options="serialTypesOptions"
option-value="type"
option-label="type"
hide-selected
dense
outlined
rounded
/>
<VnInputDate
v-model="formData.invoiceDate"
:label="t('invoiceDate')"
@ -168,6 +189,7 @@ en:
printer: Printer
invoiceOut: Invoice out
client: Client
invoiceOutSerialType: Serial Type
stop: Stop
es:
@ -179,5 +201,6 @@ es:
printer: Impresora
invoiceOut: Facturar
client: Cliente
invoiceOutSerialType: Tipo de Serie
stop: Parar
</i18n>

View File

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

View File

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

View File

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