mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
feat(invoice): add branch & warehouse schema.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
export default function FlagKit({ flage }) {
|
export const FlagTag = ({ flage }) => {
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<Img
|
<Img
|
||||||
@@ -10,7 +10,7 @@ export default function FlagKit({ flage }) {
|
|||||||
/>
|
/>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
const Img = styled.img`
|
const Img = styled.img`
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
export * from './CurrencyTag';
|
export * from './CurrencyTag';
|
||||||
|
export * from './FlagTag'
|
||||||
@@ -3,16 +3,11 @@ import intl from 'react-intl-universal';
|
|||||||
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
||||||
import { isBlank } from 'utils';
|
import { isBlank } from 'utils';
|
||||||
|
|
||||||
const getSchema = () => Yup.object().shape({
|
const getSchema = () =>
|
||||||
customer_id: Yup.string()
|
Yup.object().shape({
|
||||||
.label(intl.get('customer_name_'))
|
customer_id: Yup.string().label(intl.get('customer_name_')).required(),
|
||||||
.required(),
|
invoice_date: Yup.date().required().label(intl.get('invoice_date_')),
|
||||||
invoice_date: Yup.date()
|
due_date: Yup.date().required().label(intl.get('due_date_')),
|
||||||
.required()
|
|
||||||
.label(intl.get('invoice_date_')),
|
|
||||||
due_date: Yup.date()
|
|
||||||
.required()
|
|
||||||
.label(intl.get('due_date_')),
|
|
||||||
invoice_no: Yup.string()
|
invoice_no: Yup.string()
|
||||||
.max(DATATYPES_LENGTH.STRING)
|
.max(DATATYPES_LENGTH.STRING)
|
||||||
.label(intl.get('invoice_no_')),
|
.label(intl.get('invoice_no_')),
|
||||||
@@ -29,6 +24,9 @@ const getSchema = () => Yup.object().shape({
|
|||||||
.min(1)
|
.min(1)
|
||||||
.max(DATATYPES_LENGTH.TEXT)
|
.max(DATATYPES_LENGTH.TEXT)
|
||||||
.label(intl.get('note')),
|
.label(intl.get('note')),
|
||||||
|
exchange_rate: Yup.number(),
|
||||||
|
branch_id: Yup.string(),
|
||||||
|
warehouse_id: Yup.string(),
|
||||||
entries: Yup.array().of(
|
entries: Yup.array().of(
|
||||||
Yup.object().shape({
|
Yup.object().shape({
|
||||||
quantity: Yup.number()
|
quantity: Yup.number()
|
||||||
@@ -49,7 +47,7 @@ const getSchema = () => Yup.object().shape({
|
|||||||
description: Yup.string().nullable().max(DATATYPES_LENGTH.TEXT),
|
description: Yup.string().nullable().max(DATATYPES_LENGTH.TEXT),
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const getCreateInvoiceFormSchema = getSchema;
|
export const getCreateInvoiceFormSchema = getSchema;
|
||||||
export const getEditInvoiceFormSchema = getSchema;
|
export const getEditInvoiceFormSchema = getSchema;
|
||||||
|
|||||||
@@ -4,12 +4,13 @@ import {
|
|||||||
InputGroup,
|
InputGroup,
|
||||||
Position,
|
Position,
|
||||||
ControlGroup,
|
ControlGroup,
|
||||||
Classes,
|
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import { DateInput } from '@blueprintjs/datetime';
|
import { DateInput } from '@blueprintjs/datetime';
|
||||||
import { FastField, Field, ErrorMessage } from 'formik';
|
import { FastField, Field, ErrorMessage } from 'formik';
|
||||||
import { FormattedMessage as T, Col, Row } from 'components';
|
import { FormattedMessage as T, Col, Row } from 'components';
|
||||||
import { momentFormatter, compose, tansformDateValue } from 'utils';
|
import { momentFormatter, compose, tansformDateValue } from 'utils';
|
||||||
|
import { upperCase } from 'lodash';
|
||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
@@ -25,19 +26,22 @@ import {
|
|||||||
Icon,
|
Icon,
|
||||||
InputPrependButton,
|
InputPrependButton,
|
||||||
MoneyInputGroup,
|
MoneyInputGroup,
|
||||||
|
FlagTag,
|
||||||
} from 'components';
|
} from 'components';
|
||||||
import ItemsSuggestField from 'components/ItemsSuggestField';
|
|
||||||
import { useInvoiceFormContext } from './InvoiceFormProvider';
|
import { useInvoiceFormContext } from './InvoiceFormProvider';
|
||||||
|
|
||||||
import withSettings from 'containers/Settings/withSettings';
|
import withSettings from 'containers/Settings/withSettings';
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
import { inputIntent, handleDateChange } from 'utils';
|
import { inputIntent, handleDateChange } from 'utils';
|
||||||
import BaseCurrency from './BaseCurrency';
|
import BaseCurrency from './BaseCurrency';
|
||||||
import FlagKit from './FlagKit';
|
|
||||||
|
|
||||||
const Data = [
|
const Data = [
|
||||||
{
|
{
|
||||||
id: '10',
|
id: 10,
|
||||||
|
name: 'Due on Receipt',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 20,
|
||||||
name: 'Due on Receipt',
|
name: 'Due on Receipt',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -118,7 +122,7 @@ function InvoiceFormHeaderFields({
|
|||||||
</CustomerName>
|
</CustomerName>
|
||||||
<ExchangeWrapp>
|
<ExchangeWrapp>
|
||||||
<ExchangeLable>
|
<ExchangeLable>
|
||||||
<FlagKit flage={'US'} /> 1 USD =
|
<FlagTag flage={'US'} /> 1 USD =
|
||||||
</ExchangeLable>
|
</ExchangeLable>
|
||||||
|
|
||||||
{/* ----------- Exchange reate ----------- */}
|
{/* ----------- Exchange reate ----------- */}
|
||||||
@@ -138,14 +142,16 @@ function InvoiceFormHeaderFields({
|
|||||||
value={field.value}
|
value={field.value}
|
||||||
allowDecimals={false}
|
allowDecimals={false}
|
||||||
allowNegativeValue={true}
|
allowNegativeValue={true}
|
||||||
onChange={(value) => {}}
|
onChange={(value) => {
|
||||||
|
setFieldValue('exchange_rate', value);
|
||||||
|
}}
|
||||||
intent={inputIntent({ error, touched })}
|
intent={inputIntent({ error, touched })}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
)}
|
)}
|
||||||
</Field>
|
</Field>
|
||||||
<ExchangeLable>
|
<ExchangeLable>
|
||||||
<FlagKit flage={'LY'} /> LYD
|
<FlagTag flage={'LY'} /> LYD
|
||||||
</ExchangeLable>
|
</ExchangeLable>
|
||||||
</ExchangeWrapp>
|
</ExchangeWrapp>
|
||||||
<Row>
|
<Row>
|
||||||
|
|||||||
@@ -17,30 +17,30 @@ export default function InvoiceFormTopBar() {
|
|||||||
return (
|
return (
|
||||||
<Navbar className={'navbar--dashboard-topbar'}>
|
<Navbar className={'navbar--dashboard-topbar'}>
|
||||||
<NavbarGroup align={Alignment.LEFT}>
|
<NavbarGroup align={Alignment.LEFT}>
|
||||||
<FastField name={'branch'}>
|
<FastField name={'branch_id'}>
|
||||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||||
<CustomSelectList
|
<CustomSelectList
|
||||||
items={branches}
|
items={branches}
|
||||||
text={'Branch'}
|
text={'Branch'}
|
||||||
onItemSelected={(item) => {
|
onItemSelected={({ id }) => {
|
||||||
form.setFieldValue('name', item.id);
|
form.setFieldValue('branch_id', id);
|
||||||
}}
|
}}
|
||||||
selectedItemId={value}
|
selectedItemId={value}
|
||||||
buttonProps={{
|
buttonProps={{
|
||||||
icon: <Icon icon={'domain-16'} iconSize={20} />,
|
icon: <Icon icon={'branch-16'} iconSize={20} />,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</FastField>
|
</FastField>
|
||||||
|
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
<FastField name={'warehouse'}>
|
<FastField name={'warehouse_id'}>
|
||||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||||
<CustomSelectList
|
<CustomSelectList
|
||||||
items={warehouses}
|
items={warehouses}
|
||||||
text={'Warehosue'}
|
text={'Warehosue'}
|
||||||
onItemSelected={(item) => {
|
onItemSelected={({ id }) => {
|
||||||
form.setFieldValue('warehouse', item.id);
|
form.setFieldValue('warehouse_id', id);
|
||||||
}}
|
}}
|
||||||
selectedItemId={value}
|
selectedItemId={value}
|
||||||
buttonProps={{
|
buttonProps={{
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ export const defaultInvoice = {
|
|||||||
reference_no: '',
|
reference_no: '',
|
||||||
invoice_message: '',
|
invoice_message: '',
|
||||||
terms_conditions: '',
|
terms_conditions: '',
|
||||||
|
exchange_rate: '',
|
||||||
|
branch_id: '',
|
||||||
|
warehouse_id: '',
|
||||||
entries: [...repeatValue(defaultInvoiceEntry, MIN_LINES_NUMBER)],
|
entries: [...repeatValue(defaultInvoiceEntry, MIN_LINES_NUMBER)],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -528,7 +528,7 @@ export default {
|
|||||||
],
|
],
|
||||||
viewBox: '0 0 24 24',
|
viewBox: '0 0 24 24',
|
||||||
},
|
},
|
||||||
'domain-16': {
|
'branch-16': {
|
||||||
path: [
|
path: [
|
||||||
'M12 7V3H2v18h20V7H12zM6 19H4v-2h2v2zm0-4H4v-2h2v2zm0-4H4V9h2v2zm0-4H4V5h2v2zm4 12H8v-2h2v2zm0-4H8v-2h2v2zm0-4H8V9h2v2zm0-4H8V5h2v2zm10 12h-8v-2h2v-2h-2v-2h2v-2h-2V9h8v10zm-2-8h-2v2h2v-2zm0 4h-2v2h2v-2z',
|
'M12 7V3H2v18h20V7H12zM6 19H4v-2h2v2zm0-4H4v-2h2v2zm0-4H4V9h2v2zm0-4H4V5h2v2zm4 12H8v-2h2v2zm0-4H8v-2h2v2zm0-4H8V9h2v2zm0-4H8V5h2v2zm10 12h-8v-2h2v-2h-2v-2h2v-2h-2V9h8v10zm-2-8h-2v2h2v-2zm0 4h-2v2h2v-2z',
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user