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