{/*------------Transaction type -----------*/}
@@ -61,69 +66,64 @@ export default function AllocateLandedCostFormFields() {
)}
- {/*------------Transaction date -----------*/}
-
- {({ form, field: { value }, meta: { error, touched } }) => (
- }
- // labelInfo={}
- intent={inputIntent({ error, touched })}
- helperText={}
- minimal={true}
- className={classNames(CLASSES.FILL, 'form-group--transaction_date')}
- inline={true}
- >
- {
- form.setFieldValue('transaction_date', formattedDate);
- })}
- value={tansformDateValue(value)}
- popoverProps={{
- position: Position.BOTTOM,
- minimal: true,
- }}
- />
-
- )}
-
{/*------------ Transaction -----------*/}
-
- {({ form, field, meta: { error, touched } }) => (
+
+ {({ form, field: { value }, meta: { error, touched } }) => (
}
// labelInfo={}
intent={inputIntent({ error, touched })}
helperText={}
- className={'form-group--transaction_id'}
+ className={classNames(CLASSES.FILL, 'form-group--transaction_id')}
inline={true}
>
-
- form.setFieldValue('transaction_id', id)
- }
- inputProps={{
- placeholder: intl.get('select_transaction'),
+ {
+ form.setFieldValue('transaction_id', id);
}}
+ filterable={false}
+ selectedItem={value}
+ selectedItemProp={'id'}
+ textProp={'name'}
+ labelProp={'id'}
+ defaultText={intl.get('select_transaction')}
+ popoverProps={{ minimal: true }}
/>
)}
-
+
+
{/*------------ Transaction line -----------*/}
-
- {({ form, field, meta: { error, touched } }) => (
+
+ {({ form, field: { value }, meta: { error, touched } }) => (
}
intent={inputIntent({ error, touched })}
helperText={}
- className={'form-group--transaction_entry_id'}
+ className={classNames(
+ CLASSES.FILL,
+ 'form-group--transaction_entry_id',
+ )}
inline={true}
>
-
+ {
+ form.setFieldValue('transaction_entry_id', id);
+ }}
+ filterable={false}
+ selectedItem={value}
+ selectedItemProp={'id'}
+ textProp={'name'}
+ labelProp={'id'}
+ defaultText={intl.get('select_transaction')}
+ popoverProps={{ minimal: true }}
+ />
)}
-
+
+
{/*------------ Amount -----------*/}
{({ form, field, meta: { error, touched } }) => (
@@ -138,6 +138,7 @@ export default function AllocateLandedCostFormFields() {
)}
+
{/*------------ Allocation method -----------*/}
{({ form, field: { value }, meta: { touched, error } }) => (
@@ -158,7 +159,7 @@ export default function AllocateLandedCostFormFields() {
inline={true}
>
} value="quantity" />
- } value="valuation" />
+ } value="value" />
)}
diff --git a/client/src/containers/Dialogs/AllocateLandedCostDialog/utils.js b/client/src/containers/Dialogs/AllocateLandedCostDialog/utils.js
new file mode 100644
index 000000000..b906a6ba0
--- /dev/null
+++ b/client/src/containers/Dialogs/AllocateLandedCostDialog/utils.js
@@ -0,0 +1,4 @@
+export function getEntriesByTransactionId(transactions, id) {
+ const transaction = transactions.find((trans) => trans.id === id);
+ return transaction ? transaction.entries : [];
+}
diff --git a/client/src/containers/Drawers/BillDrawer/BillDrawerAlerts.js b/client/src/containers/Drawers/BillDrawer/BillDrawerAlerts.js
new file mode 100644
index 000000000..278671574
--- /dev/null
+++ b/client/src/containers/Drawers/BillDrawer/BillDrawerAlerts.js
@@ -0,0 +1,13 @@
+import React from 'react';
+import BillTransactionDeleteAlert from 'containers/Alerts/Bills/BillTransactionDeleteAlert';
+
+/**
+ * Bill drawer alert.
+ */
+export default function BillDrawerAlerts() {
+ return (
+
+
+
+ );
+}
diff --git a/client/src/containers/Drawers/BillDrawer/BillDrawerContent.js b/client/src/containers/Drawers/BillDrawer/BillDrawerContent.js
index 0e93746a5..ec1579009 100644
--- a/client/src/containers/Drawers/BillDrawer/BillDrawerContent.js
+++ b/client/src/containers/Drawers/BillDrawer/BillDrawerContent.js
@@ -1,16 +1,19 @@
import React from 'react';
import { BillDrawerProvider } from './BillDrawerProvider';
import BillDrawerDetails from './BillDrawerDetails';
+import BillDrawerAlerts from './BillDrawerAlerts';
+
/**
* Bill drawer content.
*/
export default function BillDrawerContent({
// #ownProp
- billId,
+ bill,
}) {
return (
-
+
+
);
}
diff --git a/client/src/containers/Drawers/BillDrawer/BillDrawerProvider.js b/client/src/containers/Drawers/BillDrawer/BillDrawerProvider.js
index 689508ad0..5bd4a8246 100644
--- a/client/src/containers/Drawers/BillDrawer/BillDrawerProvider.js
+++ b/client/src/containers/Drawers/BillDrawer/BillDrawerProvider.js
@@ -1,6 +1,7 @@
import React from 'react';
import intl from 'react-intl-universal';
import { DrawerHeaderContent, DashboardInsider } from 'components';
+import { useBillLocatedLandedCost } from 'hooks/query';
const BillDrawerContext = React.createContext();
@@ -8,10 +9,18 @@ const BillDrawerContext = React.createContext();
* Bill drawer provider.
*/
function BillDrawerProvider({ billId, ...props }) {
+ // Handle fetch bill located landed cost transaction.
+ const { isLoading: isLandedCostLoading, data: transactions } =
+ useBillLocatedLandedCost(billId, {
+ enabled: !!billId,
+ });
+
//provider.
- const provider = {};
+ const provider = {
+ transactions,
+ };
return (
-
+
- category.amount && category.index && category.expense_account_id,
+ category.amount &&
+ category.index &&
+ category.expense_account_id &&
+ category.landed_cost,
);
const form = {
diff --git a/client/src/containers/Expenses/ExpenseForm/components.js b/client/src/containers/Expenses/ExpenseForm/components.js
index b60949896..21d71cf20 100644
--- a/client/src/containers/Expenses/ExpenseForm/components.js
+++ b/client/src/containers/Expenses/ExpenseForm/components.js
@@ -7,6 +7,7 @@ import {
InputGroupCell,
MoneyFieldCell,
AccountsListFieldCell,
+ CheckBoxFieldCell,
} from 'components/DataTableCells';
import { formattedAmount, safeSumBy } from 'utils';
@@ -49,19 +50,6 @@ const ActionsCellRenderer = ({
);
};
-/**
- * Landed cost cell.
- */
-const LandedCostCell = ({
- row: { index },
- column: { id },
- cell: { value: initialValue },
- data,
- payload,
-}) => {
- return ;
-};
-
/**
* Landed cost header cell.
*/
@@ -142,7 +130,7 @@ export function useExpenseFormTableColumns() {
{
Header: LandedCostHeaderCell,
accessor: 'landed_cost',
- Cell: LandedCostCell,
+ Cell: CheckBoxFieldCell,
disableSortBy: true,
disableResizing: true,
width: 70,
diff --git a/client/src/containers/Expenses/ExpenseForm/utils.js b/client/src/containers/Expenses/ExpenseForm/utils.js
index 36653842c..d418c42a3 100644
--- a/client/src/containers/Expenses/ExpenseForm/utils.js
+++ b/client/src/containers/Expenses/ExpenseForm/utils.js
@@ -27,7 +27,7 @@ export const defaultExpenseEntry = {
amount: '',
expense_account_id: '',
description: '',
- landed_cost: false,
+ landed_cost: 0,
};
export const defaultExpense = {
diff --git a/client/src/containers/Purchases/Bills/BillForm/utils.js b/client/src/containers/Purchases/Bills/BillForm/utils.js
index 47ebec4a2..dba011cf7 100644
--- a/client/src/containers/Purchases/Bills/BillForm/utils.js
+++ b/client/src/containers/Purchases/Bills/BillForm/utils.js
@@ -51,4 +51,14 @@ export const handleDeleteErrors = (errors) => {
intent: Intent.DANGER,
});
}
+ if (
+ errors.find((error) => error.type === 'BILL_HAS_ASSOCIATED_LANDED_COSTS')
+ ) {
+ AppToaster.show({
+ message: intl.get(
+ 'cannot_delete_bill_that_has_associated_landed_cost_transactions',
+ ),
+ intent: Intent.DANGER,
+ });
+ }
};
diff --git a/client/src/hooks/query/landedCost.js b/client/src/hooks/query/landedCost.js
index 860835f4c..f9bb28497 100644
--- a/client/src/hooks/query/landedCost.js
+++ b/client/src/hooks/query/landedCost.js
@@ -63,8 +63,11 @@ export function useLandedCostTransaction(query, props) {
params: { transaction_type: query },
},
{
- select: (res) => res.data.transactions,
- defaultData: [],
+ select: (res) => res.data,
+
+ defaultData: {
+ transactions: [],
+ },
...props,
},
);
diff --git a/client/src/lang/en/index.json b/client/src/lang/en/index.json
index a1e7da419..6742cf866 100644
--- a/client/src/lang/en/index.json
+++ b/client/src/lang/en/index.json
@@ -1126,22 +1126,25 @@
"manual_journal_number": "Manual journal {number}",
"conditions_and_terms": "Conditions and terms",
"allocate_landed_coast": "Allocate landed cost",
- "transaction_date":"Transaction date",
- "transaction_type":"Transaction type",
- "transaction_id":"Transaction #",
- "transaction_number":"Transaction number",
- "transaction_line":"Transaction line",
- "allocation_method":"Allocation method",
- "valuation":"Valuation",
- "select_transaction":"Select transaction account",
- "details":"Details",
- "located_landed_cost":"Located Landed Cost",
- "delete_transaction":"Delete transaction",
+ "transaction_date": "Transaction date",
+ "transaction_type": "Transaction type",
+ "transaction_id": "Transaction #",
+ "transaction_number": "Transaction number",
+ "transaction_line": "Transaction line",
+ "allocation_method": "Allocation method",
+ "valuation": "Valuation",
+ "select_transaction": "Select transaction account",
+ "details": "Details",
+ "located_landed_cost": "Located Landed Cost",
+ "delete_transaction": "Delete transaction",
"all_items": "All items",
"Specific items": "Specific items",
"Selected contacts": "Selected contacts",
"All contacts": "All contacts",
"Selected items ({count})": "Selected items ({count})",
"All items": "All items",
- "No items": "No items"
+ "No items": "No items",
+ "cannot_delete_bill_that_has_associated_landed_cost_transactions": "Cannot delete bill that has associated landed cost transactions.",
+ "couldn_t_delete_expense_transaction_has_associated_located_landed_cost_transaction": "Couldn't delete expense transaction has associated located landed cost transaction",
+ "the_landed_cost_has_been_created_successfully": "The landed cost has been created successfully"
}
\ No newline at end of file