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 } =