diff --git a/src/containers/Alerts/CreditNotes/CreditNoteOpenedAlert.js b/src/containers/Alerts/CreditNotes/CreditNoteOpenedAlert.js
new file mode 100644
index 000000000..58b9e8554
--- /dev/null
+++ b/src/containers/Alerts/CreditNotes/CreditNoteOpenedAlert.js
@@ -0,0 +1,68 @@
+import React from 'react';
+import { FormattedMessage as T } from 'components';
+import intl from 'react-intl-universal';
+import { Intent, Alert } from '@blueprintjs/core';
+
+import { useOpenCreditNote } from 'hooks/query';
+import { AppToaster } from 'components';
+
+import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
+import withAlertActions from 'containers/Alert/withAlertActions';
+
+import { compose } from 'utils';
+
+/**
+ * Credit note opened alert.
+ */
+function CreditNoteOpenedAlert({
+ name,
+
+ // #withAlertStoreConnect
+ isOpen,
+ payload: { creditNoteId },
+
+ // #withAlertActions
+ closeAlert,
+}) {
+ const { mutateAsync: openCreditNoteMutate, isLoading } = useOpenCreditNote();
+
+ // Handle cancel opened credit note alert.
+ const handleAlertCancel = () => {
+ closeAlert(name);
+ };
+
+ // Handle confirm credit note opened.
+ const handleAlertConfirm = () => {
+ openCreditNoteMutate(creditNoteId)
+ .then(() => {
+ AppToaster.show({
+ message: intl.get('credit_note_opened.alert.success_message'),
+ intent: Intent.SUCCESS,
+ });
+ })
+ .catch((error) => {})
+ .finally(() => {
+ closeAlert(name);
+ });
+ };
+
+ return (
+ }
+ confirmButtonText={}
+ intent={Intent.WARNING}
+ isOpen={isOpen}
+ onCancel={handleAlertCancel}
+ onConfirm={handleAlertConfirm}
+ loading={isLoading}
+ >
+
+
+
+
+ );
+}
+export default compose(
+ withAlertStoreConnect(),
+ withAlertActions,
+)(CreditNoteOpenedAlert);
diff --git a/src/containers/Alerts/VendorCeditNotes/VendorCreditOpenedAlert.js b/src/containers/Alerts/VendorCeditNotes/VendorCreditOpenedAlert.js
new file mode 100644
index 000000000..56c0fe5bf
--- /dev/null
+++ b/src/containers/Alerts/VendorCeditNotes/VendorCreditOpenedAlert.js
@@ -0,0 +1,69 @@
+import React from 'react';
+import { FormattedMessage as T } from 'components';
+import intl from 'react-intl-universal';
+import { Intent, Alert } from '@blueprintjs/core';
+
+import { useOpenVendorCredit } from 'hooks/query';
+import { AppToaster } from 'components';
+
+import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
+import withAlertActions from 'containers/Alert/withAlertActions';
+
+import { compose } from 'utils';
+
+/**
+ * Vendor credit opened alert.
+ */
+function VendorCreditOpenedAlert({
+ name,
+
+ // #withAlertStoreConnect
+ isOpen,
+ payload: { vendorCreditId },
+
+ // #withAlertActions
+ closeAlert,
+}) {
+ const { mutateAsync: openVendorCreditMutate, isLoading } =
+ useOpenVendorCredit();
+
+ // Handle cancel opened credit note alert.
+ const handleAlertCancel = () => {
+ closeAlert(name);
+ };
+
+ // Handle confirm vendor credit as opened.
+ const handleAlertConfirm = () => {
+ openVendorCreditMutate(vendorCreditId)
+ .then(() => {
+ AppToaster.show({
+ message: intl.get('vendor_credit_opened.alert.success_message'),
+ intent: Intent.SUCCESS,
+ });
+ })
+ .catch((error) => {})
+ .finally(() => {
+ closeAlert(name);
+ });
+ };
+
+ return (
+ }
+ confirmButtonText={}
+ intent={Intent.WARNING}
+ isOpen={isOpen}
+ onCancel={handleAlertCancel}
+ onConfirm={handleAlertConfirm}
+ loading={isLoading}
+ >
+
+
+
+
+ );
+}
+export default compose(
+ withAlertStoreConnect(),
+ withAlertActions,
+)(VendorCreditOpenedAlert);
diff --git a/src/containers/Dialogs/RefundCreditNoteDialog/RefundCreditNoteForm.js b/src/containers/Dialogs/RefundCreditNoteDialog/RefundCreditNoteForm.js
index d717dc0d0..05600768f 100644
--- a/src/containers/Dialogs/RefundCreditNoteDialog/RefundCreditNoteForm.js
+++ b/src/containers/Dialogs/RefundCreditNoteDialog/RefundCreditNoteForm.js
@@ -41,7 +41,7 @@ function RefundCreditNoteForm({
// Handles the form submit.
const handleFormSubmit = (values, { setSubmitting, setFieldError }) => {
const form = {
- ...omit(values, ['currency_code', 'formatted_amount']),
+ ...omit(values, ['currency_code', 'credits_remaining']),
};
// Handle request response success.
diff --git a/src/containers/Dialogs/RefundCreditNoteDialog/RefundCreditNoteFormProvider.js b/src/containers/Dialogs/RefundCreditNoteDialog/RefundCreditNoteFormProvider.js
index 596bd4dd0..978421272 100644
--- a/src/containers/Dialogs/RefundCreditNoteDialog/RefundCreditNoteFormProvider.js
+++ b/src/containers/Dialogs/RefundCreditNoteDialog/RefundCreditNoteFormProvider.js
@@ -31,8 +31,8 @@ function RefundCreditNoteFormProvider({ creditNoteId, dialogName, ...props }) {
// State provider.
const provider = {
creditNote: {
- ...pick(creditNote, ['id', 'formatted_amount', 'currency_code']),
- amount: creditNote.formatted_amount,
+ ...pick(creditNote, ['id', 'credits_remaining', 'currency_code']),
+ amount: creditNote.credits_remaining,
},
accounts,
dialogName,
diff --git a/src/containers/Dialogs/RefundVendorCreditDialog/RefundVendorCreditForm.js b/src/containers/Dialogs/RefundVendorCreditDialog/RefundVendorCreditForm.js
index 048c3beb5..0882a4dd8 100644
--- a/src/containers/Dialogs/RefundVendorCreditDialog/RefundVendorCreditForm.js
+++ b/src/containers/Dialogs/RefundVendorCreditDialog/RefundVendorCreditForm.js
@@ -41,7 +41,7 @@ function RefundVendorCreditForm({
// Handles the form submit.
const handleFormSubmit = (values, { setSubmitting, setFieldError }) => {
const form = {
- ...omit(values, ['currency_code', 'formatted_amount']),
+ ...omit(values, ['currency_code', 'credits_remaining']),
};
// Handle request response success.
diff --git a/src/containers/Dialogs/RefundVendorCreditDialog/RefundVendorCreditFormProvider.js b/src/containers/Dialogs/RefundVendorCreditDialog/RefundVendorCreditFormProvider.js
index c9cb6e779..0f97aa814 100644
--- a/src/containers/Dialogs/RefundVendorCreditDialog/RefundVendorCreditFormProvider.js
+++ b/src/containers/Dialogs/RefundVendorCreditDialog/RefundVendorCreditFormProvider.js
@@ -31,8 +31,8 @@ function RefundVendorCreditFormProvider({
// State provider.
const provider = {
vendorCredit: {
- ...pick(vendorCredit, ['id', 'formatted_amount', 'currency_code']),
- amount: vendorCredit.formatted_amount,
+ ...pick(vendorCredit, ['id', 'credits_remaining', 'currency_code']),
+ amount: vendorCredit.credits_remaining,
},
accounts,
dialogName,
diff --git a/src/containers/Drawers/CreditNoteDetailDrawer/CreditNoteDetailActionsBar.js b/src/containers/Drawers/CreditNoteDetailDrawer/CreditNoteDetailActionsBar.js
index b6e876638..dbe27e0c1 100644
--- a/src/containers/Drawers/CreditNoteDetailDrawer/CreditNoteDetailActionsBar.js
+++ b/src/containers/Drawers/CreditNoteDetailDrawer/CreditNoteDetailActionsBar.js
@@ -15,7 +15,13 @@ import withDialogActions from 'containers/Dialog/withDialogActions';
import withAlertsActions from 'containers/Alert/withAlertActions';
import withDrawerActions from 'containers/Drawer/withDrawerActions';
-import { Icon, FormattedMessage as T, MoreMenuItems, Can } from 'components';
+import {
+ Icon,
+ FormattedMessage as T,
+ If,
+ MoreMenuItems,
+ Can,
+} from 'components';
import { compose } from 'utils';
@@ -32,7 +38,7 @@ function CreditNoteDetailActionsBar({
// #withDrawerActions
closeDrawer,
}) {
- const { creditNoteId } = useCreditNoteDetailDrawerContext();
+ const { creditNoteId, creditNote } = useCreditNoteDetailDrawerContext();
const history = useHistory();
@@ -61,15 +67,15 @@ function CreditNoteDetailActionsBar({
onClick={handleEditCreditNote}
/>
- }
- text={'Refund'}
- // text={}
- onClick={handleRefundCreditNote}
- />
-
-
+
+ }
+ text={}
+ onClick={handleRefundCreditNote}
+ />
+
+
}
diff --git a/src/containers/Drawers/VendorCreditDetailDrawer/VendorCreditDetailActionsBar.js b/src/containers/Drawers/VendorCreditDetailDrawer/VendorCreditDetailActionsBar.js
index d2cfdead2..d51ab8a92 100644
--- a/src/containers/Drawers/VendorCreditDetailDrawer/VendorCreditDetailActionsBar.js
+++ b/src/containers/Drawers/VendorCreditDetailDrawer/VendorCreditDetailActionsBar.js
@@ -15,7 +15,7 @@ import withDialogActions from 'containers/Dialog/withDialogActions';
import withAlertsActions from 'containers/Alert/withAlertActions';
import withDrawerActions from 'containers/Drawer/withDrawerActions';
-import { Icon, FormattedMessage as T, Can } from 'components';
+import { If, Icon, FormattedMessage as T, Can } from 'components';
import { compose } from 'utils';
@@ -32,7 +32,7 @@ function VendorCreditDetailActionsBar({
// #withDrawerActions
closeDrawer,
}) {
- const { vendorCreditId } = useVendorCreditDetailDrawerContext();
+ const { vendorCreditId, vendorCredit } = useVendorCreditDetailDrawerContext();
const history = useHistory();
@@ -42,14 +42,15 @@ function VendorCreditDetailActionsBar({
closeDrawer('vendor-credit-detail-drawer');
};
- const handleRefundVendorCredit = () => {
- openDialog('refund-vendor-credit', { vendorCreditId });
- };
// Handle delete credit note.
const handleDeleteVendorCredit = () => {
openAlert('vendor-credit-delete', { vendorCreditId });
};
+ const handleRefundVendorCredit = () => {
+ openDialog('refund-vendor-credit', { vendorCreditId });
+ };
+
return (
@@ -60,14 +61,15 @@ function VendorCreditDetailActionsBar({
onClick={handleEditVendorCredit}
/>
- }
- text={'Refund'}
- // text={}
- onClick={handleRefundVendorCredit}
- />
-
+
+ }
+ text={}
+ onClick={handleRefundVendorCredit}
+ />
+
+
}
diff --git a/src/containers/Purchases/CreditNotes/CreditNoteForm/VendorCreditNoteFloatingActions.js b/src/containers/Purchases/CreditNotes/CreditNoteForm/VendorCreditNoteFloatingActions.js
index d831d0666..0d2c7a72b 100644
--- a/src/containers/Purchases/CreditNotes/CreditNoteForm/VendorCreditNoteFloatingActions.js
+++ b/src/containers/Purchases/CreditNotes/CreditNoteForm/VendorCreditNoteFloatingActions.js
@@ -26,35 +26,39 @@ export default function VendorCreditNoteFloatingActions() {
const { resetForm, submitForm, isSubmitting } = useFormikContext();
// Credit note form context.
- const { setSubmitPayload, isNewMode } = useVendorCreditNoteFormContext();
-
- // Handle submit, save and anothe new button click.
- const handleSubmitAndNewBtnClick = (event) => {
- setSubmitPayload({ redirect: false, status: true, resetForm: true });
+ const { setSubmitPayload, vendorCredit } = useVendorCreditNoteFormContext();
+ // Handle submit as open button click.
+ const handleSubmitOpenBtnClick = (event) => {
+ setSubmitPayload({ redirect: true, open: true });
submitForm();
};
- // Handle submit as save & continue editing button click.
- const handleSubmitSaveContinueEditingBtnClick = (event) => {
- setSubmitPayload({ redirect: false, status: true });
+ // Handle submit, open and anothe new button click.
+ const handleSubmitOpenAndNewBtnClick = (event) => {
+ setSubmitPayload({ redirect: false, open: true, resetForm: true });
submitForm();
};
+ // Handle submit as open & continue editing button click.
+ const handleSubmitOpenContinueEditingBtnClick = (event) => {
+ setSubmitPayload({ redirect: false, open: true });
+ submitForm();
+ };
// Handle submit as draft button click.
const handleSubmitDraftBtnClick = (event) => {
- setSubmitPayload({ redirect: true, status: false });
+ setSubmitPayload({ redirect: true, open: false });
submitForm();
};
// handle submit as draft & new button click.
const handleSubmitDraftAndNewBtnClick = (event) => {
- setSubmitPayload({ redirect: false, status: false, resetForm: true });
+ setSubmitPayload({ redirect: false, open: false, resetForm: true });
submitForm();
};
// Handle submit as draft & continue editing button click.
const handleSubmitDraftContinueEditingBtnClick = (event) => {
- setSubmitPayload({ redirect: false, status: false });
+ setSubmitPayload({ redirect: false, open: false });
submitForm();
};
@@ -63,89 +67,114 @@ export default function VendorCreditNoteFloatingActions() {
history.goBack();
};
- // Handle submit button click.
- const handleSubmitBtnClick = (event) => {
- setSubmitPayload({ redirect: true });
- submitForm();
- };
-
const handleClearBtnClick = (event) => {
resetForm();
};
return (
- {/* ----------- Save ----------- */}
-
- }
- />
-
-
- }
- onClick={handleSubmitAndNewBtnClick}
- />
- }
- onClick={handleSubmitSaveContinueEditingBtnClick}
- />
-
- }
- minimal={true}
- interactionKind={PopoverInteractionKind.CLICK}
- position={Position.BOTTOM_LEFT}
- >
+ {/* ----------- Save And Open ----------- */}
+
+
}
+ onClick={handleSubmitOpenBtnClick}
+ text={}
/>
-
-
- {/* ----------- Save As Draft ----------- */}
-
- }
- />
-
- }
- onClick={handleSubmitDraftAndNewBtnClick}
- />
- }
- onClick={handleSubmitDraftContinueEditingBtnClick}
- />
-
- }
- minimal={true}
- interactionKind={PopoverInteractionKind.CLICK}
- position={Position.BOTTOM_LEFT}
- >
+
+ }
+ onClick={handleSubmitOpenAndNewBtnClick}
+ />
+ }
+ onClick={handleSubmitOpenContinueEditingBtnClick}
+ />
+
+ }
+ minimal={true}
+ interactionKind={PopoverInteractionKind.CLICK}
+ position={Position.BOTTOM_LEFT}
+ >
+ }
+ />
+
+
+ {/* ----------- Save As Draft ----------- */}
+
}
+ className={'ml1'}
+ onClick={handleSubmitDraftBtnClick}
+ text={}
/>
-
-
+
+ }
+ onClick={handleSubmitDraftAndNewBtnClick}
+ />
+ }
+ onClick={handleSubmitDraftContinueEditingBtnClick}
+ />
+
+ }
+ minimal={true}
+ interactionKind={PopoverInteractionKind.CLICK}
+ position={Position.BOTTOM_LEFT}
+ >
+ }
+ />
+
+
+
+ {/* ----------- Save and New ----------- */}
+
+
+ }
+ />
+
+ }
+ onClick={handleSubmitOpenAndNewBtnClick}
+ />
+
+ }
+ minimal={true}
+ interactionKind={PopoverInteractionKind.CLICK}
+ position={Position.BOTTOM_LEFT}
+ >
+ }
+ />
+
+
+
{/* ----------- Clear & Reset----------- */}
:
}
+ text={vendorCredit ?
:
}
/>
{/* ----------- Cancel ----------- */}
+ );
+}
+
/**
* Retrieve vendors credit note table columns.
*/
@@ -103,8 +133,8 @@ export function useVendorsCreditNoteTableColumns() {
{
id: 'status',
Header: intl.get('status'),
- // accessor:
- width: 120, // 160
+ accessor: StatusAccessor,
+ width: 160,
className: 'status',
clickable: true,
},
diff --git a/src/containers/Purchases/CreditNotes/VendorCreditNotesAlerts.js b/src/containers/Purchases/CreditNotes/VendorCreditNotesAlerts.js
index 56320a325..9b4ecceba 100644
--- a/src/containers/Purchases/CreditNotes/VendorCreditNotesAlerts.js
+++ b/src/containers/Purchases/CreditNotes/VendorCreditNotesAlerts.js
@@ -8,6 +8,10 @@ const RefundVendorCreditDeleteAlert = React.lazy(() =>
import('../../Alerts/VendorCeditNotes/RefundVendorCreditDeleteAlert'),
);
+const OpenVendorCreditAlert = React.lazy(() =>
+ import('../../Alerts/VendorCeditNotes/VendorCreditOpenedAlert'),
+);
+
/**
* Vendor Credit notes alerts.
*/
@@ -16,6 +20,10 @@ export default [
name: 'vendor-credit-delete',
component: VendorCreditDeleteAlert,
},
+ {
+ name: 'vendor-credit-open',
+ component: OpenVendorCreditAlert,
+ },
{
name: 'refund-vendor-delete',
component: RefundVendorCreditDeleteAlert,
diff --git a/src/containers/Sales/CreditNotes/CreditNoteForm/CreditNoteFloatingActions.js b/src/containers/Sales/CreditNotes/CreditNoteForm/CreditNoteFloatingActions.js
index 727643a7b..db59adfe5 100644
--- a/src/containers/Sales/CreditNotes/CreditNoteForm/CreditNoteFloatingActions.js
+++ b/src/containers/Sales/CreditNotes/CreditNoteForm/CreditNoteFloatingActions.js
@@ -26,35 +26,40 @@ export default function CreditNoteFloatingActions() {
const { resetForm, submitForm, isSubmitting } = useFormikContext();
// Credit note form context.
- const { setSubmitPayload, isNewMode } = useCreditNoteFormContext();
+ const { setSubmitPayload, creditNote } = useCreditNoteFormContext();
- // Handle submit, save and anothe new button click.
- const handleSubmitAndNewBtnClick = (event) => {
- setSubmitPayload({ redirect: false, status: true, resetForm: true });
+ // Handle submit as open button click.
+ const handleSubmitOpenBtnClick = (event) => {
+ setSubmitPayload({ redirect: true, open: true });
submitForm();
};
- // Handle submit as save & continue editing button click.
- const handleSubmitSaveContinueEditingBtnClick = (event) => {
- setSubmitPayload({ redirect: false, status: true });
+ // Handle submit, open and anothe new button click.
+ const handleSubmitOpenAndNewBtnClick = (event) => {
+ setSubmitPayload({ redirect: false, open: true, resetForm: true });
submitForm();
};
+ // Handle submit as open & continue editing button click.
+ const handleSubmitOpenContinueEditingBtnClick = (event) => {
+ setSubmitPayload({ redirect: false, open: true });
+ submitForm();
+ };
// Handle submit as draft button click.
const handleSubmitDraftBtnClick = (event) => {
- setSubmitPayload({ redirect: true, status: false });
+ setSubmitPayload({ redirect: true, open: false });
submitForm();
};
// handle submit as draft & new button click.
const handleSubmitDraftAndNewBtnClick = (event) => {
- setSubmitPayload({ redirect: false, status: false, resetForm: true });
+ setSubmitPayload({ redirect: false, open: false, resetForm: true });
submitForm();
};
// Handle submit as draft & continue editing button click.
const handleSubmitDraftContinueEditingBtnClick = (event) => {
- setSubmitPayload({ redirect: false, status: false });
+ setSubmitPayload({ redirect: false, open: false });
submitForm();
};
@@ -63,89 +68,114 @@ export default function CreditNoteFloatingActions() {
history.goBack();
};
- // Handle submit button click.
- const handleSubmitBtnClick = (event) => {
- setSubmitPayload({ redirect: true });
- submitForm();
- };
-
const handleClearBtnClick = (event) => {
resetForm();
};
return (
- {/* ----------- Save ----------- */}
-
- }
- />
-
-
- }
- onClick={handleSubmitAndNewBtnClick}
- />
- }
- onClick={handleSubmitSaveContinueEditingBtnClick}
- />
-
- }
- minimal={true}
- interactionKind={PopoverInteractionKind.CLICK}
- position={Position.BOTTOM_LEFT}
- >
+ {/* ----------- Save And Open ----------- */}
+
+
}
+ onClick={handleSubmitOpenBtnClick}
+ text={}
/>
-
-
- {/* ----------- Save As Draft ----------- */}
-
- }
- />
-
- }
- onClick={handleSubmitDraftAndNewBtnClick}
- />
- }
- onClick={handleSubmitDraftContinueEditingBtnClick}
- />
-
- }
- minimal={true}
- interactionKind={PopoverInteractionKind.CLICK}
- position={Position.BOTTOM_LEFT}
- >
+
+ }
+ onClick={handleSubmitOpenAndNewBtnClick}
+ />
+ }
+ onClick={handleSubmitOpenContinueEditingBtnClick}
+ />
+
+ }
+ minimal={true}
+ interactionKind={PopoverInteractionKind.CLICK}
+ position={Position.BOTTOM_LEFT}
+ >
+ }
+ />
+
+
+ {/* ----------- Save As Draft ----------- */}
+
}
+ className={'ml1'}
+ onClick={handleSubmitDraftBtnClick}
+ text={}
/>
-
-
+
+ }
+ onClick={handleSubmitDraftAndNewBtnClick}
+ />
+ }
+ onClick={handleSubmitDraftContinueEditingBtnClick}
+ />
+
+ }
+ minimal={true}
+ interactionKind={PopoverInteractionKind.CLICK}
+ position={Position.BOTTOM_LEFT}
+ >
+ }
+ />
+
+
+
+ {/* ----------- Save and New ----------- */}
+
+
+ }
+ />
+
+ }
+ onClick={handleSubmitOpenAndNewBtnClick}
+ />
+
+ }
+ minimal={true}
+ interactionKind={PopoverInteractionKind.CLICK}
+ position={Position.BOTTOM_LEFT}
+ >
+ }
+ />
+
+
+
{/* ----------- Clear & Reset----------- */}
:
}
+ text={creditNote ?
:
}
/>
{/* ----------- Cancel ----------- */}
+ );
+}
+
/**
* Retrieve credit note table columns.
*/
@@ -100,8 +131,8 @@ export function useCreditNoteTableColumns() {
{
id: 'status',
Header: intl.get('status'),
- // accessor:
- width: 120, // 160
+ accessor: StatusAccessor,
+ width: 160, // 160
className: 'status',
clickable: true,
},
diff --git a/src/hooks/query/creditNote.js b/src/hooks/query/creditNote.js
index db43afc33..99e6887cc 100644
--- a/src/hooks/query/creditNote.js
+++ b/src/hooks/query/creditNote.js
@@ -208,3 +208,22 @@ export function useRefundCreditNote(id, props, requestProps) {
},
);
}
+
+/**
+ * Mark the given credit note as opened.
+ */
+export function useOpenCreditNote(props) {
+ const queryClient = useQueryClient();
+ const apiRequest = useApiRequest();
+
+ return useMutation((id) => apiRequest.post(`sales/credit_notes/${id}/open`), {
+ onSuccess: (res, id) => {
+ // Common invalidate queries.
+ commonInvalidateQueries(queryClient);
+
+ // Invalidate specific
+ queryClient.invalidateQueries([t.CREDIT_NOTE, id]);
+ },
+ ...props,
+ });
+}
diff --git a/src/hooks/query/vendorCredit.js b/src/hooks/query/vendorCredit.js
index e4d2a93a8..05df98147 100644
--- a/src/hooks/query/vendorCredit.js
+++ b/src/hooks/query/vendorCredit.js
@@ -219,3 +219,25 @@ export function useRefundVendorCredit(id, props, requestProps) {
},
);
}
+
+/**
+ * Mark the given vendor credit as opened.
+ */
+export function useOpenVendorCredit(props) {
+ const queryClient = useQueryClient();
+ const apiRequest = useApiRequest();
+
+ return useMutation(
+ (id) => apiRequest.post(`purchases/vendor-credit/${id}/open`),
+ {
+ onSuccess: (res, id) => {
+ // Common invalidate queries.
+ commonInvalidateQueries(queryClient);
+
+ // Invalidate specific.
+ queryClient.invalidateQueries([t.VENDOR_CREDIT, id]);
+ },
+ ...props,
+ },
+ );
+}
diff --git a/src/lang/en/index.json b/src/lang/en/index.json
index 4d4fae799..b0b5fe0bc 100644
--- a/src/lang/en/index.json
+++ b/src/lang/en/index.json
@@ -1562,6 +1562,10 @@
"refund_vendor_credit.column.withdrawal_account": "Withdrawal account",
"refund_vendor_credit_transactions.alert.delete_message":"The vendor credit refund has been deleted successfully.",
"refund_vendor_credit_transactions.once_your_delete_this_refund_vendor_credit":"Once your delete this refund vendor credit note, you won't be able to restore it later, Are your sure you want to delete this transaction?",
- "refund": "Refund"
+ "refund": "Refund",
+ "credit_note_opened.alert.success_message":"The credit note has been opened successfully",
+ "credit_opened.are_sure_to_open_this_credit": "Are you sure you want to open this credit note?",
+ "vendor_credit_opened.alert.success_message":"The vendor credit has been opened successfully",
+ "vendor_credit_opened.are_sure_to_open_this_credit": "Are you sure you want to open this vendor credit?"
}