mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-22 15:50:32 +00:00
feat: add create & edit & delete in credit note.
This commit is contained in:
@@ -14,6 +14,8 @@ export const TABLES = {
|
|||||||
EXPENSES: 'expenses',
|
EXPENSES: 'expenses',
|
||||||
CASHFLOW_ACCOUNTS: 'cashflow_accounts',
|
CASHFLOW_ACCOUNTS: 'cashflow_accounts',
|
||||||
CASHFLOW_Transactions: 'cashflow_transactions',
|
CASHFLOW_Transactions: 'cashflow_transactions',
|
||||||
|
CREDIT_NOTES: 'credit_notes',
|
||||||
|
VENDOR_CREDITS: 'vendor_credits',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const TABLE_SIZE = {
|
export const TABLE_SIZE = {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
|
|||||||
import withAlertActions from 'containers/Alert/withAlertActions';
|
import withAlertActions from 'containers/Alert/withAlertActions';
|
||||||
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||||
|
|
||||||
|
import { useDeleteCreditNote } from 'hooks/query';
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,11 +27,32 @@ function CreditNoteDeleteAlert({
|
|||||||
// #withDrawerActions
|
// #withDrawerActions
|
||||||
closeDrawer,
|
closeDrawer,
|
||||||
}) {
|
}) {
|
||||||
|
const { isLoading, mutateAsync: deleteCreditNoteMutate } =
|
||||||
|
useDeleteCreditNote();
|
||||||
|
|
||||||
// handle cancel delete credit note alert.
|
// handle cancel delete credit note alert.
|
||||||
const handleCancelDeleteAlert = () => {
|
const handleCancelDeleteAlert = () => {
|
||||||
closeAlert(name);
|
closeAlert(name);
|
||||||
};
|
};
|
||||||
const handleConfirmCreditNoteDelete = () => {};
|
const handleConfirmCreditNoteDelete = () => {
|
||||||
|
deleteCreditNoteMutate(creditNoteId)
|
||||||
|
.then(() => {
|
||||||
|
AppToaster.show({
|
||||||
|
message: intl.get('credit_note.alert.success_message'),
|
||||||
|
intent: Intent.SUCCESS,
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(
|
||||||
|
({
|
||||||
|
response: {
|
||||||
|
data: { errors },
|
||||||
|
},
|
||||||
|
}) => {},
|
||||||
|
)
|
||||||
|
.finally(() => {
|
||||||
|
closeAlert(name);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Alert
|
<Alert
|
||||||
@@ -41,7 +63,7 @@ function CreditNoteDeleteAlert({
|
|||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
onCancel={handleCancelDeleteAlert}
|
onCancel={handleCancelDeleteAlert}
|
||||||
onConfirm={handleConfirmCreditNoteDelete}
|
onConfirm={handleConfirmCreditNoteDelete}
|
||||||
// loading={isLoading}
|
loading={isLoading}
|
||||||
>
|
>
|
||||||
<p>
|
<p>
|
||||||
<FormattedHTMLMessage id={'credit_note.once_delete_this_credit_note'} />
|
<FormattedHTMLMessage id={'credit_note.once_delete_this_credit_note'} />
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ function InviteUserFormContent({
|
|||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
closeDialog(dialogName);
|
closeDialog(dialogName);
|
||||||
};
|
};
|
||||||
console.log(roles, 'XX');
|
|
||||||
return (
|
return (
|
||||||
<Form>
|
<Form>
|
||||||
<div className={CLASSES.DIALOG_BODY}>
|
<div className={CLASSES.DIALOG_BODY}>
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ export default function VendorCreditNoteFloatingActions() {
|
|||||||
// Handle submit button click.
|
// Handle submit button click.
|
||||||
const handleSubmitBtnClick = (event) => {
|
const handleSubmitBtnClick = (event) => {
|
||||||
setSubmitPayload({ redirect: true });
|
setSubmitPayload({ redirect: true });
|
||||||
|
submitForm();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClearBtnClick = (event) => {
|
const handleClearBtnClick = (event) => {
|
||||||
@@ -80,6 +81,7 @@ export default function VendorCreditNoteFloatingActions() {
|
|||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
loading={isSubmitting}
|
loading={isSubmitting}
|
||||||
intent={Intent.PRIMARY}
|
intent={Intent.PRIMARY}
|
||||||
|
onClick={handleSubmitBtnClick}
|
||||||
text={<T id={'save'} />}
|
text={<T id={'save'} />}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ function VendorsCreditNoteDataTable({
|
|||||||
|
|
||||||
// Local storage memorizing columns widths.
|
// Local storage memorizing columns widths.
|
||||||
const [initialColumnsWidths, , handleColumnResizing] =
|
const [initialColumnsWidths, , handleColumnResizing] =
|
||||||
useMemorizedColumnsWidths(TABLES.CREDIT_NOTE);
|
useMemorizedColumnsWidths(TABLES.VENDOR_CREDITS);
|
||||||
|
|
||||||
// Handles fetch data once the table state change.
|
// Handles fetch data once the table state change.
|
||||||
const handleDataTableFetchData = React.useCallback(
|
const handleDataTableFetchData = React.useCallback(
|
||||||
|
|||||||
@@ -26,32 +26,76 @@ export default function CreditNoteFloatingActions() {
|
|||||||
const { resetForm, submitForm, isSubmitting } = useFormikContext();
|
const { resetForm, submitForm, isSubmitting } = useFormikContext();
|
||||||
|
|
||||||
// Credit note form context.
|
// Credit note form context.
|
||||||
const { setSubmitPayload } = useCreditNoteFormContext();
|
const { setSubmitPayload, isNewMode } = useCreditNoteFormContext();
|
||||||
|
|
||||||
|
// Handle submit, save and anothe new button click.
|
||||||
|
const handleSubmitAndNewBtnClick = (event) => {
|
||||||
|
setSubmitPayload({ redirect: false, status: true, resetForm: true });
|
||||||
|
submitForm();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Handle submit as save & continue editing button click.
|
||||||
|
const handleSubmitSaveContinueEditingBtnClick = (event) => {
|
||||||
|
setSubmitPayload({ redirect: false, status: true });
|
||||||
|
submitForm();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Handle submit as draft button click.
|
||||||
|
const handleSubmitDraftBtnClick = (event) => {
|
||||||
|
setSubmitPayload({ redirect: true, status: false });
|
||||||
|
submitForm();
|
||||||
|
};
|
||||||
|
|
||||||
|
// handle submit as draft & new button click.
|
||||||
|
const handleSubmitDraftAndNewBtnClick = (event) => {
|
||||||
|
setSubmitPayload({ redirect: false, status: false, resetForm: true });
|
||||||
|
submitForm();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Handle submit as draft & continue editing button click.
|
||||||
|
const handleSubmitDraftContinueEditingBtnClick = (event) => {
|
||||||
|
setSubmitPayload({ redirect: false, status: false });
|
||||||
|
submitForm();
|
||||||
|
};
|
||||||
|
|
||||||
// Handle cancel button click.
|
// Handle cancel button click.
|
||||||
const handleCancelBtnClick = (event) => {
|
const handleCancelBtnClick = (event) => {
|
||||||
history.goBack();
|
history.goBack();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle submit button click.
|
||||||
|
const handleSubmitBtnClick = (event) => {
|
||||||
|
setSubmitPayload({ redirect: true });
|
||||||
|
submitForm();
|
||||||
|
};
|
||||||
|
|
||||||
const handleClearBtnClick = (event) => {
|
const handleClearBtnClick = (event) => {
|
||||||
resetForm();
|
resetForm();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}>
|
<div className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}>
|
||||||
{/* ----------- Save And Deliver ----------- */}
|
{/* ----------- Save ----------- */}
|
||||||
<ButtonGroup>
|
<ButtonGroup>
|
||||||
<Button
|
<Button
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
loading={isSubmitting}
|
loading={isSubmitting}
|
||||||
intent={Intent.PRIMARY}
|
intent={Intent.PRIMARY}
|
||||||
text={<T id={'save_and_deliver'} />}
|
onClick={handleSubmitBtnClick}
|
||||||
|
text={<T id={'save'} />}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Popover
|
<Popover
|
||||||
content={
|
content={
|
||||||
<Menu>
|
<Menu>
|
||||||
<MenuItem text={<T id={'deliver_and_new'} />} />
|
<MenuItem
|
||||||
<MenuItem text={<T id={'deliver_continue_editing'} />} />
|
text={<T id={'save_and_new'} />}
|
||||||
|
onClick={handleSubmitAndNewBtnClick}
|
||||||
|
/>
|
||||||
|
<MenuItem
|
||||||
|
text={<T id={'save_continue_editing'} />}
|
||||||
|
onClick={handleSubmitSaveContinueEditingBtnClick}
|
||||||
|
/>
|
||||||
</Menu>
|
</Menu>
|
||||||
}
|
}
|
||||||
minimal={true}
|
minimal={true}
|
||||||
@@ -70,13 +114,20 @@ export default function CreditNoteFloatingActions() {
|
|||||||
<Button
|
<Button
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
className={'ml1'}
|
className={'ml1'}
|
||||||
|
onClick={handleSubmitDraftBtnClick}
|
||||||
text={<T id={'save_as_draft'} />}
|
text={<T id={'save_as_draft'} />}
|
||||||
/>
|
/>
|
||||||
<Popover
|
<Popover
|
||||||
content={
|
content={
|
||||||
<Menu>
|
<Menu>
|
||||||
<MenuItem text={<T id={'save_and_new'} />} />
|
<MenuItem
|
||||||
<MenuItem text={<T id={'save_continue_editing'} />} />
|
text={<T id={'save_and_new'} />}
|
||||||
|
onClick={handleSubmitDraftAndNewBtnClick}
|
||||||
|
/>
|
||||||
|
<MenuItem
|
||||||
|
text={<T id={'save_continue_editing'} />}
|
||||||
|
onClick={handleSubmitDraftContinueEditingBtnClick}
|
||||||
|
/>
|
||||||
</Menu>
|
</Menu>
|
||||||
}
|
}
|
||||||
minimal={true}
|
minimal={true}
|
||||||
@@ -89,18 +140,17 @@ export default function CreditNoteFloatingActions() {
|
|||||||
/>
|
/>
|
||||||
</Popover>
|
</Popover>
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
{/* ----------- Save and New ----------- */}
|
|
||||||
|
|
||||||
{/* ----------- Clear & Reset----------- */}
|
{/* ----------- Clear & Reset----------- */}
|
||||||
<Button
|
<Button
|
||||||
className={'ml1'}
|
className={'ml1'}
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
onClick={handleClearBtnClick}
|
onClick={handleClearBtnClick}
|
||||||
// text={ ? <T id={'reset'} /> : <T id={'clear'} />}
|
text={isNewMode ? <T id={'reset'} /> : <T id={'clear'} />}
|
||||||
/>
|
/>
|
||||||
{/* ----------- Cancel ----------- */}
|
{/* ----------- Cancel ----------- */}
|
||||||
<Button
|
<Button
|
||||||
className={'ml1'}
|
className={'ml1'}
|
||||||
|
disabled={isSubmitting}
|
||||||
onClick={handleCancelBtnClick}
|
onClick={handleCancelBtnClick}
|
||||||
text={<T id={'cancel'} />}
|
text={<T id={'cancel'} />}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import { sumBy, omit, isEmpty } from 'lodash';
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
import {
|
import {
|
||||||
getCreateCreditNoteFormSchema,
|
CreateCreditNoteFormSchema,
|
||||||
getEditCreditNoteFormSchema,
|
EditCreditNoteFormSchema,
|
||||||
} from './CreditNoteForm.schema';
|
} from './CreditNoteForm.schema';
|
||||||
|
|
||||||
import CreditNoteFormHeader from './CreditNoteFormHeader';
|
import CreditNoteFormHeader from './CreditNoteFormHeader';
|
||||||
@@ -17,9 +17,21 @@ import CreditNoteFormFooter from './CreditNoteFormFooter';
|
|||||||
import CreditNoteFloatingActions from './CreditNoteFloatingActions';
|
import CreditNoteFloatingActions from './CreditNoteFloatingActions';
|
||||||
|
|
||||||
import { AppToaster } from 'components';
|
import { AppToaster } from 'components';
|
||||||
import { compose, orderingLinesIndexes, transactionNumber } from 'utils';
|
|
||||||
import { useCreditNoteFormContext } from './CreditNoteFormProvider';
|
import { useCreditNoteFormContext } from './CreditNoteFormProvider';
|
||||||
import { transformToEditForm, defaultCreditNote } from './utils';
|
import {
|
||||||
|
filterNonZeroEntries,
|
||||||
|
transformToEditForm,
|
||||||
|
transformFormValuesToRequest,
|
||||||
|
defaultCreditNote,
|
||||||
|
} from './utils';
|
||||||
|
|
||||||
|
import {
|
||||||
|
compose,
|
||||||
|
orderingLinesIndexes,
|
||||||
|
transactionNumber,
|
||||||
|
safeSumBy,
|
||||||
|
} from 'utils';
|
||||||
|
|
||||||
import withSettings from 'containers/Settings/withSettings';
|
import withSettings from 'containers/Settings/withSettings';
|
||||||
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
|
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
|
||||||
@@ -36,33 +48,35 @@ function CreditNoteForm({
|
|||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
// Credit note form context.
|
// Credit note form context.
|
||||||
const { invoice } = useCreditNoteFormContext();
|
const {
|
||||||
|
isNewMode,
|
||||||
|
submitPayload,
|
||||||
|
creditNote,
|
||||||
|
createCreditNoteMutate,
|
||||||
|
editCreditNoteMutate,
|
||||||
|
} = useCreditNoteFormContext();
|
||||||
|
|
||||||
// Initial values.
|
// Initial values.
|
||||||
const initialValues = React.useMemo(
|
const initialValues = React.useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
...(!isEmpty(invoice)
|
...(!isEmpty(creditNote)
|
||||||
? { ...transformToEditForm(invoice), currency_code: base_currency }
|
? { ...transformToEditForm(creditNote), currency_code: base_currency }
|
||||||
: {
|
: {
|
||||||
...defaultCreditNote,
|
...defaultCreditNote,
|
||||||
entries: orderingLinesIndexes(defaultCreditNote.entries),
|
entries: orderingLinesIndexes(defaultCreditNote.entries),
|
||||||
currency_code: base_currency,
|
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
|
||||||
// Handle form submit.
|
// Handles form submit.
|
||||||
const handleSubmit = (values, { setSubmitting, setErrors, resetForm }) => {
|
const handleFormSubmit = (
|
||||||
setSubmitting(true);
|
values,
|
||||||
|
{ setSubmitting, setErrors, resetForm },
|
||||||
|
) => {
|
||||||
|
const entries = filterNonZeroEntries(values.entries);
|
||||||
|
const totalQuantity = safeSumBy(entries, 'quantity');
|
||||||
|
|
||||||
const entries = values.entries.filter(
|
|
||||||
(item) => item.item_id && item.quantity,
|
|
||||||
);
|
|
||||||
|
|
||||||
const totalQuantity = sumBy(entries, (entry) => parseInt(entry.quantity));
|
|
||||||
|
|
||||||
// Throw danger toaster in case total quantity equals zero.
|
|
||||||
if (totalQuantity === 0) {
|
if (totalQuantity === 0) {
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
message: intl.get('quantity_cannot_be_zero_or_empty'),
|
message: intl.get('quantity_cannot_be_zero_or_empty'),
|
||||||
@@ -71,24 +85,45 @@ function CreditNoteForm({
|
|||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Transformes the values of the form to request.
|
|
||||||
const form = {
|
const form = {
|
||||||
// ...transformValueToRequest(values),
|
...transformFormValuesToRequest(values),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle the request success.
|
// Handle the request success.
|
||||||
const onSuccess = () => {};
|
const onSuccess = (response) => {
|
||||||
|
AppToaster.show({
|
||||||
|
message: intl.get(
|
||||||
|
isNewMode
|
||||||
|
? 'credit_note.success_message'
|
||||||
|
: 'credit_note.edit_success_message',
|
||||||
|
),
|
||||||
|
intent: Intent.SUCCESS,
|
||||||
|
});
|
||||||
|
setSubmitting(false);
|
||||||
|
|
||||||
|
if (submitPayload.redirect) {
|
||||||
|
history.push('/credit-notes');
|
||||||
|
}
|
||||||
|
if (submitPayload.resetForm) {
|
||||||
|
resetForm();
|
||||||
|
}
|
||||||
|
};
|
||||||
// Handle the request error.
|
// Handle the request error.
|
||||||
const onError = ({
|
const onError = ({
|
||||||
response: {
|
response: {
|
||||||
data: { errors },
|
data: { errors },
|
||||||
},
|
},
|
||||||
}) => {};
|
}) => {
|
||||||
|
setSubmitting(false);
|
||||||
|
};
|
||||||
|
if (isNewMode) {
|
||||||
|
createCreditNoteMutate(form).then(onSuccess).catch(onError);
|
||||||
|
} else {
|
||||||
|
editCreditNoteMutate([creditNote.id, form])
|
||||||
|
.then(onSuccess)
|
||||||
|
.catch(onError);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const CreateCreditNoteFormSchema = getCreateCreditNoteFormSchema();
|
|
||||||
const EditCreditNoteFormSchema = getEditCreditNoteFormSchema();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames(
|
className={classNames(
|
||||||
@@ -99,10 +134,10 @@ function CreditNoteForm({
|
|||||||
>
|
>
|
||||||
<Formik
|
<Formik
|
||||||
validationSchema={
|
validationSchema={
|
||||||
true ? CreateCreditNoteFormSchema : EditCreditNoteFormSchema
|
isNewMode ? CreateCreditNoteFormSchema : EditCreditNoteFormSchema
|
||||||
}
|
}
|
||||||
initialValues={initialValues}
|
initialValues={initialValues}
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleFormSubmit}
|
||||||
>
|
>
|
||||||
<Form>
|
<Form>
|
||||||
<CreditNoteFormHeader />
|
<CreditNoteFormHeader />
|
||||||
|
|||||||
@@ -3,49 +3,45 @@ import intl from 'react-intl-universal';
|
|||||||
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
||||||
import { isBlank } from 'utils';
|
import { isBlank } from 'utils';
|
||||||
|
|
||||||
const getSchema = () => Yup.object().shape({
|
const getSchema = () =>
|
||||||
customer_id: Yup.string()
|
Yup.object().shape({
|
||||||
.label(intl.get('customer_name_'))
|
customer_id: Yup.string().label(intl.get('customer_name_')).required(),
|
||||||
.required(),
|
credit_note_date: Yup.date().required().label(intl.get('invoice_date_')),
|
||||||
invoice_date: Yup.date()
|
credit_note_number: Yup.string()
|
||||||
.required()
|
.max(DATATYPES_LENGTH.STRING)
|
||||||
.label(intl.get('invoice_date_')),
|
.label(intl.get('invoice_no_')),
|
||||||
invoice_no: Yup.string()
|
reference_no: Yup.string().min(1).max(DATATYPES_LENGTH.STRING),
|
||||||
.max(DATATYPES_LENGTH.STRING)
|
note: Yup.string()
|
||||||
.label(intl.get('invoice_no_')),
|
.trim()
|
||||||
reference_no: Yup.string().min(1).max(DATATYPES_LENGTH.STRING),
|
.min(1)
|
||||||
delivered: Yup.boolean(),
|
.max(DATATYPES_LENGTH.TEXT)
|
||||||
invoice_message: Yup.string()
|
.label(intl.get('note')),
|
||||||
.trim()
|
terms_conditions: Yup.string()
|
||||||
.min(1)
|
.trim()
|
||||||
.max(DATATYPES_LENGTH.TEXT)
|
.min(1)
|
||||||
.label(intl.get('note')),
|
.max(DATATYPES_LENGTH.TEXT)
|
||||||
terms_conditions: Yup.string()
|
.label(intl.get('note')),
|
||||||
.trim()
|
entries: Yup.array().of(
|
||||||
.min(1)
|
Yup.object().shape({
|
||||||
.max(DATATYPES_LENGTH.TEXT)
|
quantity: Yup.number()
|
||||||
.label(intl.get('note')),
|
.nullable()
|
||||||
entries: Yup.array().of(
|
.max(DATATYPES_LENGTH.INT_10)
|
||||||
Yup.object().shape({
|
.when(['rate'], {
|
||||||
quantity: Yup.number()
|
is: (rate) => rate,
|
||||||
.nullable()
|
then: Yup.number().required(),
|
||||||
.max(DATATYPES_LENGTH.INT_10)
|
}),
|
||||||
.when(['rate'], {
|
rate: Yup.number().nullable().max(DATATYPES_LENGTH.INT_10),
|
||||||
is: (rate) => rate,
|
item_id: Yup.number()
|
||||||
then: Yup.number().required(),
|
.nullable()
|
||||||
}),
|
.when(['quantity', 'rate'], {
|
||||||
rate: Yup.number().nullable().max(DATATYPES_LENGTH.INT_10),
|
is: (quantity, rate) => !isBlank(quantity) && !isBlank(rate),
|
||||||
item_id: Yup.number()
|
then: Yup.number().required(),
|
||||||
.nullable()
|
}),
|
||||||
.when(['quantity', 'rate'], {
|
discount: Yup.number().nullable().min(0).max(100),
|
||||||
is: (quantity, rate) => !isBlank(quantity) && !isBlank(rate),
|
description: Yup.string().nullable().max(DATATYPES_LENGTH.TEXT),
|
||||||
then: Yup.number().required(),
|
}),
|
||||||
}),
|
),
|
||||||
discount: Yup.number().nullable().min(0).max(100),
|
});
|
||||||
description: Yup.string().nullable().max(DATATYPES_LENGTH.TEXT),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
});
|
|
||||||
|
|
||||||
export const getCreateCreditNoteFormSchema = getSchema;
|
export const CreateCreditNoteFormSchema = getSchema;
|
||||||
export const getEditCreditNoteFormSchema = getSchema;
|
export const EditCreditNoteFormSchema = getSchema;
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ export default function CreditNoteFormFooter() {
|
|||||||
<Row>
|
<Row>
|
||||||
<Col md={8}>
|
<Col md={8}>
|
||||||
{/* --------- Customer notes --------- */}
|
{/* --------- Customer notes --------- */}
|
||||||
<FastField name={'invoice_message'}>
|
<FastField name={'note'}>
|
||||||
{({ field, meta: { error, touched } }) => (
|
{({ field, meta: { error, touched } }) => (
|
||||||
<FormGroup
|
<FormGroup
|
||||||
label={<T id={'credit_note.label_customer_note'} />}
|
label={<T id={'credit_note.label_customer_note'} />}
|
||||||
className={'form-group--customer_notes'}
|
className={'form-group--note'}
|
||||||
intent={inputIntent({ error, touched })}
|
intent={inputIntent({ error, touched })}
|
||||||
>
|
>
|
||||||
<TextArea growVertically={true} {...field} />
|
<TextArea growVertically={true} {...field} />
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ function CreditNoteFormHeaderFields() {
|
|||||||
)}
|
)}
|
||||||
</FastField>
|
</FastField>
|
||||||
{/* ----------- Credit note date ----------- */}
|
{/* ----------- Credit note date ----------- */}
|
||||||
<FastField name={'invoice_date'}>
|
<FastField name={'credit_note_date'}>
|
||||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||||
<FormGroup
|
<FormGroup
|
||||||
label={<T id={'credit_note.label_credit_note_date'} />}
|
label={<T id={'credit_note.label_credit_note_date'} />}
|
||||||
@@ -73,13 +73,13 @@ function CreditNoteFormHeaderFields() {
|
|||||||
labelInfo={<FieldRequiredHint />}
|
labelInfo={<FieldRequiredHint />}
|
||||||
className={classNames('form-group--credit_note_date', CLASSES.FILL)}
|
className={classNames('form-group--credit_note_date', CLASSES.FILL)}
|
||||||
intent={inputIntent({ error, touched })}
|
intent={inputIntent({ error, touched })}
|
||||||
helperText={<ErrorMessage name="invoice_date" />}
|
helperText={<ErrorMessage name="credit_note_date" />}
|
||||||
>
|
>
|
||||||
<DateInput
|
<DateInput
|
||||||
{...momentFormatter('YYYY/MM/DD')}
|
{...momentFormatter('YYYY/MM/DD')}
|
||||||
value={tansformDateValue(value)}
|
value={tansformDateValue(value)}
|
||||||
onChange={handleDateChange((formattedDate) => {
|
onChange={handleDateChange((formattedDate) => {
|
||||||
form.setFieldValue('invoice_date', formattedDate);
|
form.setFieldValue('credit_note_date', formattedDate);
|
||||||
})}
|
})}
|
||||||
popoverProps={{ position: Position.BOTTOM_LEFT, minimal: true }}
|
popoverProps={{ position: Position.BOTTOM_LEFT, minimal: true }}
|
||||||
inputProps={{
|
inputProps={{
|
||||||
@@ -90,15 +90,15 @@ function CreditNoteFormHeaderFields() {
|
|||||||
)}
|
)}
|
||||||
</FastField>
|
</FastField>
|
||||||
{/* ----------- Credit note # ----------- */}
|
{/* ----------- Credit note # ----------- */}
|
||||||
<Field name={'invoice_no'}>
|
<Field name={'credit_note_number'}>
|
||||||
{({ form, field, meta: { error, touched } }) => (
|
{({ form, field, meta: { error, touched } }) => (
|
||||||
<FormGroup
|
<FormGroup
|
||||||
label={<T id={'credit_note.label_credit_note'} />}
|
label={<T id={'credit_note.label_credit_note'} />}
|
||||||
labelInfo={<FieldRequiredHint />}
|
labelInfo={<FieldRequiredHint />}
|
||||||
inline={true}
|
inline={true}
|
||||||
className={classNames('form-group--invoice-no', CLASSES.FILL)}
|
className={classNames('form-group--credit_note_number', CLASSES.FILL)}
|
||||||
intent={inputIntent({ error, touched })}
|
intent={inputIntent({ error, touched })}
|
||||||
helperText={<ErrorMessage name="invoice_no" />}
|
helperText={<ErrorMessage name="credit_note_number" />}
|
||||||
>
|
>
|
||||||
<InputGroup minimal={true} {...field} />
|
<InputGroup minimal={true} {...field} />
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
|
|||||||
@@ -4,7 +4,13 @@ import { isEmpty, pick } from 'lodash';
|
|||||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||||
import { transformToEditForm } from './utils';
|
import { transformToEditForm } from './utils';
|
||||||
|
|
||||||
import { useInvoice, useItems, useCustomers } from 'hooks/query';
|
import {
|
||||||
|
useCreditNote,
|
||||||
|
useCreateCreditNote,
|
||||||
|
useEditCreditNote,
|
||||||
|
useItems,
|
||||||
|
useCustomers,
|
||||||
|
} from 'hooks/query';
|
||||||
|
|
||||||
const CreditNoteFormContext = React.createContext();
|
const CreditNoteFormContext = React.createContext();
|
||||||
|
|
||||||
@@ -12,14 +18,6 @@ const CreditNoteFormContext = React.createContext();
|
|||||||
* Credit note data provider.
|
* Credit note data provider.
|
||||||
*/
|
*/
|
||||||
function CreditNoteFormProvider({ creditNoteId, ...props }) {
|
function CreditNoteFormProvider({ creditNoteId, ...props }) {
|
||||||
const { state } = useLocation();
|
|
||||||
const invoiceId = state?.action;
|
|
||||||
|
|
||||||
// Fetches the invoice by the given id.
|
|
||||||
const { data: invoice, isLoading: isInvoiceLoading } = useInvoice(invoiceId, {
|
|
||||||
enabled: !!invoiceId,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Handle fetch customers data table or list
|
// Handle fetch customers data table or list
|
||||||
const {
|
const {
|
||||||
data: { customers },
|
data: { customers },
|
||||||
@@ -34,9 +32,17 @@ function CreditNoteFormProvider({ creditNoteId, ...props }) {
|
|||||||
page_size: 10000,
|
page_size: 10000,
|
||||||
});
|
});
|
||||||
|
|
||||||
// const newCreditNote =
|
// Handle fetch vendor credit details.
|
||||||
|
const { data: creditNote, isLoading: isCreditNoteLoading } = useCreditNote(
|
||||||
|
creditNoteId,
|
||||||
|
{
|
||||||
|
enabled: !!creditNoteId,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
// Create and edit credit note mutations.
|
// Create and edit credit note mutations.
|
||||||
|
const { mutateAsync: createCreditNoteMutate } = useCreateCreditNote();
|
||||||
|
const { mutateAsync: editCreditNoteMutate } = useEditCreditNote();
|
||||||
|
|
||||||
// Form submit payload.
|
// Form submit payload.
|
||||||
const [submitPayload, setSubmitPayload] = React.useState();
|
const [submitPayload, setSubmitPayload] = React.useState();
|
||||||
@@ -46,23 +52,24 @@ function CreditNoteFormProvider({ creditNoteId, ...props }) {
|
|||||||
|
|
||||||
// Provider payload.
|
// Provider payload.
|
||||||
const provider = {
|
const provider = {
|
||||||
invoice,
|
|
||||||
items,
|
items,
|
||||||
customers,
|
customers,
|
||||||
invoiceId,
|
creditNote,
|
||||||
submitPayload,
|
submitPayload,
|
||||||
|
isNewMode,
|
||||||
|
|
||||||
isItemsLoading,
|
isItemsLoading,
|
||||||
isCustomersLoading,
|
isCustomersLoading,
|
||||||
|
|
||||||
|
createCreditNoteMutate,
|
||||||
|
editCreditNoteMutate,
|
||||||
setSubmitPayload,
|
setSubmitPayload,
|
||||||
isNewMode,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardInsider
|
<DashboardInsider
|
||||||
loading={isInvoiceLoading || isItemsLoading || isCustomersLoading}
|
loading={isItemsLoading || isCustomersLoading || isCreditNoteLoading}
|
||||||
name={'credit-note-form'}
|
name={'credit-notes-form'}
|
||||||
>
|
>
|
||||||
<CreditNoteFormContext.Provider value={provider} {...props} />
|
<CreditNoteFormContext.Provider value={provider} {...props} />
|
||||||
</DashboardInsider>
|
</DashboardInsider>
|
||||||
|
|||||||
@@ -1,18 +1,14 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import * as R from 'ramda';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import intl from 'react-intl-universal';
|
|
||||||
import { useFormikContext } from 'formik';
|
|
||||||
import { Intent } from '@blueprintjs/core';
|
|
||||||
import { omit } from 'lodash';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
compose,
|
defaultFastFieldShouldUpdate,
|
||||||
transformToForm,
|
transformToForm,
|
||||||
repeatValue,
|
repeatValue,
|
||||||
transactionNumber,
|
orderingLinesIndexes,
|
||||||
defaultFastFieldShouldUpdate,
|
|
||||||
} from 'utils';
|
} from 'utils';
|
||||||
import { AppToaster } from 'components';
|
|
||||||
import {
|
import {
|
||||||
updateItemsEntriesTotal,
|
updateItemsEntriesTotal,
|
||||||
ensureEntriesHaveEmptyLine,
|
ensureEntriesHaveEmptyLine,
|
||||||
@@ -34,11 +30,11 @@ export const defaultCreditNoteEntry = {
|
|||||||
// Default credit note object.
|
// Default credit note object.
|
||||||
export const defaultCreditNote = {
|
export const defaultCreditNote = {
|
||||||
customer_id: '',
|
customer_id: '',
|
||||||
invoice_date: moment(new Date()).format('YYYY-MM-DD'),
|
credit_note_date: moment(new Date()).format('YYYY-MM-DD'),
|
||||||
invoice_no: '',
|
credit_note_number: '',
|
||||||
invoice_no_manually: false,
|
credit_note_no_manually: false,
|
||||||
reference_no: '',
|
// reference_no: '',
|
||||||
invoice_message: '',
|
note: '',
|
||||||
terms_conditions: '',
|
terms_conditions: '',
|
||||||
entries: [...repeatValue(defaultCreditNoteEntry, MIN_LINES_NUMBER)],
|
entries: [...repeatValue(defaultCreditNoteEntry, MIN_LINES_NUMBER)],
|
||||||
};
|
};
|
||||||
@@ -56,7 +52,7 @@ export function transformToEditForm(creditNote) {
|
|||||||
Math.max(MIN_LINES_NUMBER - creditNote.entries.length, 0),
|
Math.max(MIN_LINES_NUMBER - creditNote.entries.length, 0),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
const entries = compose(
|
const entries = R.compose(
|
||||||
ensureEntriesHaveEmptyLine(defaultCreditNoteEntry),
|
ensureEntriesHaveEmptyLine(defaultCreditNoteEntry),
|
||||||
updateItemsEntriesTotal,
|
updateItemsEntriesTotal,
|
||||||
)(initialEntries);
|
)(initialEntries);
|
||||||
@@ -67,6 +63,39 @@ export function transformToEditForm(creditNote) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transformes credit note entries to submit request.
|
||||||
|
*/
|
||||||
|
export const transformEntriesToSubmit = (entries) => {
|
||||||
|
const transformCreditNoteEntry = R.compose(
|
||||||
|
R.omit(['amount']),
|
||||||
|
R.curry(transformToForm)(R.__, defaultCreditNoteEntry),
|
||||||
|
);
|
||||||
|
return R.compose(
|
||||||
|
orderingLinesIndexes,
|
||||||
|
R.map(transformCreditNoteEntry),
|
||||||
|
)(entries);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filters the givne non-zero entries.
|
||||||
|
*/
|
||||||
|
export const filterNonZeroEntries = (entries) => {
|
||||||
|
return entries.filter((item) => item.item_id && item.quantity);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transformes form values to request body.
|
||||||
|
*/
|
||||||
|
export const transformFormValuesToRequest = (values) => {
|
||||||
|
const entries = filterNonZeroEntries(values.entries);
|
||||||
|
|
||||||
|
return {
|
||||||
|
...values,
|
||||||
|
entries: transformEntriesToSubmit(entries),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines customer name field when should update.
|
* Determines customer name field when should update.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -16,9 +16,10 @@ import {
|
|||||||
DashboardFilterButton,
|
DashboardFilterButton,
|
||||||
DashboardRowsHeightButton,
|
DashboardRowsHeightButton,
|
||||||
} from 'components';
|
} from 'components';
|
||||||
|
|
||||||
import DashboardActionsBar from '../../../../components/Dashboard/DashboardActionsBar';
|
import DashboardActionsBar from '../../../../components/Dashboard/DashboardActionsBar';
|
||||||
|
|
||||||
|
import { useCreditNoteListContext } from './CreditNotesListProvider';
|
||||||
|
|
||||||
import withCreditNotes from './withCreditNotes';
|
import withCreditNotes from './withCreditNotes';
|
||||||
import withCreditNotesActions from './withCreditNotesActions';
|
import withCreditNotesActions from './withCreditNotesActions';
|
||||||
import withSettings from '../../../Settings/withSettings';
|
import withSettings from '../../../Settings/withSettings';
|
||||||
@@ -45,20 +46,26 @@ function CreditNotesActionsBar({
|
|||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
// credit note list context.
|
// credit note list context.
|
||||||
|
const { CreditNotesView, fields, refresh } = useCreditNoteListContext();
|
||||||
// credit note refresh action.
|
|
||||||
|
|
||||||
// Handle view tab change.
|
// Handle view tab change.
|
||||||
const handleTabChange = (view) => {
|
const handleTabChange = (view) => {
|
||||||
setCreditNotesTableState({ viewSlug: view ? view.slug : null });
|
setCreditNotesTableState({ viewSlug: view ? view.slug : null });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle click a new Credit.
|
||||||
|
const handleClickNewCreateNote = () => {
|
||||||
|
history.push('/credit-notes/new');
|
||||||
|
};
|
||||||
|
|
||||||
// Handle click a refresh credit note.
|
// Handle click a refresh credit note.
|
||||||
const handleRefreshBtnClick = () => {};
|
const handleRefreshBtnClick = () => {
|
||||||
|
refresh();
|
||||||
|
};
|
||||||
|
|
||||||
// Handle table row size change.
|
// Handle table row size change.
|
||||||
const handleTableRowSizeChange = (size) => {
|
const handleTableRowSizeChange = (size) => {
|
||||||
addSetting('creditNote', 'tableSize', size);
|
addSetting('creditNotes', 'tableSize', size);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -66,11 +73,31 @@ function CreditNotesActionsBar({
|
|||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
<DashboardActionViewsList
|
<DashboardActionViewsList
|
||||||
allMenuItem={true}
|
allMenuItem={true}
|
||||||
resourceName={'credit_note'}
|
resourceName={'credit_notes'}
|
||||||
views={[]}
|
views={CreditNotesView}
|
||||||
onChange={handleTabChange}
|
onChange={handleTabChange}
|
||||||
/>
|
/>
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon={'plus'} />}
|
||||||
|
text={<T id={'credit_note.label.new_credit_note'} />}
|
||||||
|
onClick={handleClickNewCreateNote}
|
||||||
|
/>
|
||||||
|
<AdvancedFilterPopover
|
||||||
|
advancedFilterProps={{
|
||||||
|
conditions: creditNoteFilterRoles,
|
||||||
|
defaultFieldKey: 'created_at',
|
||||||
|
fields: fields,
|
||||||
|
onFilterChange: (filterConditions) => {
|
||||||
|
setCreditNotesTableState({ filterRoles: filterConditions });
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<DashboardFilterButton
|
||||||
|
conditionsCount={creditNoteFilterRoles.length}
|
||||||
|
/>
|
||||||
|
</AdvancedFilterPopover>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import withCreditNotesActions from './withCreditNotesActions';
|
|||||||
import withSettings from '../../../Settings/withSettings';
|
import withSettings from '../../../Settings/withSettings';
|
||||||
import withAlertsActions from 'containers/Alert/withAlertActions';
|
import withAlertsActions from 'containers/Alert/withAlertActions';
|
||||||
|
|
||||||
import { useCreditNoteTableColumns } from './components';
|
import { useCreditNoteTableColumns, ActionsMenu } from './components';
|
||||||
import { useCreditNoteListContext } from './CreditNotesListProvider';
|
import { useCreditNoteListContext } from './CreditNotesListProvider';
|
||||||
|
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
@@ -35,13 +35,20 @@ function CreditNotesDataTable({
|
|||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
// Credit note list context.
|
// Credit note list context.
|
||||||
|
const {
|
||||||
|
creditNotes,
|
||||||
|
pagination,
|
||||||
|
isEmptyStatus,
|
||||||
|
isCreditNotesFetching,
|
||||||
|
isCreditNotesLoading,
|
||||||
|
} = useCreditNoteListContext();
|
||||||
|
|
||||||
// Credit note table columns.
|
// Credit note table columns.
|
||||||
const columns = useCreditNoteTableColumns();
|
const columns = useCreditNoteTableColumns();
|
||||||
|
|
||||||
// Local storage memorizing columns widths.
|
// Local storage memorizing columns widths.
|
||||||
const [initialColumnsWidths, , handleColumnResizing] =
|
const [initialColumnsWidths, , handleColumnResizing] =
|
||||||
useMemorizedColumnsWidths(TABLES.CREDIT_NOTE);
|
useMemorizedColumnsWidths(TABLES.CREDIT_NOTES);
|
||||||
|
|
||||||
// Handles fetch data once the table state change.
|
// Handles fetch data once the table state change.
|
||||||
const handleDataTableFetchData = React.useCallback(
|
const handleDataTableFetchData = React.useCallback(
|
||||||
@@ -55,9 +62,14 @@ function CreditNotesDataTable({
|
|||||||
[setCreditNotesTableState],
|
[setCreditNotesTableState],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Display create note empty status instead of the table.
|
||||||
|
if (isEmptyStatus) {
|
||||||
|
return <CreditNoteEmptyStatus />;
|
||||||
|
}
|
||||||
|
|
||||||
// Handle delete credit note.
|
// Handle delete credit note.
|
||||||
const handleDeleteCreditNote = ({ id }) => {
|
const handleDeleteCreditNote = ({ id }) => {
|
||||||
openAlert('sale-credit-note-delete', { creditNoteId: id });
|
openAlert('credit-note-delete', { creditNoteId: id });
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle edit credit note.
|
// Handle edit credit note.
|
||||||
@@ -69,19 +81,19 @@ function CreditNotesDataTable({
|
|||||||
<DashboardContentTable>
|
<DashboardContentTable>
|
||||||
<DataTable
|
<DataTable
|
||||||
columns={columns}
|
columns={columns}
|
||||||
data={[]}
|
data={creditNotes}
|
||||||
// loading={}
|
loading={isCreditNotesLoading}
|
||||||
// headerLoading={}
|
headerLoading={isCreditNotesLoading}
|
||||||
// progressBarLoading={}
|
progressBarLoading={isCreditNotesFetching}
|
||||||
onFetchData={handleDataTableFetchData}
|
onFetchData={handleDataTableFetchData}
|
||||||
manualSortBy={true}
|
|
||||||
selectionColumn={true}
|
selectionColumn={true}
|
||||||
noInitialFetch={true}
|
noInitialFetch={true}
|
||||||
sticky={true}
|
sticky={true}
|
||||||
autoResetSortBy={false}
|
pagination={true}
|
||||||
autoResetPage={false}
|
pagesCount={pagination.pagesCount}
|
||||||
TableLoadingRenderer={TableSkeletonRows}
|
TableLoadingRenderer={TableSkeletonRows}
|
||||||
TableHeaderSkeletonRenderer={TableSkeletonHeader}
|
TableHeaderSkeletonRenderer={TableSkeletonHeader}
|
||||||
|
ContextMenu={ActionsMenu}
|
||||||
initialColumnsWidths={initialColumnsWidths}
|
initialColumnsWidths={initialColumnsWidths}
|
||||||
onColumnResizing={handleColumnResizing}
|
onColumnResizing={handleColumnResizing}
|
||||||
size={creditNoteTableSize}
|
size={creditNoteTableSize}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { EmptyStatus } from 'components';
|
|||||||
import { FormattedMessage as T } from 'components';
|
import { FormattedMessage as T } from 'components';
|
||||||
|
|
||||||
export default function CreditNotesEmptyStatus() {
|
export default function CreditNotesEmptyStatus() {
|
||||||
|
const history = useHistory();
|
||||||
return (
|
return (
|
||||||
<EmptyStatus
|
<EmptyStatus
|
||||||
title={<T id={'the_organization_doesn_t_receive_money_yet'} />}
|
title={<T id={'the_organization_doesn_t_receive_money_yet'} />}
|
||||||
@@ -15,8 +16,12 @@ export default function CreditNotesEmptyStatus() {
|
|||||||
}
|
}
|
||||||
action={
|
action={
|
||||||
<>
|
<>
|
||||||
<Button intent={Intent.PRIMARY} large={true}>
|
<Button
|
||||||
<T id={'credit_note.new_credit_note'} />
|
intent={Intent.PRIMARY}
|
||||||
|
large={true}
|
||||||
|
onClick={() => history.push('/credit-notes/new')}
|
||||||
|
>
|
||||||
|
<T id={'credit_note.label.new_credit_note'} />
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button intent={Intent.NONE} large={true}>
|
<Button intent={Intent.NONE} large={true}>
|
||||||
|
|||||||
@@ -22,12 +22,15 @@ function CreditNotesList({
|
|||||||
resetCreditNotesTableState,
|
resetCreditNotesTableState,
|
||||||
}) {
|
}) {
|
||||||
// Resets the credit note table state once the page unmount.
|
// Resets the credit note table state once the page unmount.
|
||||||
// React.useEffect(
|
React.useEffect(
|
||||||
// () => () => {
|
() => () => {
|
||||||
// resetCreditNotesTableState();
|
resetCreditNotesTableState();
|
||||||
// },
|
},
|
||||||
// [resetCreditNotesTableState],
|
[resetCreditNotesTableState],
|
||||||
// );
|
);
|
||||||
|
|
||||||
|
console.log(creditNoteTableState, 'XX');
|
||||||
|
console.log(creditNoteTableStateChanged, 'XX');
|
||||||
return (
|
return (
|
||||||
<CreditNotesListProvider
|
<CreditNotesListProvider
|
||||||
query={transformTableStateToQuery(creditNoteTableState)}
|
query={transformTableStateToQuery(creditNoteTableState)}
|
||||||
|
|||||||
@@ -2,6 +2,13 @@ import React from 'react';
|
|||||||
import { isEmpty } from 'lodash';
|
import { isEmpty } from 'lodash';
|
||||||
|
|
||||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||||
|
import {
|
||||||
|
useResourceViews,
|
||||||
|
useResourceMeta,
|
||||||
|
useCreditNotes,
|
||||||
|
useRefreshCreditNotes,
|
||||||
|
} from 'hooks/query';
|
||||||
|
|
||||||
import { getFieldsFromResourceMeta } from 'utils';
|
import { getFieldsFromResourceMeta } from 'utils';
|
||||||
|
|
||||||
const CreditNoteListContext = React.createContext();
|
const CreditNoteListContext = React.createContext();
|
||||||
@@ -10,13 +17,53 @@ const CreditNoteListContext = React.createContext();
|
|||||||
* Credit note data provider.
|
* Credit note data provider.
|
||||||
*/
|
*/
|
||||||
function CreditNotesListProvider({ query, tableStateChanged, ...props }) {
|
function CreditNotesListProvider({ query, tableStateChanged, ...props }) {
|
||||||
|
// Credit notes refresh action.
|
||||||
|
const { refresh } = useRefreshCreditNotes();
|
||||||
|
|
||||||
|
// Fetch create notes resource views and fields.
|
||||||
|
const { data: CreditNotesView, isLoading: isViewsLoading } =
|
||||||
|
useResourceViews('credit_notes');
|
||||||
|
|
||||||
|
// Fetch the accounts resource fields.
|
||||||
|
const {
|
||||||
|
data: resourceMeta,
|
||||||
|
isLoading: isResourceLoading,
|
||||||
|
isFetching: isResourceFetching,
|
||||||
|
} = useResourceMeta('credit_notes');
|
||||||
|
|
||||||
|
// Fetch credit note list.
|
||||||
|
const {
|
||||||
|
data: { creditNotes, pagination, filterMeta },
|
||||||
|
isFetching: isCreditNotesFetching,
|
||||||
|
isLoading: isCreditNotesLoading,
|
||||||
|
} = useCreditNotes(query, { keepPreviousData: true });
|
||||||
|
|
||||||
|
// Detarmines the datatable empty status.S
|
||||||
|
const isEmptyStatus = isEmpty(creditNotes) && !isCreditNotesLoading && !tableStateChanged;
|
||||||
|
|
||||||
// Provider payload.
|
// Provider payload.
|
||||||
const provider = {};
|
const provider = {
|
||||||
|
creditNotes,
|
||||||
|
pagination,
|
||||||
|
|
||||||
|
CreditNotesView,
|
||||||
|
refresh,
|
||||||
|
|
||||||
|
resourceMeta,
|
||||||
|
fields: getFieldsFromResourceMeta(resourceMeta.fields),
|
||||||
|
isResourceLoading,
|
||||||
|
isResourceFetching,
|
||||||
|
|
||||||
|
isCreditNotesFetching,
|
||||||
|
isCreditNotesLoading,
|
||||||
|
isViewsLoading,
|
||||||
|
isEmptyStatus,
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardInsider
|
<DashboardInsider
|
||||||
// loading={}
|
loading={isViewsLoading || isResourceLoading}
|
||||||
name={'credit-note-list'}
|
name={'credit-notes-list'}
|
||||||
>
|
>
|
||||||
<CreditNoteListContext.Provider value={provider} {...props} />
|
<CreditNoteListContext.Provider value={provider} {...props} />
|
||||||
</DashboardInsider>
|
</DashboardInsider>
|
||||||
@@ -25,4 +72,4 @@ function CreditNotesListProvider({ query, tableStateChanged, ...props }) {
|
|||||||
|
|
||||||
const useCreditNoteListContext = () => React.useContext(CreditNoteListContext);
|
const useCreditNoteListContext = () => React.useContext(CreditNoteListContext);
|
||||||
|
|
||||||
export { CreditNotesListProvider , useCreditNoteListContext };
|
export { CreditNotesListProvider, useCreditNoteListContext };
|
||||||
|
|||||||
@@ -20,11 +20,9 @@ function CreditNotesViewTabs({
|
|||||||
setCreditNotesTableState,
|
setCreditNotesTableState,
|
||||||
}) {
|
}) {
|
||||||
// Credit note list context.
|
// Credit note list context.
|
||||||
|
const { CreditNotesView } = useCreditNoteListContext();
|
||||||
|
|
||||||
// Handle click a new view tab.
|
const tabs = transfromViewsToTabs(CreditNotesView);
|
||||||
const handleClickNewView = () => {};
|
|
||||||
|
|
||||||
// const tabs = transfromViewsToTabs(creditNoteCurrentView);
|
|
||||||
|
|
||||||
// Handle tab change.
|
// Handle tab change.
|
||||||
const handleTabsChange = (viewSlug) => {
|
const handleTabsChange = (viewSlug) => {
|
||||||
@@ -33,7 +31,14 @@ function CreditNotesViewTabs({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Navbar className={'navbar--dashboard-views'}>
|
<Navbar className={'navbar--dashboard-views'}>
|
||||||
<NavbarGroup align={Alignment.LEFT}></NavbarGroup>
|
<NavbarGroup align={Alignment.LEFT}>
|
||||||
|
<DashboardViewsTabs
|
||||||
|
currentViewSlug={creditNoteCurrentView}
|
||||||
|
resourceName={'credit_notes'}
|
||||||
|
tabs={tabs}
|
||||||
|
onChange={handleTabsChange}
|
||||||
|
/>
|
||||||
|
</NavbarGroup>
|
||||||
</Navbar>
|
</Navbar>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,15 +22,7 @@ import {
|
|||||||
import { formattedAmount, safeCallback, calculateStatus } from 'utils';
|
import { formattedAmount, safeCallback, calculateStatus } from 'utils';
|
||||||
|
|
||||||
export function ActionsMenu({
|
export function ActionsMenu({
|
||||||
payload: {
|
payload: { onEdit, onDelete, onViewDetails },
|
||||||
onEdit,
|
|
||||||
onDeliver,
|
|
||||||
onDelete,
|
|
||||||
onDrawer,
|
|
||||||
onQuick,
|
|
||||||
onViewDetails,
|
|
||||||
onPrint,
|
|
||||||
},
|
|
||||||
row: { original },
|
row: { original },
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
@@ -38,15 +30,16 @@ export function ActionsMenu({
|
|||||||
<MenuItem
|
<MenuItem
|
||||||
icon={<Icon icon="reader-18" />}
|
icon={<Icon icon="reader-18" />}
|
||||||
text={intl.get('view_details')}
|
text={intl.get('view_details')}
|
||||||
|
onClick={safeCallback(onViewDetails, original)}
|
||||||
/>
|
/>
|
||||||
<MenuDivider />
|
<MenuDivider />
|
||||||
<MenuItem
|
<MenuItem
|
||||||
icon={<Icon icon="pen-18" />}
|
icon={<Icon icon="pen-18" />}
|
||||||
text={intl.get('credit_note.label_edit_credit_note')}
|
text={intl.get('credit_note.action.edit_credit_note')}
|
||||||
onClick={safeCallback(onEdit, original)}
|
onClick={safeCallback(onEdit, original)}
|
||||||
/>
|
/>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
text={intl.get('credit_note.label_delete_credit_note')}
|
text={intl.get('credit_note.action.delete_credit_note')}
|
||||||
intent={Intent.DANGER}
|
intent={Intent.DANGER}
|
||||||
onClick={safeCallback(onDelete, original)}
|
onClick={safeCallback(onDelete, original)}
|
||||||
icon={<Icon icon="trash-16" iconSize={16} />}
|
icon={<Icon icon="trash-16" iconSize={16} />}
|
||||||
@@ -62,12 +55,12 @@ export function useCreditNoteTableColumns() {
|
|||||||
return React.useMemo(
|
return React.useMemo(
|
||||||
() => [
|
() => [
|
||||||
{
|
{
|
||||||
id: 'date',
|
id: 'credit_note_date',
|
||||||
Header: intl.get('date'),
|
Header: intl.get('credit_note.column.credit_date'),
|
||||||
accessor: 'date',
|
accessor: 'credit_note_date',
|
||||||
Cell: FormatDateCell,
|
Cell: FormatDateCell,
|
||||||
width: 110,
|
width: 110,
|
||||||
className: 'date',
|
className: 'credit_note_date',
|
||||||
clickable: true,
|
clickable: true,
|
||||||
textOverview: true,
|
textOverview: true,
|
||||||
},
|
},
|
||||||
@@ -81,17 +74,18 @@ export function useCreditNoteTableColumns() {
|
|||||||
textOverview: true,
|
textOverview: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'credit_note',
|
id: 'credit_note_number',
|
||||||
Header: intl.get('credit_note.label_credit_note_no'),
|
Header: intl.get('credit_note.column.credit_note_no'),
|
||||||
accessor: 'credit_note',
|
accessor: 'credit_note_number',
|
||||||
width: 100,
|
width: 100,
|
||||||
className: 'credit_note',
|
className: 'credit_note_number',
|
||||||
clickable: true,
|
clickable: true,
|
||||||
textOverview: true,
|
textOverview: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'amount',
|
id: 'amount',
|
||||||
Header: intl.get('amount'),
|
Header: intl.get('amount'),
|
||||||
|
accessor: 'amount',
|
||||||
// accessor: 'formatted_amount',
|
// accessor: 'formatted_amount',
|
||||||
width: 120,
|
width: 120,
|
||||||
align: 'right',
|
align: 'right',
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ import {
|
|||||||
resetCreditNotesTableState,
|
resetCreditNotesTableState,
|
||||||
} from '../../../../store/CreditNotes/creditNotes.actions';
|
} from '../../../../store/CreditNotes/creditNotes.actions';
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDipatchToProps = (dispatch) => ({
|
||||||
setCreditNoteTableState: (state) => dispatch(setCreditNotesTableState(state)),
|
setCreditNotesTableState: (queries) =>
|
||||||
resetCreditNoteTableState: () => dispatch(resetCreditNotesTableState()),
|
dispatch(setCreditNotesTableState(queries)),
|
||||||
|
resetCreditNotesTableState: () => dispatch(resetCreditNotesTableState()),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(null, mapDispatchToProps);
|
export default connect(null, mapDipatchToProps);
|
||||||
|
|||||||
168
src/hooks/query/creditNote.js
Normal file
168
src/hooks/query/creditNote.js
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
import { useQueryClient, useMutation } from 'react-query';
|
||||||
|
import { useRequestQuery } from '../useQueryRequest';
|
||||||
|
import { transformPagination } from 'utils';
|
||||||
|
import useApiRequest from '../useRequest';
|
||||||
|
import t from './types';
|
||||||
|
|
||||||
|
const commonInvalidateQueries = (queryClient) => {
|
||||||
|
// Invalidate credit note.
|
||||||
|
queryClient.invalidateQueries(t.CREDIT_NOTES);
|
||||||
|
queryClient.invalidateQueries(t.CREDIT_NOTE);
|
||||||
|
|
||||||
|
// Invalidate items.
|
||||||
|
queryClient.invalidateQueries(t.ITEMS);
|
||||||
|
queryClient.invalidateQueries(t.ITEM);
|
||||||
|
|
||||||
|
// Invalidate customers.
|
||||||
|
queryClient.invalidateQueries([t.CUSTOMER]);
|
||||||
|
queryClient.invalidateQueries(t.CUSTOMERS);
|
||||||
|
|
||||||
|
// Invalidate accounts.
|
||||||
|
queryClient.invalidateQueries(t.ACCOUNTS);
|
||||||
|
queryClient.invalidateQueries(t.ACCOUNT);
|
||||||
|
|
||||||
|
// Invalidate financial reports.
|
||||||
|
queryClient.invalidateQueries(t.FINANCIAL_REPORT);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new credit note.
|
||||||
|
*/
|
||||||
|
export function useCreateCreditNote(props) {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const apiRequest = useApiRequest();
|
||||||
|
|
||||||
|
return useMutation(
|
||||||
|
(values) => apiRequest.post('sales/credit_notes', values),
|
||||||
|
{
|
||||||
|
onSuccess: (res, values) => {
|
||||||
|
// Common invalidate queries.
|
||||||
|
commonInvalidateQueries(queryClient);
|
||||||
|
},
|
||||||
|
...props,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit the given credit note.
|
||||||
|
*/
|
||||||
|
export function useEditCreditNote(props) {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const apiRequest = useApiRequest();
|
||||||
|
|
||||||
|
return useMutation(
|
||||||
|
([id, values]) => apiRequest.post(`sales/credit_notes/${id}`, values),
|
||||||
|
{
|
||||||
|
onSuccess: (res, [id, values]) => {
|
||||||
|
// Common invalidate queries.
|
||||||
|
commonInvalidateQueries(queryClient);
|
||||||
|
|
||||||
|
// Invalidate credit note query.
|
||||||
|
queryClient.invalidateQueries([t.CREDIT_NOTE, id]);
|
||||||
|
},
|
||||||
|
...props,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the given credit note.
|
||||||
|
*/
|
||||||
|
export function useDeleteCreditNote(props) {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const apiRequest = useApiRequest();
|
||||||
|
|
||||||
|
return useMutation((id) => apiRequest.delete(`sales/credit_notes/${id}`), {
|
||||||
|
onSuccess: (res, id) => {
|
||||||
|
// Common invalidate queries.
|
||||||
|
commonInvalidateQueries(queryClient);
|
||||||
|
|
||||||
|
// Invalidate vendor credit query.
|
||||||
|
queryClient.invalidateQueries([t.CREDIT_NOTE, id]);
|
||||||
|
},
|
||||||
|
...props,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const transformInvoices = (res) => ({
|
||||||
|
creditNotes: res.data.credit_notes,
|
||||||
|
pagination: transformPagination(res.data.pagination),
|
||||||
|
filterMeta: res.data.filter_meta,
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve credit notes list with pagination meta.
|
||||||
|
*/
|
||||||
|
export function useCreditNotes(query, props) {
|
||||||
|
|
||||||
|
|
||||||
|
return useRequestQuery(
|
||||||
|
[t.CREDIT_NOTES, query],
|
||||||
|
{ method: 'get', url: 'sales/credit_notes', params: query },
|
||||||
|
{
|
||||||
|
select: transformInvoices,
|
||||||
|
defaultData: {
|
||||||
|
creditNotes: [],
|
||||||
|
pagination: {
|
||||||
|
page: 1,
|
||||||
|
pageSize: 20,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
filterMeta: {},
|
||||||
|
},
|
||||||
|
...props,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// export function useCreditNotes(query, props) {
|
||||||
|
// return useRequestQuery(
|
||||||
|
// [t.CREDIT_NOTES],
|
||||||
|
// {
|
||||||
|
// method: 'get',
|
||||||
|
// url: 'sales/credit_notes',
|
||||||
|
// params: query,
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// select: transformVendorCreditsResponse,
|
||||||
|
// defaultData: {
|
||||||
|
// credit_notes: {},
|
||||||
|
// pagination: {
|
||||||
|
// page: 1,
|
||||||
|
// page_size: 12,
|
||||||
|
// total: 0,
|
||||||
|
// },
|
||||||
|
// filterMeta: {},
|
||||||
|
// },
|
||||||
|
// ...props,
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve credit note detail of the given id.
|
||||||
|
* @param {number} id
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export function useCreditNote(id, props, requestProps) {
|
||||||
|
return useRequestQuery(
|
||||||
|
[t.CREDIT_NOTE, id],
|
||||||
|
{ method: 'get', url: `sales/credit_notes/${id}`, ...requestProps },
|
||||||
|
{
|
||||||
|
select: (res) => res.data.credit_note,
|
||||||
|
defaultData: {},
|
||||||
|
...props,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useRefreshCreditNotes() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return {
|
||||||
|
refresh: () => {
|
||||||
|
queryClient.invalidateQueries(t.CREDIT_NOTES);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -28,6 +28,7 @@ export * from './UniversalSearch/UniversalSearch';
|
|||||||
export * from './GenericResource';
|
export * from './GenericResource';
|
||||||
export * from './jobs';
|
export * from './jobs';
|
||||||
export * from './misc';
|
export * from './misc';
|
||||||
export * from './cashflowAccounts'
|
export * from './cashflowAccounts';
|
||||||
export * from './roles'
|
export * from './roles';
|
||||||
export * from './vendorCredit'
|
export * from './creditNote';
|
||||||
|
export * from './vendorCredit';
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ const transformInvoices = (res) => ({
|
|||||||
* Retrieve sale invoices list with pagination meta.
|
* Retrieve sale invoices list with pagination meta.
|
||||||
*/
|
*/
|
||||||
export function useInvoices(query, props) {
|
export function useInvoices(query, props) {
|
||||||
|
|
||||||
return useRequestQuery(
|
return useRequestQuery(
|
||||||
[t.SALE_INVOICES, query],
|
[t.SALE_INVOICES, query],
|
||||||
{ method: 'get', url: 'sales/invoices', params: query },
|
{ method: 'get', url: 'sales/invoices', params: query },
|
||||||
|
|||||||
@@ -1467,51 +1467,54 @@
|
|||||||
"sms_notification.payment_details.type": "Payment receive thank you.",
|
"sms_notification.payment_details.type": "Payment receive thank you.",
|
||||||
"sms_notification.receipt_details.type": "Sale receipt details",
|
"sms_notification.receipt_details.type": "Sale receipt details",
|
||||||
"personal": "Personal",
|
"personal": "Personal",
|
||||||
"list.create":"Create {value}",
|
"list.create": "Create {value}",
|
||||||
"roles.label":"Roles",
|
"roles.label": "Roles",
|
||||||
"roles.column.name":"Name",
|
"roles.column.name": "Name",
|
||||||
"roles.column.description":"Description",
|
"roles.column.description": "Description",
|
||||||
"roles.edit_roles":"Edit Roles",
|
"roles.edit_roles": "Edit Roles",
|
||||||
"roles.delete_roles":"Delete Roles",
|
"roles.delete_roles": "Delete Roles",
|
||||||
"roles.label.role_name":"Role Name",
|
"roles.label.role_name": "Role Name",
|
||||||
"roles.label.role_name_":"Role name",
|
"roles.label.role_name_": "Role name",
|
||||||
"roles.error.role_is_predefined":"Role is predefined, you cannot delete predefined roles.",
|
"roles.error.role_is_predefined": "Role is predefined, you cannot delete predefined roles.",
|
||||||
"roles.error.you_cannot_change_your_own_role":"You cannot change your own role.",
|
"roles.error.you_cannot_change_your_own_role": "You cannot change your own role.",
|
||||||
"sidebar.transactions_locaking":"Transactions Locaking",
|
"sidebar.transactions_locaking": "Transactions Locaking",
|
||||||
"transactions_locking.dialog.label":"Transactions locking",
|
"transactions_locking.dialog.label": "Transactions locking",
|
||||||
"roles.permission_schema.success_message":"The role has been created successfully.",
|
"roles.permission_schema.success_message": "The role has been created successfully.",
|
||||||
"roles.permission_schema.upload_message":"The given role has been updated successfully.",
|
"roles.permission_schema.upload_message": "The given role has been updated successfully.",
|
||||||
"roles.permission_schema.delete.alert_message":"The given role has been deleted successfully.",
|
"roles.permission_schema.delete.alert_message": "The given role has been deleted successfully.",
|
||||||
"roles.permission_schema.once_delete_this_role_you_will_able_to_restore_it":"Once you delete this role, you won't be able to restore it later. Are you sure you want to delete this role?",
|
"roles.permission_schema.once_delete_this_role_you_will_able_to_restore_it": "Once you delete this role, you won't be able to restore it later. Are you sure you want to delete this role?",
|
||||||
"users.column.role_name":"Role Name",
|
"users.column.role_name": "Role Name",
|
||||||
"roles.error.you_cannot_edit_predefined_roles":"You cannot edit predefined roles.",
|
"roles.error.you_cannot_edit_predefined_roles": "You cannot edit predefined roles.",
|
||||||
"roles.error.you_cannot_delete_predefined_roles":"You cannot delete predefined roles.",
|
"roles.error.you_cannot_delete_predefined_roles": "You cannot delete predefined roles.",
|
||||||
"roles.error.the_submit_role_has_invalid_permissions":"The submit role has invalid permissions.",
|
"roles.error.the_submit_role_has_invalid_permissions": "The submit role has invalid permissions.",
|
||||||
"roles.error.you_cannot_delete_role_that_associated_to_users":"You cannot delete role that associated to users",
|
"roles.error.you_cannot_delete_role_that_associated_to_users": "You cannot delete role that associated to users",
|
||||||
"sidebar_credit_note": "Credit Notes",
|
"sidebar_credit_note": "Credit Notes",
|
||||||
"credit_note.label_list": "Credit Note List",
|
"credit_note.label_create_note_list": "Credit Note List",
|
||||||
"credit_note.new_credit_note": "New Credit Note",
|
"credit_note.label.new_credit_note": "New Credit Note",
|
||||||
"credit_note.edit_credit_note": "Edit Credit Note",
|
"credit_note.label.edit_credit_note": "Edit Credit Note",
|
||||||
"credit_note.label_credit_note_no": "Credit Note #",
|
"credit_note.action.edit_credit_note": "Edit Credit note",
|
||||||
|
"credit_note.action.delete_credit_note": "Delete Credit note",
|
||||||
|
"credit_note.column.credit_note_no": "Credit Note #",
|
||||||
|
"credit_note.column.credit_date": "Credit Date",
|
||||||
"credit_note.empty_status_description": "Record sales transactions from customers who make no or partial payment and help you keep track of accounts receivable with a customer.",
|
"credit_note.empty_status_description": "Record sales transactions from customers who make no or partial payment and help you keep track of accounts receivable with a customer.",
|
||||||
"credit_note.label_credit_note_date": "Credit Note date",
|
"credit_note.label_credit_note_date": "Credit Note date",
|
||||||
"credit_note.label_credit_note": "Credit Note #",
|
"credit_note.label_credit_note": "Credit Note #",
|
||||||
"credit_note.label_credit_note_details": "Credit Note details",
|
"credit_note.label_credit_note_details": "Credit Note details",
|
||||||
"credit_note.label_customer_note": "Customer notes",
|
"credit_note.label_customer_note": "Customer notes",
|
||||||
"credit_note.label_edit_credit_note": "Edit Credit note",
|
|
||||||
"credit_note.label_delete_credit_note": "Delete Credit note",
|
|
||||||
"credit_note.once_delete_this_credit_note": "Once you delete this credit note, you won't be able to restore it later. Are you sure you want to delete this credit note?",
|
"credit_note.once_delete_this_credit_note": "Once you delete this credit note, you won't be able to restore it later. Are you sure you want to delete this credit note?",
|
||||||
|
"credit_note.alert.success_message": "The credit note has been deleted successfully",
|
||||||
"sidebar_vendor_credits":"Vendor Credits",
|
"credit_note.success_message": "The credit note has been created successfully.",
|
||||||
"vendor_credits.lable_vendor_credit_list":"Vendor Credit List",
|
"credit_note.edit_success_message": "The credit note has been edited successfully.",
|
||||||
"vendor_credits.label.new_vendor_credit":"New Vendor Credit",
|
"sidebar_vendor_credits": "Vendor Credits",
|
||||||
"vendor_credits.label.edit_vendor_credit":"Edit Vendor Credit",
|
"vendor_credits.lable_vendor_credit_list": "Vendor Credit List",
|
||||||
"vendor_credits.column.vendor_credit_no":"Vendor Credit #",
|
"vendor_credits.label.new_vendor_credit": "New Vendor Credit",
|
||||||
"vendor_credits.action.new_vendor_credit":"New Vendor Credit",
|
"vendor_credits.label.edit_vendor_credit": "Edit Vendor Credit",
|
||||||
"vendor_credits.action.edit_vendor_credit":"Edit Vendot Credit",
|
"vendor_credits.column.vendor_credit_no": "Vendor Credit #",
|
||||||
"vendor_credits.action.delete_vendor_credit":"Delete Vendot Credit",
|
"vendor_credits.action.new_vendor_credit": "New Vendor Credit",
|
||||||
"vendor_credits.success_message":"The vendor credit has been created successfully",
|
"vendor_credits.action.edit_vendor_credit": "Edit Vendot Credit",
|
||||||
"vendor_credits.edit_success_message":"The vendor credit has been edited successfully.",
|
"vendor_credits.action.delete_vendor_credit": "Delete Vendot Credit",
|
||||||
"vendor_credits.alert.success_message":"The given vendor credit has been deleted successfully.",
|
"vendor_credits.success_message": "The vendor credit has been created successfully",
|
||||||
|
"vendor_credits.edit_success_message": "The vendor credit has been edited successfully.",
|
||||||
|
"vendor_credits.alert.success_message": "The given vendor credit has been deleted successfully.",
|
||||||
"vendor_credits.note.once_delete_this_vendor_credit_note": "Once you delete this vendor credit , you won't be able to restore it later. Are you sure you want to delete this vendor credit ?"
|
"vendor_credits.note.once_delete_this_vendor_credit_note": "Once you delete this vendor credit , you won't be able to restore it later. Are you sure you want to delete this vendor credit ?"
|
||||||
}
|
}
|
||||||
@@ -640,7 +640,7 @@ export const getDashboardRoutes = () => [
|
|||||||
),
|
),
|
||||||
name: 'credit-note-edit',
|
name: 'credit-note-edit',
|
||||||
breadcrumb: intl.get('edit'),
|
breadcrumb: intl.get('edit'),
|
||||||
pageTitle: intl.get('credit_note.edit_credit_note'),
|
pageTitle: intl.get('credit_note.label.edit_credit_note'),
|
||||||
backLink: true,
|
backLink: true,
|
||||||
sidebarExpand: false,
|
sidebarExpand: false,
|
||||||
defaultSearchResource: RESOURCES_TYPES.CREDIT_NOTE,
|
defaultSearchResource: RESOURCES_TYPES.CREDIT_NOTE,
|
||||||
@@ -654,10 +654,10 @@ export const getDashboardRoutes = () => [
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
name: 'credit-note-new',
|
name: 'credit-note-new',
|
||||||
breadcrumb: intl.get('credit_note.new_credit_note'),
|
breadcrumb: intl.get('credit_note.label.new_credit_note'),
|
||||||
backLink: true,
|
backLink: true,
|
||||||
sidebarExpand: false,
|
sidebarExpand: false,
|
||||||
pageTitle: intl.get('credit_note.new_credit_note'),
|
pageTitle: intl.get('credit_note.label.new_credit_note'),
|
||||||
defaultSearchResource: RESOURCES_TYPES.CREDIT_NOTE,
|
defaultSearchResource: RESOURCES_TYPES.CREDIT_NOTE,
|
||||||
subscriptionActive: [SUBSCRIPTION_TYPE.MAIN],
|
subscriptionActive: [SUBSCRIPTION_TYPE.MAIN],
|
||||||
},
|
},
|
||||||
@@ -668,8 +668,8 @@ export const getDashboardRoutes = () => [
|
|||||||
'../containers/Sales/CreditNotes/CreditNotesLanding/CreditNotesList'
|
'../containers/Sales/CreditNotes/CreditNotesLanding/CreditNotesList'
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
breadcrumb: intl.get('credit_note.label_list'),
|
breadcrumb: intl.get('credit_note.label_create_note_list'),
|
||||||
pageTitle: intl.get('credit_note.label_list'),
|
pageTitle: intl.get('credit_note.label_create_note_list'),
|
||||||
defaultSearchResource: RESOURCES_TYPES.CREDIT_NOTE,
|
defaultSearchResource: RESOURCES_TYPES.CREDIT_NOTE,
|
||||||
subscriptionActive: [SUBSCRIPTION_TYPE.MAIN],
|
subscriptionActive: [SUBSCRIPTION_TYPE.MAIN],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ import t from 'store/types';
|
|||||||
|
|
||||||
export const setCreditNotesTableState = (queries) => {
|
export const setCreditNotesTableState = (queries) => {
|
||||||
return {
|
return {
|
||||||
type: t.CREDIT_NOTE_TABLE_STATE_SET,
|
type: t.CREDIT_NOTES_TABLE_STATE_SET,
|
||||||
payload: { queries },
|
payload: { queries },
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const resetCreditNotesTableState = () => {
|
export const resetCreditNotesTableState = () => {
|
||||||
return {
|
return {
|
||||||
type: t.CREDIT_NOTE_TABLE_STATE_RESET,
|
type: t.CREDIT_NOTES_TABLE_STATE_RESET,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const initialState = {
|
|||||||
tableState: defaultTableQuery,
|
tableState: defaultTableQuery,
|
||||||
};
|
};
|
||||||
|
|
||||||
const STORAGE_KEY = 'bigcapital:CreditNotes';
|
const STORAGE_KEY = 'bigcapital:creditNotes';
|
||||||
|
|
||||||
const CONFIG = {
|
const CONFIG = {
|
||||||
key: STORAGE_KEY,
|
key: STORAGE_KEY,
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ import { paginationLocationQuery } from 'store/selectors';
|
|||||||
import { createDeepEqualSelector } from 'utils';
|
import { createDeepEqualSelector } from 'utils';
|
||||||
import { defaultTableQuery } from './creditNotes.reducer';
|
import { defaultTableQuery } from './creditNotes.reducer';
|
||||||
|
|
||||||
const creditNotesTableStateSelector = (state) =>
|
const creditNotesTableStateSelector = (state) => state.creditNotes.tableState;
|
||||||
state.creditNotes?.tableState;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve credit note table state.
|
* Retrieve credit note table state.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export default {
|
export default {
|
||||||
CREDIT_NOTE_TABLE_STATE_SET: 'CREDIT_NOTE/TABLES_STATE_SET',
|
CREDIT_NOTES_TABLE_STATE_SET: 'CREDIT_NOTE/TABLE_STATE_SET',
|
||||||
CREDIT_NOTE_TABLE_STATE_RESET: 'CREDIT_NOTE/TABLE_STATE/RESET',
|
CREDIT_NOTES_TABLE_STATE_RESET: 'CREDIT_NOTE/TABLE_STATE_RESET',
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user