mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 23:00:34 +00:00
fix: remote line min lines.
This commit is contained in:
@@ -21,8 +21,8 @@ export default function MakeJournalEntriesTable({
|
|||||||
entries,
|
entries,
|
||||||
defaultEntry,
|
defaultEntry,
|
||||||
error,
|
error,
|
||||||
initialLinesNumber = 4,
|
initialLinesNumber = 1,
|
||||||
minLinesNumber = 4,
|
minLinesNumber = 1,
|
||||||
currencyCode,
|
currencyCode,
|
||||||
}) {
|
}) {
|
||||||
const { accounts, contacts, branches } = useMakeJournalFormContext();
|
const { accounts, contacts, branches } = useMakeJournalFormContext();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import {
|
|||||||
BranchesListFieldCell,
|
BranchesListFieldCell,
|
||||||
} from 'components/DataTableCells';
|
} from 'components/DataTableCells';
|
||||||
|
|
||||||
import { CellType, Features } from 'common';
|
import { CellType, Features, Align } from 'common';
|
||||||
|
|
||||||
import { useFeatureCan } from 'hooks/state';
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import { useCurrentOrganization } from 'hooks/state';
|
import { useCurrentOrganization } from 'hooks/state';
|
||||||
@@ -92,7 +92,6 @@ export const useJournalTableEntriesColumns = () => {
|
|||||||
id: 'account_id',
|
id: 'account_id',
|
||||||
accessor: 'account_id',
|
accessor: 'account_id',
|
||||||
Cell: AccountsListFieldCell,
|
Cell: AccountsListFieldCell,
|
||||||
className: 'account',
|
|
||||||
disableSortBy: true,
|
disableSortBy: true,
|
||||||
width: 160,
|
width: 160,
|
||||||
fieldProps: { allowCreate: true },
|
fieldProps: { allowCreate: true },
|
||||||
@@ -101,24 +100,23 @@ export const useJournalTableEntriesColumns = () => {
|
|||||||
Header: CreditHeaderCell,
|
Header: CreditHeaderCell,
|
||||||
accessor: 'credit',
|
accessor: 'credit',
|
||||||
Cell: MoneyFieldCell,
|
Cell: MoneyFieldCell,
|
||||||
className: 'credit',
|
|
||||||
disableSortBy: true,
|
disableSortBy: true,
|
||||||
width: 100,
|
width: 100,
|
||||||
|
align: Align.Right,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Header: DebitHeaderCell,
|
Header: DebitHeaderCell,
|
||||||
accessor: 'debit',
|
accessor: 'debit',
|
||||||
Cell: MoneyFieldCell,
|
Cell: MoneyFieldCell,
|
||||||
className: 'debit',
|
|
||||||
disableSortBy: true,
|
disableSortBy: true,
|
||||||
width: 100,
|
width: 100,
|
||||||
|
align: Align.Right,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Header: ContactHeaderCell,
|
Header: ContactHeaderCell,
|
||||||
id: 'contact_id',
|
id: 'contact_id',
|
||||||
accessor: 'contact_id',
|
accessor: 'contact_id',
|
||||||
Cell: ContactsListFieldCell,
|
Cell: ContactsListFieldCell,
|
||||||
className: 'contact',
|
|
||||||
disableSortBy: true,
|
disableSortBy: true,
|
||||||
width: 120,
|
width: 120,
|
||||||
},
|
},
|
||||||
@@ -129,7 +127,6 @@ export const useJournalTableEntriesColumns = () => {
|
|||||||
id: 'branch_id',
|
id: 'branch_id',
|
||||||
accessor: 'branch_id',
|
accessor: 'branch_id',
|
||||||
Cell: BranchesListFieldCell,
|
Cell: BranchesListFieldCell,
|
||||||
className: 'branch',
|
|
||||||
disableSortBy: true,
|
disableSortBy: true,
|
||||||
width: 120,
|
width: 120,
|
||||||
},
|
},
|
||||||
@@ -140,7 +137,6 @@ export const useJournalTableEntriesColumns = () => {
|
|||||||
accessor: 'note',
|
accessor: 'note',
|
||||||
Cell: InputGroupCell,
|
Cell: InputGroupCell,
|
||||||
disableSortBy: true,
|
disableSortBy: true,
|
||||||
className: 'note',
|
|
||||||
width: 200,
|
width: 200,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -150,6 +146,7 @@ export const useJournalTableEntriesColumns = () => {
|
|||||||
disableSortBy: true,
|
disableSortBy: true,
|
||||||
disableResizing: true,
|
disableResizing: true,
|
||||||
width: 45,
|
width: 45,
|
||||||
|
align: Align.Center,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[],
|
[],
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ function ItemsEntriesTable({
|
|||||||
currencyCode,
|
currencyCode,
|
||||||
itemType, // sellable or purchasable
|
itemType, // sellable or purchasable
|
||||||
landedCost = false,
|
landedCost = false,
|
||||||
|
minLinesNumber
|
||||||
}) {
|
}) {
|
||||||
const [rows, setRows] = React.useState(initialEntries);
|
const [rows, setRows] = React.useState(initialEntries);
|
||||||
|
|
||||||
@@ -76,7 +77,7 @@ function ItemsEntriesTable({
|
|||||||
const handleRemoveRow = (rowIndex) => {
|
const handleRemoveRow = (rowIndex) => {
|
||||||
const newRows = compose(
|
const newRows = compose(
|
||||||
// Ensure minimum lines count.
|
// Ensure minimum lines count.
|
||||||
updateMinEntriesLines(4, defaultEntry),
|
updateMinEntriesLines(minLinesNumber, defaultEntry),
|
||||||
// Remove the line by the given index.
|
// Remove the line by the given index.
|
||||||
updateRemoveLineByIndex(rowIndex),
|
updateRemoveLineByIndex(rowIndex),
|
||||||
)(rows);
|
)(rows);
|
||||||
@@ -117,6 +118,7 @@ ItemsEntriesTable.defaultProps = {
|
|||||||
},
|
},
|
||||||
initialEntries: [],
|
initialEntries: [],
|
||||||
linesNumber: 1,
|
linesNumber: 1,
|
||||||
|
minLinesNumber: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ItemsEntriesTable;
|
export default ItemsEntriesTable;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export default function ExpenseFormEntriesTable({
|
|||||||
onChange,
|
onChange,
|
||||||
currencyCode,
|
currencyCode,
|
||||||
landedCost = true,
|
landedCost = true,
|
||||||
|
minLines,
|
||||||
}) {
|
}) {
|
||||||
// Expense form context.
|
// Expense form context.
|
||||||
const { accounts } = useExpenseFormContext();
|
const { accounts } = useExpenseFormContext();
|
||||||
@@ -50,14 +51,14 @@ export default function ExpenseFormEntriesTable({
|
|||||||
(rowIndex) => {
|
(rowIndex) => {
|
||||||
const newRows = compose(
|
const newRows = compose(
|
||||||
// Ensure minimum lines count.
|
// Ensure minimum lines count.
|
||||||
updateMinEntriesLines(4, defaultEntry),
|
updateMinEntriesLines(minLines, defaultEntry),
|
||||||
// Remove the line by the given index.
|
// Remove the line by the given index.
|
||||||
updateRemoveLineByIndex(rowIndex),
|
updateRemoveLineByIndex(rowIndex),
|
||||||
)(entries);
|
)(entries);
|
||||||
|
|
||||||
saveInvoke(onChange, newRows);
|
saveInvoke(onChange, newRows);
|
||||||
},
|
},
|
||||||
[entries, defaultEntry, onChange],
|
[minLines, entries, defaultEntry, onChange],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -76,4 +77,8 @@ export default function ExpenseFormEntriesTable({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
ExpenseFormEntriesTable.defaultProps = {
|
||||||
|
minLines: 1,
|
||||||
}
|
}
|
||||||
@@ -177,7 +177,7 @@ export const mutateTableRow = R.curry((rowIndex, newRow, rows) => {
|
|||||||
export const deleteTableRow = R.curry((rowIndex, defaultEntry, rows) => {
|
export const deleteTableRow = R.curry((rowIndex, defaultEntry, rows) => {
|
||||||
return compose(
|
return compose(
|
||||||
// Ensure minimum lines count.
|
// Ensure minimum lines count.
|
||||||
updateMinEntriesLines(4, defaultEntry),
|
updateMinEntriesLines(MIN_LINES_NUMBER, defaultEntry),
|
||||||
// Remove the line by the given index.
|
// Remove the line by the given index.
|
||||||
updateRemoveLineByIndex(rowIndex),
|
updateRemoveLineByIndex(rowIndex),
|
||||||
)(rows);
|
)(rows);
|
||||||
|
|||||||
Reference in New Issue
Block a user