mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
feat: Assign default pdf template automatically
This commit is contained in:
@@ -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,
|
||||
}),
|
||||
};
|
||||
|
||||
@@ -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 } =
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -137,7 +137,8 @@ function PaymentReceiveFormProvider({ query, paymentReceiveId, ...props }) {
|
||||
isPaymentLoading ||
|
||||
isAccountsLoading ||
|
||||
isCustomersLoading ||
|
||||
isBrandingTemplatesLoading;
|
||||
isBrandingTemplatesLoading ||
|
||||
isPaymentReceivedStateLoading;
|
||||
|
||||
return (
|
||||
<DashboardInsider loading={isLoading} name={'payment-receive-form'}>
|
||||
|
||||
@@ -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 />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// @ts-nocheck
|
||||
import { useQueryClient, useMutation } from 'react-query';
|
||||
import { useQueryClient, useMutation, useQuery } from 'react-query';
|
||||
import { useRequestQuery } from '../useQueryRequest';
|
||||
import { transformPagination, transformToCamelCase } from '@/utils';
|
||||
import useApiRequest from '../useRequest';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// @ts-nocheck
|
||||
import { useQueryClient, useMutation } from 'react-query';
|
||||
import { useQueryClient, useMutation, useQuery } from 'react-query';
|
||||
import { useRequestQuery } from '../useQueryRequest';
|
||||
import useApiRequest from '../useRequest';
|
||||
import { transformPagination, transformToCamelCase } from '@/utils';
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
import {
|
||||
useMutation,
|
||||
useQueryClient,
|
||||
QueryClient,
|
||||
UseQueryOptions,
|
||||
UseQueryResult,
|
||||
useQuery,
|
||||
} from 'react-query';
|
||||
import useApiRequest from '../useRequest';
|
||||
import { useRequestQuery } from '../useQueryRequest';
|
||||
import { transformPagination, saveInvoke } from '@/utils';
|
||||
import { transformPagination, saveInvoke, transformToCamelCase } from '@/utils';
|
||||
import { useRequestPdf } from '../useRequestPdf';
|
||||
import t from './types';
|
||||
|
||||
@@ -297,7 +296,7 @@ export function usePaymentReceivedState(
|
||||
() =>
|
||||
apiRequest
|
||||
.get('/sales/payment_receives/state', { params: query })
|
||||
.then((res) => res.data),
|
||||
.then((res) => transformToCamelCase(res.data?.data)),
|
||||
{
|
||||
...options,
|
||||
},
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
} from 'react-query';
|
||||
import { useRequestQuery } from '../useQueryRequest';
|
||||
import useApiRequest from '../useRequest';
|
||||
import { transformPagination } from '@/utils';
|
||||
import { transformPagination, transformToCamelCase } from '@/utils';
|
||||
import { useRequestPdf } from '../useRequestPdf';
|
||||
import t from './types';
|
||||
|
||||
@@ -252,7 +252,7 @@ export function useSaleReceiptDefaultOptions(invoiceId, props) {
|
||||
}
|
||||
|
||||
export interface IGetReceiptStateResponse {
|
||||
pdfTemplateId: number;
|
||||
defaultTemplateId: number;
|
||||
}
|
||||
|
||||
export function useGetReceiptState(
|
||||
|
||||
Reference in New Issue
Block a user