Compare commits

..

1 Commits

Author SHA1 Message Date
elforjani13
b1e7720bd9 BIG-378: add Localize to invoice. 2022-04-04 17:58:39 +02:00
9 changed files with 28 additions and 136 deletions

View File

@@ -1,8 +0,0 @@
import intl from 'react-intl-universal';
export const journalTypes = [
{
name: intl.get('journal'),
value: 'Journal',
},
];

View File

@@ -4,7 +4,6 @@ import {
FormGroup,
Position,
ControlGroup,
Classes,
} from '@blueprintjs/core';
import { FastField, ErrorMessage } from 'formik';
import { DateInput } from '@blueprintjs/datetime';
@@ -12,8 +11,6 @@ import { FormattedMessage as T } from 'components';
import classNames from 'classnames';
import { CLASSES } from 'common/classes';
import { journalTypes } from '../../../common/journalTypes';
import { FFormGroup } from '../../../components';
import {
momentFormatter,
compose,
@@ -31,13 +28,12 @@ import {
} from 'components';
import withSettings from 'containers/Settings/withSettings';
import { useMakeJournalFormContext } from './MakeJournalProvider';
import { JournalExchangeRateInputField, JournalTypeSelect } from './components';
import { JournalExchangeRateInputField } from './components';
import withDialogActions from 'containers/Dialog/withDialogActions';
import {
currenciesFieldShouldUpdate,
useObserveJournalNoSettings,
} from './utils';
/**
* Make journal entries header.
*/
@@ -173,18 +169,21 @@ function MakeJournalEntriesHeader({
</FastField>
{/*------------ Journal type -----------*/}
<FFormGroup
name={'journal_type'}
label={<T id={'journal_type'} />}
inline={true}
className={classNames('form-group--select-list', Classes.FILL)}
>
<JournalTypeSelect
items={journalTypes}
name={'journal_type'}
popoverProps={{ minimal: true }}
/>
</FFormGroup>
<FastField name={'journal_type'}>
{({ form, field, meta: { error, touched } }) => (
<FormGroup
label={<T id={'journal_type'} />}
className={classNames('form-group--account-type', CLASSES.FILL)}
inline={true}
>
<InputGroup
intent={inputIntent({ error, touched })}
fill={true}
{...field}
/>
</FormGroup>
)}
</FastField>
{/*------------ Currency -----------*/}
<FastField

View File

@@ -9,7 +9,6 @@ import {
Icon,
Hint,
FormattedMessage as T,
FSelect,
} from 'components';
import {
AccountsListFieldCell,
@@ -184,71 +183,3 @@ 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')}
/>
);
}

View File

@@ -43,7 +43,10 @@ export function ActionsCellRenderer({
const exampleMenu = (
<Menu>
<MenuItem onClick={onRemoveRole} text={'item_entries.remove_row'} />
<MenuItem
onClick={onRemoveRole}
text={<T id={'item_entries.remove_row'} />}
/>
</Menu>
);

View File

@@ -50,7 +50,7 @@ export default function ItemFormFormik({
// Handles the form submit.
const handleFormSubmit = (values, form) => {
const { setSubmitting, resetForm, setErrors } = form;
const formValues = { ...values, type: values.type.toString() };
const formValues = { ...values };
setSubmitting(true);
@@ -96,7 +96,7 @@ export default function ItemFormFormik({
validationSchema={isNewMode ? CreateItemFormSchema : EditItemFormSchema}
initialValues={initialValues}
onSubmit={handleFormSubmit}
>
>
<Form>
<div class={classNames(CLASSES.PAGE_FORM_BODY)}>
<ItemFormPrimarySection />

View File

@@ -7,12 +7,7 @@ import {
Radio,
Position,
} from '@blueprintjs/core';
import {
FormattedMessage as T,
FormattedHTMLMessage,
FCheckbox,
FFormGroup,
} from 'components';
import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
import { ErrorMessage, FastField } from 'formik';
import {
CategoriesSelectList,
@@ -34,7 +29,7 @@ import { categoriesFieldShouldUpdate } from './utils';
export default function ItemFormPrimarySection() {
// Item form context.
const { isNewMode, item, itemsCategories } = useItemFormContext();
console.log(item.type, 'XXX');
const nameFieldRef = useRef(null);
useEffect(() => {
@@ -58,34 +53,7 @@ export default function ItemFormPrimarySection() {
return (
<div className={classNames(CLASSES.PAGE_FORM_HEADER_PRIMARY)}>
{/*----------- Item 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'}>
<FastField name={'type'}>
{({ form, field: { value }, meta: { touched, error } }) => (
<FormGroup
medium={true}
@@ -117,7 +85,7 @@ export default function ItemFormPrimarySection() {
</RadioGroup>
</FormGroup>
)}
</FastField> */}
</FastField>
<Row>
<Col xs={7}>

View File

@@ -147,7 +147,7 @@ function InvoiceFormHeaderFields({
</FastField>
</Col>
<Col className={'col--due-date'}>
<Col xs={6}>
{/* ----------- Due date ----------- */}
<FastField name={'due_date'}>
{({ form, field: { value }, meta: { error, touched } }) => (

View File

@@ -1960,6 +1960,7 @@
"invoice_form.label.payment_amount": "مبلغ المدفوع",
"invoice_form.label.invoice_message": "رسالة الفاتورة",
"invoice_form.invoice_message.placeholder": "Thanks for your business and have a great day!",
"invoice_form.label.terms_conditions": "الشروط والأحكام",
"invoice_form.terms_and_conditions.placeholder": "Enter the terms and conditions of your business to be displayed in your transaction",
"receipt_form.label.total": "إجمالي",
"receipt_form.label.subtotal": "المجموع",
@@ -1989,7 +1990,6 @@
"payment_made_form.label.total": "إجمالي",
"make_journal.label.subtotal": "المجموع",
"make_journal.label.total": "إجمالي",
"make_journal.label.select_journal_type":"حدد نوع القيد",
"expense.label.subtotal": "المجموع",
"expense.label.total": "إجمالي",
"expense.branch_button.label": "الفرع: {label}",

View File

@@ -1989,7 +1989,6 @@
"payment_made.form.internal_note.placeholder": "Internal note (Not visible to the vendor).",
"make_journal.label.subtotal": "Subtotal",
"make_journal.label.total": "TOTAL",
"make_journal.label.select_journal_type":"Select Journal Type",
"expense.label.subtotal": "Subtotal",
"expense.label.total": "TOTAL",
"expense.branch_button.label": "Branch: {label}",