feat: Assign default pdf template automatically

This commit is contained in:
Ahmed Bouhuolia
2024-10-03 16:36:44 +02:00
parent b23112bc92
commit 3c7e22be43
21 changed files with 332 additions and 38 deletions

View File

@@ -67,6 +67,7 @@ function CreditNoteForm({
newCreditNote,
createCreditNoteMutate,
editCreditNoteMutate,
creditNoteState,
} = useCreditNoteFormContext();
// Credit number.
@@ -85,6 +86,7 @@ function CreditNoteForm({
currency_code: base_currency,
terms_conditions: defaultTo(creditTermsConditions, ''),
note: defaultTo(creditCustomerNotes, ''),
pdf_template_id: creditNoteState?.defaultTemplateId,
...newCreditNote,
}),
};

View File

@@ -85,7 +85,7 @@ function CreditNoteFormProvider({ creditNoteId, ...props }) {
// Fetches branding templates of invoice.
const { data: brandingTemplates, isLoading: isBrandingTemplatesLoading } =
useGetPdfTemplates({ resource: 'PaymentReceive' });
useGetPdfTemplates({ resource: 'CreditNote' });
// Fetches the credit note state.
const { data: creditNoteState, isLoading: isCreditNoteStateLoading } =

View File

@@ -172,17 +172,16 @@ function InvoiceFormProvider({ invoiceId, baseCurrency, ...props }) {
isInvoiceStateLoading,
};
const isLoading =
isInvoiceLoading ||
isItemsLoading ||
isCustomersLoading ||
isEstimateLoading ||
isSettingsLoading ||
isInvoiceStateLoading;
return (
<DashboardInsider
loading={
isInvoiceLoading ||
isItemsLoading ||
isCustomersLoading ||
isEstimateLoading ||
isSettingsLoading
}
name={'invoice-form'}
>
<DashboardInsider loading={isLoading} name={'invoice-form'}>
<InvoiceFormContext.Provider value={provider} {...props} />
</DashboardInsider>
);

View File

@@ -90,7 +90,7 @@ function PaymentReceiveForm({
}),
deposit_account_id: defaultTo(preferredDepositAccount, ''),
currency_code: base_currency,
pdf_template_id: paymentReceivedState.defaultTemplateId,
pdf_template_id: paymentReceivedState?.defaultTemplateId,
}),
};
// Handle form submit.

View File

@@ -137,7 +137,8 @@ function PaymentReceiveFormProvider({ query, paymentReceiveId, ...props }) {
isPaymentLoading ||
isAccountsLoading ||
isCustomersLoading ||
isBrandingTemplatesLoading;
isBrandingTemplatesLoading ||
isPaymentReceivedStateLoading;
return (
<DashboardInsider loading={isLoading} name={'payment-receive-form'}>

View File

@@ -85,7 +85,7 @@ function ReceiptForm({
currency_code: base_currency,
receipt_message: receiptMessage,
terms_conditions: receiptTermsConditions,
pdf_template_id: saleReceiptState?.pdfTemplateId,
pdf_template_id: saleReceiptState?.defaultTemplateId,
}),
};
// Handle the form submit.
@@ -173,7 +173,7 @@ function ReceiptForm({
{/*---------- Dialogs ---------*/}
<ReceiptFormDialogs />
css
{/*---------- Effects ---------*/}
<ReceiptSyncIncrementSettingsToForm />
<ReceiptSyncAutoExRateToForm />