mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
Compare commits
2 Commits
@bigcapita
...
BIG-359-re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c49a240280 | ||
|
|
dbf4666dfc |
8
src/common/journalTypes.js
Normal file
8
src/common/journalTypes.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import intl from 'react-intl-universal';
|
||||||
|
|
||||||
|
export const journalTypes = [
|
||||||
|
{
|
||||||
|
name: intl.get('journal'),
|
||||||
|
value: 'Journal',
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
FormGroup,
|
FormGroup,
|
||||||
Position,
|
Position,
|
||||||
ControlGroup,
|
ControlGroup,
|
||||||
|
Classes,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import { FastField, ErrorMessage } from 'formik';
|
import { FastField, ErrorMessage } from 'formik';
|
||||||
import { DateInput } from '@blueprintjs/datetime';
|
import { DateInput } from '@blueprintjs/datetime';
|
||||||
@@ -11,6 +12,8 @@ import { FormattedMessage as T } from 'components';
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
|
import { journalTypes } from '../../../common/journalTypes';
|
||||||
|
import { FFormGroup } from '../../../components';
|
||||||
import {
|
import {
|
||||||
momentFormatter,
|
momentFormatter,
|
||||||
compose,
|
compose,
|
||||||
@@ -28,12 +31,13 @@ import {
|
|||||||
} from 'components';
|
} from 'components';
|
||||||
import withSettings from 'containers/Settings/withSettings';
|
import withSettings from 'containers/Settings/withSettings';
|
||||||
import { useMakeJournalFormContext } from './MakeJournalProvider';
|
import { useMakeJournalFormContext } from './MakeJournalProvider';
|
||||||
import { JournalExchangeRateInputField } from './components';
|
import { JournalExchangeRateInputField, JournalTypeSelect } from './components';
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
import {
|
import {
|
||||||
currenciesFieldShouldUpdate,
|
currenciesFieldShouldUpdate,
|
||||||
useObserveJournalNoSettings,
|
useObserveJournalNoSettings,
|
||||||
} from './utils';
|
} from './utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make journal entries header.
|
* Make journal entries header.
|
||||||
*/
|
*/
|
||||||
@@ -169,21 +173,18 @@ function MakeJournalEntriesHeader({
|
|||||||
</FastField>
|
</FastField>
|
||||||
|
|
||||||
{/*------------ Journal type -----------*/}
|
{/*------------ Journal type -----------*/}
|
||||||
<FastField name={'journal_type'}>
|
<FFormGroup
|
||||||
{({ form, field, meta: { error, touched } }) => (
|
name={'journal_type'}
|
||||||
<FormGroup
|
label={<T id={'journal_type'} />}
|
||||||
label={<T id={'journal_type'} />}
|
inline={true}
|
||||||
className={classNames('form-group--account-type', CLASSES.FILL)}
|
className={classNames('form-group--select-list', Classes.FILL)}
|
||||||
inline={true}
|
>
|
||||||
>
|
<JournalTypeSelect
|
||||||
<InputGroup
|
items={journalTypes}
|
||||||
intent={inputIntent({ error, touched })}
|
name={'journal_type'}
|
||||||
fill={true}
|
popoverProps={{ minimal: true }}
|
||||||
{...field}
|
/>
|
||||||
/>
|
</FFormGroup>
|
||||||
</FormGroup>
|
|
||||||
)}
|
|
||||||
</FastField>
|
|
||||||
|
|
||||||
{/*------------ Currency -----------*/}
|
{/*------------ Currency -----------*/}
|
||||||
<FastField
|
<FastField
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
Icon,
|
Icon,
|
||||||
Hint,
|
Hint,
|
||||||
FormattedMessage as T,
|
FormattedMessage as T,
|
||||||
|
FSelect,
|
||||||
} from 'components';
|
} from 'components';
|
||||||
import {
|
import {
|
||||||
AccountsListFieldCell,
|
AccountsListFieldCell,
|
||||||
@@ -183,3 +184,71 @@ export function JournalExchangeRateInputField({ ...props }) {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {*} query
|
||||||
|
* @param {*} journal
|
||||||
|
* @param {*} _index
|
||||||
|
* @param {*} exactMatch
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
const itemPredicate = (query, journal, _index, exactMatch) => {
|
||||||
|
const normalizedTitle = journal.name.toLowerCase();
|
||||||
|
const normalizedQuery = query.toLowerCase();
|
||||||
|
|
||||||
|
if (exactMatch) {
|
||||||
|
return normalizedTitle === normalizedQuery;
|
||||||
|
} else {
|
||||||
|
return normalizedTitle.indexOf(normalizedQuery) >= 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {*} item
|
||||||
|
* @param {*} param1
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
const itemRenderer = (item, { handleClick, modifiers, query }) => {
|
||||||
|
return (
|
||||||
|
<MenuItem
|
||||||
|
active={modifiers.active}
|
||||||
|
disabled={modifiers.disabled}
|
||||||
|
text={item.name}
|
||||||
|
label={item.label}
|
||||||
|
key={item.id}
|
||||||
|
onClick={handleClick}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const itemSelectProps = {
|
||||||
|
itemPredicate: itemPredicate,
|
||||||
|
itemRenderer: itemRenderer,
|
||||||
|
valueAccessor: 'name',
|
||||||
|
labelAccessor: 'name',
|
||||||
|
};
|
||||||
|
|
||||||
|
export function JournalTypeSelect({ items, ...rest }) {
|
||||||
|
return (
|
||||||
|
<FSelect
|
||||||
|
{...itemSelectProps}
|
||||||
|
{...rest}
|
||||||
|
items={items}
|
||||||
|
input={itemSelectButton}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {*} label
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
function itemSelectButton({ label }) {
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
text={label ? label : intl.get('make_journal.label.select_journal_type')}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export default function ItemFormFormik({
|
|||||||
// Handles the form submit.
|
// Handles the form submit.
|
||||||
const handleFormSubmit = (values, form) => {
|
const handleFormSubmit = (values, form) => {
|
||||||
const { setSubmitting, resetForm, setErrors } = form;
|
const { setSubmitting, resetForm, setErrors } = form;
|
||||||
const formValues = { ...values };
|
const formValues = { ...values, type: values.type.toString() };
|
||||||
|
|
||||||
setSubmitting(true);
|
setSubmitting(true);
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ export default function ItemFormFormik({
|
|||||||
validationSchema={isNewMode ? CreateItemFormSchema : EditItemFormSchema}
|
validationSchema={isNewMode ? CreateItemFormSchema : EditItemFormSchema}
|
||||||
initialValues={initialValues}
|
initialValues={initialValues}
|
||||||
onSubmit={handleFormSubmit}
|
onSubmit={handleFormSubmit}
|
||||||
>
|
>
|
||||||
<Form>
|
<Form>
|
||||||
<div class={classNames(CLASSES.PAGE_FORM_BODY)}>
|
<div class={classNames(CLASSES.PAGE_FORM_BODY)}>
|
||||||
<ItemFormPrimarySection />
|
<ItemFormPrimarySection />
|
||||||
|
|||||||
@@ -7,7 +7,12 @@ import {
|
|||||||
Radio,
|
Radio,
|
||||||
Position,
|
Position,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
|
import {
|
||||||
|
FormattedMessage as T,
|
||||||
|
FormattedHTMLMessage,
|
||||||
|
FCheckbox,
|
||||||
|
FFormGroup,
|
||||||
|
} from 'components';
|
||||||
import { ErrorMessage, FastField } from 'formik';
|
import { ErrorMessage, FastField } from 'formik';
|
||||||
import {
|
import {
|
||||||
CategoriesSelectList,
|
CategoriesSelectList,
|
||||||
@@ -29,7 +34,7 @@ import { categoriesFieldShouldUpdate } from './utils';
|
|||||||
export default function ItemFormPrimarySection() {
|
export default function ItemFormPrimarySection() {
|
||||||
// Item form context.
|
// Item form context.
|
||||||
const { isNewMode, item, itemsCategories } = useItemFormContext();
|
const { isNewMode, item, itemsCategories } = useItemFormContext();
|
||||||
|
console.log(item.type, 'XXX');
|
||||||
const nameFieldRef = useRef(null);
|
const nameFieldRef = useRef(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -53,7 +58,34 @@ export default function ItemFormPrimarySection() {
|
|||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM_HEADER_PRIMARY)}>
|
<div className={classNames(CLASSES.PAGE_FORM_HEADER_PRIMARY)}>
|
||||||
{/*----------- Item type ----------*/}
|
{/*----------- Item type ----------*/}
|
||||||
<FastField name={'type'}>
|
<FFormGroup
|
||||||
|
name={'type'}
|
||||||
|
label={<T id={'item_type'} />}
|
||||||
|
labelInfo={
|
||||||
|
<span>
|
||||||
|
<FieldRequiredHint />
|
||||||
|
<Hint
|
||||||
|
content={itemTypeHintContent}
|
||||||
|
position={Position.BOTTOM_LEFT}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
inline={true}
|
||||||
|
>
|
||||||
|
<FCheckbox
|
||||||
|
inline={true}
|
||||||
|
name="type"
|
||||||
|
label={<T id={'service'} />}
|
||||||
|
value="service"
|
||||||
|
/>
|
||||||
|
<FCheckbox
|
||||||
|
inline={true}
|
||||||
|
name="type"
|
||||||
|
label={<T id={'inventory'} />}
|
||||||
|
value="inventory"
|
||||||
|
/>
|
||||||
|
</FFormGroup>
|
||||||
|
{/* <FastField name={'type'}>
|
||||||
{({ form, field: { value }, meta: { touched, error } }) => (
|
{({ form, field: { value }, meta: { touched, error } }) => (
|
||||||
<FormGroup
|
<FormGroup
|
||||||
medium={true}
|
medium={true}
|
||||||
@@ -85,7 +117,7 @@ export default function ItemFormPrimarySection() {
|
|||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
)}
|
)}
|
||||||
</FastField>
|
</FastField> */}
|
||||||
|
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs={7}>
|
<Col xs={7}>
|
||||||
|
|||||||
@@ -1989,6 +1989,7 @@
|
|||||||
"payment_made_form.label.total": "إجمالي",
|
"payment_made_form.label.total": "إجمالي",
|
||||||
"make_journal.label.subtotal": "المجموع",
|
"make_journal.label.subtotal": "المجموع",
|
||||||
"make_journal.label.total": "إجمالي",
|
"make_journal.label.total": "إجمالي",
|
||||||
|
"make_journal.label.select_journal_type":"حدد نوع القيد",
|
||||||
"expense.label.subtotal": "المجموع",
|
"expense.label.subtotal": "المجموع",
|
||||||
"expense.label.total": "إجمالي",
|
"expense.label.total": "إجمالي",
|
||||||
"expense.branch_button.label": "الفرع: {label}",
|
"expense.branch_button.label": "الفرع: {label}",
|
||||||
|
|||||||
@@ -1989,6 +1989,7 @@
|
|||||||
"payment_made.form.internal_note.placeholder": "Internal note (Not visible to the vendor).",
|
"payment_made.form.internal_note.placeholder": "Internal note (Not visible to the vendor).",
|
||||||
"make_journal.label.subtotal": "Subtotal",
|
"make_journal.label.subtotal": "Subtotal",
|
||||||
"make_journal.label.total": "TOTAL",
|
"make_journal.label.total": "TOTAL",
|
||||||
|
"make_journal.label.select_journal_type":"Select Journal Type",
|
||||||
"expense.label.subtotal": "Subtotal",
|
"expense.label.subtotal": "Subtotal",
|
||||||
"expense.label.total": "TOTAL",
|
"expense.label.total": "TOTAL",
|
||||||
"expense.branch_button.label": "Branch: {label}",
|
"expense.branch_button.label": "Branch: {label}",
|
||||||
|
|||||||
Reference in New Issue
Block a user