feat: Add tax numbers to the organization details (#269)

This commit is contained in:
Robert Koch
2023-10-26 06:10:46 +10:00
committed by GitHub
parent 2c5537efad
commit e4a7f09dbc
7 changed files with 55 additions and 3 deletions

View File

@@ -31,14 +31,14 @@ export default class OrganizationController extends BaseController {
router.post(
'/build',
this.organizationValidationSchema,
this.buildOrganizationValidationSchema,
this.validationResult,
asyncMiddleware(this.build.bind(this)),
this.handleServiceErrors.bind(this)
);
router.put(
'/',
this.organizationValidationSchema,
this.updateOrganizationValidationSchema,
this.validationResult,
this.asyncMiddleware(this.updateOrganization.bind(this)),
this.handleServiceErrors.bind(this)
@@ -55,7 +55,7 @@ export default class OrganizationController extends BaseController {
* Organization setup schema.
* @return {ValidationChain[]}
*/
private get organizationValidationSchema(): ValidationChain[] {
private get commonOrganizationValidationSchema(): ValidationChain[] {
return [
check('name').exists().trim(),
check('industry').optional({ nullable: true }).isString().trim().escape(),
@@ -68,6 +68,29 @@ export default class OrganizationController extends BaseController {
];
}
/**
* Build organization validation schema.
* @returns {ValidationChain[]}
*/
private get buildOrganizationValidationSchema(): ValidationChain[] {
return [...this.commonOrganizationValidationSchema];
}
/**
* Update organization validation schema.
* @returns {ValidationChain[]}
*/
private get updateOrganizationValidationSchema(): ValidationChain[] {
return [
...this.commonOrganizationValidationSchema,
check('tax_number')
.optional({ nullable: true })
.isString()
.trim()
.escape(),
];
}
/**
* Builds tenant database and migrate database schema.
* @param {Request} req - Express request.

View File

@@ -25,6 +25,7 @@ export interface IOrganizationUpdateDTO {
timezone: string;
fiscalYear: string;
industry: string;
taxNumber: string;
}
export interface IOrganizationBuildEventPayload {

View File

@@ -0,0 +1,11 @@
exports.up = function (knex) {
return knex.schema.table('tenants_metadata', (table) => {
table.string('tax_number')
});
};
exports.down = function (knex) {
return knex.schema.table('tenants_metadata', (table) => {
table.dropColumn('tax_number');
});
};

View File

@@ -6,6 +6,9 @@ const Schema = Yup.object().shape({
name: Yup.string()
.required()
.label(intl.get('organization_name_')),
tax_number: Yup.string()
.nullable()
.label(intl.get('organization_tax_number_')),
industry: Yup.string()
.nullable()
.label(intl.get('organization_industry_')),

View File

@@ -59,6 +59,17 @@ export default function PreferencesGeneralForm({ isSubmitting }) {
<FInputGroup medium={'true'} name={'name'} fastField={true} />
</FFormGroup>
{/* ---------- Organization Tax Number ---------- */}
<FFormGroup
name={'tax_number'}
label={<T id={'organization_tax_number'} />}
inline={true}
helperText={<T id={'shown_on_sales_forms_and_purchase_orders'} />}
fastField={true}
>
<FInputGroup medium={'true'} name={'tax_number'} fastField={true} />
</FFormGroup>
{/* ---------- Industry ---------- */}
<FFormGroup
name={'industry'}

View File

@@ -23,6 +23,7 @@ const defaultValues = {
fiscal_year: '',
date_format: '',
timezone: '',
tax_number: '',
};
/**

View File

@@ -37,6 +37,7 @@
"success": "Success",
"register_a_new_organization": "Register a New Organization.",
"organization_name": "Organization Name",
"organization_tax_number": "Organization Tax Number",
"email": "Email",
"email_address": "Email Address",
"register": "Register",
@@ -339,6 +340,7 @@
"item_type_": "Item type",
"item_name_": "Item name",
"organization_industry_": "Organization industry",
"organization_tax_number_": "Organization tax number",
"base_currency_": "Base currency",
"date_format_": "Date format",
"category_name_": "Category name",