mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
feat: Organization address and branding patch endpoint
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @param { import("knex").Knex } knex
|
||||
* @returns { Promise<void> }
|
||||
*/
|
||||
exports.up = function (knex) {
|
||||
return knex.schema.table('tenants_metadata', (table) => {
|
||||
table.string('primary_color');
|
||||
table.string('logo_key');
|
||||
table.json('address');
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param { import("knex").Knex } knex
|
||||
* @returns { Promise<void> }
|
||||
*/
|
||||
exports.down = function (knex) {
|
||||
return knex.schema.table('tenants_metadata', (table) => {
|
||||
table.dropColumn('primary_color');
|
||||
table.dropColumn('logo_key');
|
||||
table.dropColumn('address');
|
||||
});
|
||||
};
|
||||
@@ -169,7 +169,7 @@ export default class Tenant extends BaseModel {
|
||||
*/
|
||||
static async saveMetadata(tenantId, metadata) {
|
||||
const foundMetadata = await TenantMetadata.query().findOne({ tenantId });
|
||||
const updateOrInsert = foundMetadata ? 'update' : 'insert';
|
||||
const updateOrInsert = foundMetadata ? 'patch' : 'insert';
|
||||
|
||||
return TenantMetadata.query()
|
||||
[updateOrInsert]({
|
||||
|
||||
@@ -1,8 +1,39 @@
|
||||
import BaseModel from 'models/Model';
|
||||
|
||||
export default class TenantMetadata extends BaseModel {
|
||||
baseCurrency: string;
|
||||
name: string;
|
||||
baseCurrency!: string;
|
||||
name!: string;
|
||||
tenantId!: number;
|
||||
industry!: string;
|
||||
location!: string;
|
||||
language!: string;
|
||||
timezone!: string;
|
||||
dateFormat!: string;
|
||||
fiscalYear!: string;
|
||||
primaryColor!: string;
|
||||
logoKey!: string;
|
||||
address!: object;
|
||||
|
||||
static get jsonSchema() {
|
||||
return {
|
||||
type: 'object',
|
||||
required: ['tenantId', 'name', 'baseCurrency'],
|
||||
properties: {
|
||||
tenantId: { type: 'integer' },
|
||||
name: { type: 'string', maxLength: 255 },
|
||||
industry: { type: 'string', maxLength: 255 },
|
||||
location: { type: 'string', maxLength: 255 },
|
||||
baseCurrency: { type: 'string', maxLength: 3 },
|
||||
language: { type: 'string', maxLength: 255 },
|
||||
timezone: { type: 'string', maxLength: 255 },
|
||||
dateFormat: { type: 'string', maxLength: 255 },
|
||||
fiscalYear: { type: 'string', maxLength: 255 },
|
||||
primaryColor: { type: 'string', maxLength: 7 }, // Assuming hex color code
|
||||
logoKey: { type: 'string', maxLength: 255 },
|
||||
address: { type: 'object' },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Table name.
|
||||
|
||||
Reference in New Issue
Block a user