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, 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';
@@ -12,8 +11,6 @@ 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,
@@ -31,13 +28,12 @@ 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, JournalTypeSelect } from './components'; import { JournalExchangeRateInputField } 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.
*/ */
@@ -173,18 +169,21 @@ function MakeJournalEntriesHeader({
</FastField> </FastField>
{/*------------ Journal type -----------*/} {/*------------ Journal type -----------*/}
<FFormGroup <FastField name={'journal_type'}>
name={'journal_type'} {({ form, field, meta: { error, touched } }) => (
label={<T id={'journal_type'} />} <FormGroup
inline={true} label={<T id={'journal_type'} />}
className={classNames('form-group--select-list', Classes.FILL)} className={classNames('form-group--account-type', CLASSES.FILL)}
> inline={true}
<JournalTypeSelect >
items={journalTypes} <InputGroup
name={'journal_type'} intent={inputIntent({ error, touched })}
popoverProps={{ minimal: true }} fill={true}
/> {...field}
</FFormGroup> />
</FormGroup>
)}
</FastField>
{/*------------ Currency -----------*/} {/*------------ Currency -----------*/}
<FastField <FastField

View File

@@ -9,7 +9,6 @@ import {
Icon, Icon,
Hint, Hint,
FormattedMessage as T, FormattedMessage as T,
FSelect,
} from 'components'; } from 'components';
import { import {
AccountsListFieldCell, 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 = ( const exampleMenu = (
<Menu> <Menu>
<MenuItem onClick={onRemoveRole} text={'item_entries.remove_row'} /> <MenuItem
onClick={onRemoveRole}
text={<T id={'item_entries.remove_row'} />}
/>
</Menu> </Menu>
); );

View File

@@ -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, type: values.type.toString() }; const formValues = { ...values };
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 />

View File

@@ -7,12 +7,7 @@ import {
Radio, Radio,
Position, Position,
} from '@blueprintjs/core'; } from '@blueprintjs/core';
import { import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
FormattedMessage as T,
FormattedHTMLMessage,
FCheckbox,
FFormGroup,
} from 'components';
import { ErrorMessage, FastField } from 'formik'; import { ErrorMessage, FastField } from 'formik';
import { import {
CategoriesSelectList, CategoriesSelectList,
@@ -34,7 +29,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(() => {
@@ -58,34 +53,7 @@ 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 ----------*/}
<FFormGroup <FastField name={'type'}>
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}
@@ -117,7 +85,7 @@ export default function ItemFormPrimarySection() {
</RadioGroup> </RadioGroup>
</FormGroup> </FormGroup>
)} )}
</FastField> */} </FastField>
<Row> <Row>
<Col xs={7}> <Col xs={7}>

View File

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

View File

@@ -1960,6 +1960,7 @@
"invoice_form.label.payment_amount": "مبلغ المدفوع", "invoice_form.label.payment_amount": "مبلغ المدفوع",
"invoice_form.label.invoice_message": "رسالة الفاتورة", "invoice_form.label.invoice_message": "رسالة الفاتورة",
"invoice_form.invoice_message.placeholder": "Thanks for your business and have a great day!", "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", "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.total": "إجمالي",
"receipt_form.label.subtotal": "المجموع", "receipt_form.label.subtotal": "المجموع",
@@ -1989,7 +1990,6 @@
"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}",

View File

@@ -1989,7 +1989,6 @@
"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}",