diff --git a/packages/server/src/common/config/inventory.ts b/packages/server/src/common/config/inventory.ts index 1a5785521..70c3bd614 100644 --- a/packages/server/src/common/config/inventory.ts +++ b/packages/server/src/common/config/inventory.ts @@ -1,4 +1,4 @@ -import { registerAs } from "@nestjs/config"; +import { registerAs } from '@nestjs/config'; export default registerAs('inventory', () => ({ scheduleComputeItemCost: process.env.INVENTORY_SCHEDULE_COMPUTE_ITEM_COST, diff --git a/packages/server/src/common/config/loops.ts b/packages/server/src/common/config/loops.ts index 294caacb5..c26e2771f 100644 --- a/packages/server/src/common/config/loops.ts +++ b/packages/server/src/common/config/loops.ts @@ -1,4 +1,3 @@ - import { registerAs } from '@nestjs/config'; export default registerAs('loops', () => ({ diff --git a/packages/server/src/common/config/system-database.ts b/packages/server/src/common/config/system-database.ts index b333aba22..b8f7d921c 100644 --- a/packages/server/src/common/config/system-database.ts +++ b/packages/server/src/common/config/system-database.ts @@ -7,6 +7,7 @@ export default registerAs('systemDatabase', () => ({ user: process.env.SYSTEM_DB_USER || process.env.DB_USER, password: process.env.SYSTEM_DB_PASSWORD || process.env.DB_PASSWORD, databaseName: process.env.SYSTEM_DB_NAME || process.env.DB_NAME, - migrationDir: process.env.SYSTEM_DB_MIGRATION_DIR || './src/database/system/migrations', + migrationDir: + process.env.SYSTEM_DB_MIGRATION_DIR || './src/database/system/migrations', seedsDir: process.env.SYSTEM_DB_SEEDS_DIR || './src/database/system/seeds', })); diff --git a/packages/server/src/common/config/throttle.ts b/packages/server/src/common/config/throttle.ts index 3ab6738ff..cac67cb02 100644 --- a/packages/server/src/common/config/throttle.ts +++ b/packages/server/src/common/config/throttle.ts @@ -10,5 +10,3 @@ export default registerAs('throttle', () => ({ limit: parseInt(process.env.THROTTLE_AUTH_LIMIT ?? '10', 10), }, })); - - diff --git a/packages/server/src/common/constants/files.constants.ts b/packages/server/src/common/constants/files.constants.ts index 9f7f763e2..fd2ef8091 100644 --- a/packages/server/src/common/constants/files.constants.ts +++ b/packages/server/src/common/constants/files.constants.ts @@ -1 +1 @@ -export const MULTER_MODULE_OPTIONS = 'MULTER_MODULE_OPTIONS'; \ No newline at end of file +export const MULTER_MODULE_OPTIONS = 'MULTER_MODULE_OPTIONS'; diff --git a/packages/server/src/common/constants/http.constants.ts b/packages/server/src/common/constants/http.constants.ts index 96022929a..b956f8c3e 100644 --- a/packages/server/src/common/constants/http.constants.ts +++ b/packages/server/src/common/constants/http.constants.ts @@ -5,4 +5,4 @@ export const ACCEPT_TYPE = { APPLICATION_XLSX: 'application/xlsx', APPLICATION_CSV: 'application/csv', APPLICATION_TEXT_HTML: 'application/json+html', -}; \ No newline at end of file +}; diff --git a/packages/server/src/common/constants/multer.constants.ts b/packages/server/src/common/constants/multer.constants.ts index 5db769551..24e6e8471 100644 --- a/packages/server/src/common/constants/multer.constants.ts +++ b/packages/server/src/common/constants/multer.constants.ts @@ -20,5 +20,3 @@ export const busboyExceptions = { MULTIPART_UNEXPECTED_END_OF_FORM: 'Unexpected end of form', MULTIPART_UNEXPECTED_END_OF_FILE: 'Unexpected end of file', }; - - diff --git a/packages/server/src/common/constants/multer.utils.ts b/packages/server/src/common/constants/multer.utils.ts index 3bd4017df..62c1a7f10 100644 --- a/packages/server/src/common/constants/multer.utils.ts +++ b/packages/server/src/common/constants/multer.utils.ts @@ -35,4 +35,4 @@ export function transformException( return new BadRequestException(`Multipart: ${error.message}`); } return error; -} \ No newline at end of file +} diff --git a/packages/server/src/common/dtos/BulkDelete.dto.ts b/packages/server/src/common/dtos/BulkDelete.dto.ts index 244475c8a..e7d0ab0ac 100644 --- a/packages/server/src/common/dtos/BulkDelete.dto.ts +++ b/packages/server/src/common/dtos/BulkDelete.dto.ts @@ -1,4 +1,10 @@ -import { IsArray, IsInt, ArrayNotEmpty, IsBoolean, IsOptional } from 'class-validator'; +import { + IsArray, + IsInt, + ArrayNotEmpty, + IsBoolean, + IsOptional, +} from 'class-validator'; import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { Transform } from 'class-transformer'; import { parseBoolean } from '@/utils/parse-boolean'; @@ -16,9 +22,12 @@ export class BulkDeleteDto { @IsOptional() @IsBoolean() - @Transform(({ value, obj }) => parseBoolean(value ?? obj?.skip_undeletable, false)) + @Transform(({ value, obj }) => + parseBoolean(value ?? obj?.skip_undeletable, false), + ) @ApiPropertyOptional({ - description: 'When true, undeletable items will be skipped and only deletable ones will be removed.', + description: + 'When true, undeletable items will be skipped and only deletable ones will be removed.', type: Boolean, default: false, }) @@ -52,4 +61,3 @@ export class ValidateBulkDeleteResponseDto { }) nonDeletableIds: number[]; } - diff --git a/packages/server/src/common/filters/service-error.filter.ts b/packages/server/src/common/filters/service-error.filter.ts index 44c2c1f68..576c5b86c 100644 --- a/packages/server/src/common/filters/service-error.filter.ts +++ b/packages/server/src/common/filters/service-error.filter.ts @@ -21,8 +21,8 @@ export class ServiceErrorFilter implements ExceptionFilter { type: exception.errorType, message: exception.message, payload: exception.payload, - } - ] + }, + ], }); } } diff --git a/packages/server/src/common/interceptors/file.interceptor.ts b/packages/server/src/common/interceptors/file.interceptor.ts index 4eb41b003..0093a9a81 100644 --- a/packages/server/src/common/interceptors/file.interceptor.ts +++ b/packages/server/src/common/interceptors/file.interceptor.ts @@ -29,12 +29,11 @@ export function FileInterceptor( constructor( @Optional() @Inject(MULTER_MODULE_OPTIONS) - options: (() => MulterModuleOptions | MulterModuleOptions) = () => ({}), + options: () => MulterModuleOptions | MulterModuleOptions = () => ({}), ) { - const resolvedOptions = typeof localOptions === 'function' - ? localOptions(this) - : localOptions; - + const resolvedOptions = + typeof localOptions === 'function' ? localOptions(this) : localOptions; + this.multer = (multer as any)({ ...(typeof options === 'function' ? options() : options), ...resolvedOptions, @@ -67,4 +66,4 @@ export function FileInterceptor( const Interceptor = mixin(MixinInterceptor); return Interceptor; -} \ No newline at end of file +} diff --git a/packages/server/src/common/interceptors/serialize.interceptor.ts b/packages/server/src/common/interceptors/serialize.interceptor.ts index d0eb60d12..7480cc1b5 100644 --- a/packages/server/src/common/interceptors/serialize.interceptor.ts +++ b/packages/server/src/common/interceptors/serialize.interceptor.ts @@ -56,7 +56,7 @@ export const DEFAULT_STRATEGY = { @Injectable() export class SerializeInterceptor implements NestInterceptor { - constructor(@Optional() readonly strategy = DEFAULT_STRATEGY) { } + constructor(@Optional() readonly strategy = DEFAULT_STRATEGY) {} intercept( context: ExecutionContext, diff --git a/packages/server/src/common/interceptors/to-json.interceptor.ts b/packages/server/src/common/interceptors/to-json.interceptor.ts index bb3ae2f6f..29f3f6f8b 100644 --- a/packages/server/src/common/interceptors/to-json.interceptor.ts +++ b/packages/server/src/common/interceptors/to-json.interceptor.ts @@ -16,7 +16,11 @@ export class ToJsonInterceptor implements NestInterceptor { return data; } return mapValuesDeep(data, (value) => { - if (value !== null && value !== undefined && typeof value.toJSON === 'function') { + if ( + value !== null && + value !== undefined && + typeof value.toJSON === 'function' + ) { return value.toJSON(); } return value; diff --git a/packages/server/src/common/repository/TenantRepository.ts b/packages/server/src/common/repository/TenantRepository.ts index f226e286a..a79443e8c 100644 --- a/packages/server/src/common/repository/TenantRepository.ts +++ b/packages/server/src/common/repository/TenantRepository.ts @@ -1,6 +1,4 @@ // import { CachableRepository } from './CachableRepository'; import { EntityRepository } from './EntityRepository'; -export class TenantRepository extends EntityRepository { - -} +export class TenantRepository extends EntityRepository {} diff --git a/packages/server/src/common/types/Date.ts b/packages/server/src/common/types/Date.ts index c6c114a7b..33907ee0e 100644 --- a/packages/server/src/common/types/Date.ts +++ b/packages/server/src/common/types/Date.ts @@ -1,3 +1,3 @@ import * as moment from 'moment'; -export type DateInput = moment.MomentInput; \ No newline at end of file +export type DateInput = moment.MomentInput; diff --git a/packages/server/src/common/types/Discount.ts b/packages/server/src/common/types/Discount.ts index 6b2fd41c3..391f79171 100644 --- a/packages/server/src/common/types/Discount.ts +++ b/packages/server/src/common/types/Discount.ts @@ -1,4 +1,4 @@ export enum DiscountType { Percentage = 'percentage', Amount = 'amount', -} \ No newline at end of file +} diff --git a/packages/server/src/database/tenant/migrations/20190822214303_create_accounts_table.ts b/packages/server/src/database/tenant/migrations/20190822214303_create_accounts_table.ts index 81abcaf26..90ac6e2f8 100644 --- a/packages/server/src/database/tenant/migrations/20190822214303_create_accounts_table.ts +++ b/packages/server/src/database/tenant/migrations/20190822214303_create_accounts_table.ts @@ -1,19 +1,25 @@ exports.up = function (knex) { - return knex.schema.createTable('accounts', (table) => { - table.increments('id').comment('Auto-generated id'); - table.string('name').index(); - table.string('slug'); - table.string('account_type').index(); - table.integer('parent_account_id').unsigned().references('id').inTable('accounts'); - table.string('code', 10).index(); - table.text('description'); - table.boolean('active').defaultTo(true).index(); - table.integer('index').unsigned(); - table.boolean('predefined').defaultTo(false).index(); - table.decimal('amount', 15, 5); - table.string('currency_code', 3).index(); - table.timestamps(); - }).raw('ALTER TABLE `ACCOUNTS` AUTO_INCREMENT = 1000'); + return knex.schema + .createTable('accounts', (table) => { + table.increments('id').comment('Auto-generated id'); + table.string('name').index(); + table.string('slug'); + table.string('account_type').index(); + table + .integer('parent_account_id') + .unsigned() + .references('id') + .inTable('accounts'); + table.string('code', 10).index(); + table.text('description'); + table.boolean('active').defaultTo(true).index(); + table.integer('index').unsigned(); + table.boolean('predefined').defaultTo(false).index(); + table.decimal('amount', 15, 5); + table.string('currency_code', 3).index(); + table.timestamps(); + }) + .raw('ALTER TABLE `ACCOUNTS` AUTO_INCREMENT = 1000'); }; exports.down = (knex) => knex.schema.dropTableIfExists('accounts'); diff --git a/packages/server/src/database/tenant/migrations/20190822214304_create_items_categories_table.ts b/packages/server/src/database/tenant/migrations/20190822214304_create_items_categories_table.ts index 2fe1ec9ef..b22d46047 100644 --- a/packages/server/src/database/tenant/migrations/20190822214304_create_items_categories_table.ts +++ b/packages/server/src/database/tenant/migrations/20190822214304_create_items_categories_table.ts @@ -1,15 +1,26 @@ - exports.up = function (knex) { return knex.schema.createTable('items_categories', (table) => { table.increments(); table.string('name').index(); - + table.text('description'); table.integer('user_id').unsigned().index(); - table.integer('cost_account_id').unsigned().references('id').inTable('accounts'); - table.integer('sell_account_id').unsigned().references('id').inTable('accounts'); - table.integer('inventory_account_id').unsigned().references('id').inTable('accounts'); + table + .integer('cost_account_id') + .unsigned() + .references('id') + .inTable('accounts'); + table + .integer('sell_account_id') + .unsigned() + .references('id') + .inTable('accounts'); + table + .integer('inventory_account_id') + .unsigned() + .references('id') + .inTable('accounts'); table.string('cost_method'); table.timestamps(); diff --git a/packages/server/src/database/tenant/migrations/20190822214306_create_items_table.ts b/packages/server/src/database/tenant/migrations/20190822214306_create_items_table.ts index 16ac1ed66..68202c8b9 100644 --- a/packages/server/src/database/tenant/migrations/20190822214306_create_items_table.ts +++ b/packages/server/src/database/tenant/migrations/20190822214306_create_items_table.ts @@ -1,30 +1,50 @@ - exports.up = function (knex) { - return knex.schema.createTable('items', (table) => { - table.increments(); - table.string('name').index(); - table.string('type').index(); - table.string('code'); - table.boolean('sellable').index(); - table.boolean('purchasable').index(); - table.decimal('sell_price', 13, 3).unsigned(); - table.decimal('cost_price', 13, 3).unsigned(); - table.string('currency_code', 3); - table.string('picture_uri'); - table.integer('cost_account_id').nullable().unsigned().references('id').inTable('accounts'); - table.integer('sell_account_id').nullable().unsigned().references('id').inTable('accounts'); - table.integer('inventory_account_id').unsigned().references('id').inTable('accounts'); - table.text('sell_description').nullable(); - table.text('purchase_description').nullable(); - table.integer('quantity_on_hand'); - table.boolean('landed_cost').nullable(); + return knex.schema + .createTable('items', (table) => { + table.increments(); + table.string('name').index(); + table.string('type').index(); + table.string('code'); + table.boolean('sellable').index(); + table.boolean('purchasable').index(); + table.decimal('sell_price', 13, 3).unsigned(); + table.decimal('cost_price', 13, 3).unsigned(); + table.string('currency_code', 3); + table.string('picture_uri'); + table + .integer('cost_account_id') + .nullable() + .unsigned() + .references('id') + .inTable('accounts'); + table + .integer('sell_account_id') + .nullable() + .unsigned() + .references('id') + .inTable('accounts'); + table + .integer('inventory_account_id') + .unsigned() + .references('id') + .inTable('accounts'); + table.text('sell_description').nullable(); + table.text('purchase_description').nullable(); + table.integer('quantity_on_hand'); + table.boolean('landed_cost').nullable(); - table.text('note').nullable(); - table.boolean('active'); - table.integer('category_id').unsigned().index().references('id').inTable('items_categories'); - table.integer('user_id').unsigned().index(); - table.timestamps(); - }).raw('ALTER TABLE `ITEMS` AUTO_INCREMENT = 1000'); + table.text('note').nullable(); + table.boolean('active'); + table + .integer('category_id') + .unsigned() + .index() + .references('id') + .inTable('items_categories'); + table.integer('user_id').unsigned().index(); + table.timestamps(); + }) + .raw('ALTER TABLE `ITEMS` AUTO_INCREMENT = 1000'); }; exports.down = (knex) => knex.schema.dropTableIfExists('items'); diff --git a/packages/server/src/database/tenant/migrations/20190822214903_create_views_table.ts b/packages/server/src/database/tenant/migrations/20190822214903_create_views_table.ts index eb3929c47..fb0d381a5 100644 --- a/packages/server/src/database/tenant/migrations/20190822214903_create_views_table.ts +++ b/packages/server/src/database/tenant/migrations/20190822214903_create_views_table.ts @@ -1,15 +1,16 @@ - exports.up = function (knex) { - return knex.schema.createTable('views', (table) => { - table.increments(); - table.string('name').index(); - table.string('slug').index(); - table.boolean('predefined'); - table.string('resource_model').index(); - table.boolean('favourite'); - table.string('roles_logic_expression'); - table.timestamps(); - }).raw('ALTER TABLE `VIEWS` AUTO_INCREMENT = 1000'); + return knex.schema + .createTable('views', (table) => { + table.increments(); + table.string('name').index(); + table.string('slug').index(); + table.boolean('predefined'); + table.string('resource_model').index(); + table.boolean('favourite'); + table.string('roles_logic_expression'); + table.timestamps(); + }) + .raw('ALTER TABLE `VIEWS` AUTO_INCREMENT = 1000'); }; exports.down = (knex) => knex.schema.dropTableIfExists('views'); diff --git a/packages/server/src/database/tenant/migrations/20190822214904_create_settings_table.ts b/packages/server/src/database/tenant/migrations/20190822214904_create_settings_table.ts index 65f3f4fdc..38c78aa86 100644 --- a/packages/server/src/database/tenant/migrations/20190822214904_create_settings_table.ts +++ b/packages/server/src/database/tenant/migrations/20190822214904_create_settings_table.ts @@ -1,13 +1,14 @@ - exports.up = function (knex) { - return knex.schema.createTable('settings', (table) => { - table.increments(); - table.integer('user_id').unsigned().index(); - table.string('group').index(); - table.string('type'); - table.string('key').index(); - table.string('value'); - }).raw('ALTER TABLE `SETTINGS` AUTO_INCREMENT = 2000'); + return knex.schema + .createTable('settings', (table) => { + table.increments(); + table.integer('user_id').unsigned().index(); + table.string('group').index(); + table.string('type'); + table.string('key').index(); + table.string('value'); + }) + .raw('ALTER TABLE `SETTINGS` AUTO_INCREMENT = 2000'); }; exports.down = (knex) => knex.schema.dropTableIfExists('settings'); diff --git a/packages/server/src/database/tenant/migrations/20190822214905_create_views_columns.ts b/packages/server/src/database/tenant/migrations/20190822214905_create_views_columns.ts index 4fc76e399..94939a45f 100644 --- a/packages/server/src/database/tenant/migrations/20190822214905_create_views_columns.ts +++ b/packages/server/src/database/tenant/migrations/20190822214905_create_views_columns.ts @@ -1,11 +1,17 @@ - exports.up = function (knex) { - return knex.schema.createTable('view_has_columns', (table) => { - table.increments(); - table.integer('view_id').unsigned().index().references('id').inTable('views'); - table.string('field_key'); - table.integer('index').unsigned(); - }).raw('ALTER TABLE `ITEMS_CATEGORIES` AUTO_INCREMENT = 1000'); + return knex.schema + .createTable('view_has_columns', (table) => { + table.increments(); + table + .integer('view_id') + .unsigned() + .index() + .references('id') + .inTable('views'); + table.string('field_key'); + table.integer('index').unsigned(); + }) + .raw('ALTER TABLE `ITEMS_CATEGORIES` AUTO_INCREMENT = 1000'); }; exports.down = (knex) => knex.schema.dropTableIfExists('view_has_columns'); diff --git a/packages/server/src/database/tenant/migrations/20200104232644_create_contacts_table.ts b/packages/server/src/database/tenant/migrations/20200104232644_create_contacts_table.ts index 09e0accde..3dc3c63af 100644 --- a/packages/server/src/database/tenant/migrations/20200104232644_create_contacts_table.ts +++ b/packages/server/src/database/tenant/migrations/20200104232644_create_contacts_table.ts @@ -1,6 +1,5 @@ - -exports.up = function(knex) { - return knex.schema.createTable('contacts', table => { +exports.up = function (knex) { + return knex.schema.createTable('contacts', (table) => { table.increments(); table.string('contact_service'); @@ -32,8 +31,7 @@ exports.up = function(knex) { table.string('billing_address_postcode').nullable(); table.string('billing_address_phone').nullable(); table.string('billing_address_state').nullable(), - - table.string('shipping_address_1').nullable(); + table.string('shipping_address_1').nullable(); table.string('shipping_address_2').nullable(); table.string('shipping_address_city').nullable(); table.string('shipping_address_country').nullable(); @@ -49,6 +47,6 @@ exports.up = function(knex) { }); }; -exports.down = function(knex) { +exports.down = function (knex) { return knex.schema.dropTableIfExists('contacts'); }; diff --git a/packages/server/src/database/tenant/migrations/20200105195823_create_manual_journals_table.ts b/packages/server/src/database/tenant/migrations/20200105195823_create_manual_journals_table.ts index 8c2714648..016c5d60b 100644 --- a/packages/server/src/database/tenant/migrations/20200105195823_create_manual_journals_table.ts +++ b/packages/server/src/database/tenant/migrations/20200105195823_create_manual_journals_table.ts @@ -1,21 +1,22 @@ - -exports.up = function(knex) { - return knex.schema.createTable('manual_journals', (table) => { - table.increments(); - table.string('journal_number').index(); - table.string('reference').index(); - table.string('journal_type').index(); - table.decimal('amount', 13, 3); - table.string('currency_code', 3); - table.date('date').index(); - table.string('description'); - table.date('published_at').index(); - table.string('attachment_file'); - table.integer('user_id').unsigned().index(); - table.timestamps(); - }).raw('ALTER TABLE `MANUAL_JOURNALS` AUTO_INCREMENT = 1000'); +exports.up = function (knex) { + return knex.schema + .createTable('manual_journals', (table) => { + table.increments(); + table.string('journal_number').index(); + table.string('reference').index(); + table.string('journal_type').index(); + table.decimal('amount', 13, 3); + table.string('currency_code', 3); + table.date('date').index(); + table.string('description'); + table.date('published_at').index(); + table.string('attachment_file'); + table.integer('user_id').unsigned().index(); + table.timestamps(); + }) + .raw('ALTER TABLE `MANUAL_JOURNALS` AUTO_INCREMENT = 1000'); }; -exports.down = function(knex) { +exports.down = function (knex) { return knex.schema.dropTableIfExists('manual_journals'); }; diff --git a/packages/server/src/database/tenant/migrations/20200105195825_create_manual_journals_entries_table.ts b/packages/server/src/database/tenant/migrations/20200105195825_create_manual_journals_entries_table.ts index ecf22cf4c..f4061cb5e 100644 --- a/packages/server/src/database/tenant/migrations/20200105195825_create_manual_journals_entries_table.ts +++ b/packages/server/src/database/tenant/migrations/20200105195825_create_manual_journals_entries_table.ts @@ -1,17 +1,28 @@ - -exports.up = function(knex) { - return knex.schema.createTable('manual_journals_entries', (table) => { - table.increments(); - table.decimal('credit', 13, 3); - table.decimal('debit', 13, 3); - table.integer('index').unsigned(); - table.integer('account_id').unsigned().index().references('id').inTable('accounts'); - table.integer('contact_id').unsigned().nullable().index(); - table.string('note'); - table.integer('manual_journal_id').unsigned().index().references('id').inTable('manual_journals'); - }).raw('ALTER TABLE `MANUAL_JOURNALS_ENTRIES` AUTO_INCREMENT = 1000'); +exports.up = function (knex) { + return knex.schema + .createTable('manual_journals_entries', (table) => { + table.increments(); + table.decimal('credit', 13, 3); + table.decimal('debit', 13, 3); + table.integer('index').unsigned(); + table + .integer('account_id') + .unsigned() + .index() + .references('id') + .inTable('accounts'); + table.integer('contact_id').unsigned().nullable().index(); + table.string('note'); + table + .integer('manual_journal_id') + .unsigned() + .index() + .references('id') + .inTable('manual_journals'); + }) + .raw('ALTER TABLE `MANUAL_JOURNALS_ENTRIES` AUTO_INCREMENT = 1000'); }; -exports.down = function(knex) { +exports.down = function (knex) { return knex.schema.dropTableIfExists('manual_journals_entries'); }; diff --git a/packages/server/src/database/tenant/migrations/20200419171451_create_currencies_table.ts b/packages/server/src/database/tenant/migrations/20200419171451_create_currencies_table.ts index 4d06717b9..6d9885ab2 100644 --- a/packages/server/src/database/tenant/migrations/20200419171451_create_currencies_table.ts +++ b/packages/server/src/database/tenant/migrations/20200419171451_create_currencies_table.ts @@ -1,14 +1,15 @@ - -exports.up = function(knex) { - return knex.schema.createTable('currencies', table => { - table.increments(); - table.string('currency_name').index(); - table.string('currency_code', 4).index(); - table.string('currency_sign').index(); - table.timestamps(); - }).raw('ALTER TABLE `CURRENCIES` AUTO_INCREMENT = 1000'); +exports.up = function (knex) { + return knex.schema + .createTable('currencies', (table) => { + table.increments(); + table.string('currency_name').index(); + table.string('currency_code', 4).index(); + table.string('currency_sign').index(); + table.timestamps(); + }) + .raw('ALTER TABLE `CURRENCIES` AUTO_INCREMENT = 1000'); }; -exports.down = function(knex) { +exports.down = function (knex) { return knex.schema.dropTableIfExists('currencies'); }; diff --git a/packages/server/src/database/tenant/migrations/20200419191832_create_exchange_rates_table.ts b/packages/server/src/database/tenant/migrations/20200419191832_create_exchange_rates_table.ts index 99db76530..1b09100f5 100644 --- a/packages/server/src/database/tenant/migrations/20200419191832_create_exchange_rates_table.ts +++ b/packages/server/src/database/tenant/migrations/20200419191832_create_exchange_rates_table.ts @@ -1,14 +1,15 @@ - -exports.up = function(knex) { - return knex.schema.createTable('exchange_rates', table => { - table.increments(); - table.string('currency_code', 4).index(); - table.decimal('exchange_rate'); - table.date('date').index(); - table.timestamps(); - }).raw('ALTER TABLE `EXCHANGE_RATES` AUTO_INCREMENT = 1000'); +exports.up = function (knex) { + return knex.schema + .createTable('exchange_rates', (table) => { + table.increments(); + table.string('currency_code', 4).index(); + table.decimal('exchange_rate'); + table.date('date').index(); + table.timestamps(); + }) + .raw('ALTER TABLE `EXCHANGE_RATES` AUTO_INCREMENT = 1000'); }; -exports.down = function(knex) { +exports.down = function (knex) { return knex.schema.dropTableIfExists('exchange_rates'); }; diff --git a/packages/server/src/database/tenant/migrations/20200423201600_create_media_table.ts b/packages/server/src/database/tenant/migrations/20200423201600_create_media_table.ts index 64ffc3940..67f6a7635 100644 --- a/packages/server/src/database/tenant/migrations/20200423201600_create_media_table.ts +++ b/packages/server/src/database/tenant/migrations/20200423201600_create_media_table.ts @@ -1,12 +1,11 @@ - -exports.up = function(knex) { +exports.up = function (knex) { return knex.schema.createTable('media', (table) => { table.increments(); table.string('attachment_file'); table.timestamps(); - }); + }); }; -exports.down = function(knex) { +exports.down = function (knex) { return knex.schema.dropTableIfExists('media'); }; diff --git a/packages/server/src/database/tenant/migrations/20200503032011_create_media_links_table.ts b/packages/server/src/database/tenant/migrations/20200503032011_create_media_links_table.ts index 31d26be4b..b38487ed7 100644 --- a/packages/server/src/database/tenant/migrations/20200503032011_create_media_links_table.ts +++ b/packages/server/src/database/tenant/migrations/20200503032011_create_media_links_table.ts @@ -1,13 +1,12 @@ - -exports.up = function(knex) { - return knex.schema.createTable('media_links', table => { +exports.up = function (knex) { + return knex.schema.createTable('media_links', (table) => { table.increments(); table.string('model_name').index(); table.integer('media_id').unsigned().references('id').inTable('media'); table.integer('model_id').unsigned().index(); - }) + }); }; -exports.down = function(knex) { +exports.down = function (knex) { return knex.schema.dropTableIfExists('media_links'); }; diff --git a/packages/server/src/database/tenant/migrations/20200713213303_create_sales_receipt_table.ts b/packages/server/src/database/tenant/migrations/20200713213303_create_sales_receipt_table.ts index c1f093312..3fb9494f7 100644 --- a/packages/server/src/database/tenant/migrations/20200713213303_create_sales_receipt_table.ts +++ b/packages/server/src/database/tenant/migrations/20200713213303_create_sales_receipt_table.ts @@ -1,11 +1,20 @@ - -exports.up = function(knex) { - return knex.schema.createTable('sales_receipts', table => { +exports.up = function (knex) { + return knex.schema.createTable('sales_receipts', (table) => { table.increments(); table.decimal('amount', 13, 3); table.string('currency_code', 3); - table.integer('deposit_account_id').unsigned().index().references('id').inTable('accounts'); - table.integer('customer_id').unsigned().index().references('id').inTable('contacts'); + table + .integer('deposit_account_id') + .unsigned() + .index() + .references('id') + .inTable('accounts'); + table + .integer('customer_id') + .unsigned() + .index() + .references('id') + .inTable('contacts'); table.date('receipt_date').index(); table.string('receipt_number').index(); table.string('reference_no').index(); @@ -14,9 +23,9 @@ exports.up = function(knex) { table.text('statement'); table.date('closed_at').index(); table.timestamps(); - }) + }); }; -exports.down = function(knex) { +exports.down = function (knex) { return knex.schema.dropTableIfExists('sales_receipts'); }; diff --git a/packages/server/src/database/tenant/migrations/20200719153909_create_bills_payments_table.ts b/packages/server/src/database/tenant/migrations/20200719153909_create_bills_payments_table.ts index 568302f3e..0c85217a6 100644 --- a/packages/server/src/database/tenant/migrations/20200719153909_create_bills_payments_table.ts +++ b/packages/server/src/database/tenant/migrations/20200719153909_create_bills_payments_table.ts @@ -1,11 +1,19 @@ - -exports.up = function(knex) { - return knex.schema.createTable('bills_payments', table => { +exports.up = function (knex) { + return knex.schema.createTable('bills_payments', (table) => { table.increments(); - table.integer('vendor_id').unsigned().index().references('id').inTable('contacts'); + table + .integer('vendor_id') + .unsigned() + .index() + .references('id') + .inTable('contacts'); table.decimal('amount', 13, 3).defaultTo(0); table.string('currency_code'); - table.integer('payment_account_id').unsigned().references('id').inTable('accounts'); + table + .integer('payment_account_id') + .unsigned() + .references('id') + .inTable('accounts'); table.string('payment_number').nullable().index(); table.date('payment_date').index(); table.string('payment_method'); @@ -13,9 +21,7 @@ exports.up = function(knex) { table.integer('user_id').unsigned().index(); table.text('statement'); table.timestamps(); - }); + }); }; -exports.down = function(knex) { - -}; +exports.down = function (knex) {}; diff --git a/packages/server/src/database/tenant/migrations/20200722164255_create_inventory_transaction_meta_table.ts b/packages/server/src/database/tenant/migrations/20200722164255_create_inventory_transaction_meta_table.ts index 15f348a17..2769c9483 100644 --- a/packages/server/src/database/tenant/migrations/20200722164255_create_inventory_transaction_meta_table.ts +++ b/packages/server/src/database/tenant/migrations/20200722164255_create_inventory_transaction_meta_table.ts @@ -1,11 +1,10 @@ exports.up = function (knex) { - return knex.schema.createTable('inventory_transaction_meta', (table) => { - table.increments('id'); - table.string('transaction_number'); - table.text('description'); - table.integer('inventory_transaction_id').unsigned(); - }); - }; - - exports.down = function (knex) {}; - \ No newline at end of file + return knex.schema.createTable('inventory_transaction_meta', (table) => { + table.increments('id'); + table.string('transaction_number'); + table.text('description'); + table.integer('inventory_transaction_id').unsigned(); + }); +}; + +exports.down = function (knex) {}; diff --git a/packages/server/src/database/tenant/migrations/20200810121809_create_inventory_adjustments_table.ts b/packages/server/src/database/tenant/migrations/20200810121809_create_inventory_adjustments_table.ts index 4774fcd23..99221ae82 100644 --- a/packages/server/src/database/tenant/migrations/20200810121809_create_inventory_adjustments_table.ts +++ b/packages/server/src/database/tenant/migrations/20200810121809_create_inventory_adjustments_table.ts @@ -1,19 +1,22 @@ - -exports.up = function(knex) { - return knex.schema.createTable('inventory_adjustments', table => { +exports.up = function (knex) { + return knex.schema.createTable('inventory_adjustments', (table) => { table.increments(); table.date('date').index(); table.string('type').index(); - table.integer('adjustment_account_id').unsigned().references('id').inTable('accounts'); + table + .integer('adjustment_account_id') + .unsigned() + .references('id') + .inTable('accounts'); table.string('reason'); table.string('reference_no').index(); table.string('description'); table.integer('user_id').unsigned(); table.date('published_at'); table.timestamps(); - }); + }); }; -exports.down = function(knex) { +exports.down = function (knex) { return knex.schema.dropTableIfExists('inventory_adjustments'); }; diff --git a/packages/server/src/database/tenant/migrations/20220229121920_rename_contacts_shipping_billing_addresses.ts b/packages/server/src/database/tenant/migrations/20220229121920_rename_contacts_shipping_billing_addresses.ts index 117086ef0..87059b759 100644 --- a/packages/server/src/database/tenant/migrations/20220229121920_rename_contacts_shipping_billing_addresses.ts +++ b/packages/server/src/database/tenant/migrations/20220229121920_rename_contacts_shipping_billing_addresses.ts @@ -1,16 +1,16 @@ exports.up = (knex) => { return knex.schema .raw( - 'ALTER TABLE CONTACTS CHANGE SHIPPING_ADDRESS_1 SHIPPING_ADDRESS1 VARCHAR(255)' + 'ALTER TABLE CONTACTS CHANGE SHIPPING_ADDRESS_1 SHIPPING_ADDRESS1 VARCHAR(255)', ) .raw( - 'ALTER TABLE CONTACTS CHANGE SHIPPING_ADDRESS_2 SHIPPING_ADDRESS2 VARCHAR(255)' + 'ALTER TABLE CONTACTS CHANGE SHIPPING_ADDRESS_2 SHIPPING_ADDRESS2 VARCHAR(255)', ) .raw( - 'ALTER TABLE CONTACTS CHANGE BILLING_ADDRESS_1 BILLING_ADDRESS1 VARCHAR(255)' + 'ALTER TABLE CONTACTS CHANGE BILLING_ADDRESS_1 BILLING_ADDRESS1 VARCHAR(255)', ) .raw( - 'ALTER TABLE CONTACTS CHANGE BILLING_ADDRESS_2 BILLING_ADDRESS2 VARCHAR(255)' + 'ALTER TABLE CONTACTS CHANGE BILLING_ADDRESS_2 BILLING_ADDRESS2 VARCHAR(255)', ); }; diff --git a/packages/server/src/database/tenant/migrations/20231108170207_create_storage_table.ts b/packages/server/src/database/tenant/migrations/20231108170207_create_storage_table.ts index 0bf9e8ef9..51801bc85 100644 --- a/packages/server/src/database/tenant/migrations/20231108170207_create_storage_table.ts +++ b/packages/server/src/database/tenant/migrations/20231108170207_create_storage_table.ts @@ -11,4 +11,4 @@ exports.up = function (knex) { exports.down = function (knex) { return knex.schema.dropTableIfExists('storage'); -}; \ No newline at end of file +}; diff --git a/packages/server/src/database/tenant/migrations/20240228183404_create_uncateogrized_cashflow_transactions_table.ts b/packages/server/src/database/tenant/migrations/20240228183404_create_uncateogrized_cashflow_transactions_table.ts index 29a596772..991aae1ea 100644 --- a/packages/server/src/database/tenant/migrations/20240228183404_create_uncateogrized_cashflow_transactions_table.ts +++ b/packages/server/src/database/tenant/migrations/20240228183404_create_uncateogrized_cashflow_transactions_table.ts @@ -19,7 +19,7 @@ exports.up = function (knex) { table.boolean('categorized').defaultTo(false); table.string('plaid_transaction_id'); table.timestamps(); - } + }, ); }; diff --git a/packages/server/src/database/tenant/migrations/20240801130829_change_tax_amount_withheld_column_precision_in_bills_and_sales_invoices_tables.ts b/packages/server/src/database/tenant/migrations/20240801130829_change_tax_amount_withheld_column_precision_in_bills_and_sales_invoices_tables.ts index e03346a5f..0448a9607 100644 --- a/packages/server/src/database/tenant/migrations/20240801130829_change_tax_amount_withheld_column_precision_in_bills_and_sales_invoices_tables.ts +++ b/packages/server/src/database/tenant/migrations/20240801130829_change_tax_amount_withheld_column_precision_in_bills_and_sales_invoices_tables.ts @@ -1,18 +1,22 @@ // This migration changes the precision of the tax_amount_withheld column in the bills and sales_invoices tables from 8, 2 to 13, 2. // This migration is necessary to allow tax_amount_withheld filed to store values bigger than 999,999.99. -exports.up = function(knex) { - return knex.schema.alterTable('bills', function (table) { - table.decimal('tax_amount_withheld', 13, 2).alter(); - }).alterTable('sales_invoices', function (table) { - table.decimal('tax_amount_withheld', 13, 2).alter(); - }); +exports.up = function (knex) { + return knex.schema + .alterTable('bills', function (table) { + table.decimal('tax_amount_withheld', 13, 2).alter(); + }) + .alterTable('sales_invoices', function (table) { + table.decimal('tax_amount_withheld', 13, 2).alter(); + }); }; -exports.down = function(knex) { - return knex.schema.alterTable('bills', function (table) { - table.decimal('tax_amount_withheld', 8, 2).alter(); - }).alterTable('sales_invoices', function (table) { - table.decimal('tax_amount_withheld', 8, 2).alter(); - }); -}; \ No newline at end of file +exports.down = function (knex) { + return knex.schema + .alterTable('bills', function (table) { + table.decimal('tax_amount_withheld', 8, 2).alter(); + }) + .alterTable('sales_invoices', function (table) { + table.decimal('tax_amount_withheld', 8, 2).alter(); + }); +}; diff --git a/packages/server/src/database/tenant/migrations/20240915155403_payment_integration.ts b/packages/server/src/database/tenant/migrations/20240915155403_payment_integration.ts index 01fac495c..6dd393ab9 100644 --- a/packages/server/src/database/tenant/migrations/20240915155403_payment_integration.ts +++ b/packages/server/src/database/tenant/migrations/20240915155403_payment_integration.ts @@ -6,7 +6,7 @@ exports.up = function (knex) { return knex.schema.createTable('payment_integrations', (table) => { table.increments('id'); table.string('service'); - table.string('name'); + table.string('name'); table.string('slug'); table.boolean('payment_enabled').defaultTo(false); table.boolean('payout_enabled').defaultTo(false); diff --git a/packages/server/src/database/tenant/migrations/20241128080734_add_discount_to_invoices_table.ts b/packages/server/src/database/tenant/migrations/20241128080734_add_discount_to_invoices_table.ts index d65b00615..caa0f0e7c 100644 --- a/packages/server/src/database/tenant/migrations/20241128080734_add_discount_to_invoices_table.ts +++ b/packages/server/src/database/tenant/migrations/20241128080734_add_discount_to_invoices_table.ts @@ -6,7 +6,7 @@ exports.up = function (knex) { return knex.schema.alterTable('sales_invoices', (table) => { table.decimal('discount', 10, 2).nullable().after('credited_amount'); table.string('discount_type').nullable().after('discount'); - table.decimal('adjustment', 10, 2).nullable().after('discount_type'); + table.decimal('adjustment', 10, 2).nullable().after('discount_type'); }); }; diff --git a/packages/server/src/database/tenant/migrations/20241128081259_add_discount_to_estimates_table.ts b/packages/server/src/database/tenant/migrations/20241128081259_add_discount_to_estimates_table.ts index 748483f26..625f4aa48 100644 --- a/packages/server/src/database/tenant/migrations/20241128081259_add_discount_to_estimates_table.ts +++ b/packages/server/src/database/tenant/migrations/20241128081259_add_discount_to_estimates_table.ts @@ -2,20 +2,20 @@ * @param { import("knex").Knex } knex * @returns { Promise } */ -exports.up = function(knex) { +exports.up = function (knex) { return knex.schema.alterTable('sales_estimates', (table) => { table.decimal('discount', 10, 2).nullable().after('amount'); table.string('discount_type').nullable().after('discount'); - table.decimal('adjustment', 10, 2).nullable().after('discount_type'); - }); + table.decimal('adjustment', 10, 2).nullable().after('discount_type'); + }); }; /** * @param { import("knex").Knex } knex * @returns { Promise } */ -exports.down = function(knex) { +exports.down = function (knex) { return knex.schema.alterTable('sales_estimates', (table) => { table.dropColumn('discount'); table.dropColumn('discount_type'); diff --git a/packages/server/src/database/tenant/migrations/20241128084550_add_discount_to_receipts_table.ts b/packages/server/src/database/tenant/migrations/20241128084550_add_discount_to_receipts_table.ts index 8b46955cc..1b7229a6e 100644 --- a/packages/server/src/database/tenant/migrations/20241128084550_add_discount_to_receipts_table.ts +++ b/packages/server/src/database/tenant/migrations/20241128084550_add_discount_to_receipts_table.ts @@ -2,7 +2,7 @@ * @param { import("knex").Knex } knex * @returns { Promise } */ -exports.up = function(knex) { +exports.up = function (knex) { return knex.schema.alterTable('sales_receipts', (table) => { table.decimal('discount', 10, 2).nullable().after('amount'); table.string('discount_type').nullable().after('discount'); @@ -15,7 +15,7 @@ exports.up = function(knex) { * @param { import("knex").Knex } knex * @returns { Promise } */ -exports.down = function(knex) { +exports.down = function (knex) { return knex.schema.alterTable('sales_receipts', (table) => { table.dropColumn('discount'); table.dropColumn('discount_type'); diff --git a/packages/server/src/database/tenant/migrations/20241128085243_add_discount_to_bills_table.ts b/packages/server/src/database/tenant/migrations/20241128085243_add_discount_to_bills_table.ts index 9de24d9ab..573563f3d 100644 --- a/packages/server/src/database/tenant/migrations/20241128085243_add_discount_to_bills_table.ts +++ b/packages/server/src/database/tenant/migrations/20241128085243_add_discount_to_bills_table.ts @@ -2,7 +2,7 @@ * @param { import("knex").Knex } knex * @returns { Promise } */ -exports.up = function(knex) { +exports.up = function (knex) { return knex.schema.alterTable('bills', (table) => { // Discount. table.decimal('discount', 10, 2).nullable().after('amount'); @@ -17,7 +17,7 @@ exports.up = function(knex) { * @param { import("knex").Knex } knex * @returns { Promise } */ -exports.down = function(knex) { +exports.down = function (knex) { return knex.schema.alterTable('bills', (table) => { table.dropColumn('discount'); table.dropColumn('discount_type'); diff --git a/packages/server/src/database/tenant/migrations/20241128090222_add_discount_to_credit_notes_table.ts b/packages/server/src/database/tenant/migrations/20241128090222_add_discount_to_credit_notes_table.ts index fcca5bfa4..605ddf37c 100644 --- a/packages/server/src/database/tenant/migrations/20241128090222_add_discount_to_credit_notes_table.ts +++ b/packages/server/src/database/tenant/migrations/20241128090222_add_discount_to_credit_notes_table.ts @@ -2,7 +2,7 @@ * @param { import("knex").Knex } knex * @returns { Promise } */ -exports.up = function(knex) { +exports.up = function (knex) { return knex.schema.alterTable('credit_notes', (table) => { table.decimal('discount', 10, 2).nullable().after('exchange_rate'); table.string('discount_type').nullable().after('discount'); @@ -14,7 +14,7 @@ exports.up = function(knex) { * @param { import("knex").Knex } knex * @returns { Promise } */ -exports.down = function(knex) { +exports.down = function (knex) { return knex.schema.alterTable('credit_notes', (table) => { table.dropColumn('discount'); table.dropColumn('discount_type'); diff --git a/packages/server/src/database/tenant/migrations/20241128160604_add_discount_to_vendor_credits_table.ts b/packages/server/src/database/tenant/migrations/20241128160604_add_discount_to_vendor_credits_table.ts index 706bad1f7..67ed3c956 100644 --- a/packages/server/src/database/tenant/migrations/20241128160604_add_discount_to_vendor_credits_table.ts +++ b/packages/server/src/database/tenant/migrations/20241128160604_add_discount_to_vendor_credits_table.ts @@ -2,7 +2,7 @@ * @param { import("knex").Knex } knex * @returns { Promise } */ -exports.up = function(knex) { +exports.up = function (knex) { return knex.schema.alterTable('vendor_credits', (table) => { table.decimal('discount', 10, 2).nullable().after('amount'); table.string('discount_type').nullable().after('discount'); @@ -14,7 +14,7 @@ exports.up = function(knex) { * @param { import("knex").Knex } knex * @returns { Promise } */ -exports.down = function(knex) { +exports.down = function (knex) { return knex.schema.alterTable('vendor_credits', (table) => { table.dropColumn('discount'); table.dropColumn('discount_type'); diff --git a/packages/server/src/database/tenant/migrations/20250326120000_add_contact_code_to_contacts.ts b/packages/server/src/database/tenant/migrations/20250326120000_add_contact_code_to_contacts.ts index 28caa2762..977cb387e 100644 --- a/packages/server/src/database/tenant/migrations/20250326120000_add_contact_code_to_contacts.ts +++ b/packages/server/src/database/tenant/migrations/20250326120000_add_contact_code_to_contacts.ts @@ -1,12 +1,11 @@ - -exports.up = function(knex) { - return knex.schema.alterTable('contacts', table => { +exports.up = function (knex) { + return knex.schema.alterTable('contacts', (table) => { table.string('code').nullable().unique(); }); }; -exports.down = function(knex) { - return knex.schema.alterTable('contacts', table => { +exports.down = function (knex) { + return knex.schema.alterTable('contacts', (table) => { table.dropColumn('code'); }); }; diff --git a/packages/server/src/database/tenant/seeds/core/20200810121909_seed_items_settings.ts b/packages/server/src/database/tenant/seeds/core/20200810121909_seed_items_settings.ts index b07e5c39e..faa12d8d4 100644 --- a/packages/server/src/database/tenant/seeds/core/20200810121909_seed_items_settings.ts +++ b/packages/server/src/database/tenant/seeds/core/20200810121909_seed_items_settings.ts @@ -2,9 +2,9 @@ import { TenantSeeder } from '@/libs/migration-seed/TenantSeeder'; export default class SeedSettings extends TenantSeeder { /** - * - * @param knex - * @returns + * + * @param knex + * @returns */ async up(knex) { const costAccount = await knex('accounts') diff --git a/packages/server/src/database/tenant/seeds/core/index.ts b/packages/server/src/database/tenant/seeds/core/index.ts index 0b95c889d..30f81639f 100644 --- a/packages/server/src/database/tenant/seeds/core/index.ts +++ b/packages/server/src/database/tenant/seeds/core/index.ts @@ -1 +1 @@ -// .gitkeep \ No newline at end of file +// .gitkeep diff --git a/packages/server/src/libs/accounts-utils/AccountTypesUtils.ts b/packages/server/src/libs/accounts-utils/AccountTypesUtils.ts index 57d3e3484..396851aaf 100644 --- a/packages/server/src/libs/accounts-utils/AccountTypesUtils.ts +++ b/packages/server/src/libs/accounts-utils/AccountTypesUtils.ts @@ -20,8 +20,8 @@ export class AccountTypesUtils { /** * Retrieve account type by the given account type key. - * @param {string} key - * @param {string} accessor + * @param {string} key + * @param {string} accessor */ static getType(key: string, accessor?: string) { const type = ACCOUNT_TYPES.find((type) => type.key === key); @@ -34,7 +34,7 @@ export class AccountTypesUtils { /** * Retrieve accounts types by the parent account type. - * @param {string} parentType + * @param {string} parentType */ static getTypesByParentType(parentType: string) { return ACCOUNT_TYPES.filter((type) => type.parentType === parentType); @@ -42,16 +42,16 @@ export class AccountTypesUtils { /** * Retrieve accounts types by the given account normal. - * @param {string} normal + * @param {string} normal */ static getTypesByNormal(normal: string) { return ACCOUNT_TYPES.filter((type) => type.normal === normal); } /** - * Detarmines whether the root type equals the account type. - * @param {string} key - * @param {string} rootType + * Detarmines whether the root type equals the account type. + * @param {string} key + * @param {string} rootType */ static isRootTypeEqualsKey(key: string, rootType: string): boolean { return ACCOUNT_TYPES.some((type) => { @@ -79,7 +79,7 @@ export class AccountTypesUtils { /** * Detarmines whether account type has balance sheet. * @param {string} key - Account type key. - * + * */ static isTypeBalanceSheet(key: string): boolean { return ACCOUNT_TYPES.some((type) => { @@ -98,4 +98,4 @@ export class AccountTypesUtils { return isType && type.incomeSheet; }); } -} \ No newline at end of file +} diff --git a/packages/server/src/libs/chromiumly/ConvertUtils.ts b/packages/server/src/libs/chromiumly/ConvertUtils.ts index d3b405fb0..3a2778ca6 100644 --- a/packages/server/src/libs/chromiumly/ConvertUtils.ts +++ b/packages/server/src/libs/chromiumly/ConvertUtils.ts @@ -5,12 +5,12 @@ import { PageProperties } from './_types'; export class ConverterUtils { public static injectPageProperties( data: FormData, - pageProperties: PageProperties + pageProperties: PageProperties, ): void { if (pageProperties.size) { GotenbergUtils.assert( pageProperties.size.width >= 1.0 && pageProperties.size.height >= 1.5, - 'size is smaller than the minimum printing requirements (i.e. 1.0 x 1.5 in)' + 'size is smaller than the minimum printing requirements (i.e. 1.0 x 1.5 in)', ); data.append('paperWidth', pageProperties.size.width); @@ -22,7 +22,7 @@ export class ConverterUtils { pageProperties.margins.bottom >= 0 && pageProperties.margins.left >= 0 && pageProperties.margins.left >= 0, - 'negative margins are not allowed' + 'negative margins are not allowed', ); data.append('marginTop', pageProperties.margins.top); data.append('marginBottom', pageProperties.margins.bottom); @@ -32,7 +32,7 @@ export class ConverterUtils { if (pageProperties.preferCssPageSize) { data.append( 'preferCssPageSize', - String(pageProperties.preferCssPageSize) + String(pageProperties.preferCssPageSize), ); } if (pageProperties.printBackground) { @@ -44,7 +44,7 @@ export class ConverterUtils { if (pageProperties.scale) { GotenbergUtils.assert( pageProperties.scale >= 0.1 && pageProperties.scale <= 2.0, - 'scale is outside of [0.1 - 2] range' + 'scale is outside of [0.1 - 2] range', ); data.append('scale', pageProperties.scale); } @@ -55,11 +55,11 @@ export class ConverterUtils { pageProperties.nativePageRanges.to > 0 && pageProperties.nativePageRanges.to >= pageProperties.nativePageRanges.from, - 'page ranges syntax error' + 'page ranges syntax error', ); data.append( 'nativePageRanges', - `${pageProperties.nativePageRanges.from}-${pageProperties.nativePageRanges.to}` + `${pageProperties.nativePageRanges.from}-${pageProperties.nativePageRanges.to}`, ); } } diff --git a/packages/server/src/libs/chromiumly/UrlConvert.ts b/packages/server/src/libs/chromiumly/UrlConvert.ts index 50c5b1c2f..e24f67ae0 100644 --- a/packages/server/src/libs/chromiumly/UrlConvert.ts +++ b/packages/server/src/libs/chromiumly/UrlConvert.ts @@ -1,4 +1,4 @@ -import * as FormData from 'form-data'; +import * as FormData from 'form-data'; import { IConverter, PageProperties, PdfFormat, ChromiumRoute } from './_types'; import { ConverterUtils } from './ConvertUtils'; import { Converter } from './Converter'; diff --git a/packages/server/src/libs/dependency-graph/index.ts b/packages/server/src/libs/dependency-graph/index.ts index 4cd8780fb..b3a956913 100644 --- a/packages/server/src/libs/dependency-graph/index.ts +++ b/packages/server/src/libs/dependency-graph/index.ts @@ -14,337 +14,337 @@ * @param circular A boolean to allow circular dependencies */ function createDFS(edges, leavesOnly, result, circular) { - var visited = {}; - return function (start) { - if (visited[start]) { - return; - } - var inCurrentPath = {}; - var currentPath = []; - var todo = []; // used as a stack - todo.push({ node: start, processed: false }); - while (todo.length > 0) { - var current = todo[todo.length - 1]; // peek at the todo stack - var processed = current.processed; - var node = current.node; - if (!processed) { - // Haven't visited edges yet (visiting phase) - if (visited[node]) { - todo.pop(); - continue; - } else if (inCurrentPath[node]) { - // It's not a DAG - if (circular) { - todo.pop(); - // If we're tolerating cycles, don't revisit the node - continue; - } - currentPath.push(node); - throw new DepGraphCycleError(currentPath); - } - - inCurrentPath[node] = true; - currentPath.push(node); - var nodeEdges = edges[node]; - // (push edges onto the todo stack in reverse order to be order-compatible with the old DFS implementation) - for (var i = nodeEdges.length - 1; i >= 0; i--) { - todo.push({ node: nodeEdges[i], processed: false }); - } - current.processed = true; - } else { - // Have visited edges (stack unrolling phase) + var visited = {}; + return function (start) { + if (visited[start]) { + return; + } + var inCurrentPath = {}; + var currentPath = []; + var todo = []; // used as a stack + todo.push({ node: start, processed: false }); + while (todo.length > 0) { + var current = todo[todo.length - 1]; // peek at the todo stack + var processed = current.processed; + var node = current.node; + if (!processed) { + // Haven't visited edges yet (visiting phase) + if (visited[node]) { todo.pop(); - currentPath.pop(); - inCurrentPath[node] = false; - visited[node] = true; - if (!leavesOnly || edges[node].length === 0) { - result.push(node); + continue; + } else if (inCurrentPath[node]) { + // It's not a DAG + if (circular) { + todo.pop(); + // If we're tolerating cycles, don't revisit the node + continue; } + currentPath.push(node); + throw new DepGraphCycleError(currentPath); } - } - }; - } - - /** - * Simple Dependency Graph - */ - var DepGraph = (DepGraph = function DepGraph(opts) { - this.nodes = {}; // Node -> Node/Data (treated like a Set) - this.outgoingEdges = {}; // Node -> [Dependency Node] - this.incomingEdges = {}; // Node -> [Dependant Node] - this.circular = opts && !!opts.circular; // Allows circular deps - }); - - DepGraph.fromArray = ( - items, - options = { itemId: 'id', parentItemId: 'parent_id' } - ) => { - const depGraph = new DepGraph(); - - items.forEach((item) => { - depGraph.addNode(item[options.itemId], item); - }); - items.forEach((item) => { - if (item[options.parentItemId]) { - depGraph.addDependency(item[options.parentItemId], item[options.itemId]); - } - }); - return depGraph; - }; - - DepGraph.prototype = { - /** - * The number of nodes in the graph. - */ - size: function () { - return Object.keys(this.nodes).length; - }, - /** - * Add a node to the dependency graph. If a node already exists, this method will do nothing. - */ - addNode: function (node, data) { - if (!this.hasNode(node)) { - // Checking the arguments length allows the user to add a node with undefined data - if (arguments.length === 2) { - this.nodes[node] = data; - } else { - this.nodes[node] = node; + + inCurrentPath[node] = true; + currentPath.push(node); + var nodeEdges = edges[node]; + // (push edges onto the todo stack in reverse order to be order-compatible with the old DFS implementation) + for (var i = nodeEdges.length - 1; i >= 0; i--) { + todo.push({ node: nodeEdges[i], processed: false }); } - this.outgoingEdges[node] = []; - this.incomingEdges[node] = []; - } - }, - /** - * Remove a node from the dependency graph. If a node does not exist, this method will do nothing. - */ - removeNode: function (node) { - if (this.hasNode(node)) { - delete this.nodes[node]; - delete this.outgoingEdges[node]; - delete this.incomingEdges[node]; - [this.incomingEdges, this.outgoingEdges].forEach(function (edgeList) { - Object.keys(edgeList).forEach(function (key) { - var idx = edgeList[key].indexOf(node); - if (idx >= 0) { - edgeList[key].splice(idx, 1); - } - }, this); - }); - } - }, - /** - * Check if a node exists in the graph - */ - hasNode: function (node) { - return this.nodes.hasOwnProperty(node); - }, - /** - * Get the data associated with a node name - */ - getNodeData: function (node) { - if (this.hasNode(node)) { - return this.nodes[node]; + current.processed = true; } else { - throw new Error('Node does not exist: ' + node); + // Have visited edges (stack unrolling phase) + todo.pop(); + currentPath.pop(); + inCurrentPath[node] = false; + visited[node] = true; + if (!leavesOnly || edges[node].length === 0) { + result.push(node); + } } - }, - - /** - * Set the associated data for a given node name. If the node does not exist, this method will throw an error - */ - setNodeData: function (node, data) { - if (this.hasNode(node)) { + } + }; +} + +/** + * Simple Dependency Graph + */ +var DepGraph = (DepGraph = function DepGraph(opts) { + this.nodes = {}; // Node -> Node/Data (treated like a Set) + this.outgoingEdges = {}; // Node -> [Dependency Node] + this.incomingEdges = {}; // Node -> [Dependant Node] + this.circular = opts && !!opts.circular; // Allows circular deps +}); + +DepGraph.fromArray = ( + items, + options = { itemId: 'id', parentItemId: 'parent_id' }, +) => { + const depGraph = new DepGraph(); + + items.forEach((item) => { + depGraph.addNode(item[options.itemId], item); + }); + items.forEach((item) => { + if (item[options.parentItemId]) { + depGraph.addDependency(item[options.parentItemId], item[options.itemId]); + } + }); + return depGraph; +}; + +DepGraph.prototype = { + /** + * The number of nodes in the graph. + */ + size: function () { + return Object.keys(this.nodes).length; + }, + /** + * Add a node to the dependency graph. If a node already exists, this method will do nothing. + */ + addNode: function (node, data) { + if (!this.hasNode(node)) { + // Checking the arguments length allows the user to add a node with undefined data + if (arguments.length === 2) { this.nodes[node] = data; } else { - throw new Error('Node does not exist: ' + node); + this.nodes[node] = node; } - }, - /** - * Add a dependency between two nodes. If either of the nodes does not exist, - * an Error will be thrown. - */ - addDependency: function (from, to) { - if (!this.hasNode(from)) { - throw new Error('Node does not exist: ' + from); - } - if (!this.hasNode(to)) { - throw new Error('Node does not exist: ' + to); - } - if (this.outgoingEdges[from].indexOf(to) === -1) { - this.outgoingEdges[from].push(to); - } - if (this.incomingEdges[to].indexOf(from) === -1) { - this.incomingEdges[to].push(from); - } - return true; - }, - /** - * Remove a dependency between two nodes. - */ - removeDependency: function (from, to) { - var idx; - if (this.hasNode(from)) { - idx = this.outgoingEdges[from].indexOf(to); - if (idx >= 0) { - this.outgoingEdges[from].splice(idx, 1); - } - } - - if (this.hasNode(to)) { - idx = this.incomingEdges[to].indexOf(from); - if (idx >= 0) { - this.incomingEdges[to].splice(idx, 1); - } - } - }, - /** - * Return a clone of the dependency graph. If any custom data is attached - * to the nodes, it will only be shallow copied. - */ - clone: function () { - var source = this; - var result = new DepGraph(); - var keys = Object.keys(source.nodes); - keys.forEach(function (n) { - result.nodes[n] = source.nodes[n]; - result.outgoingEdges[n] = source.outgoingEdges[n].slice(0); - result.incomingEdges[n] = source.incomingEdges[n].slice(0); + this.outgoingEdges[node] = []; + this.incomingEdges[node] = []; + } + }, + /** + * Remove a node from the dependency graph. If a node does not exist, this method will do nothing. + */ + removeNode: function (node) { + if (this.hasNode(node)) { + delete this.nodes[node]; + delete this.outgoingEdges[node]; + delete this.incomingEdges[node]; + [this.incomingEdges, this.outgoingEdges].forEach(function (edgeList) { + Object.keys(edgeList).forEach(function (key) { + var idx = edgeList[key].indexOf(node); + if (idx >= 0) { + edgeList[key].splice(idx, 1); + } + }, this); }); - return result; - }, - /** - * Get an array containing the nodes that the specified node depends on (transitively). - * - * Throws an Error if the graph has a cycle, or the specified node does not exist. - * - * If `leavesOnly` is true, only nodes that do not depend on any other nodes will be returned - * in the array. - */ - dependenciesOf: function (node, leavesOnly) { - if (this.hasNode(node)) { - var result = []; - var DFS = createDFS( - this.outgoingEdges, - leavesOnly, - result, - this.circular - ); - DFS(node); - var idx = result.indexOf(node); - if (idx >= 0) { - result.splice(idx, 1); - } - return result; - } else { - throw new Error('Node does not exist: ' + node); + } + }, + /** + * Check if a node exists in the graph + */ + hasNode: function (node) { + return this.nodes.hasOwnProperty(node); + }, + /** + * Get the data associated with a node name + */ + getNodeData: function (node) { + if (this.hasNode(node)) { + return this.nodes[node]; + } else { + throw new Error('Node does not exist: ' + node); + } + }, + + /** + * Set the associated data for a given node name. If the node does not exist, this method will throw an error + */ + setNodeData: function (node, data) { + if (this.hasNode(node)) { + this.nodes[node] = data; + } else { + throw new Error('Node does not exist: ' + node); + } + }, + /** + * Add a dependency between two nodes. If either of the nodes does not exist, + * an Error will be thrown. + */ + addDependency: function (from, to) { + if (!this.hasNode(from)) { + throw new Error('Node does not exist: ' + from); + } + if (!this.hasNode(to)) { + throw new Error('Node does not exist: ' + to); + } + if (this.outgoingEdges[from].indexOf(to) === -1) { + this.outgoingEdges[from].push(to); + } + if (this.incomingEdges[to].indexOf(from) === -1) { + this.incomingEdges[to].push(from); + } + return true; + }, + /** + * Remove a dependency between two nodes. + */ + removeDependency: function (from, to) { + var idx; + if (this.hasNode(from)) { + idx = this.outgoingEdges[from].indexOf(to); + if (idx >= 0) { + this.outgoingEdges[from].splice(idx, 1); } - }, - /** - * get an array containing the nodes that depend on the specified node (transitively). - * - * Throws an Error if the graph has a cycle, or the specified node does not exist. - * - * If `leavesOnly` is true, only nodes that do not have any dependants will be returned in the array. - */ - dependantsOf: function (node, leavesOnly) { - if (this.hasNode(node)) { - var result = []; - var DFS = createDFS( - this.incomingEdges, - leavesOnly, - result, - this.circular - ); - DFS(node); - var idx = result.indexOf(node); - if (idx >= 0) { - result.splice(idx, 1); - } - return result; - } else { - throw new Error('Node does not exist: ' + node); + } + + if (this.hasNode(to)) { + idx = this.incomingEdges[to].indexOf(from); + if (idx >= 0) { + this.incomingEdges[to].splice(idx, 1); } - }, - /** - * Construct the overall processing order for the dependency graph. - * - * Throws an Error if the graph has a cycle. - * - * If `leavesOnly` is true, only nodes that do not depend on any other nodes will be returned. - */ - overallOrder: function (leavesOnly) { - var self = this; + } + }, + /** + * Return a clone of the dependency graph. If any custom data is attached + * to the nodes, it will only be shallow copied. + */ + clone: function () { + var source = this; + var result = new DepGraph(); + var keys = Object.keys(source.nodes); + keys.forEach(function (n) { + result.nodes[n] = source.nodes[n]; + result.outgoingEdges[n] = source.outgoingEdges[n].slice(0); + result.incomingEdges[n] = source.incomingEdges[n].slice(0); + }); + return result; + }, + /** + * Get an array containing the nodes that the specified node depends on (transitively). + * + * Throws an Error if the graph has a cycle, or the specified node does not exist. + * + * If `leavesOnly` is true, only nodes that do not depend on any other nodes will be returned + * in the array. + */ + dependenciesOf: function (node, leavesOnly) { + if (this.hasNode(node)) { var result = []; - var keys = Object.keys(this.nodes); - if (keys.length === 0) { - return result; // Empty graph - } else { - if (!this.circular) { - // Look for cycles - we run the DFS starting at all the nodes in case there - // are several disconnected subgraphs inside this dependency graph. - var CycleDFS = createDFS(this.outgoingEdges, false, [], this.circular); - keys.forEach(function (n) { - CycleDFS(n); - }); - } - - var DFS = createDFS( - this.outgoingEdges, - leavesOnly, - result, - this.circular - ); - // Find all potential starting points (nodes with nothing depending on them) an - // run a DFS starting at these points to get the order + var DFS = createDFS( + this.outgoingEdges, + leavesOnly, + result, + this.circular, + ); + DFS(node); + var idx = result.indexOf(node); + if (idx >= 0) { + result.splice(idx, 1); + } + return result; + } else { + throw new Error('Node does not exist: ' + node); + } + }, + /** + * get an array containing the nodes that depend on the specified node (transitively). + * + * Throws an Error if the graph has a cycle, or the specified node does not exist. + * + * If `leavesOnly` is true, only nodes that do not have any dependants will be returned in the array. + */ + dependantsOf: function (node, leavesOnly) { + if (this.hasNode(node)) { + var result = []; + var DFS = createDFS( + this.incomingEdges, + leavesOnly, + result, + this.circular, + ); + DFS(node); + var idx = result.indexOf(node); + if (idx >= 0) { + result.splice(idx, 1); + } + return result; + } else { + throw new Error('Node does not exist: ' + node); + } + }, + /** + * Construct the overall processing order for the dependency graph. + * + * Throws an Error if the graph has a cycle. + * + * If `leavesOnly` is true, only nodes that do not depend on any other nodes will be returned. + */ + overallOrder: function (leavesOnly) { + var self = this; + var result = []; + var keys = Object.keys(this.nodes); + if (keys.length === 0) { + return result; // Empty graph + } else { + if (!this.circular) { + // Look for cycles - we run the DFS starting at all the nodes in case there + // are several disconnected subgraphs inside this dependency graph. + var CycleDFS = createDFS(this.outgoingEdges, false, [], this.circular); + keys.forEach(function (n) { + CycleDFS(n); + }); + } + + var DFS = createDFS( + this.outgoingEdges, + leavesOnly, + result, + this.circular, + ); + // Find all potential starting points (nodes with nothing depending on them) an + // run a DFS starting at these points to get the order + keys + .filter(function (node) { + return self.incomingEdges[node].length === 0; + }) + .forEach(function (n) { + DFS(n); + }); + + // If we're allowing cycles - we need to run the DFS against any remaining + // nodes that did not end up in the initial result (as they are part of a + // subgraph that does not have a clear starting point) + if (this.circular) { keys .filter(function (node) { - return self.incomingEdges[node].length === 0; + return result.indexOf(node) === -1; }) .forEach(function (n) { DFS(n); }); - - // If we're allowing cycles - we need to run the DFS against any remaining - // nodes that did not end up in the initial result (as they are part of a - // subgraph that does not have a clear starting point) - if (this.circular) { - keys - .filter(function (node) { - return result.indexOf(node) === -1; - }) - .forEach(function (n) { - DFS(n); - }); - } - - return result; } - }, - - mapNodes(mapper) {}, - }; - - /** - * Cycle error, including the path of the cycle. - */ - var DepGraphCycleError = (exports.DepGraphCycleError = function (cyclePath) { - var message = 'Dependency Cycle Found: ' + cyclePath.join(' -> '); - var instance = new Error(message); - instance.cyclePath = cyclePath; - Object.setPrototypeOf(instance, Object.getPrototypeOf(this)); - if (Error.captureStackTrace) { - Error.captureStackTrace(instance, DepGraphCycleError); + + return result; } - return instance; - }); - DepGraphCycleError.prototype = Object.create(Error.prototype, { - constructor: { - value: Error, - enumerable: false, - writable: true, - configurable: true, - }, - }); - Object.setPrototypeOf(DepGraphCycleError, Error); - - export default DepGraph; \ No newline at end of file + }, + + mapNodes(mapper) {}, +}; + +/** + * Cycle error, including the path of the cycle. + */ +var DepGraphCycleError = (exports.DepGraphCycleError = function (cyclePath) { + var message = 'Dependency Cycle Found: ' + cyclePath.join(' -> '); + var instance = new Error(message); + instance.cyclePath = cyclePath; + Object.setPrototypeOf(instance, Object.getPrototypeOf(this)); + if (Error.captureStackTrace) { + Error.captureStackTrace(instance, DepGraphCycleError); + } + return instance; +}); +DepGraphCycleError.prototype = Object.create(Error.prototype, { + constructor: { + value: Error, + enumerable: false, + writable: true, + configurable: true, + }, +}); +Object.setPrototypeOf(DepGraphCycleError, Error); + +export default DepGraph; diff --git a/packages/server/src/libs/logic-evaluation/Lexer.ts b/packages/server/src/libs/logic-evaluation/Lexer.ts index 67ed7c871..0ff0caad5 100644 --- a/packages/server/src/libs/logic-evaluation/Lexer.ts +++ b/packages/server/src/libs/logic-evaluation/Lexer.ts @@ -1,4 +1,3 @@ - const OperationType = { LOGIC: 'LOGIC', STRING: 'STRING', @@ -20,7 +19,7 @@ export class Lexer { '?': OperationType.LOGIC, ':': OperationType.LOGIC, - '\'': OperationType.STRING, + "'": OperationType.STRING, '"': OperationType.STRING, '!': OperationType.COMPARISON, @@ -79,11 +78,13 @@ export class Lexer { // we must move the pos forward // so here we should throw error, for example `1 & 2` if (pos === this.currentIndex && tok !== undefined) { - const err = new Error(`unkonw token ${tok} from input string ${this.input}`); + const err = new Error( + `unkonw token ${tok} from input string ${this.input}`, + ); err.name = 'UnknowToken'; throw err; } - } while (tok !== undefined) + } while (tok !== undefined); return this.tokenList; } @@ -103,7 +104,9 @@ export class Lexer { * @param index */ receiveToken(index = 1) { - const tok = this.input.slice(this.currentIndex, this.currentIndex + index).trim(); + const tok = this.input + .slice(this.currentIndex, this.currentIndex + index) + .trim(); // skip empty string if (tok) { this.tokenList.push(tok); diff --git a/packages/server/src/libs/logic-evaluation/Parser.ts b/packages/server/src/libs/logic-evaluation/Parser.ts index e2aa94a60..0eaceb01d 100644 --- a/packages/server/src/libs/logic-evaluation/Parser.ts +++ b/packages/server/src/libs/logic-evaluation/Parser.ts @@ -38,8 +38,8 @@ export class Parser { } /** - * - * @return {Node | string} =- + * + * @return {Node | string} =- */ parse() { let tok; @@ -67,7 +67,9 @@ export class Parser { root.right = this.parseStatement(); } else { if (typeof tok !== 'string') { - throw new Error('operation must be string, but get ' + JSON.stringify(tok)); + throw new Error( + 'operation must be string, but get ' + JSON.stringify(tok), + ); } root = this.addNode(tok, this.parseStatement(), root); } @@ -86,19 +88,21 @@ export class Parser { } /** - * - * @param {string} operation - * @param {Node|String|null} right - * @param {Node} root + * + * @param {string} operation + * @param {Node|String|null} right + * @param {Node} root */ addNode(operation, right, root) { let pre = root; - + if (this.compare(pre.operation, operation) < 0 && !pre.grouped) { - - while (pre.right !== null && + while ( + pre.right !== null && typeof pre.right !== 'string' && - this.compare(pre.right.operation, operation) < 0 && !pre.right.grouped) { + this.compare(pre.right.operation, operation) < 0 && + !pre.right.grouped + ) { pre = pre.right; } @@ -113,13 +117,13 @@ export class Parser { left: pre, right, operation, - } + }; } /** - * - * @param {String} a - * @param {String} b + * + * @param {String} a + * @param {String} b */ compare(a, b) { if (!OPERATION.hasOwnProperty(a) || !OPERATION.hasOwnProperty(b)) { @@ -149,12 +153,20 @@ export class Parser { } if (token === '!') { - return { left: null, operation: token, right: this.parseStatement() } + return { left: null, operation: token, right: this.parseStatement() }; } // 3 > -12 or -12 + 10 - if (token === '-' && (OPERATION[this.prevToken()] > 0 || this.prevToken() === undefined)) { - return { left: '0', operation: token, right: this.parseStatement(), grouped: true }; + if ( + token === '-' && + (OPERATION[this.prevToken()] > 0 || this.prevToken() === undefined) + ) { + return { + left: '0', + operation: token, + right: this.parseStatement(), + grouped: true, + }; } return token; diff --git a/packages/server/src/libs/logic-evaluation/QueryParser.ts b/packages/server/src/libs/logic-evaluation/QueryParser.ts index 3f72dcb7c..86fa14a3a 100644 --- a/packages/server/src/libs/logic-evaluation/QueryParser.ts +++ b/packages/server/src/libs/logic-evaluation/QueryParser.ts @@ -22,7 +22,9 @@ export class QueryParser { parseNode(node) { if (typeof node === 'string') { const nodeQuery = this.getQuery(node); - return (query) => { nodeQuery(query); }; + return (query) => { + nodeQuery(query); + }; } if (OPERATION[node.operation] === undefined) { throw new Error(`unknow expression ${node.operation}`); @@ -34,16 +36,26 @@ export class QueryParser { case '&&': case 'AND': default: - return (nodeQuery) => nodeQuery.where((query) => { - query.where((q) => { leftQuery(q); }); - query.andWhere((q) => { rightQuery(q); }); - }); + return (nodeQuery) => + nodeQuery.where((query) => { + query.where((q) => { + leftQuery(q); + }); + query.andWhere((q) => { + rightQuery(q); + }); + }); case '||': case 'OR': - return (nodeQuery) => nodeQuery.where((query) => { - query.where((q) => { leftQuery(q); }); - query.orWhere((q) => { rightQuery(q); }); - }); + return (nodeQuery) => + nodeQuery.where((query) => { + query.where((q) => { + leftQuery(q); + }); + query.orWhere((q) => { + rightQuery(q); + }); + }); } } @@ -61,4 +73,4 @@ export class QueryParser { } return null; } -} \ No newline at end of file +} diff --git a/packages/server/src/libs/migration-seed/Seeder.ts b/packages/server/src/libs/migration-seed/Seeder.ts index 8ad674048..15564a8c7 100644 --- a/packages/server/src/libs/migration-seed/Seeder.ts +++ b/packages/server/src/libs/migration-seed/Seeder.ts @@ -1,4 +1,3 @@ - export class Seeder { knex: any; @@ -8,4 +7,3 @@ export class Seeder { up(knex) {} down(knex) {} } - diff --git a/packages/server/src/libs/migration-seed/SeederConfig.ts b/packages/server/src/libs/migration-seed/SeederConfig.ts index 465e6522f..5421792ad 100644 --- a/packages/server/src/libs/migration-seed/SeederConfig.ts +++ b/packages/server/src/libs/migration-seed/SeederConfig.ts @@ -37,7 +37,7 @@ export default function getMergedConfig(config, currentConfig) { mergedConfig.migrationSource = new FsMigrations( mergedConfig.directory, mergedConfig.sortDirsSeparately, - mergedConfig.loadExtensions + mergedConfig.loadExtensions, ); } return mergedConfig; diff --git a/packages/server/src/libs/migration-seed/TableUtils.ts b/packages/server/src/libs/migration-seed/TableUtils.ts index 587112887..7110bdd66 100644 --- a/packages/server/src/libs/migration-seed/TableUtils.ts +++ b/packages/server/src/libs/migration-seed/TableUtils.ts @@ -35,7 +35,7 @@ export function getLockTableName(tableName: string): string { */ export function getLockTableNameWithSchema( tableName: string, - schemaName = null + schemaName = null, ): string { return schemaName ? `${schemaName} + ${getLockTableName(tableName)}` diff --git a/packages/server/src/models/Model.ts b/packages/server/src/models/Model.ts index 83ef76c63..a1fd482cd 100644 --- a/packages/server/src/models/Model.ts +++ b/packages/server/src/models/Model.ts @@ -50,13 +50,14 @@ export class PaginationQueryBuilder< return this.delete(); } - // Only check HasManyRelation and ManyToManyRelation relations, as BelongsToOneRelation are just + // Only check HasManyRelation and ManyToManyRelation relations, as BelongsToOneRelation are just // foreign key references and shouldn't prevent deletion. Only dependent records should block deletion. const dependentRelationNames = relationNames.filter((name) => { const relation = relationMappings[name]; - return relation && ( - relation.relation === Model.HasManyRelation || - relation.relation === Model.ManyToManyRelation + return ( + relation && + (relation.relation === Model.HasManyRelation || + relation.relation === Model.ManyToManyRelation) ); }); diff --git a/packages/server/src/models/withDateSessionMixin.ts b/packages/server/src/models/withDateSessionMixin.ts index 772ea7676..d40fd7bb9 100644 --- a/packages/server/src/models/withDateSessionMixin.ts +++ b/packages/server/src/models/withDateSessionMixin.ts @@ -3,7 +3,9 @@ import { Model } from 'objection'; type Constructor = new (...args: any[]) => T; -export const withDateSessionMixin = >(BaseModel: T) => { +export const withDateSessionMixin = >( + BaseModel: T, +) => { return class DateSession extends BaseModel { constructor(...args: any[]) { super(...args); @@ -12,7 +14,7 @@ export const withDateSessionMixin = >(BaseModel: T) get timestamps() { return []; } - + $beforeUpdate(opt, context) { const maybePromise = super.$beforeUpdate(opt, context); @@ -36,5 +38,5 @@ export const withDateSessionMixin = >(BaseModel: T) } }); } - } -} \ No newline at end of file + }; +}; diff --git a/packages/server/src/modules/Accounts/Accounts.controller.ts b/packages/server/src/modules/Accounts/Accounts.controller.ts index 0a58bce0f..61615ad28 100644 --- a/packages/server/src/modules/Accounts/Accounts.controller.ts +++ b/packages/server/src/modules/Accounts/Accounts.controller.ts @@ -48,7 +48,7 @@ import { AccountAction } from './Accounts.types'; @ApiCommonHeaders() @UseGuards(AuthorizationGuard, PermissionGuard) export class AccountsController { - constructor(private readonly accountsApplication: AccountsApplication) { } + constructor(private readonly accountsApplication: AccountsApplication) {} @Post('validate-bulk-delete') @HttpCode(200) diff --git a/packages/server/src/modules/Accounts/AccountsApplication.service.ts b/packages/server/src/modules/Accounts/AccountsApplication.service.ts index 7eab22bfc..29b6b5f6d 100644 --- a/packages/server/src/modules/Accounts/AccountsApplication.service.ts +++ b/packages/server/src/modules/Accounts/AccountsApplication.service.ts @@ -42,7 +42,7 @@ export class AccountsApplication { private readonly getAccountsService: GetAccountsService, private readonly bulkDeleteAccountsService: BulkDeleteAccountsService, private readonly validateBulkDeleteAccountsService: ValidateBulkDeleteAccountsService, - ) { } + ) {} /** * Creates a new account. diff --git a/packages/server/src/modules/Accounts/AccountsExportable.service.ts b/packages/server/src/modules/Accounts/AccountsExportable.service.ts index 2931916c6..c93d07d46 100644 --- a/packages/server/src/modules/Accounts/AccountsExportable.service.ts +++ b/packages/server/src/modules/Accounts/AccountsExportable.service.ts @@ -11,7 +11,7 @@ import { Account } from './models/Account.model'; @Global() export class AccountsExportable extends Exportable { /** - * @param {AccountsApplication} accountsApplication + * @param {AccountsApplication} accountsApplication */ constructor(private readonly accountsApplication: AccountsApplication) { super(); diff --git a/packages/server/src/modules/Accounts/AccountsImportable.service.ts b/packages/server/src/modules/Accounts/AccountsImportable.service.ts index dfd0548f6..810a0aef8 100644 --- a/packages/server/src/modules/Accounts/AccountsImportable.service.ts +++ b/packages/server/src/modules/Accounts/AccountsImportable.service.ts @@ -23,10 +23,7 @@ export class AccountsImportable extends Importable { createAccountDTO: CreateAccountDTO, trx?: Knex.Transaction, ) { - return this.createAccountService.createAccount( - createAccountDTO, - trx, - ); + return this.createAccountService.createAccount(createAccountDTO, trx); } /** diff --git a/packages/server/src/modules/Accounts/BulkDeleteAccounts.service.ts b/packages/server/src/modules/Accounts/BulkDeleteAccounts.service.ts index 7f40c16f4..c7df5ede9 100644 --- a/packages/server/src/modules/Accounts/BulkDeleteAccounts.service.ts +++ b/packages/server/src/modules/Accounts/BulkDeleteAccounts.service.ts @@ -6,7 +6,7 @@ import { DeleteAccount } from './DeleteAccount.service'; @Injectable() export class BulkDeleteAccountsService { - constructor(private readonly deleteAccountService: DeleteAccount) { } + constructor(private readonly deleteAccountService: DeleteAccount) {} /** * Deletes multiple accounts. @@ -38,4 +38,3 @@ export class BulkDeleteAccountsService { } } } - diff --git a/packages/server/src/modules/Accounts/CommandAccountValidators.service.ts b/packages/server/src/modules/Accounts/CommandAccountValidators.service.ts index f1499ac45..8a479c809 100644 --- a/packages/server/src/modules/Accounts/CommandAccountValidators.service.ts +++ b/packages/server/src/modules/Accounts/CommandAccountValidators.service.ts @@ -17,7 +17,7 @@ export class CommandAccountValidators { @Inject(Account.name) private readonly accountModel: TenantModelProxy, private readonly accountRepository: AccountRepository, - ) { } + ) {} /** * Throws error if the account was prefined. diff --git a/packages/server/src/modules/Accounts/DeleteAccount.service.ts b/packages/server/src/modules/Accounts/DeleteAccount.service.ts index 8868ca689..1b134aa24 100644 --- a/packages/server/src/modules/Accounts/DeleteAccount.service.ts +++ b/packages/server/src/modules/Accounts/DeleteAccount.service.ts @@ -18,7 +18,7 @@ export class DeleteAccount { private eventEmitter: EventEmitter2, private uow: UnitOfWork, private validator: CommandAccountValidators, - ) { } + ) {} /** * Authorize account delete. diff --git a/packages/server/src/modules/Accounts/GetAccountTypes.service.ts b/packages/server/src/modules/Accounts/GetAccountTypes.service.ts index 441cb4114..776581690 100644 --- a/packages/server/src/modules/Accounts/GetAccountTypes.service.ts +++ b/packages/server/src/modules/Accounts/GetAccountTypes.service.ts @@ -6,7 +6,7 @@ import { AccountTypesUtils } from './utils/AccountType.utils'; export class GetAccountTypesService { /** * Retrieve all accounts types. - * @param {number} tenantId - + * @param {number} tenantId - * @return {IAccountType} */ public getAccountsTypes() { diff --git a/packages/server/src/modules/Accounts/GetAccounts.service.ts b/packages/server/src/modules/Accounts/GetAccounts.service.ts index 3c1cb9904..d5546d58a 100644 --- a/packages/server/src/modules/Accounts/GetAccounts.service.ts +++ b/packages/server/src/modules/Accounts/GetAccounts.service.ts @@ -19,7 +19,7 @@ export class GetAccountsService { @Inject(Account.name) private readonly accountModel: TenantModelProxy, - ) { } + ) {} /** * Retrieve accounts datatable list. diff --git a/packages/server/src/modules/Accounts/ValidateBulkDeleteAccounts.service.ts b/packages/server/src/modules/Accounts/ValidateBulkDeleteAccounts.service.ts index b65398875..a050ffc44 100644 --- a/packages/server/src/modules/Accounts/ValidateBulkDeleteAccounts.service.ts +++ b/packages/server/src/modules/Accounts/ValidateBulkDeleteAccounts.service.ts @@ -60,4 +60,3 @@ export class ValidateBulkDeleteAccountsService { } } } - diff --git a/packages/server/src/modules/Accounts/dtos/GetAccountsQuery.dto.ts b/packages/server/src/modules/Accounts/dtos/GetAccountsQuery.dto.ts index b07b7264f..07cf7e6ae 100644 --- a/packages/server/src/modules/Accounts/dtos/GetAccountsQuery.dto.ts +++ b/packages/server/src/modules/Accounts/dtos/GetAccountsQuery.dto.ts @@ -1,9 +1,20 @@ -import { IsArray, IsBoolean, IsEnum, IsInt, IsOptional, IsString, Min } from 'class-validator'; +import { + IsArray, + IsBoolean, + IsEnum, + IsInt, + IsOptional, + IsString, + Min, +} from 'class-validator'; import { ApiPropertyOptional } from '@nestjs/swagger'; import { Transform } from 'class-transformer'; import { parseBoolean } from '@/utils/parse-boolean'; import { IAccountsStructureType } from '../Accounts.types'; -import { IFilterRole, ISortOrder } from '@/modules/DynamicListing/DynamicFilter/DynamicFilter.types'; +import { + IFilterRole, + ISortOrder, +} from '@/modules/DynamicListing/DynamicFilter/DynamicFilter.types'; import { ToNumber } from '@/common/decorators/Validators'; export class GetAccountsQueryDto { @@ -114,4 +125,3 @@ export class GetAccountsQueryDto { @Min(1) pageSize?: number; } - diff --git a/packages/server/src/modules/Accounts/models/Account.meta.ts b/packages/server/src/modules/Accounts/models/Account.meta.ts index 5830414ee..3fe721222 100644 --- a/packages/server/src/modules/Accounts/models/Account.meta.ts +++ b/packages/server/src/modules/Accounts/models/Account.meta.ts @@ -1,4 +1,4 @@ -import { ACCOUNT_TYPES } from "../Accounts.constants"; +import { ACCOUNT_TYPES } from '../Accounts.constants'; export const AccountMeta = { defaultFilterField: 'name', @@ -196,4 +196,4 @@ function RootTypeFieldFilterQuery(query, role) { */ function NormalTypeFieldFilterQuery(query, role) { query.modify('filterByAccountNormal', role.value); -} \ No newline at end of file +} diff --git a/packages/server/src/modules/Accounts/susbcribers/MutateBaseCurrencyAccounts.subscriber.ts b/packages/server/src/modules/Accounts/susbcribers/MutateBaseCurrencyAccounts.subscriber.ts index f44efb079..aa9108a68 100644 --- a/packages/server/src/modules/Accounts/susbcribers/MutateBaseCurrencyAccounts.subscriber.ts +++ b/packages/server/src/modules/Accounts/susbcribers/MutateBaseCurrencyAccounts.subscriber.ts @@ -14,11 +14,9 @@ export class MutateBaseCurrencyAccountsSubscriber { * of the organization is mutated. */ @OnEvent(events.organization.baseCurrencyUpdated) - async updateAccountsCurrencyOnBaseCurrencyMutated({ - organizationDTO, - }) { + async updateAccountsCurrencyOnBaseCurrencyMutated({ organizationDTO }) { await this.mutateBaseCurrencyAccounts.mutateAllAccountsCurrency( - organizationDTO.baseCurrency + organizationDTO.baseCurrency, ); - }; + } } diff --git a/packages/server/src/modules/App/App.controller.spec.ts b/packages/server/src/modules/App/App.controller.spec.ts index 06b88372f..fbda2f7ad 100644 --- a/packages/server/src/modules/App/App.controller.spec.ts +++ b/packages/server/src/modules/App/App.controller.spec.ts @@ -15,7 +15,6 @@ describe('AppController', () => { }); describe('root', () => { - it('should return "Hello World!"', () => { - }); + it('should return "Hello World!"', () => {}); }); }); diff --git a/packages/server/src/modules/App/AppThrottle.module.ts b/packages/server/src/modules/App/AppThrottle.module.ts index 69b4cda62..eb071a391 100644 --- a/packages/server/src/modules/App/AppThrottle.module.ts +++ b/packages/server/src/modules/App/AppThrottle.module.ts @@ -10,7 +10,9 @@ import { ThrottlerStorageRedisService } from '@nest-lab/throttler-storage-redis' inject: [ConfigService], useFactory: (configService: ConfigService) => { // Use in-memory storage with very high limits for test environment - const isTest = process.env.NODE_ENV === 'test' || process.env.JEST_WORKER_ID !== undefined; + const isTest = + process.env.NODE_ENV === 'test' || + process.env.JEST_WORKER_ID !== undefined; if (isTest) { return { @@ -64,6 +66,4 @@ import { ThrottlerStorageRedisService } from '@nest-lab/throttler-storage-redis' }), ], }) -export class AppThrottleModule { } - - +export class AppThrottleModule {} diff --git a/packages/server/src/modules/Attachments/Attachment.module.ts b/packages/server/src/modules/Attachments/Attachment.module.ts index 08d3fad58..efd0556ea 100644 --- a/packages/server/src/modules/Attachments/Attachment.module.ts +++ b/packages/server/src/modules/Attachments/Attachment.module.ts @@ -1,32 +1,32 @@ -import { Module } from "@nestjs/common"; +import { Module } from '@nestjs/common'; import * as multerS3 from 'multer-s3'; -import { S3_CLIENT, S3Module } from "../S3/S3.module"; -import { DeleteAttachment } from "./DeleteAttachment"; -import { GetAttachment } from "./GetAttachment"; -import { GetAttachmentPresignedUrl } from "./GetAttachmentPresignedUrl"; -import { LinkAttachment } from "./LinkAttachment"; -import { UnlinkAttachment } from "./UnlinkAttachment"; -import { ValidateAttachments } from "./ValidateAttachments"; -import { AttachmentsOnBillPayments } from "./events/AttachmentsOnPaymentsMade"; -import { AttachmentsOnBills } from "./events/AttachmentsOnBills"; -import { AttachmentsOnCreditNote } from "./events/AttachmentsOnCreditNote"; -import { AttachmentsOnExpenses } from "./events/AttachmentsOnExpenses"; -import { AttachmentsOnPaymentsReceived } from "./events/AttachmentsOnPaymentsReceived"; -import { AttachmentsOnManualJournals } from "./events/AttachmentsOnManualJournals"; -import { AttachmentsOnVendorCredits } from "./events/AttachmentsOnVendorCredits"; -import { AttachmentsOnSaleInvoiceCreated } from "./events/AttachmentsOnSaleInvoice"; -import { AttachmentsOnSaleReceipt } from "./events/AttachmentsOnSaleReceipts"; -import { AttachmentsOnSaleEstimates } from "./events/AttachmentsOnSaleEstimates"; -import { AttachmentsController } from "./Attachments.controller"; -import { RegisterTenancyModel } from "../Tenancy/TenancyModels/Tenancy.module"; -import { DocumentModel } from "./models/Document.model"; -import { DocumentLinkModel } from "./models/DocumentLink.model"; -import { AttachmentsApplication } from "./AttachmentsApplication"; -import { UploadDocument } from "./UploadDocument"; -import { AttachmentUploadPipeline } from "./S3UploadPipeline"; -import { MULTER_MODULE_OPTIONS } from "@/common/constants/files.constants"; -import { ConfigService } from "@nestjs/config"; -import { S3Client } from "@aws-sdk/client-s3"; +import { S3_CLIENT, S3Module } from '../S3/S3.module'; +import { DeleteAttachment } from './DeleteAttachment'; +import { GetAttachment } from './GetAttachment'; +import { GetAttachmentPresignedUrl } from './GetAttachmentPresignedUrl'; +import { LinkAttachment } from './LinkAttachment'; +import { UnlinkAttachment } from './UnlinkAttachment'; +import { ValidateAttachments } from './ValidateAttachments'; +import { AttachmentsOnBillPayments } from './events/AttachmentsOnPaymentsMade'; +import { AttachmentsOnBills } from './events/AttachmentsOnBills'; +import { AttachmentsOnCreditNote } from './events/AttachmentsOnCreditNote'; +import { AttachmentsOnExpenses } from './events/AttachmentsOnExpenses'; +import { AttachmentsOnPaymentsReceived } from './events/AttachmentsOnPaymentsReceived'; +import { AttachmentsOnManualJournals } from './events/AttachmentsOnManualJournals'; +import { AttachmentsOnVendorCredits } from './events/AttachmentsOnVendorCredits'; +import { AttachmentsOnSaleInvoiceCreated } from './events/AttachmentsOnSaleInvoice'; +import { AttachmentsOnSaleReceipt } from './events/AttachmentsOnSaleReceipts'; +import { AttachmentsOnSaleEstimates } from './events/AttachmentsOnSaleEstimates'; +import { AttachmentsController } from './Attachments.controller'; +import { RegisterTenancyModel } from '../Tenancy/TenancyModels/Tenancy.module'; +import { DocumentModel } from './models/Document.model'; +import { DocumentLinkModel } from './models/DocumentLink.model'; +import { AttachmentsApplication } from './AttachmentsApplication'; +import { UploadDocument } from './UploadDocument'; +import { AttachmentUploadPipeline } from './S3UploadPipeline'; +import { MULTER_MODULE_OPTIONS } from '@/common/constants/files.constants'; +import { ConfigService } from '@nestjs/config'; +import { S3Client } from '@aws-sdk/client-s3'; const models = [ RegisterTenancyModel(DocumentModel), @@ -71,15 +71,15 @@ const models = [ key: function (req, file, cb) { cb(null, Date.now().toString()); }, - acl: function(req, file, cb) { + acl: function (req, file, cb) { // Conditionally set file to public or private based on isPublic flag const aclValue = true ? 'public-read' : 'private'; // Set ACL based on the isPublic flag - cb(null, aclValue); - } + cb(null, aclValue); + }, }), - }) - } - ] + }), + }, + ], }) -export class AttachmentsModule {} \ No newline at end of file +export class AttachmentsModule {} diff --git a/packages/server/src/modules/Attachments/Attachment.transformer.ts b/packages/server/src/modules/Attachments/Attachment.transformer.ts index 25601b888..12395eb68 100644 --- a/packages/server/src/modules/Attachments/Attachment.transformer.ts +++ b/packages/server/src/modules/Attachments/Attachment.transformer.ts @@ -1,4 +1,4 @@ -import { Transformer } from "../Transformer/Transformer"; +import { Transformer } from '../Transformer/Transformer'; export class AttachmentTransformer extends Transformer { /** diff --git a/packages/server/src/modules/Attachments/AttachmentTransformer.ts b/packages/server/src/modules/Attachments/AttachmentTransformer.ts index af9a7a8a6..12395eb68 100644 --- a/packages/server/src/modules/Attachments/AttachmentTransformer.ts +++ b/packages/server/src/modules/Attachments/AttachmentTransformer.ts @@ -1,6 +1,6 @@ -import { Transformer } from "../Transformer/Transformer"; +import { Transformer } from '../Transformer/Transformer'; -export class AttachmentTransformer extends Transformer{ +export class AttachmentTransformer extends Transformer { /** * Exclude attributes. * @returns {string[]} diff --git a/packages/server/src/modules/Attachments/GetAttachment.ts b/packages/server/src/modules/Attachments/GetAttachment.ts index 5c448200a..887cef918 100644 --- a/packages/server/src/modules/Attachments/GetAttachment.ts +++ b/packages/server/src/modules/Attachments/GetAttachment.ts @@ -11,7 +11,7 @@ export class GetAttachment { @Inject(S3_CLIENT) private readonly s3: S3Client, ) {} - + /** * Retrieves data of the given document key. * @param {string} filekey diff --git a/packages/server/src/modules/Attachments/GetAttachmentPresignedUrl.ts b/packages/server/src/modules/Attachments/GetAttachmentPresignedUrl.ts index 10536ca77..011707a2a 100644 --- a/packages/server/src/modules/Attachments/GetAttachmentPresignedUrl.ts +++ b/packages/server/src/modules/Attachments/GetAttachmentPresignedUrl.ts @@ -10,7 +10,7 @@ import { S3_CLIENT } from '../S3/S3.module'; export class GetAttachmentPresignedUrl { constructor( private readonly configService: ConfigService, - + @Inject(DocumentModel.name) private readonly documentModel: TenantModelProxy, @@ -20,7 +20,7 @@ export class GetAttachmentPresignedUrl { /** * Retrieves the presigned url of the given attachment key with the original filename. - * @param {string} key - + * @param {string} key - * @returns {string} */ async getPresignedUrl(key: string) { @@ -36,7 +36,9 @@ export class GetAttachmentPresignedUrl { Key: key, ResponseContentDisposition, }); - const signedUrl = await getSignedUrl(this.s3Client, command, { expiresIn: 300 }); + const signedUrl = await getSignedUrl(this.s3Client, command, { + expiresIn: 300, + }); return signedUrl; } diff --git a/packages/server/src/modules/Attachments/S3UploadPipeline.ts b/packages/server/src/modules/Attachments/S3UploadPipeline.ts index be93d598c..a6aa00255 100644 --- a/packages/server/src/modules/Attachments/S3UploadPipeline.ts +++ b/packages/server/src/modules/Attachments/S3UploadPipeline.ts @@ -4,9 +4,7 @@ import { Injectable } from '@nestjs/common'; @Injectable() export class AttachmentUploadPipeline { - constructor( - private readonly configService: ConfigService - ) {} + constructor(private readonly configService: ConfigService) {} /** * Middleware to ensure that S3 configuration is properly set before proceeding. @@ -18,11 +16,7 @@ export class AttachmentUploadPipeline { public validateS3Configured(req: Request, res: Response, next: NextFunction) { const config = this.configService.get('s3'); - if ( - !config.region || - !config.accessKeyId || - !config.secretAccessKey - ) { + if (!config.region || !config.accessKeyId || !config.secretAccessKey) { const missingKeys = []; if (!config.region) missingKeys.push('region'); if (!config.accessKeyId) missingKeys.push('accessKeyId'); diff --git a/packages/server/src/modules/Attachments/UnlinkAttachment.ts b/packages/server/src/modules/Attachments/UnlinkAttachment.ts index f3073ddab..1400d8295 100644 --- a/packages/server/src/modules/Attachments/UnlinkAttachment.ts +++ b/packages/server/src/modules/Attachments/UnlinkAttachment.ts @@ -47,10 +47,13 @@ export class UnlinkAttachment { const foundLinkModel = await LinkModel().query(trx).findById(modelId); validateLinkModelEntryExists(foundLinkModel); - const document = await this.documentModel().query(trx).findOne('key', filekey); + const document = await this.documentModel() + .query(trx) + .findOne('key', filekey); // Delete the document link. - await this.documentLinkModel().query(trx) + await this.documentLinkModel() + .query(trx) .where('modelRef', modelRef) .where('modelId', modelId) .where('documentId', document.id) diff --git a/packages/server/src/modules/Attachments/constants.ts b/packages/server/src/modules/Attachments/constants.ts index b046e9ca7..8d7cba4b1 100644 --- a/packages/server/src/modules/Attachments/constants.ts +++ b/packages/server/src/modules/Attachments/constants.ts @@ -1,5 +1,5 @@ export enum ERRORS { DOCUMENT_LINK_REF_INVALID = 'DOCUMENT_LINK_REF_INVALID', DOCUMENT_LINK_ID_INVALID = 'DOCUMENT_LINK_ID_INVALID', - DOCUMENT_LINK_ALREADY_LINKED = 'DOCUMENT_LINK_ALREADY_LINKED' + DOCUMENT_LINK_ALREADY_LINKED = 'DOCUMENT_LINK_ALREADY_LINKED', } diff --git a/packages/server/src/modules/Attachments/decorators/InjectAttachable.decorator.ts b/packages/server/src/modules/Attachments/decorators/InjectAttachable.decorator.ts index f62fde8d0..afb0ea03a 100644 --- a/packages/server/src/modules/Attachments/decorators/InjectAttachable.decorator.ts +++ b/packages/server/src/modules/Attachments/decorators/InjectAttachable.decorator.ts @@ -20,4 +20,3 @@ export function InjectAttachable() { export function getAttachableModelsMap() { return attachableModelsMap; } - diff --git a/packages/server/src/modules/Attachments/dtos/Attachment.dto.ts b/packages/server/src/modules/Attachments/dtos/Attachment.dto.ts index 6a70f3245..cf8a02f80 100644 --- a/packages/server/src/modules/Attachments/dtos/Attachment.dto.ts +++ b/packages/server/src/modules/Attachments/dtos/Attachment.dto.ts @@ -1,6 +1,5 @@ -import { ApiProperty } from "@nestjs/swagger"; -import { IsNotEmpty, IsString } from "class-validator"; - +import { ApiProperty } from '@nestjs/swagger'; +import { IsNotEmpty, IsString } from 'class-validator'; export class AttachmentLinkDto { @IsString() @@ -8,12 +7,10 @@ export class AttachmentLinkDto { key: string; } - export class UnlinkAttachmentDto { @IsNotEmpty() modelRef: string; - @IsNotEmpty() modelId: number; } @@ -22,12 +19,11 @@ export class LinkAttachmentDto { @IsNotEmpty() modelRef: string; - @IsNotEmpty() - modelId: number; + modelId: number; } export class UploadAttachmentDto { @ApiProperty({ type: 'string', format: 'binary' }) file: any; -} \ No newline at end of file +} diff --git a/packages/server/src/modules/Attachments/events/AttachmentsOnBills.ts b/packages/server/src/modules/Attachments/events/AttachmentsOnBills.ts index 9e9dc4b14..eee13b315 100644 --- a/packages/server/src/modules/Attachments/events/AttachmentsOnBills.ts +++ b/packages/server/src/modules/Attachments/events/AttachmentsOnBills.ts @@ -15,9 +15,9 @@ import { events } from '@/common/events/events'; @Injectable() export class AttachmentsOnBills { /** - * @param {LinkAttachment} linkAttachmentService - * @param {UnlinkAttachment} unlinkAttachmentService - * @param {ValidateAttachments} validateDocuments + * @param {LinkAttachment} linkAttachmentService + * @param {UnlinkAttachment} unlinkAttachmentService + * @param {ValidateAttachments} validateDocuments */ constructor( private readonly linkAttachmentService: LinkAttachment, diff --git a/packages/server/src/modules/Attachments/events/AttachmentsOnCreditNote.ts b/packages/server/src/modules/Attachments/events/AttachmentsOnCreditNote.ts index 9fecf3f2f..6f992cca5 100644 --- a/packages/server/src/modules/Attachments/events/AttachmentsOnCreditNote.ts +++ b/packages/server/src/modules/Attachments/events/AttachmentsOnCreditNote.ts @@ -15,9 +15,9 @@ import { events } from '@/common/events/events'; @Injectable() export class AttachmentsOnCreditNote { /** - * @param {LinkAttachment} linkAttachmentService - - * @param {UnlinkAttachment} unlinkAttachmentService - - * @param {ValidateAttachments} validateDocuments - + * @param {LinkAttachment} linkAttachmentService - + * @param {UnlinkAttachment} unlinkAttachmentService - + * @param {ValidateAttachments} validateDocuments - */ constructor( private readonly linkAttachmentService: LinkAttachment, diff --git a/packages/server/src/modules/Attachments/events/AttachmentsOnExpenses.ts b/packages/server/src/modules/Attachments/events/AttachmentsOnExpenses.ts index d501001a1..cc94586e5 100644 --- a/packages/server/src/modules/Attachments/events/AttachmentsOnExpenses.ts +++ b/packages/server/src/modules/Attachments/events/AttachmentsOnExpenses.ts @@ -52,12 +52,7 @@ export class AttachmentsOnExpenses { const keys = expenseDTO.attachments?.map((attachment) => attachment.key); - await this.linkAttachmentService.bulkLink( - keys, - 'Expense', - expense.id, - trx, - ); + await this.linkAttachmentService.bulkLink(keys, 'Expense', expense.id, trx); } /** diff --git a/packages/server/src/modules/Auth/Auth.controller.ts b/packages/server/src/modules/Auth/Auth.controller.ts index b8b18554a..c89b51e94 100644 --- a/packages/server/src/modules/Auth/Auth.controller.ts +++ b/packages/server/src/modules/Auth/Auth.controller.ts @@ -44,7 +44,7 @@ export class AuthController { @Inject(TenantModel.name) private readonly tenantModel: typeof TenantModel, - ) { } + ) {} @Post('/signin') @UseGuards(LocalAuthGuard) @@ -52,7 +52,8 @@ export class AuthController { @ApiBody({ type: AuthSigninDto }) @ApiResponse({ status: 200, - description: 'Sign-in successful. Returns access token and tenant/organization IDs.', + description: + 'Sign-in successful. Returns access token and tenant/organization IDs.', schema: { $ref: getSchemaPath(AuthSigninResponseDto) }, }) async signin( @@ -73,7 +74,10 @@ export class AuthController { @Post('/signup') @ApiOperation({ summary: 'Sign up a new user' }) @ApiBody({ type: AuthSignupDto }) - @ApiResponse({ status: 201, description: 'Sign-up initiated. Check email for confirmation.' }) + @ApiResponse({ + status: 201, + description: 'Sign-up initiated. Check email for confirmation.', + }) signup(@Request() req: Request, @Body() signupDto: AuthSignupDto) { return this.authApp.signUp(signupDto); } @@ -89,14 +93,20 @@ export class AuthController { @Post('/send_reset_password') @ApiOperation({ summary: 'Send reset password email' }) @ApiBody({ type: AuthSendResetPasswordDto }) - @ApiResponse({ status: 200, description: 'Reset password email sent if the account exists.' }) + @ApiResponse({ + status: 200, + description: 'Reset password email sent if the account exists.', + }) sendResetPassword(@Body() body: AuthSendResetPasswordDto) { return this.authApp.sendResetPassword(body.email); } @Post('/reset_password/:token') @ApiOperation({ summary: 'Reset password using token' }) - @ApiParam({ name: 'token', description: 'Reset password token from email link' }) + @ApiParam({ + name: 'token', + description: 'Reset password token from email link', + }) @ApiBody({ type: AuthResetPasswordDto }) @ApiResponse({ status: 200, description: 'Password reset successfully.' }) resetPassword( diff --git a/packages/server/src/modules/Auth/AuthApiKeys.controllers.ts b/packages/server/src/modules/Auth/AuthApiKeys.controllers.ts index f5d1d971d..e5be0c04e 100644 --- a/packages/server/src/modules/Auth/AuthApiKeys.controllers.ts +++ b/packages/server/src/modules/Auth/AuthApiKeys.controllers.ts @@ -45,7 +45,7 @@ export class AuthApiKeysController { constructor( private readonly getApiKeysService: GetApiKeysService, private readonly generateApiKeyService: GenerateApiKey, - ) { } + ) {} @Post('generate') @ApiOperation({ summary: 'Generate a new API key' }) diff --git a/packages/server/src/modules/Auth/AuthMailMessages.esrvice.ts b/packages/server/src/modules/Auth/AuthMailMessages.esrvice.ts index 7aaf4003b..44bfc9e4a 100644 --- a/packages/server/src/modules/Auth/AuthMailMessages.esrvice.ts +++ b/packages/server/src/modules/Auth/AuthMailMessages.esrvice.ts @@ -41,9 +41,9 @@ export class AuthenticationMailMesssages { } sendResetPasswordMail(user: ModelObject, token: string) { - const mail = this.resetPasswordMessage(user, token); + const mail = this.resetPasswordMessage(user, token); - return this.mailTransporter.send(mail); + return this.mailTransporter.send(mail); } /** @@ -72,11 +72,7 @@ export class AuthenticationMailMesssages { } sendSignupVerificationMail(email: string, fullName: string, token: string) { - const mail = this.signupVerificationMail( - email, - fullName, - token, - ); + const mail = this.signupVerificationMail(email, fullName, token); return this.mailTransporter.send(mail); } } diff --git a/packages/server/src/modules/Auth/Authed.controller.ts b/packages/server/src/modules/Auth/Authed.controller.ts index e18b3635c..d0bed7ab4 100644 --- a/packages/server/src/modules/Auth/Authed.controller.ts +++ b/packages/server/src/modules/Auth/Authed.controller.ts @@ -20,7 +20,7 @@ export class AuthedController { constructor( private readonly getAuthedAccountService: GetAuthenticatedAccount, private readonly authApp: AuthenticationApplication, - ) { } + ) {} @Post('/signup/verify/resend') @ApiOperation({ summary: 'Resend the signup confirmation message' }) diff --git a/packages/server/src/modules/Auth/commands/AuthSendResetPassword.service.ts b/packages/server/src/modules/Auth/commands/AuthSendResetPassword.service.ts index 0fe2725e2..b965d22bf 100644 --- a/packages/server/src/modules/Auth/commands/AuthSendResetPassword.service.ts +++ b/packages/server/src/modules/Auth/commands/AuthSendResetPassword.service.ts @@ -24,16 +24,14 @@ export class AuthSendResetPasswordService { @Inject(SystemUser.name) private readonly systemUserModel: typeof SystemUser, - ) { } + ) {} /** * Sends the given email reset password email. * @param {string} email - Email address. */ async sendResetPassword(email: string): Promise { - const user = await this.systemUserModel - .query() - .findOne({ email }); + const user = await this.systemUserModel.query().findOne({ email }); if (!user) return; diff --git a/packages/server/src/modules/Auth/commands/AuthSignin.service.ts b/packages/server/src/modules/Auth/commands/AuthSignin.service.ts index 48694d3ea..917485cde 100644 --- a/packages/server/src/modules/Auth/commands/AuthSignin.service.ts +++ b/packages/server/src/modules/Auth/commands/AuthSignin.service.ts @@ -14,7 +14,7 @@ export class AuthSigninService { private readonly systemUserModel: typeof SystemUser, private readonly jwtService: JwtService, private readonly clsService: ClsService, - ) { } + ) {} /** * Validates the given email and password. diff --git a/packages/server/src/modules/Auth/commands/AuthSignup.service.ts b/packages/server/src/modules/Auth/commands/AuthSignup.service.ts index 8cf42390a..2b28ced5d 100644 --- a/packages/server/src/modules/Auth/commands/AuthSignup.service.ts +++ b/packages/server/src/modules/Auth/commands/AuthSignup.service.ts @@ -33,7 +33,7 @@ export class AuthSignupService { @Inject(SystemUser.name) private readonly systemUserModel: typeof SystemUser, - ) { } + ) {} /** * Registers a new tenant with user from user input. @@ -53,7 +53,7 @@ export class AuthSignupService { const verifiedEnabed = signupConfirmation.enabled ?? false; const verifyToken = verifiedEnabed ? verifyTokenCrypto : ''; const verified = !verifiedEnabed; - + const inviteAcceptedAt = moment().format('YYYY-MM-DD'); // Triggers signin up event. diff --git a/packages/server/src/modules/Auth/commands/GenerateApiKey.service.ts b/packages/server/src/modules/Auth/commands/GenerateApiKey.service.ts index 2b91c60e0..85891bcb9 100644 --- a/packages/server/src/modules/Auth/commands/GenerateApiKey.service.ts +++ b/packages/server/src/modules/Auth/commands/GenerateApiKey.service.ts @@ -10,7 +10,7 @@ export class GenerateApiKey { private readonly tenancyContext: TenancyContext, @Inject(ApiKeyModel.name) private readonly apiKeyModel: typeof ApiKeyModel, - ) { } + ) {} /** * Generates a new secure API key for the current tenant and system user. diff --git a/packages/server/src/modules/Auth/exceptions/InvalidEmailPassword.exception.ts b/packages/server/src/modules/Auth/exceptions/InvalidEmailPassword.exception.ts index 15626b1b4..b272df701 100644 --- a/packages/server/src/modules/Auth/exceptions/InvalidEmailPassword.exception.ts +++ b/packages/server/src/modules/Auth/exceptions/InvalidEmailPassword.exception.ts @@ -11,5 +11,3 @@ export class InvalidEmailPasswordException extends UnauthorizedException { }); } } - - diff --git a/packages/server/src/modules/Auth/queries/GetApiKeys.transformer.ts b/packages/server/src/modules/Auth/queries/GetApiKeys.transformer.ts index a7bfd938f..a143a98c6 100644 --- a/packages/server/src/modules/Auth/queries/GetApiKeys.transformer.ts +++ b/packages/server/src/modules/Auth/queries/GetApiKeys.transformer.ts @@ -1,7 +1,6 @@ import { Transformer } from '@/modules/Transformer/Transformer'; export class GetApiKeysTransformer extends Transformer { - public includeAttributes = (): string[] => { return ['token']; }; diff --git a/packages/server/src/modules/Auth/queries/GetAuthMeta.service.ts b/packages/server/src/modules/Auth/queries/GetAuthMeta.service.ts index 70e3b0a14..bd2e29397 100644 --- a/packages/server/src/modules/Auth/queries/GetAuthMeta.service.ts +++ b/packages/server/src/modules/Auth/queries/GetAuthMeta.service.ts @@ -4,12 +4,7 @@ import { IAuthGetMetaPOJO } from '../Auth.interfaces'; @Injectable() export class GetAuthMetaService { - - constructor( - private readonly configService: ConfigService, - ) { - - } + constructor(private readonly configService: ConfigService) {} /** * Retrieves the authentication meta for SPA. * @returns {Promise} diff --git a/packages/server/src/modules/BankRules/BankRulesApplication.ts b/packages/server/src/modules/BankRules/BankRulesApplication.ts index ba4e05e04..e1f9bb16f 100644 --- a/packages/server/src/modules/BankRules/BankRulesApplication.ts +++ b/packages/server/src/modules/BankRules/BankRulesApplication.ts @@ -22,9 +22,7 @@ export class BankRulesApplication { * @param {ICreateBankRuleDTO} createRuleDTO - Bank rule data. * @returns {Promise} */ - public createBankRule( - createRuleDTO: CreateBankRuleDto, - ): Promise { + public createBankRule(createRuleDTO: CreateBankRuleDto): Promise { return this.createBankRuleService.createBankRule(createRuleDTO); } diff --git a/packages/server/src/modules/BankRules/queries/GetBankRuleTransformer.ts b/packages/server/src/modules/BankRules/queries/GetBankRuleTransformer.ts index b01979ecb..6777122c5 100644 --- a/packages/server/src/modules/BankRules/queries/GetBankRuleTransformer.ts +++ b/packages/server/src/modules/BankRules/queries/GetBankRuleTransformer.ts @@ -1,4 +1,4 @@ -import { Transformer } from "@/modules/Transformer/Transformer"; +import { Transformer } from '@/modules/Transformer/Transformer'; export class GetBankRuleTransformer extends Transformer { /** diff --git a/packages/server/src/modules/BankingAccounts/BankAccounts.controller.ts b/packages/server/src/modules/BankingAccounts/BankAccounts.controller.ts index f77fe0285..23ae60c7f 100644 --- a/packages/server/src/modules/BankingAccounts/BankAccounts.controller.ts +++ b/packages/server/src/modules/BankingAccounts/BankAccounts.controller.ts @@ -7,7 +7,7 @@ import { BankAccountResponseDto } from './dtos/BankAccountResponse.dto'; @Controller('banking/accounts') @ApiTags('Bank Accounts') export class BankAccountsController { - constructor(private bankAccountsApplication: BankAccountsApplication) { } + constructor(private bankAccountsApplication: BankAccountsApplication) {} @Get() @ApiOperation({ summary: 'Retrieve the bank accounts.' }) diff --git a/packages/server/src/modules/BankingAccounts/BankAccountsApplication.service.ts b/packages/server/src/modules/BankingAccounts/BankAccountsApplication.service.ts index e3d0a583f..0e4c3d9ee 100644 --- a/packages/server/src/modules/BankingAccounts/BankAccountsApplication.service.ts +++ b/packages/server/src/modules/BankingAccounts/BankAccountsApplication.service.ts @@ -17,7 +17,7 @@ export class BankAccountsApplication { private readonly refreshBankAccountService: RefreshBankAccountService, private readonly resumeBankAccountFeedsService: ResumeBankAccountFeedsService, private readonly pauseBankAccountFeedsService: PauseBankAccountFeeds, - ) { } + ) {} /** * Retrieves the bank accounts. diff --git a/packages/server/src/modules/BankingAccounts/dtos/BankAccountsQuery.dto.ts b/packages/server/src/modules/BankingAccounts/dtos/BankAccountsQuery.dto.ts index 8f2653be3..d14c91219 100644 --- a/packages/server/src/modules/BankingAccounts/dtos/BankAccountsQuery.dto.ts +++ b/packages/server/src/modules/BankingAccounts/dtos/BankAccountsQuery.dto.ts @@ -1,8 +1,19 @@ import { ApiPropertyOptional } from '@nestjs/swagger'; import { Transform } from 'class-transformer'; -import { IsArray, IsBoolean, IsEnum, IsInt, IsOptional, IsString, Min } from 'class-validator'; +import { + IsArray, + IsBoolean, + IsEnum, + IsInt, + IsOptional, + IsString, + Min, +} from 'class-validator'; import { ToNumber } from '@/common/decorators/Validators'; -import { IFilterRole, ISortOrder } from '@/modules/DynamicListing/DynamicFilter/DynamicFilter.types'; +import { + IFilterRole, + ISortOrder, +} from '@/modules/DynamicListing/DynamicFilter/DynamicFilter.types'; import { parseBoolean } from '@/utils/parse-boolean'; export class BankAccountsQueryDto { diff --git a/packages/server/src/modules/BankingAccounts/queries/GetBankAccounts.ts b/packages/server/src/modules/BankingAccounts/queries/GetBankAccounts.ts index 42c82cd80..7554f82c7 100644 --- a/packages/server/src/modules/BankingAccounts/queries/GetBankAccounts.ts +++ b/packages/server/src/modules/BankingAccounts/queries/GetBankAccounts.ts @@ -17,7 +17,7 @@ export class GetBankAccountsService { @Inject(Account.name) private readonly accountModel: TenantModelProxy, - ) { } + ) {} /** * Retrieve the cash flow accounts. @@ -32,9 +32,10 @@ export class GetBankAccountsService { ...filterDTO, }; // Parsees accounts list filter DTO. - const filter = this.dynamicListService.parseStringifiedFilter( - _filterDto, - ); + const filter = + this.dynamicListService.parseStringifiedFilter( + _filterDto, + ); // Dynamic list service. const dynamicList = await this.dynamicListService.dynamicList( diff --git a/packages/server/src/modules/BankingAccounts/types/BankAccounts.types.ts b/packages/server/src/modules/BankingAccounts/types/BankAccounts.types.ts index d607334a4..d51692ce8 100644 --- a/packages/server/src/modules/BankingAccounts/types/BankAccounts.types.ts +++ b/packages/server/src/modules/BankingAccounts/types/BankAccounts.types.ts @@ -17,10 +17,9 @@ export const ERRORS = { BANK_ACCOUNT_FEEDS_ALREADY_RESUMED: 'BANK_ACCOUNT_FEEDS_ALREADY_RESUMED', }; - -export interface ICashflowAccountsFilter extends IDynamicListFilter{ +export interface ICashflowAccountsFilter extends IDynamicListFilter { page: number; pageSize: number; inactiveMode: boolean; viewSlug?: string; -} \ No newline at end of file +} diff --git a/packages/server/src/modules/BankingCategorize/BankingCategorize.controller.ts b/packages/server/src/modules/BankingCategorize/BankingCategorize.controller.ts index e650b1cbe..7078f8e23 100644 --- a/packages/server/src/modules/BankingCategorize/BankingCategorize.controller.ts +++ b/packages/server/src/modules/BankingCategorize/BankingCategorize.controller.ts @@ -53,12 +53,8 @@ export class BankingCategorizeController { @Query('uncategorizedTransactionIds') uncategorizedTransactionIds: number[] | number, ) { - const ids = castArray(uncategorizedTransactionIds).map((id) => - Number(id), - ); - return this.bankingCategorizeApplication.uncategorizeTransactionsBulk( - ids, - ); + const ids = castArray(uncategorizedTransactionIds).map((id) => Number(id)); + return this.bankingCategorizeApplication.uncategorizeTransactionsBulk(ids); } @Delete('/:id') diff --git a/packages/server/src/modules/BankingCategorize/commands/UncategorizeBankTransactionsBulk.service.ts b/packages/server/src/modules/BankingCategorize/commands/UncategorizeBankTransactionsBulk.service.ts index dbc4cf2eb..c2fc49981 100644 --- a/packages/server/src/modules/BankingCategorize/commands/UncategorizeBankTransactionsBulk.service.ts +++ b/packages/server/src/modules/BankingCategorize/commands/UncategorizeBankTransactionsBulk.service.ts @@ -6,7 +6,7 @@ import { UncategorizeBankTransactionService } from './UncategorizeBankTransactio @Injectable() export class UncategorizeBankTransactionsBulk { constructor( - private readonly uncategorizeTransactionService: UncategorizeBankTransactionService + private readonly uncategorizeTransactionService: UncategorizeBankTransactionService, ) {} /** @@ -14,7 +14,7 @@ export class UncategorizeBankTransactionsBulk { * @param {number | Array} uncategorizedTransactionId */ public async uncategorizeBulk( - uncategorizedTransactionId: number | Array + uncategorizedTransactionId: number | Array, ) { const uncategorizedTransactionIds = castArray(uncategorizedTransactionId); @@ -22,7 +22,7 @@ export class UncategorizeBankTransactionsBulk { .for(uncategorizedTransactionIds) .process(async (_uncategorizedTransactionId: number, index, pool) => { await this.uncategorizeTransactionService.uncategorize( - _uncategorizedTransactionId + _uncategorizedTransactionId, ); }); } diff --git a/packages/server/src/modules/BankingCategorize/commands/UncategorizedTransaction.transformer.ts b/packages/server/src/modules/BankingCategorize/commands/UncategorizedTransaction.transformer.ts index b7134c2a5..689d4c5c7 100644 --- a/packages/server/src/modules/BankingCategorize/commands/UncategorizedTransaction.transformer.ts +++ b/packages/server/src/modules/BankingCategorize/commands/UncategorizedTransaction.transformer.ts @@ -1,4 +1,4 @@ -import { Transformer } from "../../Transformer/Transformer"; +import { Transformer } from '../../Transformer/Transformer'; export class UncategorizedTransactionTransformer extends Transformer { /** diff --git a/packages/server/src/modules/BankingCategorize/types/BankingCategorize.types.ts b/packages/server/src/modules/BankingCategorize/types/BankingCategorize.types.ts index 060ada382..5e1471376 100644 --- a/packages/server/src/modules/BankingCategorize/types/BankingCategorize.types.ts +++ b/packages/server/src/modules/BankingCategorize/types/BankingCategorize.types.ts @@ -1,6 +1,6 @@ -import { BankTransaction } from "@/modules/BankingTransactions/models/BankTransaction"; -import { UncategorizedBankTransaction } from "@/modules/BankingTransactions/models/UncategorizedBankTransaction"; -import { Knex } from "knex"; +import { BankTransaction } from '@/modules/BankingTransactions/models/BankTransaction'; +import { UncategorizedBankTransaction } from '@/modules/BankingTransactions/models/UncategorizedBankTransaction'; +import { Knex } from 'knex'; export interface ICashflowTransactionCategorizedPayload { uncategorizedTransactions: Array; @@ -36,7 +36,6 @@ export interface ICategorizeCashflowTransactioDTO { branchId: number; } - export interface IUncategorizedTransactionCreatingEventPayload { tenantId: number; createUncategorizedTransactionDTO: CreateUncategorizedTransactionDTO; diff --git a/packages/server/src/modules/BankingMatching/BankingMatching.controller.ts b/packages/server/src/modules/BankingMatching/BankingMatching.controller.ts index 51f674934..e55ae082d 100644 --- a/packages/server/src/modules/BankingMatching/BankingMatching.controller.ts +++ b/packages/server/src/modules/BankingMatching/BankingMatching.controller.ts @@ -6,7 +6,15 @@ import { ApiTags, getSchemaPath, } from '@nestjs/swagger'; -import { Body, Controller, Get, Param, Patch, Post, Query } from '@nestjs/common'; +import { + Body, + Controller, + Get, + Param, + Patch, + Post, + Query, +} from '@nestjs/common'; import { BankingMatchingApplication } from './BankingMatchingApplication'; import { MatchBankTransactionDto } from './dtos/MatchBankTransaction.dto'; import { GetMatchedTransactionsQueryDto } from './dtos/GetMatchedTransactionsQuery.dto'; diff --git a/packages/server/src/modules/BankingMatching/_utils.ts b/packages/server/src/modules/BankingMatching/_utils.ts index 914a725dc..27ad0f499 100644 --- a/packages/server/src/modules/BankingMatching/_utils.ts +++ b/packages/server/src/modules/BankingMatching/_utils.ts @@ -7,35 +7,32 @@ import { ServiceError } from '../Items/ServiceError'; export const sortClosestMatchTransactions = ( amount: number, date: Date, - matches: MatchedTransactionPOJO[] + matches: MatchedTransactionPOJO[], ) => { return R.sortWith([ // Sort by amount difference (closest to uncategorized transaction amount first) R.ascend((match: MatchedTransactionPOJO) => - Math.abs(match.amount - amount) + Math.abs(match.amount - amount), ), // Sort by date difference (closest to uncategorized transaction date first) R.ascend((match: MatchedTransactionPOJO) => - Math.abs(moment(match.date).diff(moment(date), 'days')) + Math.abs(moment(match.date).diff(moment(date), 'days')), ), ])(matches); }; export const sumMatchTranasctions = (transactions: Array) => { - const total = transactions.reduce( - (sum, item) => { - const amount = parseFloat(item.amount) || 0; - const multiplier = item.transactionNormal === 'debit' ? 1 : -1; - return sum + multiplier * amount; - }, - 0 - ); + const total = transactions.reduce((sum, item) => { + const amount = parseFloat(item.amount) || 0; + const multiplier = item.transactionNormal === 'debit' ? 1 : -1; + return sum + multiplier * amount; + }, 0); // Round to 2 decimal places to avoid floating-point precision issues return round(total, 2); }; export const sumUncategorizedTransactions = ( - uncategorizedTransactions: Array + uncategorizedTransactions: Array, ) => { const total = sumBy(uncategorizedTransactions, 'amount'); // Round to 2 decimal places to avoid floating-point precision issues @@ -43,10 +40,10 @@ export const sumUncategorizedTransactions = ( }; export const validateUncategorizedTransactionsNotMatched = ( - uncategorizedTransactions: any + uncategorizedTransactions: any, ) => { const matchedTransactions = uncategorizedTransactions.filter( - (trans) => !isEmpty(trans.matchedBankTransactions) + (trans) => !isEmpty(trans.matchedBankTransactions), ); // if (matchedTransactions.length > 0) { @@ -57,10 +54,10 @@ export const validateUncategorizedTransactionsNotMatched = ( }; export const validateUncategorizedTransactionsExcluded = ( - uncategorizedTransactions: any + uncategorizedTransactions: any, ) => { const excludedTransactions = uncategorizedTransactions.filter( - (trans) => trans.excluded + (trans) => trans.excluded, ); if (excludedTransactions.length > 0) { throw new ServiceError(ERRORS.CANNOT_MATCH_EXCLUDED_TRANSACTION, '', { diff --git a/packages/server/src/modules/BankingMatching/commands/MatchTransactions.ts b/packages/server/src/modules/BankingMatching/commands/MatchTransactions.ts index 7c4e9664a..d1a1a1861 100644 --- a/packages/server/src/modules/BankingMatching/commands/MatchTransactions.ts +++ b/packages/server/src/modules/BankingMatching/commands/MatchTransactions.ts @@ -34,7 +34,7 @@ export class MatchBankTransactions { private readonly uncategorizedBankTransactionModel: TenantModelProxy< typeof UncategorizedBankTransaction >, - ) { } + ) {} /** * Validates the match bank transactions DTO. @@ -102,7 +102,9 @@ export class MatchBankTransactions { // uncategorized transaction amount. // Use tolerance-based comparison to handle floating-point precision issues const tolerance = 0.01; // Allow 0.01 difference for floating-point precision - const difference = Math.abs(totalUncategorizedTransactions - totalMatchedTranasctions); + const difference = Math.abs( + totalUncategorizedTransactions - totalMatchedTranasctions, + ); if (difference > tolerance) { throw new ServiceError(ERRORS.TOTAL_MATCHING_TRANSACTIONS_INVALID); } @@ -115,7 +117,9 @@ export class MatchBankTransactions { */ public async matchTransaction( uncategorizedTransactionId: number | Array, - matchedTransactionsDto: MatchTransactionEntryDto | Array, + matchedTransactionsDto: + | MatchTransactionEntryDto + | Array, ): Promise { const uncategorizedTransactionIds = castArray(uncategorizedTransactionId); const matchedTransactions = castArray(matchedTransactionsDto); diff --git a/packages/server/src/modules/BankingMatching/commands/MatchTransactionsTypesRegistry.ts b/packages/server/src/modules/BankingMatching/commands/MatchTransactionsTypesRegistry.ts index e27016b44..69ecebd09 100644 --- a/packages/server/src/modules/BankingMatching/commands/MatchTransactionsTypesRegistry.ts +++ b/packages/server/src/modules/BankingMatching/commands/MatchTransactionsTypesRegistry.ts @@ -28,7 +28,7 @@ export class MatchTransactionsTypesRegistry { */ public register( resource: string, - importable: GetMatchedTransactionsByType + importable: GetMatchedTransactionsByType, ): void { const _resource = this.sanitizeResourceName(resource); this.importables[_resource] = importable; diff --git a/packages/server/src/modules/BankingMatching/dtos/GetMatchedTransactionsQuery.dto.ts b/packages/server/src/modules/BankingMatching/dtos/GetMatchedTransactionsQuery.dto.ts index 9c6163807..082f26de6 100644 --- a/packages/server/src/modules/BankingMatching/dtos/GetMatchedTransactionsQuery.dto.ts +++ b/packages/server/src/modules/BankingMatching/dtos/GetMatchedTransactionsQuery.dto.ts @@ -3,7 +3,10 @@ import { IsOptional, IsString, IsNumber, Min, Max } from 'class-validator'; import { Type } from 'class-transformer'; export class GetMatchedTransactionsQueryDto { - @ApiPropertyOptional({ description: 'Filter from date', example: '2024-01-01' }) + @ApiPropertyOptional({ + description: 'Filter from date', + example: '2024-01-01', + }) @IsOptional() @IsString() fromDate?: string; diff --git a/packages/server/src/modules/BankingMatching/dtos/MatchBankTransaction.dto.ts b/packages/server/src/modules/BankingMatching/dtos/MatchBankTransaction.dto.ts index 306073d14..544448658 100644 --- a/packages/server/src/modules/BankingMatching/dtos/MatchBankTransaction.dto.ts +++ b/packages/server/src/modules/BankingMatching/dtos/MatchBankTransaction.dto.ts @@ -48,4 +48,4 @@ export class MatchBankTransactionDto { ], }) matchedTransactions: MatchTransactionEntryDto[]; -} \ No newline at end of file +} diff --git a/packages/server/src/modules/BankingMatching/models/MatchedBankTransaction.ts b/packages/server/src/modules/BankingMatching/models/MatchedBankTransaction.ts index fc2eddb36..a5c3383f6 100644 --- a/packages/server/src/modules/BankingMatching/models/MatchedBankTransaction.ts +++ b/packages/server/src/modules/BankingMatching/models/MatchedBankTransaction.ts @@ -5,7 +5,6 @@ export class MatchedBankTransaction extends BaseModel { public referenceType!: string; public uncategorizedTransactionId!: number; - /** * Table name. */ diff --git a/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionBillsTransformer.ts b/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionBillsTransformer.ts index 3f4969196..d1f076a36 100644 --- a/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionBillsTransformer.ts +++ b/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionBillsTransformer.ts @@ -1,4 +1,4 @@ -import { Transformer } from "@/modules/Transformer/Transformer"; +import { Transformer } from '@/modules/Transformer/Transformer'; export class GetMatchedTransactionBillsTransformer extends Transformer { /** diff --git a/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionCashflowTransformer.ts b/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionCashflowTransformer.ts index 0204d3536..03b6dc7e4 100644 --- a/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionCashflowTransformer.ts +++ b/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionCashflowTransformer.ts @@ -1,4 +1,4 @@ -import { Transformer } from "@/modules/Transformer/Transformer"; +import { Transformer } from '@/modules/Transformer/Transformer'; export class GetMatchedTransactionCashflowTransformer extends Transformer { /** diff --git a/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionExpensesTransformer.ts b/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionExpensesTransformer.ts index cda810dd0..cc412be76 100644 --- a/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionExpensesTransformer.ts +++ b/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionExpensesTransformer.ts @@ -1,4 +1,4 @@ -import { Transformer } from "@/modules/Transformer/Transformer"; +import { Transformer } from '@/modules/Transformer/Transformer'; export class GetMatchedTransactionExpensesTransformer extends Transformer { /** diff --git a/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionInvoicesTransformer.ts b/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionInvoicesTransformer.ts index eb376bfc6..ae13cb682 100644 --- a/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionInvoicesTransformer.ts +++ b/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionInvoicesTransformer.ts @@ -1,4 +1,4 @@ -import { Transformer } from "@/modules/Transformer/Transformer"; +import { Transformer } from '@/modules/Transformer/Transformer'; export class GetMatchedTransactionInvoicesTransformer extends Transformer { /** @@ -19,7 +19,7 @@ export class GetMatchedTransactionInvoicesTransformer extends Transformer { 'transsactionTypeFormatted', 'transactionNormal', 'referenceType', - 'referenceId' + 'referenceId', ]; }; @@ -123,13 +123,13 @@ export class GetMatchedTransactionInvoicesTransformer extends Transformer { /** * Retrieve the transaction reference type. * @returns {string} - */ protected referenceType() { + */ protected referenceType() { return 'SaleInvoice'; } /** * Retrieve the transaction reference id. - * @param transaction + * @param transaction * @returns {number} */ protected referenceId(transaction) { diff --git a/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionsByExpenses.ts b/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionsByExpenses.ts index c963969ec..8f66943a3 100644 --- a/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionsByExpenses.ts +++ b/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionsByExpenses.ts @@ -1,5 +1,9 @@ import { Inject, Injectable } from '@nestjs/common'; -import { GetMatchedTransactionsFilter, MatchedTransactionPOJO, MatchedTransactionsPOJO } from '../types'; +import { + GetMatchedTransactionsFilter, + MatchedTransactionPOJO, + MatchedTransactionsPOJO, +} from '../types'; import { GetMatchedTransactionsByType } from './GetMatchedTransactionsByType'; import { GetMatchedTransactionExpensesTransformer } from './GetMatchedTransactionExpensesTransformer'; import { TransformerInjectable } from '@/modules/Transformer/TransformerInjectable.service'; @@ -22,7 +26,6 @@ export class GetMatchedTransactionsByExpenses extends GetMatchedTransactionsByTy @Inject('TENANT_MODELS_INIT') private readonly tenantModelsInit: () => Promise, - ) { super(); } diff --git a/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionsByType.ts b/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionsByType.ts index 7a4e29356..8e1b5a0ff 100644 --- a/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionsByType.ts +++ b/packages/server/src/modules/BankingMatching/queries/GetMatchedTransactionsByType.ts @@ -12,9 +12,7 @@ import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel'; export abstract class GetMatchedTransactionsByType { @Inject(MatchedBankTransaction.name) - matchedBankTransactionModel: TenantModelProxy< - typeof MatchedBankTransaction - >; + matchedBankTransactionModel: TenantModelProxy; /** * Retrieves the matched transactions. diff --git a/packages/server/src/modules/BankingPlaid/BankingPlaidWebhooks.controller.ts b/packages/server/src/modules/BankingPlaid/BankingPlaidWebhooks.controller.ts index 42a79f769..521e5ff69 100644 --- a/packages/server/src/modules/BankingPlaid/BankingPlaidWebhooks.controller.ts +++ b/packages/server/src/modules/BankingPlaid/BankingPlaidWebhooks.controller.ts @@ -17,15 +17,8 @@ export class BankingPlaidWebhooksController { @Post('webhooks') @ApiOperation({ summary: 'Listen to Plaid webhooks' }) webhooks(@Body() { itemId, webhookType, webhookCode }: PlaidWebhookDto) { - return this.setupPlaidItemTenantService.setupPlaidTenant( - itemId, - () => { - return this.plaidApplication.webhooks( - itemId, - webhookType, - webhookCode, - ); - }, - ); + return this.setupPlaidItemTenantService.setupPlaidTenant(itemId, () => { + return this.plaidApplication.webhooks(itemId, webhookType, webhookCode); + }); } } diff --git a/packages/server/src/modules/BankingPlaid/subscribers/RecognizeSyncedBankTransactions.subscriber.ts b/packages/server/src/modules/BankingPlaid/subscribers/RecognizeSyncedBankTransactions.subscriber.ts index 4f7f99abb..5b3e1d681 100644 --- a/packages/server/src/modules/BankingPlaid/subscribers/RecognizeSyncedBankTransactions.subscriber.ts +++ b/packages/server/src/modules/BankingPlaid/subscribers/RecognizeSyncedBankTransactions.subscriber.ts @@ -6,7 +6,7 @@ import { runAfterTransaction } from '@/modules/Tenancy/TenancyDB/TransactionsHoo import { IPlaidTransactionsSyncedEventPayload } from '../types/BankingPlaid.types'; @Injectable() -export class RecognizeSyncedBankTranasctionsSubscriber { +export class RecognizeSyncedBankTranasctionsSubscriber { constructor( private readonly recognizeTranasctionsService: RecognizeTranasctionsService, ) {} @@ -21,10 +21,9 @@ export class RecognizeSyncedBankTranasctionsSubscriber { trx, }: IPlaidTransactionsSyncedEventPayload) { runAfterTransaction(trx, async () => { - await this.recognizeTranasctionsService.recognizeTransactions( - null, - { batch } - ); + await this.recognizeTranasctionsService.recognizeTransactions(null, { + batch, + }); }); - }; + } } diff --git a/packages/server/src/modules/BankingPlaid/types/BankingPlaid.types.ts b/packages/server/src/modules/BankingPlaid/types/BankingPlaid.types.ts index ac083f661..25d87e284 100644 --- a/packages/server/src/modules/BankingPlaid/types/BankingPlaid.types.ts +++ b/packages/server/src/modules/BankingPlaid/types/BankingPlaid.types.ts @@ -31,10 +31,9 @@ export interface IPlaidItemCreatedEventPayload { export const UpdateBankingPlaidTransitionsJob = 'update-banking-plaid-transitions-job'; - export const UpdateBankingPlaidTransitionsQueueJob = +export const UpdateBankingPlaidTransitionsQueueJob = 'update-banking-plaid-transitions-query'; - export interface PlaidFetchTransitonsEventPayload { plaidItemId: string; -} \ No newline at end of file +} diff --git a/packages/server/src/modules/BankingPlaid/utils.ts b/packages/server/src/modules/BankingPlaid/utils.ts index 1b468ebf2..daaa944c5 100644 --- a/packages/server/src/modules/BankingPlaid/utils.ts +++ b/packages/server/src/modules/BankingPlaid/utils.ts @@ -58,24 +58,24 @@ export const transformPlaidAccountToCreateAccount = ( * @returns {CreateUncategorizedTransactionDTO} */ export const transformPlaidTrxsToCashflowCreate = ( - cashflowAccountId: number, - plaidTranasction: PlaidTransactionBase, - ): CreateUncategorizedTransactionDTO => { - return { - date: plaidTranasction.date, + cashflowAccountId: number, + plaidTranasction: PlaidTransactionBase, +): CreateUncategorizedTransactionDTO => { + return { + date: plaidTranasction.date, - // Plaid: Positive values when money moves out of the account; negative values - // when money moves in. For example, debit card purchases are positive; - // credit card payments, direct deposits, and refunds are negative. - amount: -1 * plaidTranasction.amount, + // Plaid: Positive values when money moves out of the account; negative values + // when money moves in. For example, debit card purchases are positive; + // credit card payments, direct deposits, and refunds are negative. + amount: -1 * plaidTranasction.amount, - description: plaidTranasction.name, - payee: plaidTranasction.payment_meta?.payee, - currencyCode: plaidTranasction.iso_currency_code, - accountId: cashflowAccountId, - referenceNo: plaidTranasction.payment_meta?.reference_number, - plaidTransactionId: plaidTranasction.transaction_id, - pending: plaidTranasction.pending, - pendingPlaidTransactionId: plaidTranasction.pending_transaction_id, - }; + description: plaidTranasction.name, + payee: plaidTranasction.payment_meta?.payee, + currencyCode: plaidTranasction.iso_currency_code, + accountId: cashflowAccountId, + referenceNo: plaidTranasction.payment_meta?.reference_number, + plaidTransactionId: plaidTranasction.transaction_id, + pending: plaidTranasction.pending, + pendingPlaidTransactionId: plaidTranasction.pending_transaction_id, }; +}; diff --git a/packages/server/src/modules/BankingTranasctionsRegonize/BankingRecognizedTransactions.controller.ts b/packages/server/src/modules/BankingTranasctionsRegonize/BankingRecognizedTransactions.controller.ts index 2ee21edee..ce155e93a 100644 --- a/packages/server/src/modules/BankingTranasctionsRegonize/BankingRecognizedTransactions.controller.ts +++ b/packages/server/src/modules/BankingTranasctionsRegonize/BankingRecognizedTransactions.controller.ts @@ -65,7 +65,9 @@ export class BankingRecognizedTransactionsController { properties: { data: { type: 'array', - items: { $ref: getSchemaPath(GetRecognizedTransactionResponseDto) }, + items: { + $ref: getSchemaPath(GetRecognizedTransactionResponseDto), + }, }, }, }, diff --git a/packages/server/src/modules/BankingTranasctionsRegonize/GetRecongizedTransactions.ts b/packages/server/src/modules/BankingTranasctionsRegonize/GetRecongizedTransactions.ts index 559f44730..de8e58218 100644 --- a/packages/server/src/modules/BankingTranasctionsRegonize/GetRecongizedTransactions.ts +++ b/packages/server/src/modules/BankingTranasctionsRegonize/GetRecongizedTransactions.ts @@ -11,7 +11,9 @@ export class GetRecognizedTransactionsService { private readonly transformer: TransformerInjectable, @Inject(UncategorizedBankTransaction.name) - private readonly uncategorizedBankTransactionModel: TenantModelProxy, + private readonly uncategorizedBankTransactionModel: TenantModelProxy< + typeof UncategorizedBankTransaction + >, ) {} /** @@ -26,7 +28,8 @@ export class GetRecognizedTransactionsService { ...filter, }; const { results, pagination } = - await this.uncategorizedBankTransactionModel().query() + await this.uncategorizedBankTransactionModel() + .query() .onBuild((q) => { q.withGraphFetched('recognizedTransaction.assignAccount'); q.withGraphFetched('recognizedTransaction.bankRule'); diff --git a/packages/server/src/modules/BankingTranasctionsRegonize/_types.ts b/packages/server/src/modules/BankingTranasctionsRegonize/_types.ts index 5e5770bd3..bd5b64fe8 100644 --- a/packages/server/src/modules/BankingTranasctionsRegonize/_types.ts +++ b/packages/server/src/modules/BankingTranasctionsRegonize/_types.ts @@ -1,4 +1,4 @@ -import { TenantJobPayload } from "@/interfaces/Tenant"; +import { TenantJobPayload } from '@/interfaces/Tenant'; export interface RevertRecognizedTransactionsCriteria { batch?: string; @@ -15,8 +15,9 @@ export const RecognizeUncategorizedTransactionsJob = export const RecognizeUncategorizedTransactionsQueue = 'recognize-uncategorized-transactions-queue'; -export interface RecognizeUncategorizedTransactionsJobPayload extends TenantJobPayload { - ruleId: number, +export interface RecognizeUncategorizedTransactionsJobPayload + extends TenantJobPayload { + ruleId: number; transactionsCriteria?: RecognizeTransactionsCriteria; /** * When true, first reverts recognized transactions before recognizing again. @@ -24,4 +25,4 @@ export interface RecognizeUncategorizedTransactionsJobPayload extends TenantJobP * by lower-priority rules are re-evaluated against the updated rule. */ shouldRevert?: boolean; -} \ No newline at end of file +} diff --git a/packages/server/src/modules/BankingTranasctionsRegonize/_utils.ts b/packages/server/src/modules/BankingTranasctionsRegonize/_utils.ts index 24d159dd2..e8ea21019 100644 --- a/packages/server/src/modules/BankingTranasctionsRegonize/_utils.ts +++ b/packages/server/src/modules/BankingTranasctionsRegonize/_utils.ts @@ -1,13 +1,18 @@ import { lowerCase } from 'lodash'; import { UncategorizedBankTransaction } from '../BankingTransactions/models/UncategorizedBankTransaction'; -import { BankRuleApplyIfTransactionType, BankRuleConditionComparator, BankRuleConditionType, IBankRuleCondition } from '../BankRules/types'; +import { + BankRuleApplyIfTransactionType, + BankRuleConditionComparator, + BankRuleConditionType, + IBankRuleCondition, +} from '../BankRules/types'; import { BankRule } from '../BankRules/models/BankRule'; import { BankRuleCondition } from '../BankRules/models/BankRuleCondition'; const conditionsMatch = ( transaction: UncategorizedBankTransaction, conditions: BankRuleCondition[], - conditionsType: BankRuleConditionType = BankRuleConditionType.And + conditionsType: BankRuleConditionType = BankRuleConditionType.And, ) => { const method = conditionsType === BankRuleConditionType.And ? 'every' : 'some'; @@ -26,7 +31,7 @@ const conditionsMatch = ( const matchNumberCondition = ( transaction: UncategorizedBankTransaction, - condition: BankRuleCondition + condition: BankRuleCondition, ) => { const conditionValue = parseFloat(condition.value); const transactionAmount = @@ -58,7 +63,7 @@ const matchNumberCondition = ( const matchTextCondition = ( transaction: UncategorizedBankTransaction, - condition: BankRuleCondition + condition: BankRuleCondition, ): boolean => { const transactionValue = transaction[condition.field] as string; @@ -80,7 +85,7 @@ const matchTextCondition = ( const matchTransactionType = ( bankRule: BankRule, - transaction: UncategorizedBankTransaction + transaction: UncategorizedBankTransaction, ): boolean => { return ( (transaction.isDepositTransaction && @@ -94,7 +99,7 @@ const matchTransactionType = ( export const bankRulesMatchTransaction = ( transaction: UncategorizedBankTransaction, - bankRules: BankRule[] + bankRules: BankRule[], ) => { return bankRules.find((rule) => { return ( diff --git a/packages/server/src/modules/BankingTranasctionsRegonize/events/TriggerRecognizedTransactions.ts b/packages/server/src/modules/BankingTranasctionsRegonize/events/TriggerRecognizedTransactions.ts index 7a3ce7286..eb9c2a759 100644 --- a/packages/server/src/modules/BankingTranasctionsRegonize/events/TriggerRecognizedTransactions.ts +++ b/packages/server/src/modules/BankingTranasctionsRegonize/events/TriggerRecognizedTransactions.ts @@ -55,7 +55,6 @@ export class TriggerRecognizedTransactionsSubscriber { oldBankRule, bankRule, }: IBankRuleEventEditedPayload) { - // Cannot continue if the new and old bank rule values are the same, // after excluding `createdAt` and `updatedAt` dates. if ( diff --git a/packages/server/src/modules/BankingTranasctionsRegonize/queries/GetRecognizedTransactionTransformer.ts b/packages/server/src/modules/BankingTranasctionsRegonize/queries/GetRecognizedTransactionTransformer.ts index a85b8a7d6..8a8eee553 100644 --- a/packages/server/src/modules/BankingTranasctionsRegonize/queries/GetRecognizedTransactionTransformer.ts +++ b/packages/server/src/modules/BankingTranasctionsRegonize/queries/GetRecognizedTransactionTransformer.ts @@ -1,4 +1,4 @@ -import { Transformer } from "@/modules/Transformer/Transformer"; +import { Transformer } from '@/modules/Transformer/Transformer'; export class GetRecognizedTransactionTransformer extends Transformer { /** @@ -43,12 +43,12 @@ export class GetRecognizedTransactionTransformer extends Transformer { /** * Get the uncategorized transaction id. - * @param transaction + * @param transaction * @returns {number} */ public uncategorizedTransactionId = (transaction): number => { - return transaction.id; - } + return transaction.id; + }; /** * Get the reference number of the transaction. @@ -170,11 +170,11 @@ export class GetRecognizedTransactionTransformer extends Transformer { } /** - * + * * @returns {string} */ public assignedCategoryFormatted() { - return 'Other Income' + return 'Other Income'; } /** diff --git a/packages/server/src/modules/BankingTransactions/BankingTransactions.module.ts b/packages/server/src/modules/BankingTransactions/BankingTransactions.module.ts index eaf517811..6d629c641 100644 --- a/packages/server/src/modules/BankingTransactions/BankingTransactions.module.ts +++ b/packages/server/src/modules/BankingTransactions/BankingTransactions.module.ts @@ -82,7 +82,7 @@ const models = [ ...models, RemovePendingUncategorizedTransaction, CommandBankTransactionValidator, - CreateBankTransactionService + CreateBankTransactionService, ], }) -export class BankingTransactionsModule { } +export class BankingTransactionsModule {} diff --git a/packages/server/src/modules/BankingTransactions/commands/BankTransactionGLEntries.ts b/packages/server/src/modules/BankingTransactions/commands/BankTransactionGLEntries.ts index 287ceacbb..c935c800f 100644 --- a/packages/server/src/modules/BankingTransactions/commands/BankTransactionGLEntries.ts +++ b/packages/server/src/modules/BankingTransactions/commands/BankTransactionGLEntries.ts @@ -11,7 +11,9 @@ export class BankTransactionGLEntriesService { private readonly ledgerStorage: LedgerStorageService, @Inject(BankTransaction.name) - private readonly bankTransactionModel: TenantModelProxy, + private readonly bankTransactionModel: TenantModelProxy< + typeof BankTransaction + >, ) {} /** diff --git a/packages/server/src/modules/BankingTransactions/commands/CommandCasflowValidator.service.ts b/packages/server/src/modules/BankingTransactions/commands/CommandCasflowValidator.service.ts index 5b1c86e4d..5571c7d53 100644 --- a/packages/server/src/modules/BankingTransactions/commands/CommandCasflowValidator.service.ts +++ b/packages/server/src/modules/BankingTransactions/commands/CommandCasflowValidator.service.ts @@ -19,14 +19,14 @@ export class CommandBankTransactionValidator { */ public validateCreditAccountWithCashflowType = ( creditAccount: Account, - cashflowTransactionType: CASHFLOW_TRANSACTION_TYPE + cashflowTransactionType: CASHFLOW_TRANSACTION_TYPE, ): void => { const transactionTypeMeta = getCashflowTransactionType( - cashflowTransactionType + cashflowTransactionType, ); const noneCashflowAccount = !includes( transactionTypeMeta.creditType, - creditAccount.accountType + creditAccount.accountType, ); if (noneCashflowAccount) { throw new ServiceError(ERRORS.CREDIT_ACCOUNTS_HAS_INVALID_TYPE); @@ -40,7 +40,7 @@ export class CommandBankTransactionValidator { */ public validateCashflowTransactionType = (transactionType: string) => { const transformedType = upperFirst( - camelCase(transactionType) + camelCase(transactionType), ) as CASHFLOW_TRANSACTION_TYPE; // Retrieve the given transaction type meta. @@ -58,7 +58,7 @@ export class CommandBankTransactionValidator { * @param {CashflowTransaction} cashflowTransaction */ public validateTransactionShouldCategorized( - cashflowTransaction: BankTransaction + cashflowTransaction: BankTransaction, ) { if (!cashflowTransaction.uncategorize) { throw new ServiceError(ERRORS.TRANSACTION_ALREADY_CATEGORIZED); @@ -70,7 +70,7 @@ export class CommandBankTransactionValidator { * @param {CashflowTransaction} cashflowTransaction */ public validateTransactionsShouldNotCategorized( - cashflowTransactions: Array + cashflowTransactions: Array, ) { const categorized = cashflowTransactions.filter((t) => t.categorized); @@ -89,14 +89,14 @@ export class CommandBankTransactionValidator { */ public validateUncategorizeTransactionType( uncategorizeTransactions: Array, - transactionType: string + transactionType: string, ) { const amount = sumBy(uncategorizeTransactions, 'amount'); const isDepositTransaction = amount > 0; const isWithdrawalTransaction = amount <= 0; const type = getCashflowTransactionType( - transactionType as CASHFLOW_TRANSACTION_TYPE + transactionType as CASHFLOW_TRANSACTION_TYPE, ); if ( (type.direction === CASHFLOW_DIRECTION.IN && isDepositTransaction) || diff --git a/packages/server/src/modules/BankingTransactions/controllers/BankingUncategorizedTransactions.controller.ts b/packages/server/src/modules/BankingTransactions/controllers/BankingUncategorizedTransactions.controller.ts index 3a6e4b727..29d5caed7 100644 --- a/packages/server/src/modules/BankingTransactions/controllers/BankingUncategorizedTransactions.controller.ts +++ b/packages/server/src/modules/BankingTransactions/controllers/BankingUncategorizedTransactions.controller.ts @@ -34,7 +34,9 @@ export class BankingUncategorizedTransactionsController { @ApiResponse({ status: 200, description: 'Returns autofill values for categorize transactions', - schema: { $ref: getSchemaPath(GetAutofillCategorizeTransactionResponseDto) }, + schema: { + $ref: getSchemaPath(GetAutofillCategorizeTransactionResponseDto), + }, }) async getAutofillCategorizeTransaction( @Query('uncategorizedTransactionIds') diff --git a/packages/server/src/modules/BankingTransactions/dtos/GetAutofillCategorizeTransactionResponse.dto.ts b/packages/server/src/modules/BankingTransactions/dtos/GetAutofillCategorizeTransactionResponse.dto.ts index 031f1017e..fe4f0def6 100644 --- a/packages/server/src/modules/BankingTransactions/dtos/GetAutofillCategorizeTransactionResponse.dto.ts +++ b/packages/server/src/modules/BankingTransactions/dtos/GetAutofillCategorizeTransactionResponse.dto.ts @@ -13,7 +13,10 @@ export class GetAutofillCategorizeTransactionResponseDto { }) debitAccountId?: number | null; - @ApiProperty({ description: 'Total amount of uncategorized transactions', example: -150.5 }) + @ApiProperty({ + description: 'Total amount of uncategorized transactions', + example: -150.5, + }) amount: number; @ApiProperty({ description: 'Formatted amount', example: '$150.50' }) @@ -25,25 +28,43 @@ export class GetAutofillCategorizeTransactionResponseDto { @ApiProperty({ description: 'Formatted date', example: 'Jan 15, 2024' }) formattedDate: string; - @ApiProperty({ description: 'Whether the transaction is recognized by a rule', example: true }) + @ApiProperty({ + description: 'Whether the transaction is recognized by a rule', + example: true, + }) isRecognized: boolean; - @ApiPropertyOptional({ description: 'Bank rule ID that recognized the transaction', example: 1 }) + @ApiPropertyOptional({ + description: 'Bank rule ID that recognized the transaction', + example: 1, + }) recognizedByRuleId?: number | null; - @ApiPropertyOptional({ description: 'Bank rule name that recognized the transaction', example: 'Salary Rule' }) + @ApiPropertyOptional({ + description: 'Bank rule name that recognized the transaction', + example: 'Salary Rule', + }) recognizedByRuleName?: string | null; @ApiPropertyOptional({ description: 'Reference number', example: 'REF-001' }) referenceNo?: string | null; - @ApiProperty({ description: 'Transaction type (category)', example: 'other_expense' }) + @ApiProperty({ + description: 'Transaction type (category)', + example: 'other_expense', + }) transactionType: string; - @ApiProperty({ description: 'Whether this is a deposit transaction', example: false }) + @ApiProperty({ + description: 'Whether this is a deposit transaction', + example: false, + }) isDepositTransaction: boolean; - @ApiProperty({ description: 'Whether this is a withdrawal transaction', example: true }) + @ApiProperty({ + description: 'Whether this is a withdrawal transaction', + example: true, + }) isWithdrawalTransaction: boolean; @ApiPropertyOptional({ description: 'Assigned payee from recognition' }) diff --git a/packages/server/src/modules/BankingTransactions/dtos/GetBankTranasctionsQuery.dto.ts b/packages/server/src/modules/BankingTransactions/dtos/GetBankTranasctionsQuery.dto.ts index 8d8356103..ad0b82314 100644 --- a/packages/server/src/modules/BankingTransactions/dtos/GetBankTranasctionsQuery.dto.ts +++ b/packages/server/src/modules/BankingTransactions/dtos/GetBankTranasctionsQuery.dto.ts @@ -16,7 +16,7 @@ export class GetBankTransactionsQueryDto { description: 'Page number for pagination', required: false, type: Number, - example: 1 + example: 1, }) page: number; @@ -27,7 +27,7 @@ export class GetBankTransactionsQueryDto { description: 'Number of items per page', required: false, type: Number, - example: 10 + example: 10, }) pageSize: number; @@ -38,7 +38,7 @@ export class GetBankTransactionsQueryDto { description: 'Bank account ID', required: true, type: Number, - example: 1 + example: 1, }) accountId: number; @@ -46,7 +46,7 @@ export class GetBankTransactionsQueryDto { @ApiProperty({ description: 'Number format options', required: false, - type: NumberFormatQueryDto + type: NumberFormatQueryDto, }) numberFormat: NumberFormatQueryDto; } diff --git a/packages/server/src/modules/BankingTransactions/dtos/GetPendingTransactionsQuery.dto.ts b/packages/server/src/modules/BankingTransactions/dtos/GetPendingTransactionsQuery.dto.ts index 61e141ea6..562a8eef6 100644 --- a/packages/server/src/modules/BankingTransactions/dtos/GetPendingTransactionsQuery.dto.ts +++ b/packages/server/src/modules/BankingTransactions/dtos/GetPendingTransactionsQuery.dto.ts @@ -1,5 +1,5 @@ -import { IsOptional } from "class-validator"; -import { ApiProperty } from "@nestjs/swagger"; +import { IsOptional } from 'class-validator'; +import { ApiProperty } from '@nestjs/swagger'; export class GetPendingTransactionsQueryDto { @IsOptional() @@ -7,7 +7,7 @@ export class GetPendingTransactionsQueryDto { description: 'Page number for pagination', required: false, type: Number, - example: 1 + example: 1, }) page?: number; @@ -16,7 +16,7 @@ export class GetPendingTransactionsQueryDto { description: 'Number of items per page', required: false, type: Number, - example: 10 + example: 10, }) pageSize?: number; @@ -25,7 +25,7 @@ export class GetPendingTransactionsQueryDto { description: 'Filter by bank account ID', required: false, type: Number, - example: 1 + example: 1, }) accountId?: number; } diff --git a/packages/server/src/modules/BankingTransactions/dtos/GetUncategorizedTransactionsQuery.dto.ts b/packages/server/src/modules/BankingTransactions/dtos/GetUncategorizedTransactionsQuery.dto.ts index a06e4ac39..fb1b5e9fd 100644 --- a/packages/server/src/modules/BankingTransactions/dtos/GetUncategorizedTransactionsQuery.dto.ts +++ b/packages/server/src/modules/BankingTransactions/dtos/GetUncategorizedTransactionsQuery.dto.ts @@ -7,7 +7,7 @@ export class GetUncategorizedTransactionsQueryDto { description: 'Page number for pagination', required: false, type: Number, - example: 1 + example: 1, }) page?: number; @@ -16,7 +16,7 @@ export class GetUncategorizedTransactionsQueryDto { description: 'Number of items per page', required: false, type: Number, - example: 10 + example: 10, }) pageSize?: number; @@ -25,7 +25,7 @@ export class GetUncategorizedTransactionsQueryDto { description: 'Minimum date for filtering transactions', required: false, type: Date, - example: '2023-01-01' + example: '2023-01-01', }) minDate?: Date; @@ -34,7 +34,7 @@ export class GetUncategorizedTransactionsQueryDto { description: 'Maximum date for filtering transactions', required: false, type: Date, - example: '2023-12-31' + example: '2023-12-31', }) maxDate?: Date; @@ -43,7 +43,7 @@ export class GetUncategorizedTransactionsQueryDto { description: 'Minimum amount for filtering transactions', required: false, type: Number, - example: 100 + example: 100, }) minAmount?: number; @@ -52,7 +52,7 @@ export class GetUncategorizedTransactionsQueryDto { description: 'Maximum amount for filtering transactions', required: false, type: Number, - example: 1000 + example: 1000, }) maxAmount?: number; } diff --git a/packages/server/src/modules/BankingTransactions/models/BankTransactionLine.ts b/packages/server/src/modules/BankingTransactions/models/BankTransactionLine.ts index a286bbfa7..b96dac441 100644 --- a/packages/server/src/modules/BankingTransactions/models/BankTransactionLine.ts +++ b/packages/server/src/modules/BankingTransactions/models/BankTransactionLine.ts @@ -2,7 +2,7 @@ import { Model } from 'objection'; import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel'; -export class BankTransactionLine extends TenantBaseModel{ +export class BankTransactionLine extends TenantBaseModel { /** * Table name. */ diff --git a/packages/server/src/modules/BankingTransactions/models/UncategorizedBankTransaction.meta.ts b/packages/server/src/modules/BankingTransactions/models/UncategorizedBankTransaction.meta.ts index 35e712c4b..7e88199ca 100644 --- a/packages/server/src/modules/BankingTransactions/models/UncategorizedBankTransaction.meta.ts +++ b/packages/server/src/modules/BankingTransactions/models/UncategorizedBankTransaction.meta.ts @@ -69,4 +69,4 @@ export const UncategorizedBankTransactionMeta = { required: true, }, }, -}; \ No newline at end of file +}; diff --git a/packages/server/src/modules/BankingTransactions/queries/BankTransactionsTransformer.ts b/packages/server/src/modules/BankingTransactions/queries/BankTransactionsTransformer.ts index dcf0b3056..29ea3c29a 100644 --- a/packages/server/src/modules/BankingTransactions/queries/BankTransactionsTransformer.ts +++ b/packages/server/src/modules/BankingTransactions/queries/BankTransactionsTransformer.ts @@ -1,4 +1,4 @@ -import { Transformer } from "@/modules/Transformer/Transformer"; +import { Transformer } from '@/modules/Transformer/Transformer'; export class BankTransactionsTransformer extends Transformer { /** diff --git a/packages/server/src/modules/BankingTransactions/queries/GetBankAccountTransactions/GetBankAccountTransactions.service.ts b/packages/server/src/modules/BankingTransactions/queries/GetBankAccountTransactions/GetBankAccountTransactions.service.ts index 510001435..2054d0a47 100644 --- a/packages/server/src/modules/BankingTransactions/queries/GetBankAccountTransactions/GetBankAccountTransactions.service.ts +++ b/packages/server/src/modules/BankingTransactions/queries/GetBankAccountTransactions/GetBankAccountTransactions.service.ts @@ -19,9 +19,7 @@ export class GetBankAccountTransactionsService { * @param {ICashflowAccountTransactionsQuery} query - * @return {Promise} */ - public async bankAccountTransactions( - query: GetBankTransactionsQueryDto, - ) { + public async bankAccountTransactions(query: GetBankTransactionsQueryDto) { const parsedQuery = { ...getBankAccountTransactionsDefaultQuery(), ...query, diff --git a/packages/server/src/modules/BankingTransactions/queries/GetBankAccountTransactions/_constants.ts b/packages/server/src/modules/BankingTransactions/queries/GetBankAccountTransactions/_constants.ts index 478ae88ee..298cbe801 100644 --- a/packages/server/src/modules/BankingTransactions/queries/GetBankAccountTransactions/_constants.ts +++ b/packages/server/src/modules/BankingTransactions/queries/GetBankAccountTransactions/_constants.ts @@ -6,4 +6,4 @@ export enum BankTransactionStatus { Categorized = 'categorized', Matched = 'matched', Manual = 'manual', -} \ No newline at end of file +} diff --git a/packages/server/src/modules/BankingTransactions/queries/GetUncategorizedTransactions.ts b/packages/server/src/modules/BankingTransactions/queries/GetUncategorizedTransactions.ts index bec164ec1..7a97632df 100644 --- a/packages/server/src/modules/BankingTransactions/queries/GetUncategorizedTransactions.ts +++ b/packages/server/src/modules/BankingTransactions/queries/GetUncategorizedTransactions.ts @@ -8,8 +8,8 @@ import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel'; @Injectable() export class GetUncategorizedTransactions { /** - * @param {TransformerInjectable} transformer - * @param {UncategorizedBankTransaction.name} uncategorizedBankTransactionModel + * @param {TransformerInjectable} transformer + * @param {UncategorizedBankTransaction.name} uncategorizedBankTransactionModel */ constructor( private readonly transformer: TransformerInjectable, diff --git a/packages/server/src/modules/BankingTransactions/subscribers/CashflowWithAccountSubscriber.ts b/packages/server/src/modules/BankingTransactions/subscribers/CashflowWithAccountSubscriber.ts index ebc152685..ebdde5728 100644 --- a/packages/server/src/modules/BankingTransactions/subscribers/CashflowWithAccountSubscriber.ts +++ b/packages/server/src/modules/BankingTransactions/subscribers/CashflowWithAccountSubscriber.ts @@ -20,7 +20,7 @@ export class CashflowWithAccountSubscriber { oldAccount, }: IAccountEventDeletePayload) { await this.validateDeleteBankAccount.validateAccountHasNoCashflowEntries( - oldAccount.id + oldAccount.id, ); - }; + } } diff --git a/packages/server/src/modules/BankingTransactions/subscribers/DeleteCashflowTransactionOnUncategorize.ts b/packages/server/src/modules/BankingTransactions/subscribers/DeleteCashflowTransactionOnUncategorize.ts index c5b8d37d0..e6765aaab 100644 --- a/packages/server/src/modules/BankingTransactions/subscribers/DeleteCashflowTransactionOnUncategorize.ts +++ b/packages/server/src/modules/BankingTransactions/subscribers/DeleteCashflowTransactionOnUncategorize.ts @@ -29,7 +29,7 @@ export class DeleteCashflowTransactionOnUncategorizeSubscriber { } await this.deleteCashflowTransactionService.deleteCashflowTransaction( oldMainUncategorizedTransaction.categorizeRefId, - trx + trx, ); } } diff --git a/packages/server/src/modules/BankingTransactions/types/BankingTransactions.types.ts b/packages/server/src/modules/BankingTransactions/types/BankingTransactions.types.ts index 9e611b8fa..f0f90c013 100644 --- a/packages/server/src/modules/BankingTransactions/types/BankingTransactions.types.ts +++ b/packages/server/src/modules/BankingTransactions/types/BankingTransactions.types.ts @@ -164,4 +164,4 @@ export interface ICashflowAccountTransaction { formattedStatus: string; uncategorizedTransactionId: number; -} \ No newline at end of file +} diff --git a/packages/server/src/modules/BankingTransactionsExclude/BankingTransactionsExclude.controller.ts b/packages/server/src/modules/BankingTransactionsExclude/BankingTransactionsExclude.controller.ts index c3d3c27f2..1983589dc 100644 --- a/packages/server/src/modules/BankingTransactionsExclude/BankingTransactionsExclude.controller.ts +++ b/packages/server/src/modules/BankingTransactionsExclude/BankingTransactionsExclude.controller.ts @@ -23,7 +23,11 @@ import { GetExcludedBankTransactionsQueryDto } from './dtos/GetExcludedBankTrans @Controller('banking/exclude') @ApiTags('Banking Transactions') -@ApiExtraModels(GetExcludedBankTransactionResponseDto, ExcludeBankTransactionsBulkDto, PaginatedResponseDto) +@ApiExtraModels( + GetExcludedBankTransactionResponseDto, + ExcludeBankTransactionsBulkDto, + PaginatedResponseDto, +) @ApiCommonHeaders() export class BankingTransactionsExcludeController { constructor( @@ -32,7 +36,10 @@ export class BankingTransactionsExcludeController { @Put('bulk') @ApiOperation({ summary: 'Exclude the given bank transactions.' }) - @ApiResponse({ status: 200, description: 'Bank transactions excluded successfully.' }) + @ApiResponse({ + status: 200, + description: 'Bank transactions excluded successfully.', + }) public excludeBankTransactions(@Body() body: ExcludeBankTransactionsBulkDto) { return this.excludeBankTransactionsApplication.excludeBankTransactions( body.ids, @@ -41,8 +48,13 @@ export class BankingTransactionsExcludeController { @Delete('bulk') @ApiOperation({ summary: 'Unexclude the given bank transactions.' }) - @ApiResponse({ status: 200, description: 'Bank transactions unexcluded successfully.' }) - public unexcludeBankTransactions(@Body() body: ExcludeBankTransactionsBulkDto) { + @ApiResponse({ + status: 200, + description: 'Bank transactions unexcluded successfully.', + }) + public unexcludeBankTransactions( + @Body() body: ExcludeBankTransactionsBulkDto, + ) { return this.excludeBankTransactionsApplication.unexcludeBankTransactions( body.ids, ); @@ -61,7 +73,9 @@ export class BankingTransactionsExcludeController { properties: { data: { type: 'array', - items: { $ref: getSchemaPath(GetExcludedBankTransactionResponseDto) }, + items: { + $ref: getSchemaPath(GetExcludedBankTransactionResponseDto), + }, }, }, }, diff --git a/packages/server/src/modules/BankingTransactionsExclude/BankingTransactionsExclude.module.ts b/packages/server/src/modules/BankingTransactionsExclude/BankingTransactionsExclude.module.ts index a0a332ec6..82f15d75b 100644 --- a/packages/server/src/modules/BankingTransactionsExclude/BankingTransactionsExclude.module.ts +++ b/packages/server/src/modules/BankingTransactionsExclude/BankingTransactionsExclude.module.ts @@ -10,9 +10,7 @@ import { BankingTransactionsExcludeController } from './BankingTransactionsExclu import { BankingTransactionsModule } from '../BankingTransactions/BankingTransactions.module'; @Module({ - imports: [ - forwardRef(() => BankingTransactionsModule), - ], + imports: [forwardRef(() => BankingTransactionsModule)], providers: [ ExcludeBankTransactionsApplication, ExcludeBankTransactionService, @@ -20,7 +18,7 @@ import { BankingTransactionsModule } from '../BankingTransactions/BankingTransac GetExcludedBankTransactionsService, ExcludeBankTransactionsService, UnexcludeBankTransactionsService, - DecrementUncategorizedTransactionOnExclude + DecrementUncategorizedTransactionOnExclude, ], controllers: [BankingTransactionsExcludeController], }) diff --git a/packages/server/src/modules/BankingTransactionsExclude/commands/UnexcludeBankTransaction.service.ts b/packages/server/src/modules/BankingTransactionsExclude/commands/UnexcludeBankTransaction.service.ts index 3a3ec6d75..6800096c6 100644 --- a/packages/server/src/modules/BankingTransactionsExclude/commands/UnexcludeBankTransaction.service.ts +++ b/packages/server/src/modules/BankingTransactionsExclude/commands/UnexcludeBankTransaction.service.ts @@ -24,7 +24,7 @@ export class UnexcludeBankTransactionService { private readonly uncategorizedBankTransactionModel: TenantModelProxy< typeof UncategorizedBankTransaction >, - ) { } + ) {} /** * Marks the given bank transaction as excluded. diff --git a/packages/server/src/modules/BankingTransactionsExclude/commands/UnexcludeBankTransactions.service.ts b/packages/server/src/modules/BankingTransactionsExclude/commands/UnexcludeBankTransactions.service.ts index 357f7e485..15515ff00 100644 --- a/packages/server/src/modules/BankingTransactionsExclude/commands/UnexcludeBankTransactions.service.ts +++ b/packages/server/src/modules/BankingTransactionsExclude/commands/UnexcludeBankTransactions.service.ts @@ -14,7 +14,7 @@ export class UnexcludeBankTransactionsService { * @param {Array | number} bankTransactionIds - The IDs of the bank transactions to unexclude. */ public async unexcludeBankTransactions( - bankTransactionIds: Array | number + bankTransactionIds: Array | number, ) { const _bankTransactionIds = uniq(castArray(bankTransactionIds)); @@ -22,7 +22,7 @@ export class UnexcludeBankTransactionsService { .for(_bankTransactionIds) .process((bankTransactionId: number) => { return this.unexcludeBankTransaction.unexcludeBankTransaction( - bankTransactionId + bankTransactionId, ); }); } diff --git a/packages/server/src/modules/BankingTransactionsExclude/commands/utils.ts b/packages/server/src/modules/BankingTransactionsExclude/commands/utils.ts index 67fe62869..ce366a11b 100644 --- a/packages/server/src/modules/BankingTransactionsExclude/commands/utils.ts +++ b/packages/server/src/modules/BankingTransactionsExclude/commands/utils.ts @@ -1,5 +1,5 @@ -import { UncategorizedBankTransaction } from "@/modules/BankingTransactions/models/UncategorizedBankTransaction"; -import { ServiceError } from "@/modules/Items/ServiceError"; +import { UncategorizedBankTransaction } from '@/modules/BankingTransactions/models/UncategorizedBankTransaction'; +import { ServiceError } from '@/modules/Items/ServiceError'; const ERRORS = { TRANSACTION_ALREADY_CATEGORIZED: 'TRANSACTION_ALREADY_CATEGORIZED', @@ -8,7 +8,7 @@ const ERRORS = { }; export const validateTransactionNotCategorized = ( - transaction: UncategorizedBankTransaction + transaction: UncategorizedBankTransaction, ) => { if (transaction.categorized) { throw new ServiceError(ERRORS.TRANSACTION_ALREADY_CATEGORIZED); @@ -16,7 +16,7 @@ export const validateTransactionNotCategorized = ( }; export const validateTransactionNotExcluded = ( - transaction: UncategorizedBankTransaction + transaction: UncategorizedBankTransaction, ) => { if (transaction.isExcluded) { throw new ServiceError(ERRORS.TRANSACTION_ALREADY_EXCLUDED); @@ -24,7 +24,7 @@ export const validateTransactionNotExcluded = ( }; export const validateTransactionShouldBeExcluded = ( - transaction: UncategorizedBankTransaction + transaction: UncategorizedBankTransaction, ) => { if (!transaction.isExcluded) { throw new ServiceError(ERRORS.TRANSACTION_NOT_EXCLUDED); diff --git a/packages/server/src/modules/BankingTransactionsExclude/dtos/ExcludeBankTransactionsBulk.dto.ts b/packages/server/src/modules/BankingTransactionsExclude/dtos/ExcludeBankTransactionsBulk.dto.ts index 85671632f..78c5f64c0 100644 --- a/packages/server/src/modules/BankingTransactionsExclude/dtos/ExcludeBankTransactionsBulk.dto.ts +++ b/packages/server/src/modules/BankingTransactionsExclude/dtos/ExcludeBankTransactionsBulk.dto.ts @@ -4,7 +4,8 @@ import { Type } from 'class-transformer'; export class ExcludeBankTransactionsBulkDto { @ApiProperty({ - description: 'IDs of uncategorized bank transactions to exclude or unexclude', + description: + 'IDs of uncategorized bank transactions to exclude or unexclude', type: [Number], example: [1, 2, 3], }) diff --git a/packages/server/src/modules/BankingTransactionsExclude/dtos/GetExcludedBankTransactionsQuery.dto.ts b/packages/server/src/modules/BankingTransactionsExclude/dtos/GetExcludedBankTransactionsQuery.dto.ts index a6abd165b..67e97fcf0 100644 --- a/packages/server/src/modules/BankingTransactionsExclude/dtos/GetExcludedBankTransactionsQuery.dto.ts +++ b/packages/server/src/modules/BankingTransactionsExclude/dtos/GetExcludedBankTransactionsQuery.dto.ts @@ -21,12 +21,18 @@ export class GetExcludedBankTransactionsQueryDto { @IsNumber() accountId?: number; - @ApiPropertyOptional({ description: 'Minimum date (ISO)', example: '2024-01-01' }) + @ApiPropertyOptional({ + description: 'Minimum date (ISO)', + example: '2024-01-01', + }) @IsOptional() @IsDateString() minDate?: string; - @ApiPropertyOptional({ description: 'Maximum date (ISO)', example: '2024-12-31' }) + @ApiPropertyOptional({ + description: 'Maximum date (ISO)', + example: '2024-12-31', + }) @IsOptional() @IsDateString() maxDate?: string; diff --git a/packages/server/src/modules/BankingTransactionsExclude/subscribers/DecrementUncategorizedTransactionOnExclude.ts b/packages/server/src/modules/BankingTransactionsExclude/subscribers/DecrementUncategorizedTransactionOnExclude.ts index fc97d259a..efb859a5d 100644 --- a/packages/server/src/modules/BankingTransactionsExclude/subscribers/DecrementUncategorizedTransactionOnExclude.ts +++ b/packages/server/src/modules/BankingTransactionsExclude/subscribers/DecrementUncategorizedTransactionOnExclude.ts @@ -19,7 +19,7 @@ export class DecrementUncategorizedTransactionOnExclude { private readonly uncategorizedBankTransaction: TenantModelProxy< typeof UncategorizedBankTransaction >, - ) { } + ) {} /** * Validates the cashflow transaction whether matched with bank transaction on deleting. diff --git a/packages/server/src/modules/BankingTransactionsExclude/types/BankTransactionsExclude.types.ts b/packages/server/src/modules/BankingTransactionsExclude/types/BankTransactionsExclude.types.ts index 4bd23b98a..dfeba3820 100644 --- a/packages/server/src/modules/BankingTransactionsExclude/types/BankTransactionsExclude.types.ts +++ b/packages/server/src/modules/BankingTransactionsExclude/types/BankTransactionsExclude.types.ts @@ -1,4 +1,4 @@ -import { Knex } from "knex"; +import { Knex } from 'knex'; export interface ExcludedBankTransactionsQuery { page?: number; @@ -12,19 +12,19 @@ export interface ExcludedBankTransactionsQuery { export interface IBankTransactionUnexcludingEventPayload { uncategorizedTransactionId: number; - trx?: Knex.Transaction + trx?: Knex.Transaction; } export interface IBankTransactionUnexcludedEventPayload { uncategorizedTransactionId: number; - trx?: Knex.Transaction + trx?: Knex.Transaction; } export interface IBankTransactionExcludingEventPayload { uncategorizedTransactionId: number; - trx?: Knex.Transaction + trx?: Knex.Transaction; } export interface IBankTransactionExcludedEventPayload { uncategorizedTransactionId: number; - trx?: Knex.Transaction + trx?: Knex.Transaction; } diff --git a/packages/server/src/modules/BankingTransactionsExclude/utils.ts b/packages/server/src/modules/BankingTransactionsExclude/utils.ts index f07be91ec..9af315624 100644 --- a/packages/server/src/modules/BankingTransactionsExclude/utils.ts +++ b/packages/server/src/modules/BankingTransactionsExclude/utils.ts @@ -1,7 +1,8 @@ import { UncategorizedBankTransaction } from '../BankingTransactions/models/UncategorizedBankTransaction'; import { ServiceError } from '../Items/ServiceError'; -const ERRORS = { TRANSACTION_ALREADY_CATEGORIZED: 'TRANSACTION_ALREADY_CATEGORIZED', +const ERRORS = { + TRANSACTION_ALREADY_CATEGORIZED: 'TRANSACTION_ALREADY_CATEGORIZED', TRANSACTION_ALREADY_EXCLUDED: 'TRANSACTION_ALREADY_EXCLUDED', TRANSACTION_NOT_EXCLUDED: 'TRANSACTION_NOT_EXCLUDED', }; diff --git a/packages/server/src/modules/BillLandedCosts/LandedCost.controller.ts b/packages/server/src/modules/BillLandedCosts/LandedCost.controller.ts index bed8535b0..6ed7ed8a5 100644 --- a/packages/server/src/modules/BillLandedCosts/LandedCost.controller.ts +++ b/packages/server/src/modules/BillLandedCosts/LandedCost.controller.ts @@ -25,7 +25,7 @@ export class BillAllocateLandedCostController { private billAllocatedCostTransactions: BillAllocatedLandedCostTransactions, private revertAllocatedLandedCost: RevertAllocatedLandedCost, private landedCostTransactions: LandedCostTranasctions, - ) { } + ) {} @Get('/transactions') @ApiOperation({ summary: 'Get landed cost transactions' }) diff --git a/packages/server/src/modules/BillLandedCosts/commands/BillAllocatedLandedCostTransactions.service.ts b/packages/server/src/modules/BillLandedCosts/commands/BillAllocatedLandedCostTransactions.service.ts index a50af6284..5e18ea2f5 100644 --- a/packages/server/src/modules/BillLandedCosts/commands/BillAllocatedLandedCostTransactions.service.ts +++ b/packages/server/src/modules/BillLandedCosts/commands/BillAllocatedLandedCostTransactions.service.ts @@ -21,7 +21,7 @@ export class BillAllocatedLandedCostTransactions { private readonly billLandedCostModel: TenantModelProxy< typeof BillLandedCost >, - ) { } + ) {} /** * Retrieve the bill associated landed cost transactions. @@ -80,8 +80,8 @@ export class BillAllocatedLandedCostTransactions { const allocationMethodFormattedKey = transaction.allocationMethodFormatted; const allocationMethodFormatted = allocationMethodFormattedKey ? this.i18nService.t(allocationMethodFormattedKey, { - defaultValue: allocationMethodFormattedKey, - }) + defaultValue: allocationMethodFormattedKey, + }) : ''; return { diff --git a/packages/server/src/modules/BillLandedCosts/commands/LandedCostSyncCostTransactions.service.ts b/packages/server/src/modules/BillLandedCosts/commands/LandedCostSyncCostTransactions.service.ts index 1b0480ec2..d2f6645a0 100644 --- a/packages/server/src/modules/BillLandedCosts/commands/LandedCostSyncCostTransactions.service.ts +++ b/packages/server/src/modules/BillLandedCosts/commands/LandedCostSyncCostTransactions.service.ts @@ -5,9 +5,7 @@ import { TransactionLandedCost } from './TransctionLandedCost.service'; @Injectable() export class LandedCostSyncCostTransactions { - constructor( - private readonly transactionLandedCost: TransactionLandedCost, - ) {} + constructor(private readonly transactionLandedCost: TransactionLandedCost) {} /** * Allocate the landed cost amount to cost transactions. @@ -19,20 +17,20 @@ export class LandedCostSyncCostTransactions { transactionId: number, transactionEntryId: number, amount: number, - trx?: Knex.Transaction + trx?: Knex.Transaction, ): Promise => { - const Model = await this.transactionLandedCost.getModel( - transactionType - ); + const Model = await this.transactionLandedCost.getModel(transactionType); const relation = CONFIG.COST_TYPES[transactionType].entries; // Increment the landed cost transaction amount. - await Model().query(trx) + await Model() + .query(trx) .where('id', transactionId) .increment('allocatedCostAmount', amount); // Increment the landed cost entry. - await Model().relatedQuery(relation, trx) + await Model() + .relatedQuery(relation, trx) .for(transactionId) .where('id', transactionEntryId) .increment('allocatedCostAmount', amount); @@ -51,22 +49,22 @@ export class LandedCostSyncCostTransactions { transactionId: number, transactionEntryId: number, amount: number, - trx?: Knex.Transaction + trx?: Knex.Transaction, ) => { - const Model = await this.transactionLandedCost.getModel( - transactionType - ); + const Model = await this.transactionLandedCost.getModel(transactionType); const relation = CONFIG.COST_TYPES[transactionType].entries; // Decrement the allocate cost amount of cost transaction. - await Model().query(trx) + await Model() + .query(trx) .where('id', transactionId) .decrement('allocatedCostAmount', amount); // Decrement the allocated cost amount cost transaction entry. - await Model().relatedQuery(relation, trx) + await Model() + .relatedQuery(relation, trx) .for(transactionId) .where('id', transactionEntryId) .decrement('allocatedCostAmount', amount); }; -} \ No newline at end of file +} diff --git a/packages/server/src/modules/BillLandedCosts/commands/LandedCostTransactions.service.ts b/packages/server/src/modules/BillLandedCosts/commands/LandedCostTransactions.service.ts index 6b866779c..5d88d6134 100644 --- a/packages/server/src/modules/BillLandedCosts/commands/LandedCostTransactions.service.ts +++ b/packages/server/src/modules/BillLandedCosts/commands/LandedCostTransactions.service.ts @@ -14,7 +14,7 @@ import { LandedCostTransactionsQueryDto } from '../dtos/LandedCostTransactionsQu @Injectable() export class LandedCostTranasctions { - constructor(private readonly transactionLandedCost: TransactionLandedCost) { } + constructor(private readonly transactionLandedCost: TransactionLandedCost) {} /** * Retrieve the landed costs based on the given query. diff --git a/packages/server/src/modules/BillLandedCosts/commands/TransctionLandedCost.service.ts b/packages/server/src/modules/BillLandedCosts/commands/TransctionLandedCost.service.ts index e328658e0..2b49fe705 100644 --- a/packages/server/src/modules/BillLandedCosts/commands/TransctionLandedCost.service.ts +++ b/packages/server/src/modules/BillLandedCosts/commands/TransctionLandedCost.service.ts @@ -51,22 +51,21 @@ export class TransactionLandedCost { * @param {IBill|IExpense} transaction - Expense or bill transaction. * @returns {ILandedCostTransaction} */ - public transformToLandedCost = - ( - transactionType: LandedCostTransactionType, - transaction: LandedCostTransactionModel, - ): ILandedCostTransaction => { - return R.compose( - R.when( - R.always(transactionType === 'Bill'), - this.billLandedCost.transformToLandedCost, - ), - R.when( - R.always(transactionType === 'Expense'), - this.expenseLandedCost.transformToLandedCost, - ), - )(transaction) as ILandedCostTransaction; - }; + public transformToLandedCost = ( + transactionType: LandedCostTransactionType, + transaction: LandedCostTransactionModel, + ): ILandedCostTransaction => { + return R.compose( + R.when( + R.always(transactionType === 'Bill'), + this.billLandedCost.transformToLandedCost, + ), + R.when( + R.always(transactionType === 'Expense'), + this.expenseLandedCost.transformToLandedCost, + ), + )(transaction) as ILandedCostTransaction; + }; /** * Transformes the given expense or bill entry to landed cost transaction entry. diff --git a/packages/server/src/modules/BillLandedCosts/dtos/AllocateBillLandedCost.dto.ts b/packages/server/src/modules/BillLandedCosts/dtos/AllocateBillLandedCost.dto.ts index 2cc4f833d..c40af742b 100644 --- a/packages/server/src/modules/BillLandedCosts/dtos/AllocateBillLandedCost.dto.ts +++ b/packages/server/src/modules/BillLandedCosts/dtos/AllocateBillLandedCost.dto.ts @@ -43,4 +43,4 @@ export class AllocateBillLandedCostDto { @ValidateNested({ each: true }) @Type(() => AllocateBillLandedCostItemDto) items: AllocateBillLandedCostItemDto[]; -} \ No newline at end of file +} diff --git a/packages/server/src/modules/BillLandedCosts/dtos/LandedCostTransactionsQuery.dto.ts b/packages/server/src/modules/BillLandedCosts/dtos/LandedCostTransactionsQuery.dto.ts index 3f50a2f32..57c66b526 100644 --- a/packages/server/src/modules/BillLandedCosts/dtos/LandedCostTransactionsQuery.dto.ts +++ b/packages/server/src/modules/BillLandedCosts/dtos/LandedCostTransactionsQuery.dto.ts @@ -1,6 +1,12 @@ -import { IsDateString, IsEnum, IsIn, IsNotEmpty, IsOptional, IsString } from "class-validator"; -import { LandedCostTransactionType } from "../types/BillLandedCosts.types"; - +import { + IsDateString, + IsEnum, + IsIn, + IsNotEmpty, + IsOptional, + IsString, +} from 'class-validator'; +import { LandedCostTransactionType } from '../types/BillLandedCosts.types'; export class LandedCostTransactionsQueryDto { @IsString() @@ -11,4 +17,4 @@ export class LandedCostTransactionsQueryDto { @IsDateString() @IsOptional() date: string; -} \ No newline at end of file +} diff --git a/packages/server/src/modules/BillLandedCosts/types/BillLandedCosts.types.ts b/packages/server/src/modules/BillLandedCosts/types/BillLandedCosts.types.ts index 9ac309db5..14c23dd38 100644 --- a/packages/server/src/modules/BillLandedCosts/types/BillLandedCosts.types.ts +++ b/packages/server/src/modules/BillLandedCosts/types/BillLandedCosts.types.ts @@ -123,7 +123,6 @@ export interface IAllocatedLandedCostCreatedPayload { export interface IBillAssociatedLandedCostTransactions {} - interface ICommonEntry { id?: number; amount: number; @@ -143,6 +142,5 @@ export interface ICommonLandedCostEntryDTO extends ICommonEntryDTO { landedCost?: boolean; } - export type LandedCostTransactionType = 'Bill' | 'Expense'; -export type LandedCostTransactionModel = Bill | Expense; \ No newline at end of file +export type LandedCostTransactionModel = Bill | Expense; diff --git a/packages/server/src/modules/BillLandedCosts/utils.ts b/packages/server/src/modules/BillLandedCosts/utils.ts index e121c16cb..4502ecf71 100644 --- a/packages/server/src/modules/BillLandedCosts/utils.ts +++ b/packages/server/src/modules/BillLandedCosts/utils.ts @@ -25,7 +25,7 @@ export const ERRORS = { */ export const mergeLocatedWithBillEntries = ( locatedEntries: IBillLandedCostTransactionEntry[], - billEntries: ModelObject[] + billEntries: ModelObject[], ): (IBillLandedCostTransactionEntry & { entry: ModelObject })[] => { const billEntriesByEntryId = transformToMap(billEntries, 'id'); @@ -35,7 +35,6 @@ export const mergeLocatedWithBillEntries = ( })); }; - export const CONFIG = { COST_TYPES: { Expense: { @@ -45,4 +44,4 @@ export const CONFIG = { entries: 'entries', }, }, -}; \ No newline at end of file +}; diff --git a/packages/server/src/modules/BillPayments/BillPayments.module.ts b/packages/server/src/modules/BillPayments/BillPayments.module.ts index 5d1494cfc..ad1195060 100644 --- a/packages/server/src/modules/BillPayments/BillPayments.module.ts +++ b/packages/server/src/modules/BillPayments/BillPayments.module.ts @@ -54,4 +54,4 @@ import { BillPaymentsPages } from './commands/BillPaymentsPages.service'; ], controllers: [BillPaymentsController], }) -export class BillPaymentsModule { } +export class BillPaymentsModule {} diff --git a/packages/server/src/modules/BillPayments/BillPaymentsApplication.service.ts b/packages/server/src/modules/BillPayments/BillPaymentsApplication.service.ts index c53ed9b5c..d2091b052 100644 --- a/packages/server/src/modules/BillPayments/BillPaymentsApplication.service.ts +++ b/packages/server/src/modules/BillPayments/BillPaymentsApplication.service.ts @@ -4,7 +4,10 @@ import { DeleteBillPayment } from './commands/DeleteBillPayment.service'; import { EditBillPayment } from './commands/EditBillPayment.service'; import { GetBillPayment } from './queries/GetBillPayment.service'; import { GetPaymentBills } from './queries/GetPaymentBills.service'; -import { CreateBillPaymentDto, EditBillPaymentDto } from './dtos/BillPayment.dto'; +import { + CreateBillPaymentDto, + EditBillPaymentDto, +} from './dtos/BillPayment.dto'; import { GetBillPaymentsService } from './queries/GetBillPayments.service'; import { GetBillPaymentsFilterDto } from './dtos/GetBillPaymentsFilter.dto'; diff --git a/packages/server/src/modules/BillPayments/commands/BillPaymentGL.ts b/packages/server/src/modules/BillPayments/commands/BillPaymentGL.ts index fa96dd23e..6299f6334 100644 --- a/packages/server/src/modules/BillPayments/commands/BillPaymentGL.ts +++ b/packages/server/src/modules/BillPayments/commands/BillPaymentGL.ts @@ -176,7 +176,7 @@ export class BillPaymentGL { const exGainLossEntries = this.paymentExGainOrLossEntries; return [paymentEntry, payableEntry, ...exGainLossEntries]; - }; + } /** * Retrieves the bill payment ledger. diff --git a/packages/server/src/modules/BillPayments/commands/BillPaymentsImportable.ts b/packages/server/src/modules/BillPayments/commands/BillPaymentsImportable.ts index ad890f897..7a84797c0 100644 --- a/packages/server/src/modules/BillPayments/commands/BillPaymentsImportable.ts +++ b/packages/server/src/modules/BillPayments/commands/BillPaymentsImportable.ts @@ -11,7 +11,7 @@ import { BillPayment } from '../models/BillPayment'; @ImportableService({ name: BillPayment.name }) export class BillPaymentsImportable extends Importable { constructor( - private readonly createBillPaymentService: CreateBillPaymentService + private readonly createBillPaymentService: CreateBillPaymentService, ) { super(); } @@ -24,12 +24,9 @@ export class BillPaymentsImportable extends Importable { */ public importable( billPaymentDTO: CreateBillPaymentDto, - trx?: Knex.Transaction + trx?: Knex.Transaction, ) { - return this.createBillPaymentService.createBillPayment( - billPaymentDTO, - trx - ); + return this.createBillPaymentService.createBillPayment(billPaymentDTO, trx); } /** diff --git a/packages/server/src/modules/BillPayments/commands/BillPaymentsPages.service.ts b/packages/server/src/modules/BillPayments/commands/BillPaymentsPages.service.ts index 84c908873..056cd1b62 100644 --- a/packages/server/src/modules/BillPayments/commands/BillPaymentsPages.service.ts +++ b/packages/server/src/modules/BillPayments/commands/BillPaymentsPages.service.ts @@ -19,7 +19,7 @@ export class BillPaymentsPages { @Inject(BillPayment.name) private readonly billPaymentModel: TenantModelProxy, - ) { } + ) {} /** * Retrieve bill payment with associated metadata. diff --git a/packages/server/src/modules/BillPayments/commands/CreateBillPayment.service.ts b/packages/server/src/modules/BillPayments/commands/CreateBillPayment.service.ts index 5b9d05146..4bfcb7ed7 100644 --- a/packages/server/src/modules/BillPayments/commands/CreateBillPayment.service.ts +++ b/packages/server/src/modules/BillPayments/commands/CreateBillPayment.service.ts @@ -38,7 +38,7 @@ export class CreateBillPaymentService { @Inject(BillPayment.name) private readonly billPaymentModel: TenantModelProxy, - ) { } + ) {} /** * Creates a new bill payment transcations and store it to the storage diff --git a/packages/server/src/modules/BillPayments/commands/EditBillPayment.service.ts b/packages/server/src/modules/BillPayments/commands/EditBillPayment.service.ts index ffa2285e8..c08c65262 100644 --- a/packages/server/src/modules/BillPayments/commands/EditBillPayment.service.ts +++ b/packages/server/src/modules/BillPayments/commands/EditBillPayment.service.ts @@ -29,7 +29,7 @@ export class EditBillPayment { @Inject(Vendor.name) private readonly vendorModel: TenantModelProxy, - ) { } + ) {} /** * Edits the details of the given bill payment. diff --git a/packages/server/src/modules/BillPayments/models/BillPayment.meta.ts b/packages/server/src/modules/BillPayments/models/BillPayment.meta.ts index b602c4a9c..3206d6569 100644 --- a/packages/server/src/modules/BillPayments/models/BillPayment.meta.ts +++ b/packages/server/src/modules/BillPayments/models/BillPayment.meta.ts @@ -1,4 +1,4 @@ -import { Features } from "@/common/types/Features"; +import { Features } from '@/common/types/Features'; export const BillPaymentMeta = { defaultFilterField: 'vendor', @@ -221,4 +221,4 @@ export const BillPaymentMeta = { required: true, }, }, -}; \ No newline at end of file +}; diff --git a/packages/server/src/modules/BillPayments/queries/BillPaymentEntry.transformer.ts b/packages/server/src/modules/BillPayments/queries/BillPaymentEntry.transformer.ts index b72a1d982..8acef3d8e 100644 --- a/packages/server/src/modules/BillPayments/queries/BillPaymentEntry.transformer.ts +++ b/packages/server/src/modules/BillPayments/queries/BillPaymentEntry.transformer.ts @@ -1,7 +1,7 @@ -import { BillTransformer } from "../../Bills/queries/Bill.transformer"; -import { Transformer } from "../../Transformer/Transformer"; +import { BillTransformer } from '../../Bills/queries/Bill.transformer'; +import { Transformer } from '../../Transformer/Transformer'; -export class BillPaymentEntryTransformer extends Transformer{ +export class BillPaymentEntryTransformer extends Transformer { /** * Include these attributes to bill payment object. * @returns {Array} diff --git a/packages/server/src/modules/BillPayments/subscribers/BillPaymentBillSyncSubscriber.ts b/packages/server/src/modules/BillPayments/subscribers/BillPaymentBillSyncSubscriber.ts index ab93f5bf9..df6358886 100644 --- a/packages/server/src/modules/BillPayments/subscribers/BillPaymentBillSyncSubscriber.ts +++ b/packages/server/src/modules/BillPayments/subscribers/BillPaymentBillSyncSubscriber.ts @@ -13,7 +13,7 @@ export class BillPaymentBillSyncSubscriber { /** * @param {BillPaymentBillSync} billPaymentBillSync - Bill payment bill sync service. */ - constructor(private readonly billPaymentBillSync: BillPaymentBillSync) { } + constructor(private readonly billPaymentBillSync: BillPaymentBillSync) {} /** * Handle bill increment/decrement payment amount diff --git a/packages/server/src/modules/BillPayments/subscribers/BillPaymentGLEntriesSubscriber.ts b/packages/server/src/modules/BillPayments/subscribers/BillPaymentGLEntriesSubscriber.ts index ee92ef285..910e2cb5d 100644 --- a/packages/server/src/modules/BillPayments/subscribers/BillPaymentGLEntriesSubscriber.ts +++ b/packages/server/src/modules/BillPayments/subscribers/BillPaymentGLEntriesSubscriber.ts @@ -10,9 +10,7 @@ import { events } from '@/common/events/events'; @Injectable() export class BillPaymentGLEntriesSubscriber { - constructor( - private readonly billPaymentGLEntries: BillPaymentGLEntries, - ) {} + constructor(private readonly billPaymentGLEntries: BillPaymentGLEntries) {} /** * Handle bill payment writing journal entries once created. @@ -24,11 +22,8 @@ export class BillPaymentGLEntriesSubscriber { }: IBillPaymentEventCreatedPayload) { // Records the journal transactions after bills payment // and change diff account balance. - await this.billPaymentGLEntries.writePaymentGLEntries( - billPayment.id, - trx - ); - }; + await this.billPaymentGLEntries.writePaymentGLEntries(billPayment.id, trx); + } /** * Handle bill payment re-writing journal entries once the payment transaction be edited. @@ -40,9 +35,9 @@ export class BillPaymentGLEntriesSubscriber { }: IBillPaymentEventEditedPayload) { await this.billPaymentGLEntries.rewritePaymentGLEntries( billPayment.id, - trx + trx, ); - }; + } /** * Reverts journal entries once bill payment deleted. @@ -52,9 +47,6 @@ export class BillPaymentGLEntriesSubscriber { billPaymentId, trx, }: IBillPaymentEventDeletedPayload) { - await this.billPaymentGLEntries.revertPaymentGLEntries( - billPaymentId, - trx - ); - }; + await this.billPaymentGLEntries.revertPaymentGLEntries(billPaymentId, trx); + } } diff --git a/packages/server/src/modules/BillPayments/types/BillPayments.types.ts b/packages/server/src/modules/BillPayments/types/BillPayments.types.ts index bca7f222a..eea5c60b0 100644 --- a/packages/server/src/modules/BillPayments/types/BillPayments.types.ts +++ b/packages/server/src/modules/BillPayments/types/BillPayments.types.ts @@ -1,7 +1,10 @@ import { Knex } from 'knex'; import { BillPayment } from '../models/BillPayment'; import { AttachmentLinkDTO } from '@/modules/Attachments/Attachments.types'; -import { CreateBillPaymentDto, EditBillPaymentDto } from '../dtos/BillPayment.dto'; +import { + CreateBillPaymentDto, + EditBillPaymentDto, +} from '../dtos/BillPayment.dto'; export interface IBillReceivePageEntry { billId: number; diff --git a/packages/server/src/modules/Bills/Bills.application.ts b/packages/server/src/modules/Bills/Bills.application.ts index 9a99e49ed..834449b7c 100644 --- a/packages/server/src/modules/Bills/Bills.application.ts +++ b/packages/server/src/modules/Bills/Bills.application.ts @@ -28,7 +28,7 @@ export class BillsApplication { private getBillPaymentTransactionsService: GetBillPaymentTransactionsService, private bulkDeleteBillsService: BulkDeleteBillsService, private validateBulkDeleteBillsService: ValidateBulkDeleteBillsService, - ) { } + ) {} /** * Creates a new bill with associated GL entries. diff --git a/packages/server/src/modules/Bills/Bills.controller.ts b/packages/server/src/modules/Bills/Bills.controller.ts index 92f684a90..564d70ba2 100644 --- a/packages/server/src/modules/Bills/Bills.controller.ts +++ b/packages/server/src/modules/Bills/Bills.controller.ts @@ -44,7 +44,7 @@ import { BillAction } from './Bills.types'; @ApiExtraModels(ValidateBulkDeleteResponseDto) @UseGuards(AuthorizationGuard, PermissionGuard) export class BillsController { - constructor(private billsApplication: BillsApplication) { } + constructor(private billsApplication: BillsApplication) {} @Post('validate-bulk-delete') @RequirePermission(BillAction.Delete, AbilitySubject.Bill) @@ -74,9 +74,7 @@ export class BillsController { status: 200, description: 'Bills deleted successfully', }) - bulkDeleteBills( - @Body() bulkDeleteDto: BulkDeleteDto, - ): Promise { + bulkDeleteBills(@Body() bulkDeleteDto: BulkDeleteDto): Promise { return this.billsApplication.bulkDeleteBills(bulkDeleteDto.ids, { skipUndeletable: bulkDeleteDto.skipUndeletable ?? false, }); diff --git a/packages/server/src/modules/Bills/Bills.module.ts b/packages/server/src/modules/Bills/Bills.module.ts index 7b768f124..49337506b 100644 --- a/packages/server/src/modules/Bills/Bills.module.ts +++ b/packages/server/src/modules/Bills/Bills.module.ts @@ -71,4 +71,4 @@ import { ValidateBulkDeleteBillsService } from './ValidateBulkDeleteBills.servic controllers: [BillsController], exports: [BillsExportable, BillsImportable], }) -export class BillsModule { } +export class BillsModule {} diff --git a/packages/server/src/modules/Bills/BulkDeleteBills.service.ts b/packages/server/src/modules/Bills/BulkDeleteBills.service.ts index 338c740ce..9b088de84 100644 --- a/packages/server/src/modules/Bills/BulkDeleteBills.service.ts +++ b/packages/server/src/modules/Bills/BulkDeleteBills.service.ts @@ -6,7 +6,7 @@ import { DeleteBill } from './commands/DeleteBill.service'; @Injectable() export class BulkDeleteBillsService { - constructor(private readonly deleteBillService: DeleteBill) { } + constructor(private readonly deleteBillService: DeleteBill) {} async bulkDeleteBills( billIds: number | Array, @@ -33,4 +33,3 @@ export class BulkDeleteBillsService { } } } - diff --git a/packages/server/src/modules/Bills/ValidateBulkDeleteBills.service.ts b/packages/server/src/modules/Bills/ValidateBulkDeleteBills.service.ts index f65f076a6..975e0226c 100644 --- a/packages/server/src/modules/Bills/ValidateBulkDeleteBills.service.ts +++ b/packages/server/src/modules/Bills/ValidateBulkDeleteBills.service.ts @@ -9,7 +9,7 @@ export class ValidateBulkDeleteBillsService { private readonly deleteBillService: DeleteBill, @Inject(TENANCY_DB_CONNECTION) private readonly tenantKnex: () => Knex, - ) { } + ) {} public async validateBulkDeleteBills(billIds: number[]): Promise<{ deletableCount: number; @@ -48,4 +48,3 @@ export class ValidateBulkDeleteBillsService { } } } - diff --git a/packages/server/src/modules/Bills/commands/BillsImportable.ts b/packages/server/src/modules/Bills/commands/BillsImportable.ts index f9d172a28..f6ff7abd5 100644 --- a/packages/server/src/modules/Bills/commands/BillsImportable.ts +++ b/packages/server/src/modules/Bills/commands/BillsImportable.ts @@ -7,9 +7,7 @@ import { CreateBillDto } from '../dtos/Bill.dto'; @Injectable() export class BillsImportable extends Importable { - constructor( - private readonly createBillService: CreateBill, - ) { + constructor(private readonly createBillService: CreateBill) { super(); } @@ -19,14 +17,8 @@ export class BillsImportable extends Importable { * @param {IAccountCreateDTO} createAccountDTO * @returns */ - public importable( - createBillDto: CreateBillDto, - trx?: Knex.Transaction - ) { - return this.createBillService.createBill( - createBillDto, - trx - ); + public importable(createBillDto: CreateBillDto, trx?: Knex.Transaction) { + return this.createBillService.createBill(createBillDto, trx); } /** diff --git a/packages/server/src/modules/Bills/commands/EditBill.service.ts b/packages/server/src/modules/Bills/commands/EditBill.service.ts index e2416eacb..29d3ec51c 100644 --- a/packages/server/src/modules/Bills/commands/EditBill.service.ts +++ b/packages/server/src/modules/Bills/commands/EditBill.service.ts @@ -29,7 +29,7 @@ export class EditBillService { @Inject(Bill.name) private billModel: TenantModelProxy, @Inject(Vendor.name) private vendorModel: TenantModelProxy, - ) { } + ) {} /** * Edits details of the given bill id with associated entries. diff --git a/packages/server/src/modules/Bills/dtos/Bill.dto.ts b/packages/server/src/modules/Bills/dtos/Bill.dto.ts index 99d3fb6d7..43de52989 100644 --- a/packages/server/src/modules/Bills/dtos/Bill.dto.ts +++ b/packages/server/src/modules/Bills/dtos/Bill.dto.ts @@ -213,5 +213,5 @@ export class CommandBillDto { adjustment?: number; } -export class CreateBillDto extends CommandBillDto { } -export class EditBillDto extends CommandBillDto { } +export class CreateBillDto extends CommandBillDto {} +export class EditBillDto extends CommandBillDto {} diff --git a/packages/server/src/modules/Bills/models/Bill.meta.ts b/packages/server/src/modules/Bills/models/Bill.meta.ts index 51d9bb613..4d085bbba 100644 --- a/packages/server/src/modules/Bills/models/Bill.meta.ts +++ b/packages/server/src/modules/Bills/models/Bill.meta.ts @@ -1,4 +1,4 @@ -import { Features } from "@/common/types/Features"; +import { Features } from '@/common/types/Features'; export const BillMeta = { defaultFilterField: 'vendor', @@ -283,4 +283,4 @@ function StatusFieldFilterQuery(query, role) { */ function StatusFieldSortQuery(query, role) { query.modify('sortByStatus', role.order); -} \ No newline at end of file +} diff --git a/packages/server/src/modules/Bills/models/Bill.ts b/packages/server/src/modules/Bills/models/Bill.ts index 480c42607..a5077f3cb 100644 --- a/packages/server/src/modules/Bills/models/Bill.ts +++ b/packages/server/src/modules/Bills/models/Bill.ts @@ -636,7 +636,7 @@ export class Bill extends TenantBaseModel { return this.query(trx) .where('id', billId) - [changeMethod]('payment_amount', Math.abs(amount)); + [changeMethod]('payment_amount', Math.abs(amount)); } /** diff --git a/packages/server/src/modules/Bills/subscribers/BillGLEntriesSubscriber.ts b/packages/server/src/modules/Bills/subscribers/BillGLEntriesSubscriber.ts index b5752580f..b3c36baea 100644 --- a/packages/server/src/modules/Bills/subscribers/BillGLEntriesSubscriber.ts +++ b/packages/server/src/modules/Bills/subscribers/BillGLEntriesSubscriber.ts @@ -29,7 +29,7 @@ export class BillGLEntriesSubscriber { if (!bill.openedAt) return null; await this.billGLEntries.writeBillGLEntries(bill.id, trx); - }; + } /** * Handles the overwriting journal entries once bill edited. @@ -43,7 +43,7 @@ export class BillGLEntriesSubscriber { if (!bill.openedAt) return null; await this.billGLEntries.rewriteBillGLEntries(bill.id, trx); - }; + } /** * Handles revert journal entries on bill deleted. @@ -55,5 +55,5 @@ export class BillGLEntriesSubscriber { trx, }: IBIllEventDeletedPayload) { await this.billGLEntries.revertBillGLEntries(oldBill.id, trx); - }; + } } diff --git a/packages/server/src/modules/Bills/subscribers/BillWriteInventoryTransactionsSubscriber.ts b/packages/server/src/modules/Bills/subscribers/BillWriteInventoryTransactionsSubscriber.ts index 740e8a385..24e9f8461 100644 --- a/packages/server/src/modules/Bills/subscribers/BillWriteInventoryTransactionsSubscriber.ts +++ b/packages/server/src/modules/Bills/subscribers/BillWriteInventoryTransactionsSubscriber.ts @@ -42,7 +42,7 @@ export class BillWriteInventoryTransactionsSubscriber { if (!bill.openedAt) return null; await this.billsInventory.recordInventoryTransactions(bill.id, true, trx); - }; + } /** * Handles the reverting the inventory transactions once the bill deleted. diff --git a/packages/server/src/modules/Branches/Branches.module.ts b/packages/server/src/modules/Branches/Branches.module.ts index a6c661d45..9124ad42e 100644 --- a/packages/server/src/modules/Branches/Branches.module.ts +++ b/packages/server/src/modules/Branches/Branches.module.ts @@ -78,7 +78,7 @@ import { FeaturesModule } from '../Features/Features.module'; BillPaymentsActivateBranches, BillBranchesActivateSubscriber, VendorCreditBranchesActivateSubscriber, - PaymentMadeActivateBranchesSubscriber + PaymentMadeActivateBranchesSubscriber, ], exports: [ BranchesSettingsService, @@ -86,4 +86,4 @@ import { FeaturesModule } from '../Features/Features.module'; ManualJournalBranchesDTOTransformer, ], }) -export class BranchesModule { } +export class BranchesModule {} diff --git a/packages/server/src/modules/Branches/BranchesApplication.service.ts b/packages/server/src/modules/Branches/BranchesApplication.service.ts index f151686b6..733792fc7 100644 --- a/packages/server/src/modules/Branches/BranchesApplication.service.ts +++ b/packages/server/src/modules/Branches/BranchesApplication.service.ts @@ -1,11 +1,7 @@ import { ICreateBranchDTO, IEditBranchDTO } from './Branches.types'; import { ActivateBranches } from './commands/ActivateBranchesFeature.service'; -import { - CreateBranchService, -} from './commands/CreateBranch.service'; -import { - DeleteBranchService, -} from './commands/DeleteBranch.service'; +import { CreateBranchService } from './commands/CreateBranch.service'; +import { DeleteBranchService } from './commands/DeleteBranch.service'; import { EditBranchService } from './commands/EditBranch.service'; import { GetBranchService } from './queries/GetBranch.service'; import { GetBranchesService } from './queries/GetBranches.service'; @@ -58,9 +54,7 @@ export class BranchesApplication { * @param {ICreateBranchDTO} createBranchDTO * @returns {Promise} */ - public createBranch = ( - createBranchDTO: CreateBranchDto, - ): Promise => { + public createBranch = (createBranchDTO: CreateBranchDto): Promise => { return this.createBranchService.createBranch(createBranchDTO); }; @@ -100,9 +94,7 @@ export class BranchesApplication { * @param {number} branchId * @returns {Promise} */ - public markBranchAsPrimary = async ( - branchId: number, - ): Promise => { + public markBranchAsPrimary = async (branchId: number): Promise => { return this.markBranchAsPrimaryService.markAsPrimary(branchId); }; } diff --git a/packages/server/src/modules/Branches/CRUDBranch.ts b/packages/server/src/modules/Branches/CRUDBranch.ts index bceee5134..894181c14 100644 --- a/packages/server/src/modules/Branches/CRUDBranch.ts +++ b/packages/server/src/modules/Branches/CRUDBranch.ts @@ -8,13 +8,13 @@ // tenancy: HasTenancyService; // /** -// * -// * @param branch +// * +// * @param branch // */ // throwIfBranchNotFound = (branch) => { // if (!branch) { // throw new ServiceError(ERRORS.BRANCH_NOT_FOUND); -// } +// } // } // getBranchOrThrowNotFound = async (tenantId: number, branchId: number) => { @@ -26,5 +26,5 @@ // throw new ServiceError(ERRORS.BRANCH_NOT_FOUND); // } // return foundBranch; -// } -// } \ No newline at end of file +// } +// } diff --git a/packages/server/src/modules/Branches/constants.ts b/packages/server/src/modules/Branches/constants.ts index e0d80f876..7125611b8 100644 --- a/packages/server/src/modules/Branches/constants.ts +++ b/packages/server/src/modules/Branches/constants.ts @@ -3,5 +3,5 @@ export const ERRORS = { MUTLI_BRANCHES_ALREADY_ACTIVATED: 'MUTLI_BRANCHES_ALREADY_ACTIVATED', COULD_NOT_DELETE_ONLY_BRANCH: 'COULD_NOT_DELETE_ONLY_BRANCH', BRANCH_CODE_NOT_UNIQUE: 'BRANCH_CODE_NOT_UNIQUE', - BRANCH_HAS_ASSOCIATED_TRANSACTIONS: 'BRANCH_HAS_ASSOCIATED_TRANSACTIONS' + BRANCH_HAS_ASSOCIATED_TRANSACTIONS: 'BRANCH_HAS_ASSOCIATED_TRANSACTIONS', }; diff --git a/packages/server/src/modules/Branches/integrations/Purchases/PaymentMadeBranchesActivate.ts b/packages/server/src/modules/Branches/integrations/Purchases/PaymentMadeBranchesActivate.ts index dcfc1c15d..837cc0a9f 100644 --- a/packages/server/src/modules/Branches/integrations/Purchases/PaymentMadeBranchesActivate.ts +++ b/packages/server/src/modules/Branches/integrations/Purchases/PaymentMadeBranchesActivate.ts @@ -17,9 +17,11 @@ export class BillPaymentsActivateBranches { */ public updateBillPaymentsWithBranch = async ( primaryBranchId: number, - trx?: Knex.Transaction + trx?: Knex.Transaction, ) => { // Updates the bill payments with primary branch. - await this.billPaymentModel().query(trx).update({ branchId: primaryBranchId }); + await this.billPaymentModel() + .query(trx) + .update({ branchId: primaryBranchId }); }; } diff --git a/packages/server/src/modules/Branches/integrations/Sales/CreditNoteBranchesActivate.ts b/packages/server/src/modules/Branches/integrations/Sales/CreditNoteBranchesActivate.ts index 7cb835b01..12f9d8ff6 100644 --- a/packages/server/src/modules/Branches/integrations/Sales/CreditNoteBranchesActivate.ts +++ b/packages/server/src/modules/Branches/integrations/Sales/CreditNoteBranchesActivate.ts @@ -16,9 +16,11 @@ export class CreditNoteActivateBranches { */ public updateCreditsWithBranch = async ( primaryBranchId: number, - trx?: Knex.Transaction + trx?: Knex.Transaction, ) => { // Updates the sale invoice with primary branch. - await this.creditNoteModel().query(trx).update({ branchId: primaryBranchId }); + await this.creditNoteModel() + .query(trx) + .update({ branchId: primaryBranchId }); }; } diff --git a/packages/server/src/modules/Branches/integrations/Sales/PaymentReceiveBranchesActivate.ts b/packages/server/src/modules/Branches/integrations/Sales/PaymentReceiveBranchesActivate.ts index fe7c0bea7..9b7138931 100644 --- a/packages/server/src/modules/Branches/integrations/Sales/PaymentReceiveBranchesActivate.ts +++ b/packages/server/src/modules/Branches/integrations/Sales/PaymentReceiveBranchesActivate.ts @@ -6,7 +6,9 @@ import { Knex } from 'knex'; @Injectable() export class PaymentReceiveActivateBranches { constructor( - private readonly paymentReceivedModel: TenantModelProxy, + private readonly paymentReceivedModel: TenantModelProxy< + typeof PaymentReceived + >, ) {} /** @@ -16,9 +18,11 @@ export class PaymentReceiveActivateBranches { */ public updatePaymentsWithBranch = async ( primaryBranchId: number, - trx?: Knex.Transaction + trx?: Knex.Transaction, ) => { // Updates the sale invoice with primary branch. - await this.paymentReceivedModel().query(trx).update({ branchId: primaryBranchId }); + await this.paymentReceivedModel() + .query(trx) + .update({ branchId: primaryBranchId }); }; } diff --git a/packages/server/src/modules/Branches/integrations/Sales/SaleEstimatesBranchesActivate.ts b/packages/server/src/modules/Branches/integrations/Sales/SaleEstimatesBranchesActivate.ts index 54856b689..92ec40700 100644 --- a/packages/server/src/modules/Branches/integrations/Sales/SaleEstimatesBranchesActivate.ts +++ b/packages/server/src/modules/Branches/integrations/Sales/SaleEstimatesBranchesActivate.ts @@ -7,7 +7,9 @@ import { Inject, Injectable } from '@nestjs/common'; export class SaleEstimateActivateBranches { constructor( @Inject(PaymentReceived.name) - private readonly paymentReceivedModel: TenantModelProxy, + private readonly paymentReceivedModel: TenantModelProxy< + typeof PaymentReceived + >, ) {} /** @@ -17,9 +19,11 @@ export class SaleEstimateActivateBranches { */ public updateEstimatesWithBranch = async ( primaryBranchId: number, - trx?: Knex.Transaction + trx?: Knex.Transaction, ) => { // Updates the sale invoice with primary branch. - await this.paymentReceivedModel().query(trx).update({ branchId: primaryBranchId }); + await this.paymentReceivedModel() + .query(trx) + .update({ branchId: primaryBranchId }); }; } diff --git a/packages/server/src/modules/Branches/integrations/constants.ts b/packages/server/src/modules/Branches/integrations/constants.ts index af66f6dae..9f8c5e972 100644 --- a/packages/server/src/modules/Branches/integrations/constants.ts +++ b/packages/server/src/modules/Branches/integrations/constants.ts @@ -1,6 +1,4 @@ - - export const ERRORS = { BRANCH_ID_REQUIRED: 'BRANCH_ID_REQUIRED', - BRANCH_ID_NOT_FOUND: 'BRANCH_ID_NOT_FOUND' -} \ No newline at end of file + BRANCH_ID_NOT_FOUND: 'BRANCH_ID_NOT_FOUND', +}; diff --git a/packages/server/src/modules/Branches/models/Branch.meta.ts b/packages/server/src/modules/Branches/models/Branch.meta.ts index 0361d10bd..3b997f507 100644 --- a/packages/server/src/modules/Branches/models/Branch.meta.ts +++ b/packages/server/src/modules/Branches/models/Branch.meta.ts @@ -7,5 +7,5 @@ export const BranchMeta = { }, }, columns: {}, - fields: {} -}; \ No newline at end of file + fields: {}, +}; diff --git a/packages/server/src/modules/Branches/models/Branch.model.ts b/packages/server/src/modules/Branches/models/Branch.model.ts index e60750176..e65fd28e1 100644 --- a/packages/server/src/modules/Branches/models/Branch.model.ts +++ b/packages/server/src/modules/Branches/models/Branch.model.ts @@ -7,7 +7,7 @@ import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/Inje import { BranchMeta } from './Branch.meta'; @InjectModelMeta(BranchMeta) -export class Branch extends BaseModel{ +export class Branch extends BaseModel { name!: string; code!: string; address!: string; diff --git a/packages/server/src/modules/Branches/queries/GetBranches.service.ts b/packages/server/src/modules/Branches/queries/GetBranches.service.ts index 503f417e3..933eb60bc 100644 --- a/packages/server/src/modules/Branches/queries/GetBranches.service.ts +++ b/packages/server/src/modules/Branches/queries/GetBranches.service.ts @@ -12,7 +12,7 @@ export class GetBranchesService { /** * Retrieves branches list. * @returns - */ + */ public getBranches = async () => { const branches = await this.branch().query().orderBy('name', 'DESC'); diff --git a/packages/server/src/modules/Branches/subscribers/Activate/BillBranchesActivateSubscriber.ts b/packages/server/src/modules/Branches/subscribers/Activate/BillBranchesActivateSubscriber.ts index c819932f4..8d815b880 100644 --- a/packages/server/src/modules/Branches/subscribers/Activate/BillBranchesActivateSubscriber.ts +++ b/packages/server/src/modules/Branches/subscribers/Activate/BillBranchesActivateSubscriber.ts @@ -6,9 +6,7 @@ import { OnEvent } from '@nestjs/event-emitter'; @Injectable() export class BillBranchesActivateSubscriber { - constructor( - private readonly billActivateBranches: BillActivateBranches, - ) { } + constructor(private readonly billActivateBranches: BillActivateBranches) {} /** * Updates bills transactions with the primary branch once diff --git a/packages/server/src/modules/Branches/subscribers/Activate/CashflowBranchesActivateSubscriber.ts b/packages/server/src/modules/Branches/subscribers/Activate/CashflowBranchesActivateSubscriber.ts index 2a0aa8c6f..270549063 100644 --- a/packages/server/src/modules/Branches/subscribers/Activate/CashflowBranchesActivateSubscriber.ts +++ b/packages/server/src/modules/Branches/subscribers/Activate/CashflowBranchesActivateSubscriber.ts @@ -8,7 +8,7 @@ import { events } from '@/common/events/events'; export class CreditNoteActivateBranchesSubscriber { constructor( private readonly cashflowActivateBranches: CashflowTransactionsActivateBranches, - ) { } + ) {} /** * Updates accounts transactions with the primary branch once @@ -17,13 +17,12 @@ export class CreditNoteActivateBranchesSubscriber { */ @OnEvent(events.branch.onActivated) async updateCashflowWithBranchOnActivated({ - primaryBranch, trx, }: IBranchesActivatedPayload) { await this.cashflowActivateBranches.updateCashflowTransactionsWithBranch( primaryBranch.id, - trx + trx, ); - }; + } } diff --git a/packages/server/src/modules/Branches/subscribers/Activate/CreditNoteBranchesActivateSubscriber.ts b/packages/server/src/modules/Branches/subscribers/Activate/CreditNoteBranchesActivateSubscriber.ts index aef0b6f59..a3462b5a5 100644 --- a/packages/server/src/modules/Branches/subscribers/Activate/CreditNoteBranchesActivateSubscriber.ts +++ b/packages/server/src/modules/Branches/subscribers/Activate/CreditNoteBranchesActivateSubscriber.ts @@ -22,7 +22,7 @@ export class CreditNoteActivateBranchesSubscriber { }: IBranchesActivatedPayload) { await this.creditNotesActivateBranches.updateCreditsWithBranch( primaryBranch.id, - trx + trx, ); - }; + } } diff --git a/packages/server/src/modules/Branches/subscribers/Activate/ExpenseBranchesActivateSubscriber.ts b/packages/server/src/modules/Branches/subscribers/Activate/ExpenseBranchesActivateSubscriber.ts index 46d7a9f2c..0527ba402 100644 --- a/packages/server/src/modules/Branches/subscribers/Activate/ExpenseBranchesActivateSubscriber.ts +++ b/packages/server/src/modules/Branches/subscribers/Activate/ExpenseBranchesActivateSubscriber.ts @@ -8,7 +8,7 @@ import { OnEvent } from '@nestjs/event-emitter'; export class ExpenseActivateBranchesSubscriber { constructor( private readonly expensesActivateBranches: ExpensesActivateBranches, - ) { } + ) {} /** * Updates accounts transactions with the primary branch once diff --git a/packages/server/src/modules/Branches/subscribers/Activate/PaymentMadeBranchesActivateSubscriber.ts b/packages/server/src/modules/Branches/subscribers/Activate/PaymentMadeBranchesActivateSubscriber.ts index 11f81998c..d8d4b972b 100644 --- a/packages/server/src/modules/Branches/subscribers/Activate/PaymentMadeBranchesActivateSubscriber.ts +++ b/packages/server/src/modules/Branches/subscribers/Activate/PaymentMadeBranchesActivateSubscriber.ts @@ -8,7 +8,7 @@ import { IBranchesActivatedPayload } from '../../Branches.types'; export class PaymentMadeActivateBranchesSubscriber { constructor( private readonly paymentsActivateBranches: BillPaymentsActivateBranches, - ) { } + ) {} /** * Updates accounts transactions with the primary branch once diff --git a/packages/server/src/modules/Branches/subscribers/Activate/PaymentReceiveBranchesActivateSubscriber.ts b/packages/server/src/modules/Branches/subscribers/Activate/PaymentReceiveBranchesActivateSubscriber.ts index 464b94fec..0c52dc13e 100644 --- a/packages/server/src/modules/Branches/subscribers/Activate/PaymentReceiveBranchesActivateSubscriber.ts +++ b/packages/server/src/modules/Branches/subscribers/Activate/PaymentReceiveBranchesActivateSubscriber.ts @@ -22,7 +22,7 @@ export class PaymentReceiveActivateBranchesSubscriber { }: IBranchesActivatedPayload) { await this.paymentsActivateBranches.updatePaymentsWithBranch( primaryBranch.id, - trx + trx, ); - }; + } } diff --git a/packages/server/src/modules/Branches/subscribers/Activate/SaleEstiamtesBranchesActivateSubscriber.ts b/packages/server/src/modules/Branches/subscribers/Activate/SaleEstiamtesBranchesActivateSubscriber.ts index 0a4cdaf45..ba47fc466 100644 --- a/packages/server/src/modules/Branches/subscribers/Activate/SaleEstiamtesBranchesActivateSubscriber.ts +++ b/packages/server/src/modules/Branches/subscribers/Activate/SaleEstiamtesBranchesActivateSubscriber.ts @@ -7,8 +7,8 @@ import { SaleEstimateActivateBranches } from '../../integrations/Sales/SaleEstim @Injectable() export class SaleEstimatesActivateBranchesSubscriber { constructor( - private readonly estimatesActivateBranches: SaleEstimateActivateBranches, - ) {} + private readonly estimatesActivateBranches: SaleEstimateActivateBranches, + ) {} /** * Updates accounts transactions with the primary branch once @@ -22,7 +22,7 @@ export class SaleEstimatesActivateBranchesSubscriber { }: IBranchesActivatedPayload) { await this.estimatesActivateBranches.updateEstimatesWithBranch( primaryBranch.id, - trx + trx, ); - }; + } } diff --git a/packages/server/src/modules/Branches/subscribers/Activate/SaleInvoiceBranchesActivateSubscriber.ts b/packages/server/src/modules/Branches/subscribers/Activate/SaleInvoiceBranchesActivateSubscriber.ts index 135a62bd4..91f3f218e 100644 --- a/packages/server/src/modules/Branches/subscribers/Activate/SaleInvoiceBranchesActivateSubscriber.ts +++ b/packages/server/src/modules/Branches/subscribers/Activate/SaleInvoiceBranchesActivateSubscriber.ts @@ -8,7 +8,7 @@ import { Injectable } from '@nestjs/common'; export class SaleInvoicesActivateBranchesSubscriber { constructor( private readonly invoicesActivateBranches: SaleInvoiceActivateBranches, - ) { } + ) {} /** * Updates accounts transactions with the primary branch once @@ -22,7 +22,7 @@ export class SaleInvoicesActivateBranchesSubscriber { }: IBranchesActivatedPayload) { await this.invoicesActivateBranches.updateInvoicesWithBranch( primaryBranch.id, - trx + trx, ); - }; + } } diff --git a/packages/server/src/modules/Branches/subscribers/Activate/VendorCreditBranchesActivateSubscriber.ts b/packages/server/src/modules/Branches/subscribers/Activate/VendorCreditBranchesActivateSubscriber.ts index 3d2991092..b2d6a4424 100644 --- a/packages/server/src/modules/Branches/subscribers/Activate/VendorCreditBranchesActivateSubscriber.ts +++ b/packages/server/src/modules/Branches/subscribers/Activate/VendorCreditBranchesActivateSubscriber.ts @@ -8,7 +8,7 @@ import { OnEvent } from '@nestjs/event-emitter'; export class VendorCreditBranchesActivateSubscriber { constructor( private readonly vendorCreditActivateBranches: VendorCreditActivateBranches, - ) { } + ) {} /** * Updates vendor credits transactions with the primary branch once diff --git a/packages/server/src/modules/Branches/subscribers/Validators/BillBranchSubscriber.ts b/packages/server/src/modules/Branches/subscribers/Validators/BillBranchSubscriber.ts index cca717adc..88e025cdb 100644 --- a/packages/server/src/modules/Branches/subscribers/Validators/BillBranchSubscriber.ts +++ b/packages/server/src/modules/Branches/subscribers/Validators/BillBranchSubscriber.ts @@ -11,7 +11,7 @@ import { export class BillBranchValidateSubscriber { constructor( private readonly validateBranchExistance: ValidateBranchExistance, - ) { } + ) {} /** * Validate branch existance on bill creating. diff --git a/packages/server/src/modules/Branches/subscribers/Validators/CashflowBranchDTOValidatorSubscriber.ts b/packages/server/src/modules/Branches/subscribers/Validators/CashflowBranchDTOValidatorSubscriber.ts index adc1a19d7..df29729c6 100644 --- a/packages/server/src/modules/Branches/subscribers/Validators/CashflowBranchDTOValidatorSubscriber.ts +++ b/packages/server/src/modules/Branches/subscribers/Validators/CashflowBranchDTOValidatorSubscriber.ts @@ -8,7 +8,7 @@ import { ICommandCashflowCreatingPayload } from '@/modules/BankingTransactions/t export class CashflowBranchDTOValidatorSubscriber { constructor( private readonly validateBranchExistance: ValidateBranchExistance, - ) { } + ) {} /** * Validate branch existance once cashflow transaction creating. diff --git a/packages/server/src/modules/Branches/subscribers/Validators/CreditNoteBranchesSubscriber.ts b/packages/server/src/modules/Branches/subscribers/Validators/CreditNoteBranchesSubscriber.ts index c75af2419..40bf4007d 100644 --- a/packages/server/src/modules/Branches/subscribers/Validators/CreditNoteBranchesSubscriber.ts +++ b/packages/server/src/modules/Branches/subscribers/Validators/CreditNoteBranchesSubscriber.ts @@ -9,7 +9,7 @@ import { ICreditNoteCreatingPayload } from '@/modules/CreditNotes/types/CreditNo export class CreditNoteBranchValidateSubscriber { constructor( private readonly validateBranchExistance: ValidateBranchExistance, - ) { } + ) {} /** * Validate branch existance on credit note creating. diff --git a/packages/server/src/modules/Branches/subscribers/Validators/CreditNoteRefundBranchSubscriber.ts b/packages/server/src/modules/Branches/subscribers/Validators/CreditNoteRefundBranchSubscriber.ts index ac24f347e..fd089d8c2 100644 --- a/packages/server/src/modules/Branches/subscribers/Validators/CreditNoteRefundBranchSubscriber.ts +++ b/packages/server/src/modules/Branches/subscribers/Validators/CreditNoteRefundBranchSubscriber.ts @@ -7,8 +7,8 @@ import { IRefundCreditNoteCreatingPayload } from '@/modules/CreditNoteRefunds/ty @Injectable() export class CreditNoteRefundBranchValidateSubscriber { constructor( - private readonly validateBranchExistance: ValidateBranchExistance - ) { } + private readonly validateBranchExistance: ValidateBranchExistance, + ) {} /** * Validate branch existance on refund credit note creating. @@ -19,7 +19,7 @@ export class CreditNoteRefundBranchValidateSubscriber { newCreditNoteDTO, }: IRefundCreditNoteCreatingPayload) { await this.validateBranchExistance.validateTransactionBranchWhenActive( - newCreditNoteDTO.branchId + newCreditNoteDTO.branchId, ); } } diff --git a/packages/server/src/modules/Branches/subscribers/Validators/ExpenseBranchSubscriber.ts b/packages/server/src/modules/Branches/subscribers/Validators/ExpenseBranchSubscriber.ts index d654c3302..32c947482 100644 --- a/packages/server/src/modules/Branches/subscribers/Validators/ExpenseBranchSubscriber.ts +++ b/packages/server/src/modules/Branches/subscribers/Validators/ExpenseBranchSubscriber.ts @@ -10,7 +10,7 @@ import { export class ExpenseBranchValidateSubscriber { constructor( private readonly validateBranchExistance: ValidateBranchExistance, - ) { } + ) {} /** * Validate branch existance once expense transaction creating. diff --git a/packages/server/src/modules/Branches/subscribers/Validators/InventoryAdjustmentBranchValidatorSubscriber.ts b/packages/server/src/modules/Branches/subscribers/Validators/InventoryAdjustmentBranchValidatorSubscriber.ts index 6f2123cae..767aacda5 100644 --- a/packages/server/src/modules/Branches/subscribers/Validators/InventoryAdjustmentBranchValidatorSubscriber.ts +++ b/packages/server/src/modules/Branches/subscribers/Validators/InventoryAdjustmentBranchValidatorSubscriber.ts @@ -8,13 +8,15 @@ import { IInventoryAdjustmentCreatingPayload } from '@/modules/InventoryAdjutmen export class InventoryAdjustmentBranchValidateSubscriber { constructor( private readonly validateBranchExistance: ValidateBranchExistance, - ) { } + ) {} /** * Validate branch existance on inventory adjustment creating. * @param {IInventoryAdjustmentCreatingPayload} payload */ - @OnEvent(events.inventoryAdjustment.onQuickCreating, { suppressErrors: false }) + @OnEvent(events.inventoryAdjustment.onQuickCreating, { + suppressErrors: false, + }) async validateBranchExistanceOnInventoryCreating({ quickAdjustmentDTO, }: IInventoryAdjustmentCreatingPayload) { diff --git a/packages/server/src/modules/Branches/subscribers/Validators/InvoiceBranchValidatorSubscriber.ts b/packages/server/src/modules/Branches/subscribers/Validators/InvoiceBranchValidatorSubscriber.ts index 8f8aae3e8..256d8b7db 100644 --- a/packages/server/src/modules/Branches/subscribers/Validators/InvoiceBranchValidatorSubscriber.ts +++ b/packages/server/src/modules/Branches/subscribers/Validators/InvoiceBranchValidatorSubscriber.ts @@ -11,7 +11,7 @@ import { export class InvoiceBranchValidateSubscriber { constructor( private readonly validateBranchExistance: ValidateBranchExistance, - ) { } + ) {} /** * Validate branch existance on invoice creating. diff --git a/packages/server/src/modules/Branches/subscribers/Validators/ManualJournalBranchSubscriber.ts b/packages/server/src/modules/Branches/subscribers/Validators/ManualJournalBranchSubscriber.ts index c7e177302..70966db8f 100644 --- a/packages/server/src/modules/Branches/subscribers/Validators/ManualJournalBranchSubscriber.ts +++ b/packages/server/src/modules/Branches/subscribers/Validators/ManualJournalBranchSubscriber.ts @@ -1,4 +1,3 @@ - import { IManualJournalCreatingPayload, IManualJournalEditingPayload, @@ -15,7 +14,7 @@ export class ManualJournalBranchValidateSubscriber { constructor( private readonly validateManualJournalBranch: ManualJournalBranchesValidator, private readonly featuresManager: FeaturesManager, - ) { } + ) {} /** * Validate branch existance on estimate creating. @@ -27,16 +26,16 @@ export class ManualJournalBranchValidateSubscriber { }: IManualJournalCreatingPayload) { // Detarmines whether the multi-branches is accessible by tenant. const isAccessible = await this.featuresManager.accessible( - Features.BRANCHES + Features.BRANCHES, ); // Can't continue if the multi-branches feature is inactive. if (!isAccessible) return; // Validates the entries whether have branch id. await this.validateManualJournalBranch.validateEntriesHasBranchId( - manualJournalDTO + manualJournalDTO, ); - }; + } /** * Validate branch existance once estimate editing. @@ -48,13 +47,13 @@ export class ManualJournalBranchValidateSubscriber { }: IManualJournalEditingPayload) { // Detarmines whether the multi-branches is accessible by tenant. const isAccessible = await this.featuresManager.accessible( - Features.BRANCHES + Features.BRANCHES, ); // Can't continue if the multi-branches feature is inactive. if (!isAccessible) return; await this.validateManualJournalBranch.validateEntriesHasBranchId( - manualJournalDTO + manualJournalDTO, ); - }; + } } diff --git a/packages/server/src/modules/Branches/subscribers/Validators/PaymentMadeBranchSubscriber.ts b/packages/server/src/modules/Branches/subscribers/Validators/PaymentMadeBranchSubscriber.ts index 63d79a7c2..0b1b2bb11 100644 --- a/packages/server/src/modules/Branches/subscribers/Validators/PaymentMadeBranchSubscriber.ts +++ b/packages/server/src/modules/Branches/subscribers/Validators/PaymentMadeBranchSubscriber.ts @@ -11,7 +11,7 @@ import { events } from '@/common/events/events'; export class PaymentMadeBranchValidateSubscriber { constructor( private readonly validateBranchExistance: ValidateBranchExistance, - ) { } + ) {} /** * Validate branch existance on estimate creating. diff --git a/packages/server/src/modules/Branches/subscribers/Validators/PaymentReceiveBranchSubscriber.ts b/packages/server/src/modules/Branches/subscribers/Validators/PaymentReceiveBranchSubscriber.ts index 780590f4e..0d3c11dac 100644 --- a/packages/server/src/modules/Branches/subscribers/Validators/PaymentReceiveBranchSubscriber.ts +++ b/packages/server/src/modules/Branches/subscribers/Validators/PaymentReceiveBranchSubscriber.ts @@ -11,7 +11,7 @@ import { events } from '@/common/events/events'; export class PaymentReceiveBranchValidateSubscriber { constructor( private readonly validateBranchExistance: ValidateBranchExistance, - ) { } + ) {} /** * Validate branch existance on estimate creating. diff --git a/packages/server/src/modules/Branches/subscribers/Validators/SaleEstimateMultiBranchesSubscriber.ts b/packages/server/src/modules/Branches/subscribers/Validators/SaleEstimateMultiBranchesSubscriber.ts index c4e1cdc41..3147d237c 100644 --- a/packages/server/src/modules/Branches/subscribers/Validators/SaleEstimateMultiBranchesSubscriber.ts +++ b/packages/server/src/modules/Branches/subscribers/Validators/SaleEstimateMultiBranchesSubscriber.ts @@ -11,7 +11,7 @@ import { ValidateBranchExistance } from '../../integrations/ValidateBranchExista export class SaleEstimateBranchValidateSubscriber { constructor( private readonly validateBranchExistance: ValidateBranchExistance, - ) { } + ) {} /** * Validate branch existance on estimate creating. diff --git a/packages/server/src/modules/Branches/subscribers/Validators/SaleReceiptBranchesSubscriber.ts b/packages/server/src/modules/Branches/subscribers/Validators/SaleReceiptBranchesSubscriber.ts index d4e8fc513..23c74fcc8 100644 --- a/packages/server/src/modules/Branches/subscribers/Validators/SaleReceiptBranchesSubscriber.ts +++ b/packages/server/src/modules/Branches/subscribers/Validators/SaleReceiptBranchesSubscriber.ts @@ -11,7 +11,7 @@ import { events } from '@/common/events/events'; export class SaleReceiptBranchValidateSubscriber { constructor( private readonly validateBranchExistance: ValidateBranchExistance, - ) { } + ) {} /** * Validate branch existance on estimate creating. diff --git a/packages/server/src/modules/Branches/subscribers/Validators/VendorCreditBranchSubscriber.ts b/packages/server/src/modules/Branches/subscribers/Validators/VendorCreditBranchSubscriber.ts index e129fbbd9..fb3f0737f 100644 --- a/packages/server/src/modules/Branches/subscribers/Validators/VendorCreditBranchSubscriber.ts +++ b/packages/server/src/modules/Branches/subscribers/Validators/VendorCreditBranchSubscriber.ts @@ -11,7 +11,7 @@ import { events } from '@/common/events/events'; export class VendorCreditBranchValidateSubscriber { constructor( private readonly validateBranchExistance: ValidateBranchExistance, - ) { } + ) {} /** * Validate branch existance on estimate creating. diff --git a/packages/server/src/modules/Branches/subscribers/Validators/VendorCreditRefundBranchSubscriber.ts b/packages/server/src/modules/Branches/subscribers/Validators/VendorCreditRefundBranchSubscriber.ts index 17bbf3d5b..3fc01757a 100644 --- a/packages/server/src/modules/Branches/subscribers/Validators/VendorCreditRefundBranchSubscriber.ts +++ b/packages/server/src/modules/Branches/subscribers/Validators/VendorCreditRefundBranchSubscriber.ts @@ -8,7 +8,7 @@ import { IRefundVendorCreditCreatingPayload } from '@/modules/VendorCreditsRefun export class VendorCreditRefundBranchValidateSubscriber { constructor( private readonly validateBranchExistance: ValidateBranchExistance, - ) { } + ) {} /** * Validate branch existance on refund credit note creating. diff --git a/packages/server/src/modules/CLI/CLI.module.ts b/packages/server/src/modules/CLI/CLI.module.ts index df491b23e..de71827a0 100644 --- a/packages/server/src/modules/CLI/CLI.module.ts +++ b/packages/server/src/modules/CLI/CLI.module.ts @@ -34,4 +34,4 @@ import { OpenApiExportCommand } from './commands/OpenApiExport.command'; OpenApiExportCommand, ], }) -export class CLIModule { } +export class CLIModule {} diff --git a/packages/server/src/modules/CLI/commands/BaseCommand.ts b/packages/server/src/modules/CLI/commands/BaseCommand.ts index 896dd386e..c58a9925b 100644 --- a/packages/server/src/modules/CLI/commands/BaseCommand.ts +++ b/packages/server/src/modules/CLI/commands/BaseCommand.ts @@ -43,11 +43,15 @@ export abstract class BaseCommand extends CommandRunner { charset: 'utf8', }, migrations: { - directory: this.configService.get('tenantDatabase.migrationsDir') || './src/database/migrations', + directory: + this.configService.get('tenantDatabase.migrationsDir') || + './src/database/migrations', loadExtensions: ['.js'], }, seeds: { - directory: this.configService.get('tenantDatabase.seedsDir') || './src/database/seeds/core', + directory: + this.configService.get('tenantDatabase.seedsDir') || + './src/database/seeds/core', }, pool: { min: 0, diff --git a/packages/server/src/modules/CLI/commands/OpenApiExport.command.ts b/packages/server/src/modules/CLI/commands/OpenApiExport.command.ts index 981d417e5..ee2fd9d19 100644 --- a/packages/server/src/modules/CLI/commands/OpenApiExport.command.ts +++ b/packages/server/src/modules/CLI/commands/OpenApiExport.command.ts @@ -10,7 +10,8 @@ import { NestExpressApplication } from '@nestjs/platform-express'; @Command({ name: 'openapi:export', - description: 'Export the OpenAPI document from the NestJS app to shared/sdk-ts/openapi.json', + description: + 'Export the OpenAPI document from the NestJS app to shared/sdk-ts/openapi.json', }) export class OpenApiExportCommand extends CommandRunner { async run(): Promise { @@ -36,7 +37,10 @@ export class OpenApiExportCommand extends CommandRunner { const document = SwaggerModule.createDocument(app, config); await app.close(); - const outputPath = path.resolve(process.cwd(), '../../shared/sdk-ts/openapi.json'); + const outputPath = path.resolve( + process.cwd(), + '../../shared/sdk-ts/openapi.json', + ); fs.mkdirSync(path.dirname(outputPath), { recursive: true }); fs.writeFileSync(outputPath, JSON.stringify(document, null, 2), 'utf-8'); console.log(`OpenAPI spec written to ${outputPath}`); diff --git a/packages/server/src/modules/CLI/commands/SystemMigrateLatest.command.ts b/packages/server/src/modules/CLI/commands/SystemMigrateLatest.command.ts index 8732d3205..626eaabbe 100644 --- a/packages/server/src/modules/CLI/commands/SystemMigrateLatest.command.ts +++ b/packages/server/src/modules/CLI/commands/SystemMigrateLatest.command.ts @@ -22,9 +22,7 @@ export class SystemMigrateLatestCommand extends BaseCommand { this.success('Already up to date'); } - this.success( - `Batch ${batchNo} run: ${log.length} migrations` - ); + this.success(`Batch ${batchNo} run: ${log.length} migrations`); } catch (error) { this.exit(error); } diff --git a/packages/server/src/modules/CLI/commands/SystemMigrateRollback.command.ts b/packages/server/src/modules/CLI/commands/SystemMigrateRollback.command.ts index d82620595..1404c4028 100644 --- a/packages/server/src/modules/CLI/commands/SystemMigrateRollback.command.ts +++ b/packages/server/src/modules/CLI/commands/SystemMigrateRollback.command.ts @@ -22,9 +22,7 @@ export class SystemMigrateRollbackCommand extends BaseCommand { this.success('Already at the base migration'); } - this.success( - `Batch ${batchNo} rolled back: ${_log.length} migrations` - ); + this.success(`Batch ${batchNo} rolled back: ${_log.length} migrations`); } catch (error) { this.exit(error); } diff --git a/packages/server/src/modules/CLI/commands/TenantsList.command.ts b/packages/server/src/modules/CLI/commands/TenantsList.command.ts index a268ffc73..787e3c2d0 100644 --- a/packages/server/src/modules/CLI/commands/TenantsList.command.ts +++ b/packages/server/src/modules/CLI/commands/TenantsList.command.ts @@ -25,7 +25,10 @@ export class TenantsListCommand extends BaseCommand { return true; } - async run(passedParams: string[], options: TenantsListOptions): Promise { + async run( + passedParams: string[], + options: TenantsListOptions, + ): Promise { try { const sysKnex = this.initSystemKnex(); const tenants = options.all @@ -35,7 +38,7 @@ export class TenantsListCommand extends BaseCommand { tenants.forEach((tenant: any) => { const dbName = `${this.configService.get('tenantDatabase.dbNamePrefix')}${tenant.organizationId}`; console.log( - `ID: ${tenant.id} | Organization ID: ${tenant.organizationId} | DB Name: ${dbName}` + `ID: ${tenant.id} | Organization ID: ${tenant.organizationId} | DB Name: ${dbName}`, ); }); diff --git a/packages/server/src/modules/CLI/commands/TenantsMigrateLatest.command.ts b/packages/server/src/modules/CLI/commands/TenantsMigrateLatest.command.ts index ab0b8cc4f..41ad74191 100644 --- a/packages/server/src/modules/CLI/commands/TenantsMigrateLatest.command.ts +++ b/packages/server/src/modules/CLI/commands/TenantsMigrateLatest.command.ts @@ -28,13 +28,21 @@ export class TenantsMigrateLatestCommand extends BaseCommand { return val; } - async run(passedParams: string[], options: TenantsMigrateLatestOptions): Promise { + async run( + passedParams: string[], + options: TenantsMigrateLatestOptions, + ): Promise { try { const sysKnex = this.initSystemKnex(); const tenants = await this.getAllInitializedTenants(sysKnex); - const tenantsOrgsIds = tenants.map((tenant: any) => tenant.organizationId); + const tenantsOrgsIds = tenants.map( + (tenant: any) => tenant.organizationId, + ); - if (options.tenant_id && tenantsOrgsIds.indexOf(options.tenant_id) === -1) { + if ( + options.tenant_id && + tenantsOrgsIds.indexOf(options.tenant_id) === -1 + ) { this.exit(`The given tenant id ${options.tenant_id} does not exist.`); } @@ -49,7 +57,7 @@ export class TenantsMigrateLatestCommand extends BaseCommand { } this.log( - `Tenant ${tenantDb} > Batch ${batchNo} run: ${_log.length} migrations` + `Tenant ${tenantDb} > Batch ${batchNo} run: ${_log.length} migrations`, ); this.log('-------------------'); } catch (error) { diff --git a/packages/server/src/modules/CLI/commands/TenantsMigrateRollback.command.ts b/packages/server/src/modules/CLI/commands/TenantsMigrateRollback.command.ts index adb068a22..5216b7bd7 100644 --- a/packages/server/src/modules/CLI/commands/TenantsMigrateRollback.command.ts +++ b/packages/server/src/modules/CLI/commands/TenantsMigrateRollback.command.ts @@ -28,13 +28,21 @@ export class TenantsMigrateRollbackCommand extends BaseCommand { return val; } - async run(passedParams: string[], options: TenantsMigrateRollbackOptions): Promise { + async run( + passedParams: string[], + options: TenantsMigrateRollbackOptions, + ): Promise { try { const sysKnex = this.initSystemKnex(); const tenants = await this.getAllInitializedTenants(sysKnex); - const tenantsOrgsIds = tenants.map((tenant: any) => tenant.organizationId); + const tenantsOrgsIds = tenants.map( + (tenant: any) => tenant.organizationId, + ); - if (options.tenant_id && tenantsOrgsIds.indexOf(options.tenant_id) === -1) { + if ( + options.tenant_id && + tenantsOrgsIds.indexOf(options.tenant_id) === -1 + ) { this.exit(`The given tenant id ${options.tenant_id} does not exist.`); } @@ -49,7 +57,7 @@ export class TenantsMigrateRollbackCommand extends BaseCommand { } this.log( - `Tenant: ${tenantDb} > Batch ${batchNo} rolled back: ${_log.length} migrations` + `Tenant: ${tenantDb} > Batch ${batchNo} rolled back: ${_log.length} migrations`, ); this.log('---------------'); } catch (error) { diff --git a/packages/server/src/modules/ChromiumlyTenancy/ChromiumlyHtmlConvert.service.ts b/packages/server/src/modules/ChromiumlyTenancy/ChromiumlyHtmlConvert.service.ts index bdbcbc134..10d12e441 100644 --- a/packages/server/src/modules/ChromiumlyTenancy/ChromiumlyHtmlConvert.service.ts +++ b/packages/server/src/modules/ChromiumlyTenancy/ChromiumlyHtmlConvert.service.ts @@ -4,10 +4,7 @@ import { promises as fs } from 'fs'; import { PageProperties, PdfFormat } from '@/libs/chromiumly/_types'; import { UrlConverter } from '@/libs/chromiumly/UrlConvert'; import { Chromiumly } from '@/libs/chromiumly/Chromiumly'; -import { - getPdfFilePath, - getPdfFilesStorageDir, -} from './utils'; +import { getPdfFilePath, getPdfFilesStorageDir } from './utils'; import { Document } from './models/Document'; import { TenantModelProxy } from '../System/models/TenantBaseModel'; @@ -19,7 +16,7 @@ export class ChromiumlyHtmlConvert { constructor( @Inject(Document.name) private documentModel: TenantModelProxy, - ) { } + ) {} /** * Write HTML content to temporary file. diff --git a/packages/server/src/modules/ChromiumlyTenancy/ChromiumlyTenancy.service.ts b/packages/server/src/modules/ChromiumlyTenancy/ChromiumlyTenancy.service.ts index a611dab37..0e6e945e9 100644 --- a/packages/server/src/modules/ChromiumlyTenancy/ChromiumlyTenancy.service.ts +++ b/packages/server/src/modules/ChromiumlyTenancy/ChromiumlyTenancy.service.ts @@ -4,7 +4,7 @@ import { Injectable } from '@nestjs/common'; @Injectable() export class ChromiumlyTenancy { - constructor(private htmlConvert: ChromiumlyHtmlConvert) { } + constructor(private htmlConvert: ChromiumlyHtmlConvert) {} /** * Converts the given HTML content to PDF. @@ -16,12 +16,12 @@ export class ChromiumlyTenancy { public convertHtmlContent( content: string, properties?: PageProperties, - pdfFormat?: PdfFormat + pdfFormat?: PdfFormat, ) { const parsedProperties = { margins: { top: 0, bottom: 0, left: 0, right: 0 }, ...properties, - } + }; return this.htmlConvert.convert(content, parsedProperties, pdfFormat); } } diff --git a/packages/server/src/modules/ChromiumlyTenancy/models/DocumentLink.ts b/packages/server/src/modules/ChromiumlyTenancy/models/DocumentLink.ts index 5f851003e..dd0c88e78 100644 --- a/packages/server/src/modules/ChromiumlyTenancy/models/DocumentLink.ts +++ b/packages/server/src/modules/ChromiumlyTenancy/models/DocumentLink.ts @@ -4,7 +4,7 @@ import { Model, mixin } from 'objection'; // import ModelSearchable from './ModelSearchable'; import { BaseModel } from '@/models/Model'; -export class DocumentLink extends BaseModel{ +export class DocumentLink extends BaseModel { public modelRef: string; public modelId: number; public documentId: number; diff --git a/packages/server/src/modules/Contacts/Contacts.constants.ts b/packages/server/src/modules/Contacts/Contacts.constants.ts index 177196b2c..4227ad8b0 100644 --- a/packages/server/src/modules/Contacts/Contacts.constants.ts +++ b/packages/server/src/modules/Contacts/Contacts.constants.ts @@ -1,6 +1,4 @@ - - export const ERRORS = { CONTACT_ALREADY_ACTIVE: 'CONTACT_ALREADY_ACTIVE', - CONTACT_ALREADY_INACTIVE: 'CONTACT_ALREADY_INACTIVE' -} \ No newline at end of file + CONTACT_ALREADY_INACTIVE: 'CONTACT_ALREADY_INACTIVE', +}; diff --git a/packages/server/src/modules/Contacts/Contacts.controller.ts b/packages/server/src/modules/Contacts/Contacts.controller.ts index 6078a25bf..db081477d 100644 --- a/packages/server/src/modules/Contacts/Contacts.controller.ts +++ b/packages/server/src/modules/Contacts/Contacts.controller.ts @@ -32,7 +32,11 @@ export class ContactsController { @Get(':id') @ApiOperation({ summary: 'Get contact by ID (customer or vendor)' }) @ApiParam({ name: 'id', type: Number, description: 'Contact ID' }) - @ApiResponse({ status: 200, description: 'Contact details (under "customer" key for form/duplicate use)' }) + @ApiResponse({ + status: 200, + description: + 'Contact details (under "customer" key for form/duplicate use)', + }) getContact(@Param('id', ParseIntPipe) contactId: number) { return this.getContactService.getContact(contactId); } diff --git a/packages/server/src/modules/Contacts/models/Contact.ts b/packages/server/src/modules/Contacts/models/Contact.ts index fc102bcf8..9cc3ef3fa 100644 --- a/packages/server/src/modules/Contacts/models/Contact.ts +++ b/packages/server/src/modules/Contacts/models/Contact.ts @@ -135,10 +135,14 @@ export class Contact extends BaseModel { const { SaleEstimate } = require('../../SaleEstimates/models/SaleEstimate'); const { SaleReceipt } = require('../../SaleReceipts/models/SaleReceipt'); const { SaleInvoice } = require('../../SaleInvoices/models/SaleInvoice'); - const { PaymentReceived } = require('../../PaymentReceived/models/PaymentReceived'); + const { + PaymentReceived, + } = require('../../PaymentReceived/models/PaymentReceived'); const { Bill } = require('../../Bills/models/Bill'); const { BillPayment } = require('../../BillPayments/models/BillPayment'); - const { AccountTransaction } = require('../../Accounts/models/AccountTransaction.model'); + const { + AccountTransaction, + } = require('../../Accounts/models/AccountTransaction.model'); return { /** diff --git a/packages/server/src/modules/CreditNoteRefunds/CreditNoteRefunds.controller.ts b/packages/server/src/modules/CreditNoteRefunds/CreditNoteRefunds.controller.ts index 4bdd7f0ee..c7c98e77c 100644 --- a/packages/server/src/modules/CreditNoteRefunds/CreditNoteRefunds.controller.ts +++ b/packages/server/src/modules/CreditNoteRefunds/CreditNoteRefunds.controller.ts @@ -55,7 +55,9 @@ export class CreditNoteRefundsController { @Get('refunds/:refundCreditId') @RequirePermission(CreditNoteAction.View, AbilitySubject.CreditNote) - @ApiOperation({ summary: 'Retrieve a refund transaction for the given credit note.' }) + @ApiOperation({ + summary: 'Retrieve a refund transaction for the given credit note.', + }) @ApiResponse({ status: 200, description: 'Refund credit note transaction retrieved successfully.', diff --git a/packages/server/src/modules/CreditNoteRefunds/CreditNoteRefunds.module.ts b/packages/server/src/modules/CreditNoteRefunds/CreditNoteRefunds.module.ts index cd5fc564f..f018c088d 100644 --- a/packages/server/src/modules/CreditNoteRefunds/CreditNoteRefunds.module.ts +++ b/packages/server/src/modules/CreditNoteRefunds/CreditNoteRefunds.module.ts @@ -29,4 +29,4 @@ import { AccountsModule } from '../Accounts/Accounts.module'; exports: [RefundSyncCreditNoteBalanceService], controllers: [CreditNoteRefundsController], }) -export class CreditNoteRefundsModule { } +export class CreditNoteRefundsModule {} diff --git a/packages/server/src/modules/CreditNoteRefunds/commands/RefundCreditNoteGLEntries.ts b/packages/server/src/modules/CreditNoteRefunds/commands/RefundCreditNoteGLEntries.ts index 4027ac221..230acb5ce 100644 --- a/packages/server/src/modules/CreditNoteRefunds/commands/RefundCreditNoteGLEntries.ts +++ b/packages/server/src/modules/CreditNoteRefunds/commands/RefundCreditNoteGLEntries.ts @@ -123,15 +123,15 @@ export class RefundCreditNoteGLEntries { trx?: Knex.Transaction, ) => { // Retrieve the refund with associated credit note. - const refundCreditNote = await this.refundCreditNoteModel().query(trx) + const refundCreditNote = await this.refundCreditNoteModel() + .query(trx) .findById(refundCreditNoteId) .withGraphFetched('creditNote'); // Receivable account A/R. - const receivableAccount = await this.accountModel().query().findOne( - 'slug', - 'accounts-receivable', - ); + const receivableAccount = await this.accountModel() + .query() + .findOne('slug', 'accounts-receivable'); // Retrieve refund credit GL entries. const refundGLEntries = this.getRefundCreditGLEntries( refundCreditNote, diff --git a/packages/server/src/modules/CreditNoteRefunds/dto/CreditNoteRefund.dto.ts b/packages/server/src/modules/CreditNoteRefunds/dto/CreditNoteRefund.dto.ts index d3dab1ffb..65da99519 100644 --- a/packages/server/src/modules/CreditNoteRefunds/dto/CreditNoteRefund.dto.ts +++ b/packages/server/src/modules/CreditNoteRefunds/dto/CreditNoteRefund.dto.ts @@ -1,6 +1,11 @@ import { ApiProperty } from '@nestjs/swagger'; import { ToNumber, IsOptional } from '@/common/decorators/Validators'; -import { IsDateString, IsNotEmpty, IsPositive, IsString } from 'class-validator'; +import { + IsDateString, + IsNotEmpty, + IsPositive, + IsString, +} from 'class-validator'; import { IsDate } from 'class-validator'; import { IsNumber } from 'class-validator'; diff --git a/packages/server/src/modules/CreditNoteRefunds/dto/RefundCreditNoteResponse.dto.ts b/packages/server/src/modules/CreditNoteRefunds/dto/RefundCreditNoteResponse.dto.ts index cf3d72aa1..df138a11b 100644 --- a/packages/server/src/modules/CreditNoteRefunds/dto/RefundCreditNoteResponse.dto.ts +++ b/packages/server/src/modules/CreditNoteRefunds/dto/RefundCreditNoteResponse.dto.ts @@ -35,7 +35,11 @@ export class RefundCreditNoteResponseDto { @ApiProperty({ example: 'REF-001', required: false, nullable: true }) referenceNo?: string | null; - @ApiProperty({ example: 'Refund issued to customer', required: false, nullable: true }) + @ApiProperty({ + example: 'Refund issued to customer', + required: false, + nullable: true, + }) description?: string | null; @ApiProperty({ type: RefundCreditAccountDto }) diff --git a/packages/server/src/modules/CreditNotes/BulkDeleteCreditNotes.service.ts b/packages/server/src/modules/CreditNotes/BulkDeleteCreditNotes.service.ts index a5ea6a717..e02202655 100644 --- a/packages/server/src/modules/CreditNotes/BulkDeleteCreditNotes.service.ts +++ b/packages/server/src/modules/CreditNotes/BulkDeleteCreditNotes.service.ts @@ -8,7 +8,7 @@ import { DeleteCreditNoteService } from './commands/DeleteCreditNote.service'; export class BulkDeleteCreditNotesService { constructor( private readonly deleteCreditNoteService: DeleteCreditNoteService, - ) { } + ) {} async bulkDeleteCreditNotes( creditNoteIds: number | Array, @@ -35,4 +35,3 @@ export class BulkDeleteCreditNotesService { } } } - diff --git a/packages/server/src/modules/CreditNotes/CreditNoteApplication.service.ts b/packages/server/src/modules/CreditNotes/CreditNoteApplication.service.ts index b19119191..4931b624f 100644 --- a/packages/server/src/modules/CreditNotes/CreditNoteApplication.service.ts +++ b/packages/server/src/modules/CreditNotes/CreditNoteApplication.service.ts @@ -25,7 +25,7 @@ export class CreditNoteApplication { private readonly getCreditNoteService: GetCreditNoteService, private readonly bulkDeleteCreditNotesService: BulkDeleteCreditNotesService, private readonly validateBulkDeleteCreditNotesService: ValidateBulkDeleteCreditNotesService, - ) { } + ) {} /** * Creates a new credit note. diff --git a/packages/server/src/modules/CreditNotes/CreditNotes.controller.ts b/packages/server/src/modules/CreditNotes/CreditNotes.controller.ts index ddc34a6a3..8fe9edf40 100644 --- a/packages/server/src/modules/CreditNotes/CreditNotes.controller.ts +++ b/packages/server/src/modules/CreditNotes/CreditNotes.controller.ts @@ -49,7 +49,7 @@ export class CreditNotesController { /** * @param {CreditNoteApplication} creditNoteApplication - The credit note application service. */ - constructor(private creditNoteApplication: CreditNoteApplication) { } + constructor(private creditNoteApplication: CreditNoteApplication) {} @Post() @RequirePermission(CreditNoteAction.Create, AbilitySubject.CreditNote) diff --git a/packages/server/src/modules/CreditNotes/CreditNotes.module.ts b/packages/server/src/modules/CreditNotes/CreditNotes.module.ts index 26a44e004..fed356261 100644 --- a/packages/server/src/modules/CreditNotes/CreditNotes.module.ts +++ b/packages/server/src/modules/CreditNotes/CreditNotes.module.ts @@ -51,7 +51,7 @@ import { ValidateBulkDeleteCreditNotesService } from './ValidateBulkDeleteCredit DynamicListModule, InventoryCostModule, forwardRef(() => CreditNoteRefundsModule), - forwardRef(() => CreditNotesApplyInvoiceModule) + forwardRef(() => CreditNotesApplyInvoiceModule), ], providers: [ CreateCreditNoteService, @@ -95,4 +95,4 @@ import { ValidateBulkDeleteCreditNotesService } from './ValidateBulkDeleteCredit ], controllers: [CreditNotesController], }) -export class CreditNotesModule { } +export class CreditNotesModule {} diff --git a/packages/server/src/modules/CreditNotes/ValidateBulkDeleteCreditNotes.service.ts b/packages/server/src/modules/CreditNotes/ValidateBulkDeleteCreditNotes.service.ts index 18c011fb7..ed46cec36 100644 --- a/packages/server/src/modules/CreditNotes/ValidateBulkDeleteCreditNotes.service.ts +++ b/packages/server/src/modules/CreditNotes/ValidateBulkDeleteCreditNotes.service.ts @@ -9,7 +9,7 @@ export class ValidateBulkDeleteCreditNotesService { private readonly deleteCreditNoteService: DeleteCreditNoteService, @Inject(TENANCY_DB_CONNECTION) private readonly tenantKnex: () => Knex, - ) { } + ) {} public async validateBulkDeleteCreditNotes(creditNoteIds: number[]): Promise<{ deletableCount: number; @@ -51,4 +51,3 @@ export class ValidateBulkDeleteCreditNotesService { } } } - diff --git a/packages/server/src/modules/CreditNotes/commands/CommandCreditNoteDTOTransform.service.ts b/packages/server/src/modules/CreditNotes/commands/CommandCreditNoteDTOTransform.service.ts index 7e82500fc..7c2147510 100644 --- a/packages/server/src/modules/CreditNotes/commands/CommandCreditNoteDTOTransform.service.ts +++ b/packages/server/src/modules/CreditNotes/commands/CommandCreditNoteDTOTransform.service.ts @@ -34,7 +34,7 @@ export class CommandCreditNoteDTOTransform { private readonly warehouseDTOTransform: WarehouseTransactionDTOTransform, private readonly brandingTemplatesTransformer: BrandingTemplateDTOTransformer, private readonly creditNoteAutoIncrement: CreditNoteAutoIncrementService, - ) { } + ) {} /** * Transforms the credit/edit DTO to model. @@ -71,10 +71,9 @@ export class CommandCreditNoteDTOTransform { autoNextNumber; const initialDTO = { - ...formatDateFields( - omit(creditNoteDTO, ['open', 'attachments']), - ['creditNoteDate'], - ), + ...formatDateFields(omit(creditNoteDTO, ['open', 'attachments']), [ + 'creditNoteDate', + ]), creditNoteNumber, amount, currencyCode: customerCurrencyCode, @@ -82,8 +81,8 @@ export class CommandCreditNoteDTOTransform { entries, ...(creditNoteDTO.open && !oldCreditNote?.openedAt && { - openedAt: moment().toMySqlDateTime(), - }), + openedAt: moment().toMySqlDateTime(), + }), refundedAmount: 0, invoicesAmount: 0, }; diff --git a/packages/server/src/modules/CreditNotes/dtos/RefundCreditNote.dto.ts b/packages/server/src/modules/CreditNotes/dtos/RefundCreditNote.dto.ts index a78b986a3..1b2d77d5a 100644 --- a/packages/server/src/modules/CreditNotes/dtos/RefundCreditNote.dto.ts +++ b/packages/server/src/modules/CreditNotes/dtos/RefundCreditNote.dto.ts @@ -7,6 +7,4 @@ import { IsString, } from 'class-validator'; -export class RefundCreditNoteDto { - -} +export class RefundCreditNoteDto {} diff --git a/packages/server/src/modules/CreditNotes/models/CreditNote.meta.ts b/packages/server/src/modules/CreditNotes/models/CreditNote.meta.ts index c11473407..a4a973bb4 100644 --- a/packages/server/src/modules/CreditNotes/models/CreditNote.meta.ts +++ b/packages/server/src/modules/CreditNotes/models/CreditNote.meta.ts @@ -1,4 +1,4 @@ -import { Features } from "@/common/types/Features"; +import { Features } from '@/common/types/Features'; function StatusFieldFilterQuery(query, role) { query.modify('filterByStatus', role.value); @@ -246,4 +246,4 @@ export const CreditNoteMeta = { required: true, }, }, -}; \ No newline at end of file +}; diff --git a/packages/server/src/modules/CreditNotes/queries/CreditNoteTransformer.ts b/packages/server/src/modules/CreditNotes/queries/CreditNoteTransformer.ts index 4bd148eb5..edf984687 100644 --- a/packages/server/src/modules/CreditNotes/queries/CreditNoteTransformer.ts +++ b/packages/server/src/modules/CreditNotes/queries/CreditNoteTransformer.ts @@ -1,6 +1,6 @@ -import { AttachmentTransformer } from "@/modules/Attachments/Attachment.transformer"; -import { ItemEntryTransformer } from "@/modules/TransactionItemEntry/ItemEntry.transformer"; -import { Transformer } from "@/modules/Transformer/Transformer"; +import { AttachmentTransformer } from '@/modules/Attachments/Attachment.transformer'; +import { ItemEntryTransformer } from '@/modules/TransactionItemEntry/ItemEntry.transformer'; +import { Transformer } from '@/modules/Transformer/Transformer'; export class CreditNoteTransformer extends Transformer { /** diff --git a/packages/server/src/modules/CreditNotes/queries/GetCreditNotePdf.serivce.ts b/packages/server/src/modules/CreditNotes/queries/GetCreditNotePdf.serivce.ts index 1c49af845..2f9e60846 100644 --- a/packages/server/src/modules/CreditNotes/queries/GetCreditNotePdf.serivce.ts +++ b/packages/server/src/modules/CreditNotes/queries/GetCreditNotePdf.serivce.ts @@ -34,7 +34,7 @@ export class GetCreditNotePdf { private readonly pdfTemplateModel: TenantModelProxy< typeof PdfTemplateModel >, - ) { } + ) {} /** * Retrieves credit note html content. diff --git a/packages/server/src/modules/CreditNotes/queries/RefundCreditNoteTransformer.ts b/packages/server/src/modules/CreditNotes/queries/RefundCreditNoteTransformer.ts index 2c3b1a759..138489466 100644 --- a/packages/server/src/modules/CreditNotes/queries/RefundCreditNoteTransformer.ts +++ b/packages/server/src/modules/CreditNotes/queries/RefundCreditNoteTransformer.ts @@ -1,6 +1,6 @@ -import { Transformer } from "@/modules/Transformer/Transformer"; +import { Transformer } from '@/modules/Transformer/Transformer'; -export class RefundCreditNoteTransformer extends Transformer{ +export class RefundCreditNoteTransformer extends Transformer { /** * Includeded attributes. * @returns {string[]} diff --git a/packages/server/src/modules/CreditNotes/subscribers/CreditNoteAutoSerialSubscriber.ts b/packages/server/src/modules/CreditNotes/subscribers/CreditNoteAutoSerialSubscriber.ts index d1f9e332f..c3859ea57 100644 --- a/packages/server/src/modules/CreditNotes/subscribers/CreditNoteAutoSerialSubscriber.ts +++ b/packages/server/src/modules/CreditNotes/subscribers/CreditNoteAutoSerialSubscriber.ts @@ -8,14 +8,14 @@ import { events } from '@/common/events/events'; export class CreditNoteAutoSerialSubscriber { constructor( private readonly creditNoteIncrementService: CreditNoteAutoIncrementService, - ) { } + ) {} /** * Auto serial increment once credit note created. * @param {ICreditNoteCreatedPayload} payload - */ @OnEvent(events.creditNote.onCreated) - async autoSerialIncrementOnceCreated({ }: ICreditNoteCreatedPayload) { + async autoSerialIncrementOnceCreated({}: ICreditNoteCreatedPayload) { await this.creditNoteIncrementService.incrementSerialNumber(); } } diff --git a/packages/server/src/modules/CreditNotes/subscribers/CreditNoteGLEntriesSubscriber.ts b/packages/server/src/modules/CreditNotes/subscribers/CreditNoteGLEntriesSubscriber.ts index 66c085c49..3208ab348 100644 --- a/packages/server/src/modules/CreditNotes/subscribers/CreditNoteGLEntriesSubscriber.ts +++ b/packages/server/src/modules/CreditNotes/subscribers/CreditNoteGLEntriesSubscriber.ts @@ -73,6 +73,9 @@ export class CreditNoteGLEntriesSubscriber { // Can't continue if the credit note is not published yet. if (!creditNote.isPublished) return; - await this.creditNoteGLEntries.editVendorCreditGLEntries(creditNote.id, trx); + await this.creditNoteGLEntries.editVendorCreditGLEntries( + creditNote.id, + trx, + ); } } diff --git a/packages/server/src/modules/CreditNotes/utils.ts b/packages/server/src/modules/CreditNotes/utils.ts index d06550c98..193e7d6c6 100644 --- a/packages/server/src/modules/CreditNotes/utils.ts +++ b/packages/server/src/modules/CreditNotes/utils.ts @@ -3,7 +3,7 @@ import { CreditNotePdfTemplateAttributes, ICreditNote } from '@/interfaces'; import { contactAddressTextFormat } from '@/utils/address-text-format'; export const transformCreditNoteToPdfTemplate = ( - creditNote: ICreditNote + creditNote: ICreditNote, ): Partial => { return { creditNoteDate: creditNote.formattedCreditNoteDate, diff --git a/packages/server/src/modules/CreditNotesApplyInvoice/CreditNotesApplyInvoice.controller.ts b/packages/server/src/modules/CreditNotesApplyInvoice/CreditNotesApplyInvoice.controller.ts index 97cfeb803..19f29b217 100644 --- a/packages/server/src/modules/CreditNotesApplyInvoice/CreditNotesApplyInvoice.controller.ts +++ b/packages/server/src/modules/CreditNotesApplyInvoice/CreditNotesApplyInvoice.controller.ts @@ -30,7 +30,10 @@ import { CreditNoteInvoiceToApplyResponseDto } from './dtos/CreditNoteInvoiceToA @Controller('credit-notes') @ApiTags('Credit Notes Apply Invoice') -@ApiExtraModels(AppliedCreditNoteInvoiceResponseDto, CreditNoteInvoiceToApplyResponseDto) +@ApiExtraModels( + AppliedCreditNoteInvoiceResponseDto, + CreditNoteInvoiceToApplyResponseDto, +) @ApiCommonHeaders() @UseGuards(AuthorizationGuard, PermissionGuard) export class CreditNotesApplyInvoiceController { diff --git a/packages/server/src/modules/CreditNotesApplyInvoice/queries/CreditNoteWithInvoicesToApplyTransformer.ts b/packages/server/src/modules/CreditNotesApplyInvoice/queries/CreditNoteWithInvoicesToApplyTransformer.ts index db3821019..ca324d51d 100644 --- a/packages/server/src/modules/CreditNotesApplyInvoice/queries/CreditNoteWithInvoicesToApplyTransformer.ts +++ b/packages/server/src/modules/CreditNotesApplyInvoice/queries/CreditNoteWithInvoicesToApplyTransformer.ts @@ -1,4 +1,4 @@ -import { Transformer } from "@/modules/Transformer/Transformer"; +import { Transformer } from '@/modules/Transformer/Transformer'; export class CreditNoteWithInvoicesToApplyTransformer extends Transformer { /** diff --git a/packages/server/src/modules/CreditNotesApplyInvoice/queries/GetCreditNoteAssociatedAppliedInvoices.service.ts b/packages/server/src/modules/CreditNotesApplyInvoice/queries/GetCreditNoteAssociatedAppliedInvoices.service.ts index 32639282b..afc3f2de2 100644 --- a/packages/server/src/modules/CreditNotesApplyInvoice/queries/GetCreditNoteAssociatedAppliedInvoices.service.ts +++ b/packages/server/src/modules/CreditNotesApplyInvoice/queries/GetCreditNoteAssociatedAppliedInvoices.service.ts @@ -16,7 +16,9 @@ export class GetCreditNoteAssociatedAppliedInvoices { private readonly transformer: TransformerInjectable, @Inject(CreditNoteAppliedInvoice.name) - private readonly creditNoteAppliedInvoiceModel: TenantModelProxy, + private readonly creditNoteAppliedInvoiceModel: TenantModelProxy< + typeof CreditNoteAppliedInvoice + >, @Inject(CreditNote.name) private readonly creditNoteModel: TenantModelProxy, diff --git a/packages/server/src/modules/Currencies/Currencies.module.ts b/packages/server/src/modules/Currencies/Currencies.module.ts index cc00e878f..34271cd2b 100644 --- a/packages/server/src/modules/Currencies/Currencies.module.ts +++ b/packages/server/src/modules/Currencies/Currencies.module.ts @@ -25,8 +25,8 @@ const models = [RegisterTenancyModel(Currency)]; GetCurrencyService, CurrenciesApplication, InitialCurrenciesSeedService, - SeedInitialCurrenciesOnSetupSubsriber + SeedInitialCurrenciesOnSetupSubsriber, ], - controllers: [CurrenciesController] + controllers: [CurrenciesController], }) export class CurrenciesModule {} diff --git a/packages/server/src/modules/Currencies/Currency.transformer.ts b/packages/server/src/modules/Currencies/Currency.transformer.ts index 8ab985b87..fb3342371 100644 --- a/packages/server/src/modules/Currencies/Currency.transformer.ts +++ b/packages/server/src/modules/Currencies/Currency.transformer.ts @@ -1,4 +1,4 @@ -import { Transformer } from "../Transformer/Transformer"; +import { Transformer } from '../Transformer/Transformer'; export class CurrencyTransformer extends Transformer { /** diff --git a/packages/server/src/modules/Currencies/commands/DeleteCurrency.service.ts b/packages/server/src/modules/Currencies/commands/DeleteCurrency.service.ts index a50fa867b..937dfea07 100644 --- a/packages/server/src/modules/Currencies/commands/DeleteCurrency.service.ts +++ b/packages/server/src/modules/Currencies/commands/DeleteCurrency.service.ts @@ -19,7 +19,8 @@ export class DeleteCurrencyService { * @return {Promise} */ public async deleteCurrency(currencyCode: string): Promise { - const foundCurrency = await this.currencyModel().query() + const foundCurrency = await this.currencyModel() + .query() .findOne('currency_code', currencyCode) .throwIfNotFound(); diff --git a/packages/server/src/modules/Currencies/commands/InitialCurrenciesSeed.service.ts b/packages/server/src/modules/Currencies/commands/InitialCurrenciesSeed.service.ts index b4a0868cd..33350fcb5 100644 --- a/packages/server/src/modules/Currencies/commands/InitialCurrenciesSeed.service.ts +++ b/packages/server/src/modules/Currencies/commands/InitialCurrenciesSeed.service.ts @@ -10,7 +10,7 @@ export class InitialCurrenciesSeedService { constructor( @Inject(Currency.name) private readonly currencyModel: TenantModelProxy, - ) { } + ) {} /** * Seeds the given base currency to the currencies list. diff --git a/packages/server/src/modules/Currencies/dtos/CreateCurrency.dto.ts b/packages/server/src/modules/Currencies/dtos/CreateCurrency.dto.ts index 6fafe7ef4..e0c5b6fcd 100644 --- a/packages/server/src/modules/Currencies/dtos/CreateCurrency.dto.ts +++ b/packages/server/src/modules/Currencies/dtos/CreateCurrency.dto.ts @@ -1,12 +1,12 @@ -import { ApiProperty } from "@nestjs/swagger"; -import { IsNotEmpty } from "class-validator"; -import { IsString } from "class-validator"; +import { ApiProperty } from '@nestjs/swagger'; +import { IsNotEmpty } from 'class-validator'; +import { IsString } from 'class-validator'; -export class CreateCurrencyDto { +export class CreateCurrencyDto { @IsString() @IsNotEmpty() @ApiProperty({ example: 'USD', description: 'The currency name' }) - currencyName: string; + currencyName: string; @IsString() @IsNotEmpty() diff --git a/packages/server/src/modules/Currencies/dtos/EditCurrency.dto.ts b/packages/server/src/modules/Currencies/dtos/EditCurrency.dto.ts index 4c25248b9..efc2d2b4e 100644 --- a/packages/server/src/modules/Currencies/dtos/EditCurrency.dto.ts +++ b/packages/server/src/modules/Currencies/dtos/EditCurrency.dto.ts @@ -1,6 +1,6 @@ -import { ApiProperty } from "@nestjs/swagger"; -import { IsNotEmpty } from "class-validator"; -import { IsString } from "class-validator"; +import { ApiProperty } from '@nestjs/swagger'; +import { IsNotEmpty } from 'class-validator'; +import { IsString } from 'class-validator'; export class EditCurrencyDto { @IsString() diff --git a/packages/server/src/modules/Currencies/queries/GetCurrencies.service.ts b/packages/server/src/modules/Currencies/queries/GetCurrencies.service.ts index 19f4840ca..2ad9f3275 100644 --- a/packages/server/src/modules/Currencies/queries/GetCurrencies.service.ts +++ b/packages/server/src/modules/Currencies/queries/GetCurrencies.service.ts @@ -1,8 +1,8 @@ -import { Inject, Injectable } from "@nestjs/common"; -import { Currency } from "../models/Currency.model"; -import { TenantModelProxy } from "../../System/models/TenantBaseModel"; -import { TransformerInjectable } from "../../Transformer/TransformerInjectable.service"; -import { CurrencyTransformer } from "../Currency.transformer"; +import { Inject, Injectable } from '@nestjs/common'; +import { Currency } from '../models/Currency.model'; +import { TenantModelProxy } from '../../System/models/TenantBaseModel'; +import { TransformerInjectable } from '../../Transformer/TransformerInjectable.service'; +import { CurrencyTransformer } from '../Currency.transformer'; @Injectable() export class GetCurrenciesService { @@ -10,20 +10,20 @@ export class GetCurrenciesService { @Inject(Currency.name) private readonly currencyModel: TenantModelProxy, private readonly transformerInjectable: TransformerInjectable, - ) { - - } + ) {} /** * Retrieves currencies list. * @return {Promise} */ public async getCurrencies(): Promise { - const currencies = await this.currencyModel().query().onBuild((query) => { - query.orderBy('createdAt', 'ASC'); - }); + const currencies = await this.currencyModel() + .query() + .onBuild((query) => { + query.orderBy('createdAt', 'ASC'); + }); return this.transformerInjectable.transform( currencies, - new CurrencyTransformer() + new CurrencyTransformer(), ); } -} \ No newline at end of file +} diff --git a/packages/server/src/modules/Customers/BulkDeleteCustomers.service.ts b/packages/server/src/modules/Customers/BulkDeleteCustomers.service.ts index add4d19f6..de0256f71 100644 --- a/packages/server/src/modules/Customers/BulkDeleteCustomers.service.ts +++ b/packages/server/src/modules/Customers/BulkDeleteCustomers.service.ts @@ -31,4 +31,3 @@ export class BulkDeleteCustomersService { } } } - diff --git a/packages/server/src/modules/Customers/CustomerGLEntries.ts b/packages/server/src/modules/Customers/CustomerGLEntries.ts index e35b8e674..71a01e619 100644 --- a/packages/server/src/modules/Customers/CustomerGLEntries.ts +++ b/packages/server/src/modules/Customers/CustomerGLEntries.ts @@ -32,7 +32,7 @@ export class CustomerGLEntries { */ private getCustomerOpeningGLCreditEntry = ( ARAccountId: number, - customer: Customer + customer: Customer, ): ILedgerEntry => { const commonEntry = this.getCustomerOpeningGLCommonEntry(customer); @@ -51,7 +51,7 @@ export class CustomerGLEntries { */ private getCustomerOpeningGLDebitEntry = ( incomeAccountId: number, - customer: Customer + customer: Customer, ): ILedgerEntry => { const commonEntry = this.getCustomerOpeningGLCommonEntry(customer); @@ -72,15 +72,15 @@ export class CustomerGLEntries { public getCustomerOpeningGLEntries = ( ARAccountId: number, incomeAccountId: number, - customer: Customer + customer: Customer, ) => { const debitEntry = this.getCustomerOpeningGLDebitEntry( incomeAccountId, - customer + customer, ); const creditEntry = this.getCustomerOpeningGLCreditEntry( ARAccountId, - customer + customer, ); return [debitEntry, creditEntry]; }; @@ -91,12 +91,12 @@ export class CustomerGLEntries { public getCustomerOpeningLedger = ( ARAccountId: number, incomeAccountId: number, - customer: Customer + customer: Customer, ) => { const entries = this.getCustomerOpeningGLEntries( ARAccountId, incomeAccountId, - customer + customer, ); return new Ledger(entries); }; diff --git a/packages/server/src/modules/Customers/CustomerGLEntriesStorage.ts b/packages/server/src/modules/Customers/CustomerGLEntriesStorage.ts index fddd24556..ee597e27d 100644 --- a/packages/server/src/modules/Customers/CustomerGLEntriesStorage.ts +++ b/packages/server/src/modules/Customers/CustomerGLEntriesStorage.ts @@ -19,7 +19,7 @@ export class CustomerGLEntriesStorage { @Inject(Customer.name) private readonly customerModel: TenantModelProxy, - ) { } + ) {} /** * Customer opening balance journals. @@ -28,9 +28,7 @@ export class CustomerGLEntriesStorage { customerId: number, trx?: Knex.Transaction, ) => { - const customer = await this.customerModel() - .query(trx) - .findById(customerId); + const customer = await this.customerModel().query(trx).findById(customerId); // Finds the income account. const incomeAccount = await this.accountModel() diff --git a/packages/server/src/modules/Customers/Customers.controller.ts b/packages/server/src/modules/Customers/Customers.controller.ts index 577919258..e45078fb4 100644 --- a/packages/server/src/modules/Customers/Customers.controller.ts +++ b/packages/server/src/modules/Customers/Customers.controller.ts @@ -40,7 +40,7 @@ import { CustomerAction } from './types/Customers.types'; @ApiCommonHeaders() @UseGuards(AuthorizationGuard, PermissionGuard) export class CustomersController { - constructor(private customersApplication: CustomersApplication) { } + constructor(private customersApplication: CustomersApplication) {} @Get(':id') @RequirePermission(CustomerAction.View, AbilitySubject.Customer) diff --git a/packages/server/src/modules/Customers/ValidateBulkDeleteCustomers.service.ts b/packages/server/src/modules/Customers/ValidateBulkDeleteCustomers.service.ts index b8ffbed80..b866b5f60 100644 --- a/packages/server/src/modules/Customers/ValidateBulkDeleteCustomers.service.ts +++ b/packages/server/src/modules/Customers/ValidateBulkDeleteCustomers.service.ts @@ -58,4 +58,3 @@ export class ValidateBulkDeleteCustomersService { } } } - diff --git a/packages/server/src/modules/Customers/_SampleData.ts b/packages/server/src/modules/Customers/_SampleData.ts index 601d845d5..00685a8b2 100644 --- a/packages/server/src/modules/Customers/_SampleData.ts +++ b/packages/server/src/modules/Customers/_SampleData.ts @@ -1,158 +1,157 @@ - export const CustomersSampleData = [ { - "Customer Type": "Business", - "First Name": "Nicolette", - "Last Name": "Schamberger", - "Company Name": "Homenick - Hane", - "Display Name": "Rowland Rowe", - "Email": "cicero86@yahoo.com", - "Personal Phone Number": "811-603-2235", - "Work Phone Number": "906-993-5190", - "Website": "http://google.com", - "Opening Balance": 54302.23, - "Opening Balance At": "2022-02-02", - "Opening Balance Ex. Rate": 2, - "Currency": "LYD", - "Active": "F", - "Note": "Doloribus autem optio temporibus dolores mollitia sit.", - "Billing Address 1": "862 Jessika Well", - "Billing Address 2": "1091 Dorthy Mount", - "Billing Address City": "Deckowfort", - "Billing Address Country": "Ghana", - "Billing Address Phone": "825-011-5207", - "Billing Address Postcode": "38228", - "Billing Address State": "Oregon", - "Shipping Address 1": "37626 Thiel Villages", - "Shipping Address 2": "132 Batz Avenue", - "Shipping Address City": "Pagacburgh", - "Shipping Address Country": "Albania", - "Shipping Address Phone": "171-546-3701", - "Shipping Address Postcode": "13709", - "Shipping Address State": "Georgia" + 'Customer Type': 'Business', + 'First Name': 'Nicolette', + 'Last Name': 'Schamberger', + 'Company Name': 'Homenick - Hane', + 'Display Name': 'Rowland Rowe', + Email: 'cicero86@yahoo.com', + 'Personal Phone Number': '811-603-2235', + 'Work Phone Number': '906-993-5190', + Website: 'http://google.com', + 'Opening Balance': 54302.23, + 'Opening Balance At': '2022-02-02', + 'Opening Balance Ex. Rate': 2, + Currency: 'LYD', + Active: 'F', + Note: 'Doloribus autem optio temporibus dolores mollitia sit.', + 'Billing Address 1': '862 Jessika Well', + 'Billing Address 2': '1091 Dorthy Mount', + 'Billing Address City': 'Deckowfort', + 'Billing Address Country': 'Ghana', + 'Billing Address Phone': '825-011-5207', + 'Billing Address Postcode': '38228', + 'Billing Address State': 'Oregon', + 'Shipping Address 1': '37626 Thiel Villages', + 'Shipping Address 2': '132 Batz Avenue', + 'Shipping Address City': 'Pagacburgh', + 'Shipping Address Country': 'Albania', + 'Shipping Address Phone': '171-546-3701', + 'Shipping Address Postcode': '13709', + 'Shipping Address State': 'Georgia', }, { - "Customer Type": "Business", - "First Name": "Hermann", - "Last Name": "Crooks", - "Company Name": "Veum - Schaefer", - "Display Name": "Harley Veum", - "Email": "immanuel56@hotmail.com", - "Personal Phone Number": "449-780-9999", - "Work Phone Number": "970-473-5785", - "Website": "http://google.com", - "Opening Balance": 54302.23, - "Opening Balance At": "2022-02-02", - "Opening Balance Ex. Rate": 2, - "Currency": "LYD", - "Active": "T", - "Note": "Doloribus dolore dolor dicta vitae in fugit nisi quibusdam.", - "Billing Address 1": "532 Simonis Spring", - "Billing Address 2": "3122 Nicolas Inlet", - "Billing Address City": "East Matteofort", - "Billing Address Country": "Holy See (Vatican City State)", - "Billing Address Phone": "366-084-8629", - "Billing Address Postcode": "41607", - "Billing Address State": "Montana", - "Shipping Address 1": "2889 Tremblay Plaza", - "Shipping Address 2": "71355 Kutch Isle", - "Shipping Address City": "D'Amorehaven", - "Shipping Address Country": "Monaco", - "Shipping Address Phone": "614-189-3328", - "Shipping Address Postcode": "09634-0435", - "Shipping Address State": "Nevada" + 'Customer Type': 'Business', + 'First Name': 'Hermann', + 'Last Name': 'Crooks', + 'Company Name': 'Veum - Schaefer', + 'Display Name': 'Harley Veum', + Email: 'immanuel56@hotmail.com', + 'Personal Phone Number': '449-780-9999', + 'Work Phone Number': '970-473-5785', + Website: 'http://google.com', + 'Opening Balance': 54302.23, + 'Opening Balance At': '2022-02-02', + 'Opening Balance Ex. Rate': 2, + Currency: 'LYD', + Active: 'T', + Note: 'Doloribus dolore dolor dicta vitae in fugit nisi quibusdam.', + 'Billing Address 1': '532 Simonis Spring', + 'Billing Address 2': '3122 Nicolas Inlet', + 'Billing Address City': 'East Matteofort', + 'Billing Address Country': 'Holy See (Vatican City State)', + 'Billing Address Phone': '366-084-8629', + 'Billing Address Postcode': '41607', + 'Billing Address State': 'Montana', + 'Shipping Address 1': '2889 Tremblay Plaza', + 'Shipping Address 2': '71355 Kutch Isle', + 'Shipping Address City': "D'Amorehaven", + 'Shipping Address Country': 'Monaco', + 'Shipping Address Phone': '614-189-3328', + 'Shipping Address Postcode': '09634-0435', + 'Shipping Address State': 'Nevada', }, { - "Customer Type": "Business", - "First Name": "Nellie", - "Last Name": "Gulgowski", - "Company Name": "Boyle, Heller and Jones", - "Display Name": "Randall Kohler", - "Email": "anibal_frami@yahoo.com", - "Personal Phone Number": "498-578-0740", - "Work Phone Number": "394-550-6827", - "Website": "http://google.com", - "Opening Balance": 54302.23, - "Opening Balance At": "2022-02-02", - "Opening Balance Ex. Rate": 2, - "Currency": "LYD", - "Active": "T", - "Note": "Vero quibusdam rem fugit aperiam est modi.", - "Billing Address 1": "214 Sauer Villages", - "Billing Address 2": "30687 Kacey Square", - "Billing Address City": "Jayceborough", - "Billing Address Country": "Benin", - "Billing Address Phone": "332-820-1127", - "Billing Address Postcode": "16425-3887", - "Billing Address State": "Mississippi", - "Shipping Address 1": "562 Diamond Loaf", - "Shipping Address 2": "9595 Satterfield Trafficway", - "Shipping Address City": "Alexandrinefort", - "Shipping Address Country": "Puerto Rico", - "Shipping Address Phone": "776-500-8456", - "Shipping Address Postcode": "30258", - "Shipping Address State": "South Dakota" + 'Customer Type': 'Business', + 'First Name': 'Nellie', + 'Last Name': 'Gulgowski', + 'Company Name': 'Boyle, Heller and Jones', + 'Display Name': 'Randall Kohler', + Email: 'anibal_frami@yahoo.com', + 'Personal Phone Number': '498-578-0740', + 'Work Phone Number': '394-550-6827', + Website: 'http://google.com', + 'Opening Balance': 54302.23, + 'Opening Balance At': '2022-02-02', + 'Opening Balance Ex. Rate': 2, + Currency: 'LYD', + Active: 'T', + Note: 'Vero quibusdam rem fugit aperiam est modi.', + 'Billing Address 1': '214 Sauer Villages', + 'Billing Address 2': '30687 Kacey Square', + 'Billing Address City': 'Jayceborough', + 'Billing Address Country': 'Benin', + 'Billing Address Phone': '332-820-1127', + 'Billing Address Postcode': '16425-3887', + 'Billing Address State': 'Mississippi', + 'Shipping Address 1': '562 Diamond Loaf', + 'Shipping Address 2': '9595 Satterfield Trafficway', + 'Shipping Address City': 'Alexandrinefort', + 'Shipping Address Country': 'Puerto Rico', + 'Shipping Address Phone': '776-500-8456', + 'Shipping Address Postcode': '30258', + 'Shipping Address State': 'South Dakota', }, { - "Customer Type": "Business", - "First Name": "Stone", - "Last Name": "Jerde", - "Company Name": "Cassin, Casper and Maggio", - "Display Name": "Clint McLaughlin", - "Email": "nathanael22@yahoo.com", - "Personal Phone Number": "562-790-6059", - "Work Phone Number": "686-838-0027", - "Website": "http://google.com", - "Opening Balance": 54302.23, - "Opening Balance At": "2022-02-02", - "Opening Balance Ex. Rate": 2, - "Currency": "LYD", - "Active": "F", - "Note": "Quis cumque molestias rerum.", - "Billing Address 1": "22590 Cathy Harbor", - "Billing Address 2": "24493 Brycen Brooks", - "Billing Address City": "Elnorashire", - "Billing Address Country": "Andorra", - "Billing Address Phone": "701-852-8005", - "Billing Address Postcode": "5680", - "Billing Address State": "Nevada", - "Shipping Address 1": "5355 Erdman Bridge", - "Shipping Address 2": "421 Jeanette Camp", - "Shipping Address City": "East Philip", - "Shipping Address Country": "Venezuela", - "Shipping Address Phone": "426-119-0858", - "Shipping Address Postcode": "34929-0501", - "Shipping Address State": "Tennessee" + 'Customer Type': 'Business', + 'First Name': 'Stone', + 'Last Name': 'Jerde', + 'Company Name': 'Cassin, Casper and Maggio', + 'Display Name': 'Clint McLaughlin', + Email: 'nathanael22@yahoo.com', + 'Personal Phone Number': '562-790-6059', + 'Work Phone Number': '686-838-0027', + Website: 'http://google.com', + 'Opening Balance': 54302.23, + 'Opening Balance At': '2022-02-02', + 'Opening Balance Ex. Rate': 2, + Currency: 'LYD', + Active: 'F', + Note: 'Quis cumque molestias rerum.', + 'Billing Address 1': '22590 Cathy Harbor', + 'Billing Address 2': '24493 Brycen Brooks', + 'Billing Address City': 'Elnorashire', + 'Billing Address Country': 'Andorra', + 'Billing Address Phone': '701-852-8005', + 'Billing Address Postcode': '5680', + 'Billing Address State': 'Nevada', + 'Shipping Address 1': '5355 Erdman Bridge', + 'Shipping Address 2': '421 Jeanette Camp', + 'Shipping Address City': 'East Philip', + 'Shipping Address Country': 'Venezuela', + 'Shipping Address Phone': '426-119-0858', + 'Shipping Address Postcode': '34929-0501', + 'Shipping Address State': 'Tennessee', }, { - "Customer Type": "Individual", - "First Name": "Lempi", - "Last Name": "Kling", - "Company Name": "Schamberger, O'Connell and Bechtelar", - "Display Name": "Alexie Barton", - "Email": "eulah.kreiger@hotmail.com", - "Personal Phone Number": "745-756-1063", - "Work Phone Number": "965-150-1945", - "Website": "http://google.com", - "Opening Balance": 54302.23, - "Opening Balance At": "2022-02-02", - "Opening Balance Ex. Rate": 2, - "Currency": "LYD", - "Active": "F", - "Note": "Maxime laboriosam hic voluptate maiores est officia.", - "Billing Address 1": "0851 Jones Flat", - "Billing Address 2": "845 Bailee Drives", - "Billing Address City": "Kamrenport", - "Billing Address Country": "Niger", - "Billing Address Phone": "220-125-0608", - "Billing Address Postcode": "30311", - "Billing Address State": "Delaware", - "Shipping Address 1": "929 Ferry Row", - "Shipping Address 2": "020 Adam Plaza", - "Shipping Address City": "West Carmellaside", - "Shipping Address Country": "Ghana", - "Shipping Address Phone": "053-333-6679", - "Shipping Address Postcode": "79221-4681", - "Shipping Address State": "Illinois" - } -] + 'Customer Type': 'Individual', + 'First Name': 'Lempi', + 'Last Name': 'Kling', + 'Company Name': "Schamberger, O'Connell and Bechtelar", + 'Display Name': 'Alexie Barton', + Email: 'eulah.kreiger@hotmail.com', + 'Personal Phone Number': '745-756-1063', + 'Work Phone Number': '965-150-1945', + Website: 'http://google.com', + 'Opening Balance': 54302.23, + 'Opening Balance At': '2022-02-02', + 'Opening Balance Ex. Rate': 2, + Currency: 'LYD', + Active: 'F', + Note: 'Maxime laboriosam hic voluptate maiores est officia.', + 'Billing Address 1': '0851 Jones Flat', + 'Billing Address 2': '845 Bailee Drives', + 'Billing Address City': 'Kamrenport', + 'Billing Address Country': 'Niger', + 'Billing Address Phone': '220-125-0608', + 'Billing Address Postcode': '30311', + 'Billing Address State': 'Delaware', + 'Shipping Address 1': '929 Ferry Row', + 'Shipping Address 2': '020 Adam Plaza', + 'Shipping Address City': 'West Carmellaside', + 'Shipping Address Country': 'Ghana', + 'Shipping Address Phone': '053-333-6679', + 'Shipping Address Postcode': '79221-4681', + 'Shipping Address State': 'Illinois', + }, +]; diff --git a/packages/server/src/modules/Customers/dtos/BulkDeleteCustomers.dto.ts b/packages/server/src/modules/Customers/dtos/BulkDeleteCustomers.dto.ts index a08230fdf..d7c540e92 100644 --- a/packages/server/src/modules/Customers/dtos/BulkDeleteCustomers.dto.ts +++ b/packages/server/src/modules/Customers/dtos/BulkDeleteCustomers.dto.ts @@ -22,7 +22,9 @@ export class BulkDeleteCustomersDto { @IsOptional() @IsBoolean() - @Transform(({ value, obj }) => parseBoolean(value ?? obj?.skip_undeletable, false)) + @Transform(({ value, obj }) => + parseBoolean(value ?? obj?.skip_undeletable, false), + ) @ApiPropertyOptional({ description: 'When true, undeletable customers will be skipped and only deletable ones removed.', @@ -59,4 +61,3 @@ export class ValidateBulkDeleteCustomersResponseDto { }) nonDeletableIds: number[]; } - diff --git a/packages/server/src/modules/Customers/dtos/CreateCustomer.dto.ts b/packages/server/src/modules/Customers/dtos/CreateCustomer.dto.ts index fa1032e56..df5366196 100644 --- a/packages/server/src/modules/Customers/dtos/CreateCustomer.dto.ts +++ b/packages/server/src/modules/Customers/dtos/CreateCustomer.dto.ts @@ -41,11 +41,14 @@ export class CreateCustomerDto extends ContactAddressDto { @ApiProperty({ required: false, - description: 'Opening balance date (required when openingBalance is provided)', + description: + 'Opening balance date (required when openingBalance is provided)', example: '2024-01-01', }) @ValidateIf((o) => o.openingBalance != null) - @IsNotEmpty({ message: 'openingBalanceAt is required when openingBalance is provided' }) + @IsNotEmpty({ + message: 'openingBalanceAt is required when openingBalance is provided', + }) @IsString() openingBalanceAt?: string; diff --git a/packages/server/src/modules/Customers/models/Customer.meta.ts b/packages/server/src/modules/Customers/models/Customer.meta.ts index 4651a0ac4..39dfd51d6 100644 --- a/packages/server/src/modules/Customers/models/Customer.meta.ts +++ b/packages/server/src/modules/Customers/models/Customer.meta.ts @@ -146,7 +146,7 @@ export const CustomerMeta = { name: 'vendor.field.opening_balance_at', type: 'date', printable: false, - accessor: 'formattedOpeningBalanceAt' + accessor: 'formattedOpeningBalanceAt', }, currencyCode: { name: 'vendor.field.currency', @@ -419,4 +419,4 @@ function statusFieldFilterQuery(query, role) { query.modify('unpaid'); break; } -} \ No newline at end of file +} diff --git a/packages/server/src/modules/Customers/queries/CustomerTransformer.ts b/packages/server/src/modules/Customers/queries/CustomerTransformer.ts index aa5e1f132..ace67973c 100644 --- a/packages/server/src/modules/Customers/queries/CustomerTransformer.ts +++ b/packages/server/src/modules/Customers/queries/CustomerTransformer.ts @@ -1,4 +1,4 @@ -import { ContactTransfromer } from "../../Contacts/Contact.transformer"; +import { ContactTransfromer } from '../../Contacts/Contact.transformer'; export class CustomerTransfromer extends ContactTransfromer { /** diff --git a/packages/server/src/modules/Customers/subscribers/CustomerGLEntriesSubscriber.ts b/packages/server/src/modules/Customers/subscribers/CustomerGLEntriesSubscriber.ts index 8d9578bc4..d13abe898 100644 --- a/packages/server/src/modules/Customers/subscribers/CustomerGLEntriesSubscriber.ts +++ b/packages/server/src/modules/Customers/subscribers/CustomerGLEntriesSubscriber.ts @@ -10,7 +10,7 @@ import { CustomerGLEntriesStorage } from '../CustomerGLEntriesStorage'; @Injectable() export class CustomerWriteGLOpeningBalanceSubscriber { - constructor(private readonly customerGLEntries: CustomerGLEntriesStorage) { } + constructor(private readonly customerGLEntries: CustomerGLEntriesStorage) {} /** * Handles the writing opening balance journal entries once the customer created. diff --git a/packages/server/src/modules/Customers/types/Customers.types.ts b/packages/server/src/modules/Customers/types/Customers.types.ts index 3ac45a3a7..9f59b924a 100644 --- a/packages/server/src/modules/Customers/types/Customers.types.ts +++ b/packages/server/src/modules/Customers/types/Customers.types.ts @@ -129,9 +129,8 @@ export interface ICustomerOpeningBalanceEditedPayload { trx: Knex.Transaction; } - export interface ICustomerActivatingPayload { - trx: Knex.Transaction, + trx: Knex.Transaction; oldCustomer: Customer; } diff --git a/packages/server/src/modules/DynamicListing/DynamicFilter/DynamicFilter.types.ts b/packages/server/src/modules/DynamicListing/DynamicFilter/DynamicFilter.types.ts index 63e068bb0..a3e0249f4 100644 --- a/packages/server/src/modules/DynamicListing/DynamicFilter/DynamicFilter.types.ts +++ b/packages/server/src/modules/DynamicListing/DynamicFilter/DynamicFilter.types.ts @@ -2,7 +2,7 @@ import { BaseModel } from '@/models/Model'; export enum ISortOrder { DESC = 'DESC', - ASC = 'ASC' + ASC = 'ASC', } export interface IDynamicFilter { @@ -29,10 +29,7 @@ export interface IDynamicListFilter { } export interface IDynamicListService { - dynamicList( - model: any, - filter: IDynamicListFilter, - ): Promise; + dynamicList(model: any, filter: IDynamicListFilter): Promise; handlerErrorsToResponse(error, req, res, next): void; } diff --git a/packages/server/src/modules/DynamicListing/DynamicFilter/DynamicFilterViews.ts b/packages/server/src/modules/DynamicListing/DynamicFilter/DynamicFilterViews.ts index 5b40e9b17..c71657710 100644 --- a/packages/server/src/modules/DynamicListing/DynamicFilter/DynamicFilterViews.ts +++ b/packages/server/src/modules/DynamicListing/DynamicFilter/DynamicFilterViews.ts @@ -32,7 +32,7 @@ export class DynamicFilterViews extends DynamicFilterRoleAbstractor { this.buildFilterQuery( this.model, this.filterRoles, - this.logicExpression + this.logicExpression, )(builder); }; } diff --git a/packages/server/src/modules/DynamicListing/DynamicFilter/constants.ts b/packages/server/src/modules/DynamicListing/DynamicFilter/constants.ts index f845e16c9..0ad0d824b 100644 --- a/packages/server/src/modules/DynamicListing/DynamicFilter/constants.ts +++ b/packages/server/src/modules/DynamicListing/DynamicFilter/constants.ts @@ -29,7 +29,7 @@ export const COMPARATOR_TYPE = { START_WITH: 'start_with', ENDS_WITH: 'ends_with', - END_WITH: 'end_with' + END_WITH: 'end_with', }; export const FIELD_TYPE = { @@ -39,5 +39,5 @@ export const FIELD_TYPE = { BOOLEAN: 'boolean', RELATION: 'relation', DATE: 'date', - COMPUTED: 'computed' + COMPUTED: 'computed', }; diff --git a/packages/server/src/modules/DynamicListing/DynamicList.service.ts b/packages/server/src/modules/DynamicListing/DynamicList.service.ts index 05575ea6c..cfd9c49e8 100644 --- a/packages/server/src/modules/DynamicListing/DynamicList.service.ts +++ b/packages/server/src/modules/DynamicListing/DynamicList.service.ts @@ -16,7 +16,7 @@ export class DynamicListService { private dynamicListSearch: DynamicListSearch, private dynamicListSortBy: DynamicListSortBy, private dynamicListView: DynamicListCustomView, - ) { } + ) {} /** * Parses filter DTO. @@ -31,9 +31,9 @@ export class DynamicListService { // Merges the default properties with filter object. ...(model.defaultSort ? { - sortOrder: model.defaultSort.sortOrder, - columnSortBy: model.defaultSort.sortOrder, - } + sortOrder: model.defaultSort.sortOrder, + columnSortBy: model.defaultSort.sortOrder, + } : {}), ...filterDTO, }; diff --git a/packages/server/src/modules/EventsTracker/EventTracker.interfaces.ts b/packages/server/src/modules/EventsTracker/EventTracker.interfaces.ts index d07e77df0..cf69518e5 100644 --- a/packages/server/src/modules/EventsTracker/EventTracker.interfaces.ts +++ b/packages/server/src/modules/EventsTracker/EventTracker.interfaces.ts @@ -1,3 +1,3 @@ interface ReportsEvents { tenantId: number; -} \ No newline at end of file +} diff --git a/packages/server/src/modules/EventsTracker/PostHog.constants.ts b/packages/server/src/modules/EventsTracker/PostHog.constants.ts index 10cd3a809..627efe376 100644 --- a/packages/server/src/modules/EventsTracker/PostHog.constants.ts +++ b/packages/server/src/modules/EventsTracker/PostHog.constants.ts @@ -1 +1 @@ -export const POSTHOG_PROVIDER = 'POSTHOG_PROVIDER'; \ No newline at end of file +export const POSTHOG_PROVIDER = 'POSTHOG_PROVIDER'; diff --git a/packages/server/src/modules/ExchangeRates/ExchangeRates.application.ts b/packages/server/src/modules/ExchangeRates/ExchangeRates.application.ts index ff12bca40..0fcd287d7 100644 --- a/packages/server/src/modules/ExchangeRates/ExchangeRates.application.ts +++ b/packages/server/src/modules/ExchangeRates/ExchangeRates.application.ts @@ -1,6 +1,9 @@ import { Injectable } from '@nestjs/common'; import { ExchangeRatesService } from './ExchangeRates.service'; -import { ExchangeRateLatestDTO, EchangeRateLatestPOJO } from './ExchangeRates.types'; +import { + ExchangeRateLatestDTO, + EchangeRateLatestPOJO, +} from './ExchangeRates.types'; @Injectable() export class ExchangeRateApplication { diff --git a/packages/server/src/modules/ExchangeRates/ExchangeRates.controller.ts b/packages/server/src/modules/ExchangeRates/ExchangeRates.controller.ts index 00f33e011..79e5d2f34 100644 --- a/packages/server/src/modules/ExchangeRates/ExchangeRates.controller.ts +++ b/packages/server/src/modules/ExchangeRates/ExchangeRates.controller.ts @@ -7,12 +7,7 @@ import { ValidationPipe, } from '@nestjs/common'; import { Request } from 'express'; -import { - ApiOperation, - ApiTags, - ApiResponse, - ApiQuery, -} from '@nestjs/swagger'; +import { ApiOperation, ApiTags, ApiResponse, ApiQuery } from '@nestjs/swagger'; import { ExchangeRateApplication } from './ExchangeRates.application'; import { ExchangeRateLatestQueryDto } from './dtos/ExchangeRateLatestQuery.dto'; import { ExchangeRateLatestResponseDto } from './dtos/ExchangeRateLatestResponse.dto'; diff --git a/packages/server/src/modules/ExchangeRates/ExchangeRates.service.ts b/packages/server/src/modules/ExchangeRates/ExchangeRates.service.ts index 074f587b7..722d86b28 100644 --- a/packages/server/src/modules/ExchangeRates/ExchangeRates.service.ts +++ b/packages/server/src/modules/ExchangeRates/ExchangeRates.service.ts @@ -2,7 +2,10 @@ import { Injectable } from '@nestjs/common'; import { ExchangeRate } from './lib/ExchangeRate'; import { ExchangeRateServiceType } from './lib/types'; import { TenantMetadata } from '@/modules/System/models/TenantMetadataModel'; -import { ExchangeRateLatestDTO, EchangeRateLatestPOJO } from './ExchangeRates.types'; +import { + ExchangeRateLatestDTO, + EchangeRateLatestPOJO, +} from './ExchangeRates.types'; @Injectable() export class ExchangeRatesService { diff --git a/packages/server/src/modules/ExchangeRates/lib/ExchangeRate.ts b/packages/server/src/modules/ExchangeRates/lib/ExchangeRate.ts index d0dcae12e..5bb84cff3 100644 --- a/packages/server/src/modules/ExchangeRates/lib/ExchangeRate.ts +++ b/packages/server/src/modules/ExchangeRates/lib/ExchangeRate.ts @@ -42,4 +42,4 @@ export class ExchangeRate { public latest(baseCurrency: string, toCurrency: string): Promise { return this.exchangeRateService.latest(baseCurrency, toCurrency); } -} \ No newline at end of file +} diff --git a/packages/server/src/modules/ExchangeRates/lib/OpenExchangeRate.ts b/packages/server/src/modules/ExchangeRates/lib/OpenExchangeRate.ts index be8d2da2d..b4999ae93 100644 --- a/packages/server/src/modules/ExchangeRates/lib/OpenExchangeRate.ts +++ b/packages/server/src/modules/ExchangeRates/lib/OpenExchangeRate.ts @@ -21,7 +21,7 @@ export class OpenExchangeRate implements IExchangeRateService { */ public async latest( baseCurrency: string, - toCurrency: string + toCurrency: string, ): Promise { // Validates the Open Exchange Rate api id early. this.validateApiIdExistance(); @@ -48,7 +48,7 @@ export class OpenExchangeRate implements IExchangeRateService { if (!this.appId) { throw new ServiceError( EchangeRateErrors.EX_RATE_SERVICE_API_KEY_REQUIRED, - 'Invalid App ID provided. Please sign up at https://openexchangerates.org/signup, or contact support@openexchangerates.org.' + 'Invalid App ID provided. Please sign up at https://openexchangerates.org/signup, or contact support@openexchangerates.org.', ); } } @@ -62,22 +62,22 @@ export class OpenExchangeRate implements IExchangeRateService { if (error.response?.data?.message === 'missing_app_id') { throw new ServiceError( EchangeRateErrors.EX_RATE_SERVICE_API_KEY_REQUIRED, - 'Invalid App ID provided. Please sign up at https://openexchangerates.org/signup, or contact support@openexchangerates.org.' + 'Invalid App ID provided. Please sign up at https://openexchangerates.org/signup, or contact support@openexchangerates.org.', ); } else if (error.response?.data?.message === 'invalid_app_id') { throw new ServiceError( EchangeRateErrors.EX_RATE_SERVICE_API_KEY_REQUIRED, - 'Invalid App ID provided. Please sign up at https://openexchangerates.org/signup, or contact support@openexchangerates.org.' + 'Invalid App ID provided. Please sign up at https://openexchangerates.org/signup, or contact support@openexchangerates.org.', ); } else if (error.response?.data?.message === 'not_allowed') { throw new ServiceError( EchangeRateErrors.EX_RATE_SERVICE_NOT_ALLOWED, - 'Getting the exchange rate from the given base currency to the given currency is not allowed.' + 'Getting the exchange rate from the given base currency to the given currency is not allowed.', ); } else if (error.response?.data?.message === 'invalid_base') { throw new ServiceError( EchangeRateErrors.EX_RATE_INVALID_BASE_CURRENCY, - 'The given base currency is invalid.' + 'The given base currency is invalid.', ); } throw error; diff --git a/packages/server/src/modules/ExchangeRates/lib/types.ts b/packages/server/src/modules/ExchangeRates/lib/types.ts index aa1f45481..8b40125cd 100644 --- a/packages/server/src/modules/ExchangeRates/lib/types.ts +++ b/packages/server/src/modules/ExchangeRates/lib/types.ts @@ -14,4 +14,4 @@ export enum EchangeRateErrors { } export const OPEN_EXCHANGE_RATE_LATEST_URL = - 'https://openexchangerates.org/api/latest.json'; \ No newline at end of file + 'https://openexchangerates.org/api/latest.json'; diff --git a/packages/server/src/modules/Expenses/BulkDeleteExpenses.service.ts b/packages/server/src/modules/Expenses/BulkDeleteExpenses.service.ts index 7e62444c4..d5f288256 100644 --- a/packages/server/src/modules/Expenses/BulkDeleteExpenses.service.ts +++ b/packages/server/src/modules/Expenses/BulkDeleteExpenses.service.ts @@ -6,7 +6,7 @@ import { DeleteExpense } from './commands/DeleteExpense.service'; @Injectable() export class BulkDeleteExpensesService { - constructor(private readonly deleteExpenseService: DeleteExpense) { } + constructor(private readonly deleteExpenseService: DeleteExpense) {} async bulkDeleteExpenses( expenseIds: number | Array, @@ -33,4 +33,3 @@ export class BulkDeleteExpensesService { } } } - diff --git a/packages/server/src/modules/Expenses/Expenses.controller.ts b/packages/server/src/modules/Expenses/Expenses.controller.ts index a55982f11..1f1581f58 100644 --- a/packages/server/src/modules/Expenses/Expenses.controller.ts +++ b/packages/server/src/modules/Expenses/Expenses.controller.ts @@ -42,7 +42,7 @@ import { ExpenseAction } from './Expenses.types'; @ApiCommonHeaders() @UseGuards(AuthorizationGuard, PermissionGuard) export class ExpensesController { - constructor(private readonly expensesApplication: ExpensesApplication) { } + constructor(private readonly expensesApplication: ExpensesApplication) {} @Post('validate-bulk-delete') @RequirePermission(ExpenseAction.Delete, AbilitySubject.Expense) @@ -72,9 +72,7 @@ export class ExpensesController { status: 200, description: 'Expenses deleted successfully', }) - public bulkDeleteExpenses( - @Body() bulkDeleteDto: BulkDeleteDto, - ) { + public bulkDeleteExpenses(@Body() bulkDeleteDto: BulkDeleteDto) { return this.expensesApplication.bulkDeleteExpenses(bulkDeleteDto.ids, { skipUndeletable: bulkDeleteDto.skipUndeletable ?? false, }); diff --git a/packages/server/src/modules/Expenses/ExpensesApplication.service.ts b/packages/server/src/modules/Expenses/ExpensesApplication.service.ts index a8dc8b39f..527f678fc 100644 --- a/packages/server/src/modules/Expenses/ExpensesApplication.service.ts +++ b/packages/server/src/modules/Expenses/ExpensesApplication.service.ts @@ -22,7 +22,7 @@ export class ExpensesApplication { private readonly getExpensesService: GetExpensesService, private readonly bulkDeleteExpensesService: BulkDeleteExpensesService, private readonly validateBulkDeleteExpensesService: ValidateBulkDeleteExpensesService, - ) { } + ) {} /** * Create a new expense transaction. diff --git a/packages/server/src/modules/Expenses/ExpensesExportable.ts b/packages/server/src/modules/Expenses/ExpensesExportable.ts index 5d2899a99..45396609e 100644 --- a/packages/server/src/modules/Expenses/ExpensesExportable.ts +++ b/packages/server/src/modules/Expenses/ExpensesExportable.ts @@ -10,9 +10,7 @@ import { ISortOrder } from '@/modules/DynamicListing/DynamicFilter/DynamicFilter @Injectable() @ExportableService({ name: Expense.name }) export class ExpensesExportable extends Exportable { - constructor( - private readonly expensesApplication: ExpensesApplication, - ) { + constructor(private readonly expensesApplication: ExpensesApplication) { super(); } diff --git a/packages/server/src/modules/Expenses/ValidateBulkDeleteExpenses.service.ts b/packages/server/src/modules/Expenses/ValidateBulkDeleteExpenses.service.ts index 42c73e304..6ecdfd1ec 100644 --- a/packages/server/src/modules/Expenses/ValidateBulkDeleteExpenses.service.ts +++ b/packages/server/src/modules/Expenses/ValidateBulkDeleteExpenses.service.ts @@ -9,7 +9,7 @@ export class ValidateBulkDeleteExpensesService { private readonly deleteExpenseService: DeleteExpense, @Inject(TENANCY_DB_CONNECTION) private readonly tenantKnex: () => Knex, - ) { } + ) {} public async validateBulkDeleteExpenses(expenseIds: number[]): Promise<{ deletableCount: number; @@ -48,4 +48,3 @@ export class ValidateBulkDeleteExpensesService { } } } - diff --git a/packages/server/src/modules/Expenses/dtos/Expense.dto.ts b/packages/server/src/modules/Expenses/dtos/Expense.dto.ts index 1d822f2e9..e1f536003 100644 --- a/packages/server/src/modules/Expenses/dtos/Expense.dto.ts +++ b/packages/server/src/modules/Expenses/dtos/Expense.dto.ts @@ -185,5 +185,5 @@ export class CommandExpenseDto { attachments?: AttachmentDto[]; } -export class CreateExpenseDto extends CommandExpenseDto { } -export class EditExpenseDto extends CommandExpenseDto { } +export class CreateExpenseDto extends CommandExpenseDto {} +export class EditExpenseDto extends CommandExpenseDto {} diff --git a/packages/server/src/modules/Expenses/models/Expense.meta.ts b/packages/server/src/modules/Expenses/models/Expense.meta.ts index bb09912a2..0f8047907 100644 --- a/packages/server/src/modules/Expenses/models/Expense.meta.ts +++ b/packages/server/src/modules/Expenses/models/Expense.meta.ts @@ -1,4 +1,4 @@ -import { Features } from "@/common/types/Features"; +import { Features } from '@/common/types/Features'; /** * Expense - Settings. @@ -203,4 +203,4 @@ function StatusFieldFilterQuery(query, role) { function StatusFieldSortQuery(query, role) { query.modify('sortByStatus', role.order); -} \ No newline at end of file +} diff --git a/packages/server/src/modules/Expenses/queries/ExpenseCategory.transformer.ts b/packages/server/src/modules/Expenses/queries/ExpenseCategory.transformer.ts index ded66bf63..6daf23e16 100644 --- a/packages/server/src/modules/Expenses/queries/ExpenseCategory.transformer.ts +++ b/packages/server/src/modules/Expenses/queries/ExpenseCategory.transformer.ts @@ -1,4 +1,3 @@ - import { Transformer } from '@/modules/Transformer/Transformer'; import { ExpenseCategory } from '../models/ExpenseCategory.model'; diff --git a/packages/server/src/modules/Expenses/subscribers/ExpenseGLEntriesStorage.sevice.ts b/packages/server/src/modules/Expenses/subscribers/ExpenseGLEntriesStorage.sevice.ts index a934e5e1b..4b8ca2f5a 100644 --- a/packages/server/src/modules/Expenses/subscribers/ExpenseGLEntriesStorage.sevice.ts +++ b/packages/server/src/modules/Expenses/subscribers/ExpenseGLEntriesStorage.sevice.ts @@ -43,11 +43,7 @@ export class ExpenseGLEntriesStorageService { expenseId: number, trx?: Knex.Transaction, ) => { - await this.ledgerStorage.deleteByReference( - expenseId, - 'Expense', - trx, - ); + await this.ledgerStorage.deleteByReference(expenseId, 'Expense', trx); }; /** diff --git a/packages/server/src/modules/Export/Export.module.ts b/packages/server/src/modules/Export/Export.module.ts index 1aec5e4f9..445cbb285 100644 --- a/packages/server/src/modules/Export/Export.module.ts +++ b/packages/server/src/modules/Export/Export.module.ts @@ -20,14 +20,14 @@ const models = [RegisterTenancyModel(ImportModel)]; ResourceModule, TemplateInjectableModule, ChromiumlyTenancyModule, - AccountsModule + AccountsModule, ], providers: [ ExportResourceService, ExportPdf, ExportAls, ExportApplication, - ExportableRegistry + ExportableRegistry, ], exports: [...models], controllers: [ExportController], diff --git a/packages/server/src/modules/Export/Export.utils.ts b/packages/server/src/modules/Export/Export.utils.ts index c902b6fe6..6c784902b 100644 --- a/packages/server/src/modules/Export/Export.utils.ts +++ b/packages/server/src/modules/Export/Export.utils.ts @@ -11,4 +11,4 @@ export const convertAcceptFormatToFormat = (accept: string): ExportFormat => { case ACCEPT_TYPE.APPLICATION_XLSX: return ExportFormat.Xlsx; } -}; \ No newline at end of file +}; diff --git a/packages/server/src/modules/Export/ExportApplication.ts b/packages/server/src/modules/Export/ExportApplication.ts index 0743c8fd0..ea6601aab 100644 --- a/packages/server/src/modules/Export/ExportApplication.ts +++ b/packages/server/src/modules/Export/ExportApplication.ts @@ -7,9 +7,7 @@ export class ExportApplication { /** * Constructor method. */ - constructor( - private readonly exportResource: ExportResourceService, - ) {} + constructor(private readonly exportResource: ExportResourceService) {} /** * Exports the given resource to csv, xlsx or pdf format. diff --git a/packages/server/src/modules/Export/ExportPdf.ts b/packages/server/src/modules/Export/ExportPdf.ts index 99f55dbb7..33a420516 100644 --- a/packages/server/src/modules/Export/ExportPdf.ts +++ b/packages/server/src/modules/Export/ExportPdf.ts @@ -5,9 +5,7 @@ import { mapPdfRows } from './utils'; @Injectable() export class ExportPdf { - constructor( - private readonly chromiumlyTenancy: ChromiumlyTenancy, - ) { } + constructor(private readonly chromiumlyTenancy: ChromiumlyTenancy) {} /** * Generates the pdf table sheet for the given data and columns. @@ -18,10 +16,15 @@ export class ExportPdf { * @returns */ public async pdf( - columns: { accessor: string; name?: string; style?: string; group?: string }[], + columns: { + accessor: string; + name?: string; + style?: string; + group?: string; + }[], data: Record, sheetTitle: string = '', - sheetDescription: string = '' + sheetDescription: string = '', ) { const rows = mapPdfRows(columns, data); diff --git a/packages/server/src/modules/Export/ExportService.ts b/packages/server/src/modules/Export/ExportService.ts index db7f6ed3f..9ad5034e3 100644 --- a/packages/server/src/modules/Export/ExportService.ts +++ b/packages/server/src/modules/Export/ExportService.ts @@ -164,24 +164,29 @@ export class ExportResourceService { columns: { [key: string]: IModelMetaColumn }, parent = '', ) => { - return Object.entries(columns) - // @ts-expect-error - .filter(([_, value]) => value.printable !== false) - .flatMap(([key, value]) => { - if (value.type === 'collection' && value.collectionOf === 'object') { - return processColumns(value.columns, key); - } else { - const group = parent; - return [ - { - name: value.name, - type: value.type || 'text', - accessor: value.accessor || key, - group, - }, - ]; - } - }); + return ( + Object.entries(columns) + // @ts-expect-error + .filter(([_, value]) => value.printable !== false) + .flatMap(([key, value]) => { + if ( + value.type === 'collection' && + value.collectionOf === 'object' + ) { + return processColumns(value.columns, key); + } else { + const group = parent; + return [ + { + name: value.name, + type: value.type || 'text', + accessor: value.accessor || key, + group, + }, + ]; + } + }) + ); }; return processColumns(resourceMeta.columns); } diff --git a/packages/server/src/modules/Export/Exportable.ts b/packages/server/src/modules/Export/Exportable.ts index c83f94549..9831027cc 100644 --- a/packages/server/src/modules/Export/Exportable.ts +++ b/packages/server/src/modules/Export/Exportable.ts @@ -4,9 +4,7 @@ export class Exportable { * @param tenantId * @returns */ - public async exportable( - query: Record, - ): Promise { + public async exportable(query: Record): Promise { return []; } diff --git a/packages/server/src/modules/Export/decorators/ExportableModel.decorator.ts b/packages/server/src/modules/Export/decorators/ExportableModel.decorator.ts index ea9ca0fb3..8e7a81569 100644 --- a/packages/server/src/modules/Export/decorators/ExportableModel.decorator.ts +++ b/packages/server/src/modules/Export/decorators/ExportableModel.decorator.ts @@ -1,7 +1,7 @@ -import { Global } from "@nestjs/common"; +import { Global } from '@nestjs/common'; const exportableModels = new Map(); -const exportableService = new Map() +const exportableService = new Map(); /** * Decorator that marks a model as exportable and registers its metadata. @@ -31,7 +31,6 @@ export function getExportableModelMeta(modelName: string): boolean | undefined { return exportableModels.get(modelName); } - export function getExportableService(modelName: string) { return exportableService.get(modelName); -} \ No newline at end of file +} diff --git a/packages/server/src/modules/Export/utils.ts b/packages/server/src/modules/Export/utils.ts index f21515c46..39611057c 100644 --- a/packages/server/src/modules/Export/utils.ts +++ b/packages/server/src/modules/Export/utils.ts @@ -7,13 +7,13 @@ import { flatMap, get } from 'lodash'; */ export const flatDataCollections = ( data: Record, - flattenAttr: string + flattenAttr: string, ): Record[] => { return flatMap(data, (item) => item[flattenAttr].map((entry) => ({ ...item, [flattenAttr]: entry, - })) + })), ); }; diff --git a/packages/server/src/modules/Features/Features.module.ts b/packages/server/src/modules/Features/Features.module.ts index 1fe3b4938..6b24ac549 100644 --- a/packages/server/src/modules/Features/Features.module.ts +++ b/packages/server/src/modules/Features/Features.module.ts @@ -9,7 +9,7 @@ import { FeaturesConfigure } from './FeaturesConfigure'; FeaturesManager, FeaturesSettingsDriver, FeaturesConfigureManager, - FeaturesConfigure + FeaturesConfigure, ], exports: [FeaturesManager], }) diff --git a/packages/server/src/modules/Features/FeaturesConfigureManager.ts b/packages/server/src/modules/Features/FeaturesConfigureManager.ts index 414c3fa25..32cdf43dd 100644 --- a/packages/server/src/modules/Features/FeaturesConfigureManager.ts +++ b/packages/server/src/modules/Features/FeaturesConfigureManager.ts @@ -13,9 +13,9 @@ export class FeaturesConfigureManager { * @returns {IFeatureConfiugration} */ getFeatureConfigure = (featureName: string, accessor?: string) => { - const meta = this.featuresConfigure.getConfigure().find( - (feature) => feature.name === featureName - ); + const meta = this.featuresConfigure + .getConfigure() + .find((feature) => feature.name === featureName); return accessor ? get(meta, accessor) : meta; }; } diff --git a/packages/server/src/modules/Features/FeaturesManager.ts b/packages/server/src/modules/Features/FeaturesManager.ts index 2d9812aea..d9397182a 100644 --- a/packages/server/src/modules/Features/FeaturesManager.ts +++ b/packages/server/src/modules/Features/FeaturesManager.ts @@ -4,9 +4,7 @@ import { IFeatureAllItem } from '@/common/types/Features'; @Injectable() export class FeaturesManager { - constructor( - private drive: FeaturesSettingsDriver, - ) {} + constructor(private drive: FeaturesSettingsDriver) {} /** * Turns-on the given feature name. diff --git a/packages/server/src/modules/FinancialStatements/common/FinancialEvaluateEquation.ts b/packages/server/src/modules/FinancialStatements/common/FinancialEvaluateEquation.ts index ea5a863ac..d58315c0a 100644 --- a/packages/server/src/modules/FinancialStatements/common/FinancialEvaluateEquation.ts +++ b/packages/server/src/modules/FinancialStatements/common/FinancialEvaluateEquation.ts @@ -8,9 +8,11 @@ import { FinancialSheet } from './FinancialSheet'; export const FinancialEvaluateEquation = < T extends GConstructor, >( - Base: T + Base: T, ) => - class FinancialEvaluateEquation extends R.pipe(FinancialSheetStructure)(Base) { + class FinancialEvaluateEquation extends R.pipe(FinancialSheetStructure)( + Base, + ) { /** * Evauluate equaation string with the given scope table. * @param {string} equation - @@ -19,7 +21,7 @@ export const FinancialEvaluateEquation = < */ public evaluateEquation = ( equation: string, - scope: { [key: string | number]: number } + scope: { [key: string | number]: number }, ): number => { return mathjs.evaluate(equation, scope); }; @@ -49,7 +51,7 @@ export const FinancialEvaluateEquation = < public mapNodesToTotal = R.curry( (path: string, nodesById: { [key: number]: any }) => { return mapValues(nodesById, (node) => get(node, path, 0)); - } + }, ); /** @@ -59,8 +61,8 @@ export const FinancialEvaluateEquation = < (path = 'total.amount', nodes) => { return R.compose( this.mapNodesToTotal(path), - this.transformNodesToMap + this.transformNodesToMap, )(nodes); - } + }, ); }; diff --git a/packages/server/src/modules/FinancialStatements/common/FinancialTable.ts b/packages/server/src/modules/FinancialStatements/common/FinancialTable.ts index b395a5460..14f9d6bc2 100644 --- a/packages/server/src/modules/FinancialStatements/common/FinancialTable.ts +++ b/packages/server/src/modules/FinancialStatements/common/FinancialTable.ts @@ -12,7 +12,7 @@ enum IROW_TYPE { } export const FinancialTable = >( - Base: T + Base: T, ) => class extends R.pipe(FinancialSheetStructure)(Base) { public readonly i18n: I18nService; diff --git a/packages/server/src/modules/FinancialStatements/common/FinancialTablePreviousPeriod.ts b/packages/server/src/modules/FinancialStatements/common/FinancialTablePreviousPeriod.ts index 65ed2e796..8303d8507 100644 --- a/packages/server/src/modules/FinancialStatements/common/FinancialTablePreviousPeriod.ts +++ b/packages/server/src/modules/FinancialStatements/common/FinancialTablePreviousPeriod.ts @@ -26,7 +26,7 @@ export const FinancialTablePreviousPeriod = < * @returns {ITableColumn} */ public getPreviousPeriodTotalColumn = ( - dateRange?: IDateRange + dateRange?: IDateRange, ): ITableColumn => { const PPDate = dateRange ? dateRange.toDate @@ -36,7 +36,7 @@ export const FinancialTablePreviousPeriod = < return { key: 'previous_period', label: this.i18n.t(`financial_sheet.previoud_period_date`, { - args: { date: PPFormatted, } + args: { date: PPFormatted }, }), }; }; @@ -89,13 +89,12 @@ export const FinancialTablePreviousPeriod = < * Retrieves previous period percentage accessor. * @returns {ITableColumnAccessor} */ - public getPreviousPeriodPercentageAccessor = - (): ITableColumnAccessor => { - return { - key: 'previous_period_percentage', - accessor: 'previousPeriodPercentage.formattedAmount', - }; + public getPreviousPeriodPercentageAccessor = (): ITableColumnAccessor => { + return { + key: 'previous_period_percentage', + accessor: 'previousPeriodPercentage.formattedAmount', }; + }; /** * Retrieves previous period total horizontal column accessor. @@ -103,7 +102,7 @@ export const FinancialTablePreviousPeriod = < * @returns {ITableColumnAccessor} */ public getPreviousPeriodTotalHorizAccessor = ( - index: number + index: number, ): ITableColumnAccessor => { return { key: 'previous_period', @@ -117,7 +116,7 @@ export const FinancialTablePreviousPeriod = < * @returns {ITableColumnAccessor} */ public getPreviousPeriodChangeHorizAccessor = ( - index: number + index: number, ): ITableColumnAccessor => { return { key: 'previous_period_change', @@ -131,7 +130,7 @@ export const FinancialTablePreviousPeriod = < * @returns {ITableColumnAccessor} */ public getPreviousPeriodPercentageHorizAccessor = ( - index: number + index: number, ): ITableColumnAccessor => { return { key: 'previous_period_percentage', diff --git a/packages/server/src/modules/FinancialStatements/common/FinancialTableStructure.ts b/packages/server/src/modules/FinancialStatements/common/FinancialTableStructure.ts index cde90e955..a5ae585e0 100644 --- a/packages/server/src/modules/FinancialStatements/common/FinancialTableStructure.ts +++ b/packages/server/src/modules/FinancialStatements/common/FinancialTableStructure.ts @@ -16,7 +16,7 @@ export class FinancialTableStructure { */ public static flatNestedTree = ( obj: ITableRow[], - options?: FlatNestTreeOpts + options?: FlatNestTreeOpts, ): ITableRow[] => { const parsedOptions = { nestedPrefix: ' ', @@ -42,7 +42,7 @@ export class FinancialTableStructure { cells, }; }, - parsedOptions + parsedOptions, ); }; } diff --git a/packages/server/src/modules/FinancialStatements/common/TableSheetPdf.ts b/packages/server/src/modules/FinancialStatements/common/TableSheetPdf.ts index 1ac130efe..c1bc69dd5 100644 --- a/packages/server/src/modules/FinancialStatements/common/TableSheetPdf.ts +++ b/packages/server/src/modules/FinancialStatements/common/TableSheetPdf.ts @@ -11,9 +11,7 @@ export class TableSheetPdf { /** * @param {ChromiumlyTenancy} chromiumlyTenancy - The chromiumly tenancy service. */ - constructor( - private readonly chromiumlyTenancy: ChromiumlyTenancy, - ) { } + constructor(private readonly chromiumlyTenancy: ChromiumlyTenancy) {} /** * Converts the table data into a PDF format. diff --git a/packages/server/src/modules/FinancialStatements/dtos/FinancialReportResponse.dto.ts b/packages/server/src/modules/FinancialStatements/dtos/FinancialReportResponse.dto.ts index 7ae89100d..073af72ed 100644 --- a/packages/server/src/modules/FinancialStatements/dtos/FinancialReportResponse.dto.ts +++ b/packages/server/src/modules/FinancialStatements/dtos/FinancialReportResponse.dto.ts @@ -52,7 +52,10 @@ export class FinancialTableCellDto { } export class FinancialTableRowDto { - @ApiProperty({ description: 'Cell data for this row', type: [FinancialTableCellDto] }) + @ApiProperty({ + description: 'Cell data for this row', + type: [FinancialTableCellDto], + }) cells: FinancialTableCellDto[]; @ApiProperty({ description: 'Row type classifications', type: [String] }) @@ -61,7 +64,10 @@ export class FinancialTableRowDto { @ApiProperty({ description: 'Row identifier' }) id: string | number; - @ApiPropertyOptional({ description: 'Child rows', type: () => [FinancialTableRowDto] }) + @ApiPropertyOptional({ + description: 'Child rows', + type: () => [FinancialTableRowDto], + }) children?: FinancialTableRowDto[]; } @@ -75,12 +81,18 @@ export class FinancialTableColumnDto { @ApiPropertyOptional({ description: 'Cell position index', type: Number }) cellIndex?: number; - @ApiPropertyOptional({ description: 'Nested column definitions', type: () => [FinancialTableColumnDto] }) + @ApiPropertyOptional({ + description: 'Nested column definitions', + type: () => [FinancialTableColumnDto], + }) children?: FinancialTableColumnDto[]; } export class FinancialTableDataDto { - @ApiProperty({ description: 'Table column definitions', type: [FinancialTableColumnDto] }) + @ApiProperty({ + description: 'Table column definitions', + type: [FinancialTableColumnDto], + }) columns: FinancialTableColumnDto[]; @ApiProperty({ description: 'Table row data', type: [FinancialTableRowDto] }) @@ -95,7 +107,10 @@ export class BaseFinancialReportResponseDto { } export class BaseFinancialTableResponseDto { - @ApiProperty({ description: 'Table data structure', type: FinancialTableDataDto }) + @ApiProperty({ + description: 'Table data structure', + type: FinancialTableDataDto, + }) table: FinancialTableDataDto; @ApiProperty({ description: 'Report metadata', type: FinancialReportMetaDto }) diff --git a/packages/server/src/modules/FinancialStatements/modules/APAgingSummary/APAgingSummary.controller.ts b/packages/server/src/modules/FinancialStatements/modules/APAgingSummary/APAgingSummary.controller.ts index 9c87bbdfb..8d7d2904f 100644 --- a/packages/server/src/modules/FinancialStatements/modules/APAgingSummary/APAgingSummary.controller.ts +++ b/packages/server/src/modules/FinancialStatements/modules/APAgingSummary/APAgingSummary.controller.ts @@ -1,5 +1,12 @@ import { Response } from 'express'; -import { Controller, Get, Headers, Query, Res, UseGuards } from '@nestjs/common'; +import { + Controller, + Get, + Headers, + Query, + Res, + UseGuards, +} from '@nestjs/common'; import { APAgingSummaryApplication } from './APAgingSummaryApplication'; import { AcceptType } from '@/constants/accept-type'; import { @@ -29,7 +36,7 @@ import { ReportsAction } from '../../types/Report.types'; @UseGuards(AuthorizationGuard, PermissionGuard) @ApiExtraModels(APAgingSummaryResponseDto, APAgingSummaryTableResponseDto) export class APAgingSummaryController { - constructor(private readonly APAgingSummaryApp: APAgingSummaryApplication) { } + constructor(private readonly APAgingSummaryApp: APAgingSummaryApplication) {} @Get() @RequirePermission(ReportsAction.READ_AP_AGING_SUMMARY, AbilitySubject.Report) diff --git a/packages/server/src/modules/FinancialStatements/modules/APAgingSummary/APAgingSummaryResponse.dto.ts b/packages/server/src/modules/FinancialStatements/modules/APAgingSummary/APAgingSummaryResponse.dto.ts index 4c2f0e518..7dcd5ac51 100644 --- a/packages/server/src/modules/FinancialStatements/modules/APAgingSummary/APAgingSummaryResponse.dto.ts +++ b/packages/server/src/modules/FinancialStatements/modules/APAgingSummary/APAgingSummaryResponse.dto.ts @@ -29,7 +29,10 @@ export class APAgingVendorDto { @ApiProperty({ description: 'Vendor name' }) vendorName: string; - @ApiProperty({ description: 'Current balance', type: FinancialReportTotalDto }) + @ApiProperty({ + description: 'Current balance', + type: FinancialReportTotalDto, + }) current: FinancialReportTotalDto; @ApiProperty({ description: 'Aging periods', type: [APAgingPeriodTotalDto] }) @@ -68,7 +71,10 @@ export class APAgingSummaryQueryResponseDto { @ApiProperty({ description: 'Number of aging periods', type: Number }) agingPeriods: number; - @ApiProperty({ description: 'Number format settings', type: NumberFormatQueryDto }) + @ApiProperty({ + description: 'Number format settings', + type: NumberFormatQueryDto, + }) numberFormat: NumberFormatQueryDto; @ApiProperty({ description: 'Vendor IDs to include', type: [Number] }) @@ -82,7 +88,10 @@ export class APAgingSummaryQueryResponseDto { } export class APAgingSummaryResponseDto { - @ApiProperty({ description: 'Aging summary data', type: APAgingSummaryDataDto }) + @ApiProperty({ + description: 'Aging summary data', + type: APAgingSummaryDataDto, + }) data: APAgingSummaryDataDto; @ApiProperty({ description: 'Report metadata', type: APAgingSummaryMetaDto }) @@ -98,10 +107,16 @@ export { } from '../../dtos/FinancialReportResponse.dto'; export class APAgingSummaryTableResponseDto { - @ApiProperty({ description: 'Table data structure', type: () => FinancialTableDataDto }) + @ApiProperty({ + description: 'Table data structure', + type: () => FinancialTableDataDto, + }) table: FinancialTableDataDto; - @ApiProperty({ description: 'Query parameters used to generate the report', type: APAgingSummaryQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: APAgingSummaryQueryResponseDto, + }) query: APAgingSummaryQueryResponseDto; @ApiProperty({ description: 'Report metadata', type: APAgingSummaryMetaDto }) diff --git a/packages/server/src/modules/FinancialStatements/modules/APAgingSummary/APAgingSummarySheet.ts b/packages/server/src/modules/FinancialStatements/modules/APAgingSummary/APAgingSummarySheet.ts index a4399b980..ec1b45058 100644 --- a/packages/server/src/modules/FinancialStatements/modules/APAgingSummary/APAgingSummarySheet.ts +++ b/packages/server/src/modules/FinancialStatements/modules/APAgingSummary/APAgingSummarySheet.ts @@ -14,7 +14,10 @@ import { allPassedConditionsPass } from '@/utils/all-conditions-passed'; import { APAgingSummaryRepository } from './APAgingSummaryRepository'; import { Bill } from '@/modules/Bills/models/Bill'; import { APAgingSummaryQueryDto } from './APAgingSummaryQuery.dto'; -import { IFinancialReportMeta, DEFAULT_REPORT_META } from '../../types/Report.types'; +import { + IFinancialReportMeta, + DEFAULT_REPORT_META, +} from '../../types/Report.types'; export class APAgingSummarySheet extends AgingSummaryReport { readonly repository: APAgingSummaryRepository; diff --git a/packages/server/src/modules/FinancialStatements/modules/ARAgingSummary/ARAgingSummary.controller.ts b/packages/server/src/modules/FinancialStatements/modules/ARAgingSummary/ARAgingSummary.controller.ts index 19d7d2ed0..884315bc1 100644 --- a/packages/server/src/modules/FinancialStatements/modules/ARAgingSummary/ARAgingSummary.controller.ts +++ b/packages/server/src/modules/FinancialStatements/modules/ARAgingSummary/ARAgingSummary.controller.ts @@ -1,4 +1,11 @@ -import { Controller, Get, Headers, Query, Res, UseGuards } from '@nestjs/common'; +import { + Controller, + Get, + Headers, + Query, + Res, + UseGuards, +} from '@nestjs/common'; import { ARAgingSummaryApplication } from './ARAgingSummaryApplication'; import { AcceptType } from '@/constants/accept-type'; import { Response } from 'express'; diff --git a/packages/server/src/modules/FinancialStatements/modules/ARAgingSummary/ARAgingSummaryMeta.ts b/packages/server/src/modules/FinancialStatements/modules/ARAgingSummary/ARAgingSummaryMeta.ts index c10c96597..70020a5a3 100644 --- a/packages/server/src/modules/FinancialStatements/modules/ARAgingSummary/ARAgingSummaryMeta.ts +++ b/packages/server/src/modules/FinancialStatements/modules/ARAgingSummary/ARAgingSummaryMeta.ts @@ -1,22 +1,20 @@ - import { Injectable } from '@nestjs/common'; import { AgingSummaryMeta } from '../AgingSummary/AgingSummaryMeta'; -import { IAgingSummaryMeta, IAgingSummaryQuery } from '../AgingSummary/AgingSummary.types'; +import { + IAgingSummaryMeta, + IAgingSummaryQuery, +} from '../AgingSummary/AgingSummary.types'; @Injectable() export class ARAgingSummaryMeta { - constructor( - private readonly agingSummaryMeta: AgingSummaryMeta, - ) {} + constructor(private readonly agingSummaryMeta: AgingSummaryMeta) {} /** * Retrieve the aging summary meta. * @param {IAgingSummaryQuery} query - Aging summary query. * @returns {IAgingSummaryMeta} */ - public async meta( - query: IAgingSummaryQuery - ): Promise { + public async meta(query: IAgingSummaryQuery): Promise { const commonMeta = await this.agingSummaryMeta.meta(query); return { diff --git a/packages/server/src/modules/FinancialStatements/modules/ARAgingSummary/ARAgingSummaryResponse.dto.ts b/packages/server/src/modules/FinancialStatements/modules/ARAgingSummary/ARAgingSummaryResponse.dto.ts index 3c1a32fe1..00a27292a 100644 --- a/packages/server/src/modules/FinancialStatements/modules/ARAgingSummary/ARAgingSummaryResponse.dto.ts +++ b/packages/server/src/modules/FinancialStatements/modules/ARAgingSummary/ARAgingSummaryResponse.dto.ts @@ -29,7 +29,10 @@ export class ARAgingCustomerDto { @ApiProperty({ description: 'Customer name' }) customerName: string; - @ApiProperty({ description: 'Current balance', type: FinancialReportTotalDto }) + @ApiProperty({ + description: 'Current balance', + type: FinancialReportTotalDto, + }) current: FinancialReportTotalDto; @ApiProperty({ description: 'Aging periods', type: [ARAgingPeriodTotalDto] }) @@ -40,7 +43,10 @@ export class ARAgingCustomerDto { } export class ARAgingSummaryDataDto { - @ApiProperty({ description: 'Customers aging data', type: [ARAgingCustomerDto] }) + @ApiProperty({ + description: 'Customers aging data', + type: [ARAgingCustomerDto], + }) customers: ARAgingCustomerDto[]; @ApiProperty({ description: 'Current total', type: FinancialReportTotalDto }) @@ -68,7 +74,10 @@ export class ARAgingSummaryQueryResponseDto { @ApiProperty({ description: 'Number of aging periods', type: Number }) agingPeriods: number; - @ApiProperty({ description: 'Number format settings', type: NumberFormatQueryDto }) + @ApiProperty({ + description: 'Number format settings', + type: NumberFormatQueryDto, + }) numberFormat: NumberFormatQueryDto; @ApiProperty({ description: 'Customer IDs to include', type: [Number] }) @@ -82,13 +91,22 @@ export class ARAgingSummaryQueryResponseDto { } export class ARAgingSummaryResponseDto { - @ApiProperty({ description: 'Query parameters used to generate the report', type: ARAgingSummaryQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: ARAgingSummaryQueryResponseDto, + }) query: ARAgingSummaryQueryResponseDto; - @ApiProperty({ description: 'Aging columns definitions', type: [ARAgingPeriodDto] }) + @ApiProperty({ + description: 'Aging columns definitions', + type: [ARAgingPeriodDto], + }) columns: ARAgingPeriodDto[]; - @ApiProperty({ description: 'Aging summary data', type: ARAgingSummaryDataDto }) + @ApiProperty({ + description: 'Aging summary data', + type: ARAgingSummaryDataDto, + }) data: ARAgingSummaryDataDto; @ApiProperty({ description: 'Report metadata', type: ARAgingSummaryMetaDto }) @@ -104,10 +122,16 @@ export { } from '../../dtos/FinancialReportResponse.dto'; export class ARAgingSummaryTableResponseDto { - @ApiProperty({ description: 'Table data structure', type: () => FinancialTableDataDto }) + @ApiProperty({ + description: 'Table data structure', + type: () => FinancialTableDataDto, + }) table: FinancialTableDataDto; - @ApiProperty({ description: 'Query parameters used to generate the report', type: ARAgingSummaryQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: ARAgingSummaryQueryResponseDto, + }) query: ARAgingSummaryQueryResponseDto; @ApiProperty({ description: 'Report metadata', type: ARAgingSummaryMetaDto }) diff --git a/packages/server/src/modules/FinancialStatements/modules/ARAgingSummary/ARAgingSummarySheet.ts b/packages/server/src/modules/FinancialStatements/modules/ARAgingSummary/ARAgingSummarySheet.ts index 1ad382569..79d7af796 100644 --- a/packages/server/src/modules/FinancialStatements/modules/ARAgingSummary/ARAgingSummarySheet.ts +++ b/packages/server/src/modules/FinancialStatements/modules/ARAgingSummary/ARAgingSummarySheet.ts @@ -14,7 +14,10 @@ import { ARAgingSummaryRepository } from './ARAgingSummaryRepository'; import { Customer } from '@/modules/Customers/models/Customer'; import { SaleInvoice } from '@/modules/SaleInvoices/models/SaleInvoice'; import { ARAgingSummaryQueryDto } from './ARAgingSummaryQuery.dto'; -import { IFinancialReportMeta, DEFAULT_REPORT_META } from '../../types/Report.types'; +import { + IFinancialReportMeta, + DEFAULT_REPORT_META, +} from '../../types/Report.types'; export class ARAgingSummarySheet extends AgingSummaryReport { readonly query: ARAgingSummaryQueryDto; diff --git a/packages/server/src/modules/FinancialStatements/modules/ARAgingSummary/utils.ts b/packages/server/src/modules/FinancialStatements/modules/ARAgingSummary/utils.ts index 1e2fcdcd3..100f76b42 100644 --- a/packages/server/src/modules/FinancialStatements/modules/ARAgingSummary/utils.ts +++ b/packages/server/src/modules/FinancialStatements/modules/ARAgingSummary/utils.ts @@ -1,20 +1,19 @@ import * as moment from 'moment'; - -export const getARAgingSummaryDefaultQuery = () => { +export const getARAgingSummaryDefaultQuery = () => { return { asDate: moment().format('YYYY-MM-DD'), - agingDaysBefore: 30, - agingPeriods: 3, - numberFormat: { - divideOn1000: false, - negativeFormat: 'mines', - showZero: false, - formatMoney: 'total', - precision: 2, - }, - customersIds: [], - branchesIds: [], - noneZero: false, + agingDaysBefore: 30, + agingPeriods: 3, + numberFormat: { + divideOn1000: false, + negativeFormat: 'mines', + showZero: false, + formatMoney: 'total', + precision: 2, + }, + customersIds: [], + branchesIds: [], + noneZero: false, }; -}; \ No newline at end of file +}; diff --git a/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheet.controller.ts b/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheet.controller.ts index c85acfbd5..a43b8bc75 100644 --- a/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheet.controller.ts +++ b/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheet.controller.ts @@ -1,5 +1,12 @@ import { Response } from 'express'; -import { Controller, Get, Headers, Query, Res, UseGuards } from '@nestjs/common'; +import { + Controller, + Get, + Headers, + Query, + Res, + UseGuards, +} from '@nestjs/common'; import { AcceptType } from '@/constants/accept-type'; import { BalanceSheetApplication } from './BalanceSheetApplication'; import { diff --git a/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheet.ts b/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheet.ts index d44d6d61d..5480aea6e 100644 --- a/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheet.ts +++ b/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheet.ts @@ -19,7 +19,11 @@ import { BalanceSheetFiltering } from './BalanceSheetFiltering'; import { BalanceSheetNetIncome } from './BalanceSheetNetIncome'; import { BalanceSheetAggregators } from './BalanceSheetAggregators'; import { BalanceSheetAccounts } from './BalanceSheetAccounts'; -import { INumberFormatQuery, IFinancialReportMeta, DEFAULT_REPORT_META } from '../../types/Report.types'; +import { + INumberFormatQuery, + IFinancialReportMeta, + DEFAULT_REPORT_META, +} from '../../types/Report.types'; import { FinancialSheet } from '../../common/FinancialSheet'; export class BalanceSheet extends R.pipe( diff --git a/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheetExportInjectable.ts b/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheetExportInjectable.ts index bd89840ab..301f3f10c 100644 --- a/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheetExportInjectable.ts +++ b/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheetExportInjectable.ts @@ -30,9 +30,7 @@ export class BalanceSheetExportInjectable { * @param {ITrialBalanceSheetQuery} query * @returns {Promise} */ - public async csv( - query: IBalanceSheetQuery, - ): Promise { + public async csv(query: IBalanceSheetQuery): Promise { const table = await this.balanceSheetTable.table(query); const tableSheet = new TableSheet(table.table); @@ -46,9 +44,7 @@ export class BalanceSheetExportInjectable { * @param {IBalanceSheetQuery} query * @returns {Promise} */ - public async pdf( - query: IBalanceSheetQuery, - ): Promise { + public async pdf(query: IBalanceSheetQuery): Promise { return this.balanceSheetPdf.pdf(query); } } diff --git a/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheetInjectable.ts b/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheetInjectable.ts index 8b7e802bf..51b593606 100644 --- a/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheetInjectable.ts +++ b/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheetInjectable.ts @@ -1,8 +1,5 @@ // @ts-nocheck -import { - IBalanceSheetDOO, - IBalanceSheetQuery, -} from './BalanceSheet.types'; +import { IBalanceSheetDOO, IBalanceSheetQuery } from './BalanceSheet.types'; import { BalanceSheetRepository } from './BalanceSheetRepository'; import { BalanceSheetMetaInjectable } from './BalanceSheetMeta'; import { Inject, Injectable } from '@nestjs/common'; @@ -48,7 +45,10 @@ export class BalanceSheetInjectable { filter, this.balanceSheetRepository, this.i18n, - { baseCurrency: tenantMetadata.baseCurrency, dateFormat: meta.dateFormat }, + { + baseCurrency: tenantMetadata.baseCurrency, + dateFormat: meta.dateFormat, + }, ); // Balance sheet data. const data = balanceSheetInstanace.reportData(); diff --git a/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheetPdfInjectable.ts b/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheetPdfInjectable.ts index 66404400c..de58503c2 100644 --- a/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheetPdfInjectable.ts +++ b/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheetPdfInjectable.ts @@ -9,7 +9,7 @@ export class BalanceSheetPdfInjectable { constructor( private readonly balanceSheetTable: BalanceSheetTableInjectable, private readonly tableSheetPdf: TableSheetPdf, - ) { } + ) {} /** * Converts the given balance sheet table to pdf. diff --git a/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheetResponse.dto.ts b/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheetResponse.dto.ts index 04f905969..bde72ed29 100644 --- a/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheetResponse.dto.ts +++ b/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/BalanceSheetResponse.dto.ts @@ -8,7 +8,9 @@ import { } from '../../dtos/FinancialReportResponse.dto'; export class BalanceSheetDataNodeDto { - @ApiProperty({ description: 'Node identifier (string for aggregates, number for accounts)' }) + @ApiProperty({ + description: 'Node identifier (string for aggregates, number for accounts)', + }) id: string | number; @ApiProperty({ description: 'Account or category name' }) @@ -23,34 +25,64 @@ export class BalanceSheetDataNodeDto { @ApiPropertyOptional({ description: 'Node type alias' }) type?: string; - @ApiProperty({ description: 'Total amount information', type: FinancialReportTotalDto }) + @ApiProperty({ + description: 'Total amount information', + type: FinancialReportTotalDto, + }) total: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Horizontal totals for date periods', type: [FinancialReportTotalDto] }) + @ApiPropertyOptional({ + description: 'Horizontal totals for date periods', + type: [FinancialReportTotalDto], + }) horizontalTotals?: FinancialReportTotalDto[]; - @ApiPropertyOptional({ description: 'Percentage of row', type: FinancialReportPercentageDto }) + @ApiPropertyOptional({ + description: 'Percentage of row', + type: FinancialReportPercentageDto, + }) percentageRow?: FinancialReportPercentageDto; - @ApiPropertyOptional({ description: 'Percentage of column', type: FinancialReportPercentageDto }) + @ApiPropertyOptional({ + description: 'Percentage of column', + type: FinancialReportPercentageDto, + }) percentageColumn?: FinancialReportPercentageDto; - @ApiPropertyOptional({ description: 'Previous period total', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Previous period total', + type: FinancialReportTotalDto, + }) previousPeriod?: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Previous period change', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Previous period change', + type: FinancialReportTotalDto, + }) previousPeriodChange?: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Previous period percentage', type: FinancialReportPercentageDto }) + @ApiPropertyOptional({ + description: 'Previous period percentage', + type: FinancialReportPercentageDto, + }) previousPeriodPercentage?: FinancialReportPercentageDto; - @ApiPropertyOptional({ description: 'Previous year total', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Previous year total', + type: FinancialReportTotalDto, + }) previousYear?: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Previous year change', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Previous year change', + type: FinancialReportTotalDto, + }) previousYearChange?: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Previous year percentage', type: FinancialReportPercentageDto }) + @ApiPropertyOptional({ + description: 'Previous year percentage', + type: FinancialReportPercentageDto, + }) previousYearPercentage?: FinancialReportPercentageDto; @ApiPropertyOptional({ description: 'Account code' }) @@ -62,7 +94,10 @@ export class BalanceSheetDataNodeDto { @ApiPropertyOptional({ description: 'Parent account ID', type: Number }) parentAccountId?: number; - @ApiPropertyOptional({ description: 'Child nodes', type: () => [BalanceSheetDataNodeDto] }) + @ApiPropertyOptional({ + description: 'Child nodes', + type: () => [BalanceSheetDataNodeDto], + }) children?: BalanceSheetDataNodeDto[]; } @@ -75,10 +110,16 @@ export class BalanceSheetMetaDto extends FinancialReportMetaDto { } export class BalanceSheetQueryResponseDto { - @ApiProperty({ description: 'Column display type', enum: ['total', 'date_periods'] }) + @ApiProperty({ + description: 'Column display type', + enum: ['total', 'date_periods'], + }) displayColumnsType: string; - @ApiProperty({ description: 'Column grouping', enum: ['day', 'month', 'year', 'quarter'] }) + @ApiProperty({ + description: 'Column grouping', + enum: ['day', 'month', 'year', 'quarter'], + }) displayColumnsBy: string; @ApiProperty({ description: 'Start date' }) @@ -87,7 +128,10 @@ export class BalanceSheetQueryResponseDto { @ApiProperty({ description: 'End date' }) toDate: string; - @ApiProperty({ description: 'Number format settings', type: NumberFormatQueryDto }) + @ApiProperty({ + description: 'Number format settings', + type: NumberFormatQueryDto, + }) numberFormat: NumberFormatQueryDto; @ApiProperty({ description: 'Exclude zero balance accounts' }) @@ -128,10 +172,16 @@ export class BalanceSheetQueryResponseDto { } export class BalanceSheetResponseDto { - @ApiProperty({ description: 'Query parameters used to generate the report', type: BalanceSheetQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: BalanceSheetQueryResponseDto, + }) query: BalanceSheetQueryResponseDto; - @ApiProperty({ description: 'Hierarchical balance sheet data', type: [BalanceSheetDataNodeDto] }) + @ApiProperty({ + description: 'Hierarchical balance sheet data', + type: [BalanceSheetDataNodeDto], + }) data: BalanceSheetDataNodeDto[]; @ApiProperty({ description: 'Report metadata', type: BalanceSheetMetaDto }) @@ -147,10 +197,16 @@ export { } from '../../dtos/FinancialReportResponse.dto'; export class BalanceSheetTableResponseDto { - @ApiProperty({ description: 'Table data structure', type: () => FinancialTableDataDto }) + @ApiProperty({ + description: 'Table data structure', + type: () => FinancialTableDataDto, + }) table: FinancialTableDataDto; - @ApiProperty({ description: 'Query parameters used to generate the report', type: BalanceSheetQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: BalanceSheetQueryResponseDto, + }) query: BalanceSheetQueryResponseDto; @ApiProperty({ description: 'Report metadata', type: BalanceSheetMetaDto }) diff --git a/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/constants.ts b/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/constants.ts index 1c32625eb..e0eda68db 100644 --- a/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/constants.ts +++ b/packages/server/src/modules/FinancialStatements/modules/BalanceSheet/constants.ts @@ -1,5 +1,5 @@ import * as moment from 'moment'; -import { IBalanceSheetQuery } from "./BalanceSheet.types"; +import { IBalanceSheetQuery } from './BalanceSheet.types'; export const MAP_CONFIG = { childrenPath: 'children', pathFormat: 'array' }; @@ -98,4 +98,4 @@ export const getBalanceSheetDefaultQuery = (): IBalanceSheetQuery => { previousYearAmountChange: false, previousYearPercentageChange: false, }; -} +}; diff --git a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashFlow.ts b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashFlow.ts index 1b5ed0af2..7c7891f7b 100644 --- a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashFlow.ts +++ b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashFlow.ts @@ -27,7 +27,11 @@ import { DISPLAY_COLUMNS_BY } from './constants'; import { FinancialSheetStructure } from '../../common/FinancialSheetStructure'; import { Account } from '@/modules/Accounts/models/Account.model'; import { ILedger } from '@/modules/Ledger/types/Ledger.types'; -import { INumberFormatQuery, IFinancialReportMeta, DEFAULT_REPORT_META } from '../../types/Report.types'; +import { + INumberFormatQuery, + IFinancialReportMeta, + DEFAULT_REPORT_META, +} from '../../types/Report.types'; import { transformToMapBy } from '@/utils/transform-to-map-by'; import { accumSum } from '@/utils/accum-sum'; import { ModelObject } from 'objection'; diff --git a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashFlowService.ts b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashFlowService.ts index cfee2d7ef..990fb137d 100644 --- a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashFlowService.ts +++ b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashFlowService.ts @@ -96,7 +96,10 @@ export class CashFlowStatementService { netIncomeLedger, filter, this.i18n, - { baseCurrency: tenant.metadata.baseCurrency, dateFormat: meta.dateFormat }, + { + baseCurrency: tenant.metadata.baseCurrency, + dateFormat: meta.dateFormat, + }, ); return { diff --git a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashFlowTable.ts b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashFlowTable.ts index 41d425428..7d4d831ab 100644 --- a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashFlowTable.ts +++ b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashFlowTable.ts @@ -366,7 +366,9 @@ export class CashFlowTable { */ public tableColumns = (): ITableColumn[] => { return R.compose( - R.concat([{ key: 'name', label: this.i18n.t('cash_flow_statement.account_name') }]), + R.concat([ + { key: 'name', label: this.i18n.t('cash_flow_statement.account_name') }, + ]), R.when( R.always(this.isDisplayColumnsBy(DISPLAY_COLUMNS_BY.DATE_PERIODS)), R.concat(this.datePeriodsColumns()), diff --git a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/Cashflow.controller.ts b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/Cashflow.controller.ts index 967f3e5f2..c30c748c3 100644 --- a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/Cashflow.controller.ts +++ b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/Cashflow.controller.ts @@ -1,5 +1,12 @@ import { Response } from 'express'; -import { Controller, Get, Headers, Query, Res, UseGuards } from '@nestjs/common'; +import { + Controller, + Get, + Headers, + Query, + Res, + UseGuards, +} from '@nestjs/common'; import { AcceptType } from '@/constants/accept-type'; import { CashflowSheetApplication } from './CashflowSheetApplication'; import { @@ -29,7 +36,7 @@ import { ReportsAction } from '../../types/Report.types'; @UseGuards(AuthorizationGuard, PermissionGuard) @ApiExtraModels(CashflowStatementResponseDto, CashflowStatementTableResponseDto) export class CashflowController { - constructor(private readonly cashflowSheetApp: CashflowSheetApplication) { } + constructor(private readonly cashflowSheetApp: CashflowSheetApplication) {} @Get() @RequirePermission(ReportsAction.READ_CASHFLOW, AbilitySubject.Report) diff --git a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/Cashflow.types.ts b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/Cashflow.types.ts index 6d21ca118..b3f34f65f 100644 --- a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/Cashflow.types.ts +++ b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/Cashflow.types.ts @@ -1,10 +1,12 @@ import { Knex } from 'knex'; -import { IFinancialSheetCommonMeta, INumberFormatQuery } from '../../types/Report.types'; +import { + IFinancialSheetCommonMeta, + INumberFormatQuery, +} from '../../types/Report.types'; import { Account } from '@/modules/Accounts/models/Account.model'; import { Ledger } from '@/modules/Ledger/Ledger'; import { IFinancialTable, ITableRow } from '../../types/Table.types'; - export interface ICashFlowStatementQuery { fromDate: Date | string; toDate: Date | string; @@ -111,7 +113,7 @@ export interface ICashFlowStatementTable extends IFinancialTable { export interface ICashFlowStatementService { cashFlow( tenantId: number, - query: ICashFlowStatementQuery + query: ICashFlowStatementQuery, ): Promise; } @@ -202,7 +204,7 @@ export interface ICashFlowStatement { cashLedger: Ledger, netIncomeLedger: Ledger, query: ICashFlowStatementQuery, - baseCurrency: string + baseCurrency: string, ): void; reportData(): ICashFlowStatementData; diff --git a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashflowStatementBase.ts b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashflowStatementBase.ts index d10873b6d..e6ecbcdc1 100644 --- a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashflowStatementBase.ts +++ b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashflowStatementBase.ts @@ -1,14 +1,14 @@ // @ts-nocheck import * as R from 'ramda'; import { map } from 'lodash'; -import { Account } from "@/modules/Accounts/models/Account.model"; +import { Account } from '@/modules/Accounts/models/Account.model'; import { ICashFlowStatementQuery } from './Cashflow.types'; import { FinancialSheet } from '../../common/FinancialSheet'; export class CashflowStatementBase extends FinancialSheet { readonly accountsByRootType: Map; readonly query: ICashFlowStatementQuery; - + // -------------------------------------------- // # GENERAL UTILITIES // -------------------------------------------- diff --git a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashflowStatementResponse.dto.ts b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashflowStatementResponse.dto.ts index d110874c9..a94147737 100644 --- a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashflowStatementResponse.dto.ts +++ b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashflowStatementResponse.dto.ts @@ -7,7 +7,9 @@ import { } from '../../dtos/FinancialReportResponse.dto'; export class CashflowStatementDataNodeDto { - @ApiProperty({ description: 'Node identifier (string for aggregates, number for accounts)' }) + @ApiProperty({ + description: 'Node identifier (string for aggregates, number for accounts)', + }) id: string | number; @ApiProperty({ description: 'Account or category name' }) @@ -22,10 +24,16 @@ export class CashflowStatementDataNodeDto { @ApiPropertyOptional({ description: 'Node type alias' }) type?: string; - @ApiProperty({ description: 'Total amount information', type: FinancialReportTotalDto }) + @ApiProperty({ + description: 'Total amount information', + type: FinancialReportTotalDto, + }) total: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Horizontal totals for date periods', type: [FinancialReportTotalDto] }) + @ApiPropertyOptional({ + description: 'Horizontal totals for date periods', + type: [FinancialReportTotalDto], + }) horizontalTotals?: FinancialReportTotalDto[]; @ApiPropertyOptional({ description: 'Account code' }) @@ -34,7 +42,10 @@ export class CashflowStatementDataNodeDto { @ApiPropertyOptional({ description: 'Display index', type: Number }) index?: number; - @ApiPropertyOptional({ description: 'Child nodes', type: () => [CashflowStatementDataNodeDto] }) + @ApiPropertyOptional({ + description: 'Child nodes', + type: () => [CashflowStatementDataNodeDto], + }) children?: CashflowStatementDataNodeDto[]; } @@ -50,10 +61,16 @@ export class CashflowStatementMetaDto extends FinancialReportMetaDto { } export class CashflowStatementQueryResponseDto { - @ApiProperty({ description: 'Column display type', enum: ['total', 'date_periods'] }) + @ApiProperty({ + description: 'Column display type', + enum: ['total', 'date_periods'], + }) displayColumnsType: string; - @ApiProperty({ description: 'Column grouping', enum: ['day', 'month', 'year', 'quarter'] }) + @ApiProperty({ + description: 'Column grouping', + enum: ['day', 'month', 'year', 'quarter'], + }) displayColumnsBy: string; @ApiProperty({ description: 'Start date' }) @@ -62,7 +79,10 @@ export class CashflowStatementQueryResponseDto { @ApiProperty({ description: 'End date' }) toDate: string; - @ApiProperty({ description: 'Number format settings', type: NumberFormatQueryDto }) + @ApiProperty({ + description: 'Number format settings', + type: NumberFormatQueryDto, + }) numberFormat: NumberFormatQueryDto; @ApiProperty({ description: 'Exclude zero balance accounts' }) @@ -79,13 +99,22 @@ export class CashflowStatementQueryResponseDto { } export class CashflowStatementResponseDto { - @ApiProperty({ description: 'Query parameters used to generate the report', type: CashflowStatementQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: CashflowStatementQueryResponseDto, + }) query: CashflowStatementQueryResponseDto; - @ApiProperty({ description: 'Hierarchical cashflow data', type: [CashflowStatementDataNodeDto] }) + @ApiProperty({ + description: 'Hierarchical cashflow data', + type: [CashflowStatementDataNodeDto], + }) data: CashflowStatementDataNodeDto[]; - @ApiProperty({ description: 'Report metadata', type: CashflowStatementMetaDto }) + @ApiProperty({ + description: 'Report metadata', + type: CashflowStatementMetaDto, + }) meta: CashflowStatementMetaDto; } @@ -98,12 +127,21 @@ export { } from '../../dtos/FinancialReportResponse.dto'; export class CashflowStatementTableResponseDto { - @ApiProperty({ description: 'Table data structure', type: () => FinancialTableDataDto }) + @ApiProperty({ + description: 'Table data structure', + type: () => FinancialTableDataDto, + }) table: FinancialTableDataDto; - @ApiProperty({ description: 'Query parameters used to generate the report', type: CashflowStatementQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: CashflowStatementQueryResponseDto, + }) query: CashflowStatementQueryResponseDto; - @ApiProperty({ description: 'Report metadata', type: CashflowStatementMetaDto }) + @ApiProperty({ + description: 'Report metadata', + type: CashflowStatementMetaDto, + }) meta: CashflowStatementMetaDto; } diff --git a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashflowTableInjectable.ts b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashflowTableInjectable.ts index 362cd5ab1..d22b6df56 100644 --- a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashflowTableInjectable.ts +++ b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/CashflowTableInjectable.ts @@ -16,7 +16,7 @@ export class CashflowTableInjectable { /** * Retrieves the cash flow table. - * @param {ICashFlowStatementQuery} query - + * @param {ICashFlowStatementQuery} query - * @returns {Promise} */ public async table( diff --git a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/constants.ts b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/constants.ts index 6152c73ff..c0f7decd0 100644 --- a/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/constants.ts +++ b/packages/server/src/modules/FinancialStatements/modules/CashFlowStatement/constants.ts @@ -1,5 +1,5 @@ import * as moment from 'moment'; -import { ICashFlowStatementQuery } from "./Cashflow.types"; +import { ICashFlowStatementQuery } from './Cashflow.types'; export const DISPLAY_COLUMNS_BY = { DATE_PERIODS: 'date_periods', diff --git a/packages/server/src/modules/FinancialStatements/modules/ContactBalanceSummary/ContactBalanceSummary.ts b/packages/server/src/modules/FinancialStatements/modules/ContactBalanceSummary/ContactBalanceSummary.ts index ee628e0e2..a85726b24 100644 --- a/packages/server/src/modules/FinancialStatements/modules/ContactBalanceSummary/ContactBalanceSummary.ts +++ b/packages/server/src/modules/FinancialStatements/modules/ContactBalanceSummary/ContactBalanceSummary.ts @@ -24,7 +24,7 @@ export class ContactBalanceSummaryReport extends FinancialSheet { */ protected getContactPercentageOfColumn = ( customerBalance: number, - totalBalance: number + totalBalance: number, ): number => { return totalBalance / customerBalance; }; @@ -35,11 +35,11 @@ export class ContactBalanceSummaryReport extends FinancialSheet { * @returns {number} */ protected getContactsTotal = ( - contacts: IContactBalanceSummaryContact[] + contacts: IContactBalanceSummaryContact[], ): number => { return sumBy( contacts, - (contact: IContactBalanceSummaryContact) => contact.total.amount + (contact: IContactBalanceSummaryContact) => contact.total.amount, ); }; @@ -49,7 +49,7 @@ export class ContactBalanceSummaryReport extends FinancialSheet { * @returns {IContactBalanceSummaryTotal} */ protected assocTotalPercentageOfColumn = ( - node: IContactBalanceSummaryTotal + node: IContactBalanceSummaryTotal, ): IContactBalanceSummaryTotal => { return R.assoc('percentageOfColumn', this.getPercentageMeta(1), node); }; @@ -60,7 +60,7 @@ export class ContactBalanceSummaryReport extends FinancialSheet { * @returns {IContactBalanceSummaryTotal} */ protected getContactsTotalSection = ( - contacts: IContactBalanceSummaryContact[] + contacts: IContactBalanceSummaryContact[], ): IContactBalanceSummaryTotal => { const customersTotal = this.getContactsTotal(contacts); const node = { @@ -70,8 +70,8 @@ export class ContactBalanceSummaryReport extends FinancialSheet { return R.compose( R.when( R.always(this.filter.percentageColumn), - this.assocTotalPercentageOfColumn - ) + this.assocTotalPercentageOfColumn, + ), )(node); }; @@ -83,11 +83,11 @@ export class ContactBalanceSummaryReport extends FinancialSheet { */ private contactCamparsionPercentageOfColumnMapper = ( total: number, - contact: IContactBalanceSummaryContact + contact: IContactBalanceSummaryContact, ): IContactBalanceSummaryContact => { const amount = this.getContactPercentageOfColumn( total, - contact.total.amount + contact.total.amount, ); return { ...contact, @@ -101,11 +101,11 @@ export class ContactBalanceSummaryReport extends FinancialSheet { * @return {IContactBalanceSummaryContact[]} */ protected contactCamparsionPercentageOfColumn = ( - contacts: IContactBalanceSummaryContact[] + contacts: IContactBalanceSummaryContact[], ): IContactBalanceSummaryContact[] => { const customersTotal = this.getContactsTotal(contacts); const camparsionPercentageOfColummn = R.curry( - this.contactCamparsionPercentageOfColumnMapper + this.contactCamparsionPercentageOfColumnMapper, )(customersTotal); // @ts-ignore @@ -118,7 +118,7 @@ export class ContactBalanceSummaryReport extends FinancialSheet { * @return {IContactBalanceSummaryAmount} */ protected getContactTotalFormat = ( - amount: number + amount: number, ): IContactBalanceSummaryAmount => { return { amount, @@ -146,7 +146,7 @@ export class ContactBalanceSummaryReport extends FinancialSheet { * @returns {IContactBalanceSummaryPercentage} */ protected getPercentageMeta = ( - amount: number + amount: number, ): IContactBalanceSummaryPercentage => { return { amount, @@ -160,7 +160,7 @@ export class ContactBalanceSummaryReport extends FinancialSheet { * @returns {boolean} */ private filterContactNoneTransactions = ( - contact: IContactBalanceSummaryContact + contact: IContactBalanceSummaryContact, ): boolean => { const entries = this.ledger.whereContactId(contact.id).getEntries(); @@ -173,7 +173,7 @@ export class ContactBalanceSummaryReport extends FinancialSheet { * @returns {boolean} */ private filterContactNoneZero = ( - node: IContactBalanceSummaryContact + node: IContactBalanceSummaryContact, ): boolean => { return node.total.amount !== 0; }; @@ -199,7 +199,7 @@ export class ContactBalanceSummaryReport extends FinancialSheet { * @returns {ICustomerBalanceSummaryCustomer[]} */ protected contactsFilter = ( - nodes: IContactBalanceSummaryContact[] + nodes: IContactBalanceSummaryContact[], ): IContactBalanceSummaryContact[] => { return nodes.filter(this.contactNodeFilter); }; diff --git a/packages/server/src/modules/FinancialStatements/modules/ContactBalanceSummary/ContactBalanceSummary.types.ts b/packages/server/src/modules/FinancialStatements/modules/ContactBalanceSummary/ContactBalanceSummary.types.ts index eac379d54..af9193f08 100644 --- a/packages/server/src/modules/FinancialStatements/modules/ContactBalanceSummary/ContactBalanceSummary.types.ts +++ b/packages/server/src/modules/FinancialStatements/modules/ContactBalanceSummary/ContactBalanceSummary.types.ts @@ -1,4 +1,4 @@ -import { INumberFormatQuery } from "../../types/Report.types"; +import { INumberFormatQuery } from '../../types/Report.types'; export interface IContactBalanceSummaryQuery { asDate: Date; @@ -43,6 +43,6 @@ export interface ICustomerBalanceSummaryStatement { export interface ICustomerBalanceSummaryService { customerBalanceSummary( tenantId: number, - query: IContactBalanceSummaryQuery + query: IContactBalanceSummaryQuery, ): Promise; } diff --git a/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummary.controller.ts b/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummary.controller.ts index 20ff6aa01..ab90c9f5e 100644 --- a/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummary.controller.ts +++ b/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummary.controller.ts @@ -20,7 +20,10 @@ import { ApiCommonHeaders } from '@/common/decorators/ApiCommonHeaders'; @Controller('/reports/customer-balance-summary') @ApiTags('Reports') @ApiCommonHeaders() -@ApiExtraModels(CustomerBalanceSummaryResponseDto, CustomerBalanceSummaryTableResponseDto) +@ApiExtraModels( + CustomerBalanceSummaryResponseDto, + CustomerBalanceSummaryTableResponseDto, +) export class CustomerBalanceSummaryController { constructor( private readonly customerBalanceSummaryApp: CustomerBalanceSummaryApplication, diff --git a/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummary.module.ts b/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummary.module.ts index 10c841c0a..732c6eff3 100644 --- a/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummary.module.ts +++ b/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummary.module.ts @@ -11,9 +11,7 @@ import { CustomerBalanceSummaryRepository } from './CustomerBalanceSummaryReposi import { TenancyContext } from '@/modules/Tenancy/TenancyContext.service'; @Module({ - imports: [ - FinancialSheetCommonModule, - ], + imports: [FinancialSheetCommonModule], controllers: [CustomerBalanceSummaryController], providers: [ CustomerBalanceSummaryApplication, @@ -23,7 +21,7 @@ import { TenancyContext } from '@/modules/Tenancy/TenancyContext.service'; CustomerBalanceSummaryService, CustomerBalanceSummaryTableInjectable, CustomerBalanceSummaryRepository, - TenancyContext + TenancyContext, ], }) export class CustomerBalanceSummaryModule {} diff --git a/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummary.ts b/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummary.ts index 25d0854f9..fe81d55fa 100644 --- a/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummary.ts +++ b/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummary.ts @@ -8,7 +8,11 @@ import { import { ContactBalanceSummaryReport } from '../ContactBalanceSummary/ContactBalanceSummary'; import { ILedger } from '@/modules/Ledger/types/Ledger.types'; import { ModelObject } from 'objection'; -import { INumberFormatQuery, IFinancialReportMeta, DEFAULT_REPORT_META } from '../../types/Report.types'; +import { + INumberFormatQuery, + IFinancialReportMeta, + DEFAULT_REPORT_META, +} from '../../types/Report.types'; import { Customer } from '@/modules/Customers/models/Customer'; export class CustomerBalanceSummaryReport extends ContactBalanceSummaryReport { @@ -47,7 +51,7 @@ export class CustomerBalanceSummaryReport extends ContactBalanceSummaryReport { * @returns {ICustomerBalanceSummaryCustomer} */ private customerMapper = ( - customer: ModelObject + customer: ModelObject, ): ICustomerBalanceSummaryCustomer => { const closingBalance = this.ledger .whereContactId(customer.id) @@ -66,7 +70,7 @@ export class CustomerBalanceSummaryReport extends ContactBalanceSummaryReport { * @returns {ICustomerBalanceSummaryCustomer[]} */ private customersMapper = ( - customers: ModelObject[] + customers: ModelObject[], ): ICustomerBalanceSummaryCustomer[] => { return customers.map(this.customerMapper); }; @@ -85,16 +89,16 @@ export class CustomerBalanceSummaryReport extends ContactBalanceSummaryReport { * @returns {ICustomerBalanceSummaryCustomer[]} */ private getCustomersSection = ( - customers: ModelObject[] + customers: ModelObject[], ): ICustomerBalanceSummaryCustomer[] => { // @ts-ignore return R.compose( R.when(this.isCustomersPostFilter, this.contactsFilter), R.when( R.always(this.filter.percentageColumn), - this.contactCamparsionPercentageOfColumn + this.contactCamparsionPercentageOfColumn, ), - this.customersMapper + this.customersMapper, )(customers); }; diff --git a/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummary.types.ts b/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummary.types.ts index 3a5ff4c63..b30249bf8 100644 --- a/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummary.types.ts +++ b/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummary.types.ts @@ -50,7 +50,7 @@ export interface ICustomerBalanceSummaryStatement { export interface ICustomerBalanceSummaryService { customerBalanceSummary( tenantId: number, - query: ICustomerBalanceSummaryQuery + query: ICustomerBalanceSummaryQuery, ): Promise; } diff --git a/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummaryResponse.dto.ts b/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummaryResponse.dto.ts index a1dbb929f..b8edddc5c 100644 --- a/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummaryResponse.dto.ts +++ b/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummaryResponse.dto.ts @@ -13,16 +13,28 @@ export class CustomerBalanceDto { @ApiProperty({ description: 'Customer name' }) customerName: string; - @ApiPropertyOptional({ description: 'Opening balance', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Opening balance', + type: FinancialReportTotalDto, + }) openingBalance?: FinancialReportTotalDto; - @ApiProperty({ description: 'Closing balance', type: FinancialReportTotalDto }) + @ApiProperty({ + description: 'Closing balance', + type: FinancialReportTotalDto, + }) closingBalance: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Total debit', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Total debit', + type: FinancialReportTotalDto, + }) totalDebit?: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Total credit', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Total credit', + type: FinancialReportTotalDto, + }) totalCredit?: FinancialReportTotalDto; } @@ -38,7 +50,10 @@ export class CustomerBalanceSummaryQueryResponseDto { @ApiProperty({ description: 'As-of date' }) asDate: string; - @ApiProperty({ description: 'Number format settings', type: NumberFormatQueryDto }) + @ApiProperty({ + description: 'Number format settings', + type: NumberFormatQueryDto, + }) numberFormat: NumberFormatQueryDto; @ApiProperty({ description: 'Customer IDs to include', type: [Number] }) @@ -52,13 +67,19 @@ export class CustomerBalanceSummaryQueryResponseDto { } export class CustomerBalanceSummaryResponseDto { - @ApiProperty({ description: 'Query parameters used to generate the report', type: CustomerBalanceSummaryQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: CustomerBalanceSummaryQueryResponseDto, + }) query: CustomerBalanceSummaryQueryResponseDto; @ApiProperty({ description: 'Customer balances', type: [CustomerBalanceDto] }) data: CustomerBalanceDto[]; - @ApiProperty({ description: 'Report metadata', type: CustomerBalanceSummaryMetaDto }) + @ApiProperty({ + description: 'Report metadata', + type: CustomerBalanceSummaryMetaDto, + }) meta: CustomerBalanceSummaryMetaDto; } @@ -71,12 +92,21 @@ export { } from '../../dtos/FinancialReportResponse.dto'; export class CustomerBalanceSummaryTableResponseDto { - @ApiProperty({ description: 'Table data structure', type: () => FinancialTableDataDto }) + @ApiProperty({ + description: 'Table data structure', + type: () => FinancialTableDataDto, + }) table: FinancialTableDataDto; - @ApiProperty({ description: 'Query parameters used to generate the report', type: CustomerBalanceSummaryQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: CustomerBalanceSummaryQueryResponseDto, + }) query: CustomerBalanceSummaryQueryResponseDto; - @ApiProperty({ description: 'Report metadata', type: CustomerBalanceSummaryMetaDto }) + @ApiProperty({ + description: 'Report metadata', + type: CustomerBalanceSummaryMetaDto, + }) meta: CustomerBalanceSummaryMetaDto; } diff --git a/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummaryService.ts b/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummaryService.ts index 920f69816..4a3c68170 100644 --- a/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummaryService.ts +++ b/packages/server/src/modules/FinancialStatements/modules/CustomerBalanceSummary/CustomerBalanceSummaryService.ts @@ -67,12 +67,10 @@ export class CustomerBalanceSummaryService { const meta = await this.customerBalanceSummaryMeta.meta(filter); // Report instance. - const report = new CustomerBalanceSummaryReport( - ledger, - customers, - filter, - { baseCurrency: tenantMetadata.baseCurrency, dateFormat: meta.dateFormat }, - ); + const report = new CustomerBalanceSummaryReport(ledger, customers, filter, { + baseCurrency: tenantMetadata.baseCurrency, + dateFormat: meta.dateFormat, + }); // Triggers `onCustomerBalanceSummaryViewed` event. await this.eventPublisher.emitAsync( diff --git a/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedger.controller.ts b/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedger.controller.ts index dc169da1c..5a6cfd816 100644 --- a/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedger.controller.ts +++ b/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedger.controller.ts @@ -7,7 +7,14 @@ import { getSchemaPath, } from '@nestjs/swagger'; import { Response } from 'express'; -import { Controller, Get, Headers, Query, Res, UseGuards } from '@nestjs/common'; +import { + Controller, + Get, + Headers, + Query, + Res, + UseGuards, +} from '@nestjs/common'; import { GeneralLedgerApplication } from './GeneralLedgerApplication'; import { AcceptType } from '@/constants/accept-type'; import { GeneralLedgerQueryDto } from './GeneralLedgerQuery.dto'; diff --git a/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedger.module.ts b/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedger.module.ts index 885d6aaf0..47ab504ed 100644 --- a/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedger.module.ts +++ b/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedger.module.ts @@ -12,10 +12,7 @@ import { AccountsModule } from '@/modules/Accounts/Accounts.module'; import { TenancyContext } from '@/modules/Tenancy/TenancyContext.service'; @Module({ - imports: [ - FinancialSheetCommonModule, - AccountsModule - ], + imports: [FinancialSheetCommonModule, AccountsModule], providers: [ GeneralLedgerRepository, GeneralLedgerApplication, @@ -24,7 +21,7 @@ import { TenancyContext } from '@/modules/Tenancy/TenancyContext.service'; GeneralLedgerTableInjectable, GeneralLedgerService, GeneralLedgerMeta, - TenancyContext + TenancyContext, ], controllers: [GeneralLedgerController], }) diff --git a/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedger.ts b/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedger.ts index bfc946b72..f0ca083a2 100644 --- a/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedger.ts +++ b/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedger.ts @@ -19,7 +19,10 @@ import { Account } from '@/modules/Accounts/models/Account.model'; import { ModelObject } from 'objection'; import { flatToNestedArray } from '@/utils/flat-to-nested-array'; import { getTransactionTypeLabel } from '@/modules/BankingTransactions/utils'; -import { IFinancialReportMeta, DEFAULT_REPORT_META } from '../../types/Report.types'; +import { + IFinancialReportMeta, + DEFAULT_REPORT_META, +} from '../../types/Report.types'; export class GeneralLedgerSheet extends R.compose(FinancialSheetStructure)( FinancialSheet, diff --git a/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedger.types.ts b/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedger.types.ts index 05881cdf2..a66f77a25 100644 --- a/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedger.types.ts +++ b/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedger.types.ts @@ -1,5 +1,8 @@ -import { IFinancialSheetCommonMeta, INumberFormatQuery } from "../../types/Report.types"; -import { IFinancialTable } from "../../types/Table.types"; +import { + IFinancialSheetCommonMeta, + INumberFormatQuery, +} from '../../types/Report.types'; +import { IFinancialTable } from '../../types/Table.types'; export interface IGeneralLedgerSheetQuery { fromDate: Date | string; @@ -12,8 +15,7 @@ export interface IGeneralLedgerSheetQuery { branchesIds?: number[]; } -export interface IGeneralLedgerNumberFormat extends INumberFormatQuery{ -} +export interface IGeneralLedgerNumberFormat extends INumberFormatQuery {} export interface IGeneralLedgerSheetAccountTransaction { id: number; diff --git a/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedgerApplication.ts b/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedgerApplication.ts index 27b61129c..d2d432125 100644 --- a/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedgerApplication.ts +++ b/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedgerApplication.ts @@ -41,9 +41,7 @@ export class GeneralLedgerApplication { * @param {IGeneralLedgerSheetQuery} query * @returns {Promise} */ - public xlsx( - query: IGeneralLedgerSheetQuery, - ): Promise { + public xlsx(query: IGeneralLedgerSheetQuery): Promise { return this.GLExport.xlsx(query); } @@ -52,9 +50,7 @@ export class GeneralLedgerApplication { * @param {IGeneralLedgerSheetQuery} query - * @returns {Promise} */ - public csv( - query: IGeneralLedgerSheetQuery, - ): Promise { + public csv(query: IGeneralLedgerSheetQuery): Promise { return this.GLExport.csv(query); } @@ -63,9 +59,7 @@ export class GeneralLedgerApplication { * @param {IGeneralLedgerSheetQuery} query * @returns {Promise} */ - public pdf( - query: IGeneralLedgerSheetQuery, - ): Promise { + public pdf(query: IGeneralLedgerSheetQuery): Promise { return this.GLPdf.pdf(query); } } diff --git a/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedgerExport.ts b/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedgerExport.ts index 3b07fb287..2c0016308 100644 --- a/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedgerExport.ts +++ b/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedgerExport.ts @@ -1,4 +1,3 @@ - import { Injectable } from '@nestjs/common'; import { GeneralLedgerTableInjectable } from './GeneralLedgerTableInjectable'; import { IGeneralLedgerSheetQuery } from './GeneralLedger.types'; @@ -7,7 +6,7 @@ import { TableSheet } from '../../common/TableSheet'; @Injectable() export class GeneralLedgerExportInjectable { constructor( - private readonly generalLedgerTable: GeneralLedgerTableInjectable + private readonly generalLedgerTable: GeneralLedgerTableInjectable, ) {} /** @@ -29,9 +28,7 @@ export class GeneralLedgerExportInjectable { * @param {IGeneralLedgerSheetQuery} query - General ledger sheet query. * @returns {Promise} */ - public async csv( - query: IGeneralLedgerSheetQuery - ): Promise { + public async csv(query: IGeneralLedgerSheetQuery): Promise { const table = await this.generalLedgerTable.table(query); const tableSheet = new TableSheet(table.table); diff --git a/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedgerMeta.ts b/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedgerMeta.ts index 2aa82352e..a60089a46 100644 --- a/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedgerMeta.ts +++ b/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedgerMeta.ts @@ -20,7 +20,9 @@ export class GeneralLedgerMeta { const commonMeta = await this.financialSheetMeta.meta(); const formattedToDate = moment(query.toDate).format(commonMeta.dateFormat); - const formattedFromDate = moment(query.fromDate).format(commonMeta.dateFormat); + const formattedFromDate = moment(query.fromDate).format( + commonMeta.dateFormat, + ); const formattedDateRange = `From ${formattedFromDate} | To ${formattedToDate}`; return { diff --git a/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedgerResponse.dto.ts b/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedgerResponse.dto.ts index 5c2372386..e9e97bf44 100644 --- a/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedgerResponse.dto.ts +++ b/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/GeneralLedgerResponse.dto.ts @@ -84,13 +84,22 @@ export class GeneralLedgerAccountDto { @ApiPropertyOptional({ description: 'Parent account ID', type: Number }) parentAccountId: number | null; - @ApiProperty({ description: 'Opening balance', type: FinancialReportTotalDto }) + @ApiProperty({ + description: 'Opening balance', + type: FinancialReportTotalDto, + }) openingBalance: FinancialReportTotalDto; - @ApiProperty({ description: 'Account transactions', type: [GeneralLedgerTransactionDto] }) + @ApiProperty({ + description: 'Account transactions', + type: [GeneralLedgerTransactionDto], + }) transactions: GeneralLedgerTransactionDto[]; - @ApiProperty({ description: 'Closing balance', type: FinancialReportTotalDto }) + @ApiProperty({ + description: 'Closing balance', + type: FinancialReportTotalDto, + }) closingBalance: FinancialReportTotalDto; } @@ -115,7 +124,10 @@ export class GeneralLedgerQueryResponseDto { @ApiProperty({ description: 'Accounting basis', enum: ['cash', 'accrual'] }) basis: string; - @ApiProperty({ description: 'Number format settings', type: NumberFormatQueryDto }) + @ApiProperty({ + description: 'Number format settings', + type: NumberFormatQueryDto, + }) numberFormat: NumberFormatQueryDto; @ApiProperty({ description: 'Exclude zero balance accounts' }) @@ -126,10 +138,16 @@ export class GeneralLedgerQueryResponseDto { } export class GeneralLedgerResponseDto { - @ApiProperty({ description: 'Query parameters used to generate the report', type: GeneralLedgerQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: GeneralLedgerQueryResponseDto, + }) query: GeneralLedgerQueryResponseDto; - @ApiProperty({ description: 'General ledger data', type: [GeneralLedgerAccountDto] }) + @ApiProperty({ + description: 'General ledger data', + type: [GeneralLedgerAccountDto], + }) data: GeneralLedgerAccountDto[]; @ApiProperty({ description: 'Report metadata', type: GeneralLedgerMetaDto }) @@ -145,10 +163,16 @@ export { } from '../../dtos/FinancialReportResponse.dto'; export class GeneralLedgerTableResponseDto { - @ApiProperty({ description: 'Table data structure', type: () => FinancialTableDataDto }) + @ApiProperty({ + description: 'Table data structure', + type: () => FinancialTableDataDto, + }) table: FinancialTableDataDto; - @ApiProperty({ description: 'Query parameters used to generate the report', type: GeneralLedgerQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: GeneralLedgerQueryResponseDto, + }) query: GeneralLedgerQueryResponseDto; @ApiProperty({ description: 'Report metadata', type: GeneralLedgerMetaDto }) diff --git a/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/_utils.ts b/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/_utils.ts index 896133870..5455b6d25 100644 --- a/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/_utils.ts +++ b/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/_utils.ts @@ -14,8 +14,7 @@ export function calculateRunningBalance( return amount + lastRunningBalance; } -export const getGeneralLedgerReportQuery = ( -) => { +export const getGeneralLedgerReportQuery = () => { return { fromDate: moment().startOf('month').format('YYYY-MM-DD'), toDate: moment().format('YYYY-MM-DD'), diff --git a/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/constants.ts b/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/constants.ts index 9e79a81da..71c7199bc 100644 --- a/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/constants.ts +++ b/packages/server/src/modules/FinancialStatements/modules/GeneralLedger/constants.ts @@ -26,4 +26,4 @@ table tr.row-type--opening-balance .cell--account_name span, table tr.row-type--closing-balance .cell--account_name span{ white-space: nowrap; } -`; \ No newline at end of file +`; diff --git a/packages/server/src/modules/FinancialStatements/modules/InventoryItemDetails/InventoryItemDetails.controller.ts b/packages/server/src/modules/FinancialStatements/modules/InventoryItemDetails/InventoryItemDetails.controller.ts index a099900db..7619bfe71 100644 --- a/packages/server/src/modules/FinancialStatements/modules/InventoryItemDetails/InventoryItemDetails.controller.ts +++ b/packages/server/src/modules/FinancialStatements/modules/InventoryItemDetails/InventoryItemDetails.controller.ts @@ -1,5 +1,12 @@ import { Response } from 'express'; -import { ApiExtraModels, ApiOperation, ApiTags, ApiResponse, ApiProduces, getSchemaPath } from '@nestjs/swagger'; +import { + ApiExtraModels, + ApiOperation, + ApiTags, + ApiResponse, + ApiProduces, + getSchemaPath, +} from '@nestjs/swagger'; import { Controller, Get, Headers, Query, Res } from '@nestjs/common'; import { InventoryItemDetailsApplication } from './InventoryItemDetailsApplication'; import { AcceptType } from '@/constants/accept-type'; @@ -13,7 +20,10 @@ import { ApiCommonHeaders } from '@/common/decorators/ApiCommonHeaders'; @Controller('reports/inventory-item-details') @ApiTags('Reports') @ApiCommonHeaders() -@ApiExtraModels(InventoryItemDetailsResponseDto, InventoryItemDetailsTableResponseDto) +@ApiExtraModels( + InventoryItemDetailsResponseDto, + InventoryItemDetailsTableResponseDto, +) export class InventoryItemDetailsController { constructor( private readonly inventoryItemDetailsApp: InventoryItemDetailsApplication, diff --git a/packages/server/src/modules/FinancialStatements/modules/InventoryItemDetails/InventoryItemDetailsMeta.ts b/packages/server/src/modules/FinancialStatements/modules/InventoryItemDetails/InventoryItemDetailsMeta.ts index ea8c1848b..c44273561 100644 --- a/packages/server/src/modules/FinancialStatements/modules/InventoryItemDetails/InventoryItemDetailsMeta.ts +++ b/packages/server/src/modules/FinancialStatements/modules/InventoryItemDetails/InventoryItemDetailsMeta.ts @@ -19,7 +19,9 @@ export class InventoryDetailsMetaInjectable { ): Promise { const commonMeta = await this.financialSheetMeta.meta(); - const formattedFromDate = moment(query.fromDate).format(commonMeta.dateFormat); + const formattedFromDate = moment(query.fromDate).format( + commonMeta.dateFormat, + ); const formattedToDay = moment(query.toDate).format(commonMeta.dateFormat); const formattedDateRange = `From ${formattedFromDate} | To ${formattedToDay}`; diff --git a/packages/server/src/modules/FinancialStatements/modules/InventoryItemDetails/InventoryItemDetailsRepository.ts b/packages/server/src/modules/FinancialStatements/modules/InventoryItemDetails/InventoryItemDetailsRepository.ts index fbad1077c..d5cbe641d 100644 --- a/packages/server/src/modules/FinancialStatements/modules/InventoryItemDetails/InventoryItemDetailsRepository.ts +++ b/packages/server/src/modules/FinancialStatements/modules/InventoryItemDetails/InventoryItemDetailsRepository.ts @@ -144,13 +144,15 @@ export class InventoryItemDetailsRepository { public async getInventoryItems( itemsIds?: number[], ): Promise[]> { - return this.itemModel().query().onBuild((q) => { - q.where('type', 'inventory'); + return this.itemModel() + .query() + .onBuild((q) => { + q.where('type', 'inventory'); - if (!isEmpty(itemsIds)) { - q.whereIn('id', itemsIds); - } - }); + if (!isEmpty(itemsIds)) { + q.whereIn('id', itemsIds); + } + }); } /** diff --git a/packages/server/src/modules/FinancialStatements/modules/InventoryItemDetails/InventoryItemDetailsResponse.dto.ts b/packages/server/src/modules/FinancialStatements/modules/InventoryItemDetails/InventoryItemDetailsResponse.dto.ts index eeb5450b3..dfe2361ae 100644 --- a/packages/server/src/modules/FinancialStatements/modules/InventoryItemDetails/InventoryItemDetailsResponse.dto.ts +++ b/packages/server/src/modules/FinancialStatements/modules/InventoryItemDetails/InventoryItemDetailsResponse.dto.ts @@ -54,7 +54,10 @@ export class InventoryItemDetailDto { @ApiProperty({ description: 'Closing quantity', type: Number }) closingQuantity: number; - @ApiProperty({ description: 'Item transactions', type: [InventoryItemTransactionDto] }) + @ApiProperty({ + description: 'Item transactions', + type: [InventoryItemTransactionDto], + }) transactions: InventoryItemTransactionDto[]; } @@ -76,7 +79,10 @@ export class InventoryItemDetailsQueryResponseDto { @ApiProperty({ description: 'End date' }) toDate: string; - @ApiProperty({ description: 'Number format settings', type: NumberFormatQueryDto }) + @ApiProperty({ + description: 'Number format settings', + type: NumberFormatQueryDto, + }) numberFormat: NumberFormatQueryDto; @ApiProperty({ description: 'Item IDs to include', type: [Number] }) @@ -84,13 +90,22 @@ export class InventoryItemDetailsQueryResponseDto { } export class InventoryItemDetailsResponseDto { - @ApiProperty({ description: 'Query parameters used to generate the report', type: InventoryItemDetailsQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: InventoryItemDetailsQueryResponseDto, + }) query: InventoryItemDetailsQueryResponseDto; - @ApiProperty({ description: 'Inventory items with details', type: [InventoryItemDetailDto] }) + @ApiProperty({ + description: 'Inventory items with details', + type: [InventoryItemDetailDto], + }) data: InventoryItemDetailDto[]; - @ApiProperty({ description: 'Report metadata', type: InventoryItemDetailsMetaDto }) + @ApiProperty({ + description: 'Report metadata', + type: InventoryItemDetailsMetaDto, + }) meta: InventoryItemDetailsMetaDto; } @@ -103,12 +118,21 @@ export { } from '../../dtos/FinancialReportResponse.dto'; export class InventoryItemDetailsTableResponseDto { - @ApiProperty({ description: 'Table data structure', type: () => FinancialTableDataDto }) + @ApiProperty({ + description: 'Table data structure', + type: () => FinancialTableDataDto, + }) table: FinancialTableDataDto; - @ApiProperty({ description: 'Query parameters used to generate the report', type: InventoryItemDetailsQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: InventoryItemDetailsQueryResponseDto, + }) query: InventoryItemDetailsQueryResponseDto; - @ApiProperty({ description: 'Report metadata', type: InventoryItemDetailsMetaDto }) + @ApiProperty({ + description: 'Report metadata', + type: InventoryItemDetailsMetaDto, + }) meta: InventoryItemDetailsMetaDto; } diff --git a/packages/server/src/modules/FinancialStatements/modules/InventoryItemDetails/InventoryItemDetailsTable.ts b/packages/server/src/modules/FinancialStatements/modules/InventoryItemDetails/InventoryItemDetailsTable.ts index 6f55875ca..4133cb5f6 100644 --- a/packages/server/src/modules/FinancialStatements/modules/InventoryItemDetails/InventoryItemDetailsTable.ts +++ b/packages/server/src/modules/FinancialStatements/modules/InventoryItemDetails/InventoryItemDetailsTable.ts @@ -93,7 +93,10 @@ export class InventoryItemDetailsTable { ): ITableRow => { const columns: Array = [ { key: 'date', accessor: 'date.formattedDate' }, - { key: 'closing', value: this.i18n.t('inventory_item_details.opening_balance') }, + { + key: 'closing', + value: this.i18n.t('inventory_item_details.opening_balance'), + }, { key: 'empty', value: '' }, { key: 'quantity', accessor: 'quantity.formattedNumber' }, { key: 'empty', value: '' }, @@ -115,7 +118,10 @@ export class InventoryItemDetailsTable { ): ITableRow => { const columns: Array = [ { key: 'date', accessor: 'date.formattedDate' }, - { key: 'closing', value: this.i18n.t('inventory_item_details.closing_balance') }, + { + key: 'closing', + value: this.i18n.t('inventory_item_details.closing_balance'), + }, { key: 'empty', value: '' }, { key: 'quantity', accessor: 'quantity.formattedNumber' }, { key: 'empty', value: '' }, @@ -194,15 +200,33 @@ export class InventoryItemDetailsTable { public tableColumns = (): ITableColumn[] => { return [ { key: 'date', label: this.i18n.t('inventory_item_details.date') }, - { key: 'transaction_type', label: this.i18n.t('inventory_item_details.transaction_type') }, - { key: 'transaction_id', label: this.i18n.t('inventory_item_details.transaction_number') }, - { key: 'quantity', label: this.i18n.t('inventory_item_details.quantity') }, + { + key: 'transaction_type', + label: this.i18n.t('inventory_item_details.transaction_type'), + }, + { + key: 'transaction_id', + label: this.i18n.t('inventory_item_details.transaction_number'), + }, + { + key: 'quantity', + label: this.i18n.t('inventory_item_details.quantity'), + }, { key: 'rate', label: this.i18n.t('inventory_item_details.rate') }, { key: 'total', label: this.i18n.t('inventory_item_details.total') }, { key: 'value', label: this.i18n.t('inventory_item_details.value') }, - { key: 'profit_margin', label: this.i18n.t('inventory_item_details.profit_margin') }, - { key: 'running_quantity', label: this.i18n.t('inventory_item_details.running_quantity') }, - { key: 'running_value', label: this.i18n.t('inventory_item_details.running_value') }, + { + key: 'profit_margin', + label: this.i18n.t('inventory_item_details.profit_margin'), + }, + { + key: 'running_quantity', + label: this.i18n.t('inventory_item_details.running_quantity'), + }, + { + key: 'running_value', + label: this.i18n.t('inventory_item_details.running_value'), + }, ]; }; } diff --git a/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuation.controller.ts b/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuation.controller.ts index 1dfbf0c80..18f27aaee 100644 --- a/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuation.controller.ts +++ b/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuation.controller.ts @@ -20,7 +20,10 @@ import { ApiCommonHeaders } from '@/common/decorators/ApiCommonHeaders'; @Controller('reports/inventory-valuation') @ApiTags('Reports') @ApiCommonHeaders() -@ApiExtraModels(InventoryValuationResponseDto, InventoryValuationTableResponseDto) +@ApiExtraModels( + InventoryValuationResponseDto, + InventoryValuationTableResponseDto, +) export class InventoryValuationController { constructor( private readonly inventoryValuationApp: InventoryValuationSheetApplication, diff --git a/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuationResponse.dto.ts b/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuationResponse.dto.ts index d59f5a029..bc4e5bcbb 100644 --- a/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuationResponse.dto.ts +++ b/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuationResponse.dto.ts @@ -25,7 +25,10 @@ export class InventoryValuationItemDto { @ApiPropertyOptional({ description: 'Average cost', type: Number }) averageCost?: number; - @ApiPropertyOptional({ description: 'Total value', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Total value', + type: FinancialReportTotalDto, + }) totalValue?: FinancialReportTotalDto; @ApiPropertyOptional({ description: 'Asset account name' }) @@ -47,7 +50,10 @@ export class InventoryValuationQueryResponseDto { @ApiProperty({ description: 'As-of date' }) asDate: string; - @ApiProperty({ description: 'Number format settings', type: NumberFormatQueryDto }) + @ApiProperty({ + description: 'Number format settings', + type: NumberFormatQueryDto, + }) numberFormat: NumberFormatQueryDto; @ApiProperty({ description: 'Item IDs to include', type: [Number] }) @@ -58,13 +64,22 @@ export class InventoryValuationQueryResponseDto { } export class InventoryValuationResponseDto { - @ApiProperty({ description: 'Query parameters used to generate the report', type: InventoryValuationQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: InventoryValuationQueryResponseDto, + }) query: InventoryValuationQueryResponseDto; - @ApiProperty({ description: 'Inventory items valuation', type: [InventoryValuationItemDto] }) + @ApiProperty({ + description: 'Inventory items valuation', + type: [InventoryValuationItemDto], + }) data: InventoryValuationItemDto[]; - @ApiProperty({ description: 'Report metadata', type: InventoryValuationMetaDto }) + @ApiProperty({ + description: 'Report metadata', + type: InventoryValuationMetaDto, + }) meta: InventoryValuationMetaDto; } @@ -77,12 +92,21 @@ export { } from '../../dtos/FinancialReportResponse.dto'; export class InventoryValuationTableResponseDto { - @ApiProperty({ description: 'Table data structure', type: () => FinancialTableDataDto }) + @ApiProperty({ + description: 'Table data structure', + type: () => FinancialTableDataDto, + }) table: FinancialTableDataDto; - @ApiProperty({ description: 'Query parameters used to generate the report', type: InventoryValuationQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: InventoryValuationQueryResponseDto, + }) query: InventoryValuationQueryResponseDto; - @ApiProperty({ description: 'Report metadata', type: InventoryValuationMetaDto }) + @ApiProperty({ + description: 'Report metadata', + type: InventoryValuationMetaDto, + }) meta: InventoryValuationMetaDto; } diff --git a/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuationSheet.module.ts b/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuationSheet.module.ts index b882647f3..3cb088f7d 100644 --- a/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuationSheet.module.ts +++ b/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuationSheet.module.ts @@ -21,7 +21,7 @@ import { TenancyContext } from '@/modules/Tenancy/TenancyContext.service'; InventoryValuationSheetApplication, InventoryValuationSheetRepository, InventoryValuationSheetExportable, - TenancyContext + TenancyContext, ], controllers: [InventoryValuationController], exports: [InventoryValuationSheetApplication], diff --git a/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuationSheet.ts b/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuationSheet.ts index 5774fadad..b044dca48 100644 --- a/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuationSheet.ts +++ b/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuationSheet.ts @@ -12,7 +12,10 @@ import { InventoryCostLotTracker } from '@/modules/InventoryCost/models/Inventor import { FinancialSheet } from '../../common/FinancialSheet'; import { InventoryValuationSheetRepository } from './InventoryValuationSheetRepository'; import { allPassedConditionsPass } from '@/utils/all-conditions-passed'; -import { IFinancialReportMeta, DEFAULT_REPORT_META } from '../../types/Report.types'; +import { + IFinancialReportMeta, + DEFAULT_REPORT_META, +} from '../../types/Report.types'; export class InventoryValuationSheet extends FinancialSheet { readonly query: IInventoryValuationReportQuery; @@ -74,7 +77,10 @@ export class InventoryValuationSheet extends FinancialSheet { cost: number; quantity: number; } { - return this.getItemTransaction(this.repository.OUTInventoryCostLots, itemId); + return this.getItemTransaction( + this.repository.OUTInventoryCostLots, + itemId, + ); } /** @@ -196,7 +202,9 @@ export class InventoryValuationSheet extends FinancialSheet { * @param {IItem[]} items * @returns {IInventoryValuationItem[]} */ - private itemsMapper = (items: ModelObject[]): IInventoryValuationItem[] => { + private itemsMapper = ( + items: ModelObject[], + ): IInventoryValuationItem[] => { return this.repository.inventoryItems.map(this.itemMapper.bind(this)); }; diff --git a/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuationSheetRepository.ts b/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuationSheetRepository.ts index 88e8793b0..81a4b99f3 100644 --- a/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuationSheetRepository.ts +++ b/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuationSheetRepository.ts @@ -97,10 +97,10 @@ export class InventoryValuationSheetRepository { .onBuild((q) => { q.where('type', 'inventory'); - if (this.filter.itemsIds.length > 0) { - q.whereIn('id', this.filter.itemsIds); - } - }); + if (this.filter.itemsIds.length > 0) { + q.whereIn('id', this.filter.itemsIds); + } + }); this.inventoryItems = inventoryItems; } diff --git a/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuationSheetService.ts b/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuationSheetService.ts index 2a72767b4..ff8ae396c 100644 --- a/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuationSheetService.ts +++ b/packages/server/src/modules/FinancialStatements/modules/InventoryValuationSheet/InventoryValuationSheetService.ts @@ -18,7 +18,7 @@ export class InventoryValuationSheetService { private readonly inventoryValuationMeta: InventoryValuationMetaInjectable, private readonly eventPublisher: EventEmitter2, private readonly inventoryValuationSheetRepository: InventoryValuationSheetRepository, - ) { } + ) {} /** * Inventory valuation sheet. diff --git a/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheet.controller.ts b/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheet.controller.ts index 1989b30da..3a000be85 100644 --- a/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheet.controller.ts +++ b/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheet.controller.ts @@ -1,4 +1,11 @@ -import { Controller, Get, Headers, Query, Res, UseGuards } from '@nestjs/common'; +import { + Controller, + Get, + Headers, + Query, + Res, + UseGuards, +} from '@nestjs/common'; import { Response } from 'express'; import { AcceptType } from '@/constants/accept-type'; import { JournalSheetApplication } from './JournalSheetApplication'; diff --git a/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheet.ts b/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheet.ts index 39e0cbefe..ca1ebc393 100644 --- a/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheet.ts +++ b/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheet.ts @@ -11,7 +11,10 @@ import { FinancialSheet } from '../../common/FinancialSheet'; import { JournalSheetRepository } from './JournalSheetRepository'; import { ILedgerEntry } from '@/modules/Ledger/types/Ledger.types'; import { getTransactionTypeLabel } from '@/modules/BankingTransactions/utils'; -import { IFinancialReportMeta, DEFAULT_REPORT_META } from '../../types/Report.types'; +import { + IFinancialReportMeta, + DEFAULT_REPORT_META, +} from '../../types/Report.types'; export class JournalSheet extends FinancialSheet { readonly query: IJournalReportQuery; diff --git a/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheetMeta.ts b/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheetMeta.ts index acdaaff1b..9f203bb97 100644 --- a/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheetMeta.ts +++ b/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheetMeta.ts @@ -9,12 +9,10 @@ export class JournalSheetMeta { /** * Retrieves the journal sheet meta. - * @param {IJournalReportQuery} query - + * @param {IJournalReportQuery} query - * @returns {Promise} */ - public async meta( - query: IJournalReportQuery, - ): Promise { + public async meta(query: IJournalReportQuery): Promise { const common = await this.financialSheetMeta.meta(); const formattedToDate = moment(query.toDate).format(common.dateFormat); diff --git a/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheetPdfInjectable.ts b/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheetPdfInjectable.ts index d79784d4c..cbc1e79f6 100644 --- a/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheetPdfInjectable.ts +++ b/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheetPdfInjectable.ts @@ -9,7 +9,7 @@ export class JournalSheetPdfInjectable { constructor( private readonly journalSheetTable: JournalSheetTableInjectable, private readonly tableSheetPdf: TableSheetPdf, - ) { } + ) {} /** * Converts the given journal sheet table to pdf. diff --git a/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheetRepository.ts b/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheetRepository.ts index 3b0d35f51..acfa76020 100644 --- a/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheetRepository.ts +++ b/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheetRepository.ts @@ -11,7 +11,7 @@ import { ModelObject } from 'objection'; export class JournalSheetRepository { @Inject(TenancyContext) private tenancyContext: TenancyContext; - + @Inject(AccountRepository) private accountRepository: AccountRepository; @@ -25,27 +25,27 @@ export class JournalSheetRepository { private accountTransactions: Array>; /** - * + * */ public filter: any; /** - * + * */ public accountsGraph: any; /** - * + * */ - public contacts: Array> + public contacts: Array>; /** * Contacts by id map. */ public contactsById: Map>; - + /** - * + * */ public ledger: Ledger; @@ -69,7 +69,7 @@ export class JournalSheetRepository { /** * Initialize base currency. */ - async initBaseCurrency () { + async initBaseCurrency() { const metadata = await this.tenancyContext.getTenantMetadata(); this.baseCurrency = metadata.baseCurrency; @@ -127,8 +127,7 @@ export class JournalSheetRepository { this.contactsById = transformToMap(contacts, 'id'); } - async initLedger(){ + async initLedger() { this.ledger = Ledger.fromTransactions(this.accountTransactions); } - } diff --git a/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheetResponse.dto.ts b/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheetResponse.dto.ts index af529a2c8..0efd283f3 100644 --- a/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheetResponse.dto.ts +++ b/packages/server/src/modules/FinancialStatements/modules/JournalSheet/JournalSheetResponse.dto.ts @@ -107,10 +107,16 @@ export class JournalSheetQueryResponseDto { } export class JournalSheetResponseDto { - @ApiProperty({ description: 'Query parameters used to generate the report', type: JournalSheetQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: JournalSheetQueryResponseDto, + }) query: JournalSheetQueryResponseDto; - @ApiProperty({ description: 'Journal transactions', type: [JournalTransactionDto] }) + @ApiProperty({ + description: 'Journal transactions', + type: [JournalTransactionDto], + }) data: JournalTransactionDto[]; @ApiProperty({ description: 'Report metadata', type: JournalSheetMetaDto }) @@ -126,10 +132,16 @@ export { } from '../../dtos/FinancialReportResponse.dto'; export class JournalSheetTableResponseDto { - @ApiProperty({ description: 'Table data structure', type: () => FinancialTableDataDto }) + @ApiProperty({ + description: 'Table data structure', + type: () => FinancialTableDataDto, + }) table: FinancialTableDataDto; - @ApiProperty({ description: 'Query parameters used to generate the report', type: JournalSheetQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: JournalSheetQueryResponseDto, + }) query: JournalSheetQueryResponseDto; @ApiProperty({ description: 'Report metadata', type: JournalSheetMetaDto }) diff --git a/packages/server/src/modules/FinancialStatements/modules/JournalSheet/types.ts b/packages/server/src/modules/FinancialStatements/modules/JournalSheet/types.ts index 6eff84957..8b8502d8c 100644 --- a/packages/server/src/modules/FinancialStatements/modules/JournalSheet/types.ts +++ b/packages/server/src/modules/FinancialStatements/modules/JournalSheet/types.ts @@ -1,5 +1,4 @@ - export enum ROW_TYPE { ENTRY = 'ENTRY', - TOTAL = 'TOTAL' -}; \ No newline at end of file + TOTAL = 'TOTAL', +} diff --git a/packages/server/src/modules/FinancialStatements/modules/ProfitLossSheet/ProfitLossSheet.controller.ts b/packages/server/src/modules/FinancialStatements/modules/ProfitLossSheet/ProfitLossSheet.controller.ts index c28bbe370..0d47253a2 100644 --- a/packages/server/src/modules/FinancialStatements/modules/ProfitLossSheet/ProfitLossSheet.controller.ts +++ b/packages/server/src/modules/FinancialStatements/modules/ProfitLossSheet/ProfitLossSheet.controller.ts @@ -1,5 +1,12 @@ import { Response } from 'express'; -import { Controller, Get, Headers, Query, Res, UseGuards } from '@nestjs/common'; +import { + Controller, + Get, + Headers, + Query, + Res, + UseGuards, +} from '@nestjs/common'; import { ProfitLossSheetApplication } from './ProfitLossSheetApplication'; import { AcceptType } from '@/constants/accept-type'; import { diff --git a/packages/server/src/modules/FinancialStatements/modules/ProfitLossSheet/ProfitLossSheet.ts b/packages/server/src/modules/FinancialStatements/modules/ProfitLossSheet/ProfitLossSheet.ts index fe7e935fe..53c68bc82 100644 --- a/packages/server/src/modules/FinancialStatements/modules/ProfitLossSheet/ProfitLossSheet.ts +++ b/packages/server/src/modules/FinancialStatements/modules/ProfitLossSheet/ProfitLossSheet.ts @@ -28,7 +28,10 @@ import { FinancialSheetStructure } from '../../common/FinancialSheetStructure'; import { FinancialSheet } from '../../common/FinancialSheet'; import { Account } from '@/modules/Accounts/models/Account.model'; import { flatToNestedArray } from '@/utils/flat-to-nested-array'; -import { IFinancialReportMeta, DEFAULT_REPORT_META } from '../../types/Report.types'; +import { + IFinancialReportMeta, + DEFAULT_REPORT_META, +} from '../../types/Report.types'; export default class ProfitLossSheet extends R.pipe( ProfitLossSheetPreviousYear, diff --git a/packages/server/src/modules/FinancialStatements/modules/ProfitLossSheet/ProfitLossSheetBase.ts b/packages/server/src/modules/FinancialStatements/modules/ProfitLossSheet/ProfitLossSheetBase.ts index 63763b5e1..55d9dab99 100644 --- a/packages/server/src/modules/FinancialStatements/modules/ProfitLossSheet/ProfitLossSheetBase.ts +++ b/packages/server/src/modules/FinancialStatements/modules/ProfitLossSheet/ProfitLossSheetBase.ts @@ -19,7 +19,7 @@ export const ProfitLossSheetBase = >( }); /** - * + * */ protected isNodeTypeIn = R.curry((types: string[], node) => { return types.indexOf(node.nodeType) !== -1; @@ -33,9 +33,9 @@ export const ProfitLossSheetBase = >( }); /** - * - * @param node - * @returns + * + * @param node + * @returns */ isNodeTotal = (node) => { return this.isNodeTypeIn(TOTAL_NODE_TYPES, node); diff --git a/packages/server/src/modules/FinancialStatements/modules/ProfitLossSheet/ProfitLossSheetMeta.ts b/packages/server/src/modules/FinancialStatements/modules/ProfitLossSheet/ProfitLossSheetMeta.ts index 15fb0b2f1..5a6dabc81 100644 --- a/packages/server/src/modules/FinancialStatements/modules/ProfitLossSheet/ProfitLossSheetMeta.ts +++ b/packages/server/src/modules/FinancialStatements/modules/ProfitLossSheet/ProfitLossSheetMeta.ts @@ -20,7 +20,9 @@ export class ProfitLossSheetMeta { ): Promise { const commonMeta = await this.financialSheetMeta.meta(); const formattedToDate = moment(query.toDate).format(commonMeta.dateFormat); - const formattedFromDate = moment(query.fromDate).format(commonMeta.dateFormat); + const formattedFromDate = moment(query.fromDate).format( + commonMeta.dateFormat, + ); const formattedDateRange = `From ${formattedFromDate} | To ${formattedToDate}`; const sheetName = 'Cashflow Statement'; diff --git a/packages/server/src/modules/FinancialStatements/modules/ProfitLossSheet/ProfitLossSheetResponse.dto.ts b/packages/server/src/modules/FinancialStatements/modules/ProfitLossSheet/ProfitLossSheetResponse.dto.ts index 80053fb51..1fa4977ff 100644 --- a/packages/server/src/modules/FinancialStatements/modules/ProfitLossSheet/ProfitLossSheetResponse.dto.ts +++ b/packages/server/src/modules/FinancialStatements/modules/ProfitLossSheet/ProfitLossSheetResponse.dto.ts @@ -8,7 +8,9 @@ import { } from '../../dtos/FinancialReportResponse.dto'; export class ProfitLossSheetDataNodeDto { - @ApiProperty({ description: 'Node identifier (string for aggregates, number for accounts)' }) + @ApiProperty({ + description: 'Node identifier (string for aggregates, number for accounts)', + }) id: string | number; @ApiProperty({ description: 'Account or category name' }) @@ -23,40 +25,76 @@ export class ProfitLossSheetDataNodeDto { @ApiPropertyOptional({ description: 'Node type alias' }) type?: string; - @ApiProperty({ description: 'Total amount information', type: FinancialReportTotalDto }) + @ApiProperty({ + description: 'Total amount information', + type: FinancialReportTotalDto, + }) total: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Horizontal totals for date periods', type: [FinancialReportTotalDto] }) + @ApiPropertyOptional({ + description: 'Horizontal totals for date periods', + type: [FinancialReportTotalDto], + }) horizontal_totals?: FinancialReportTotalDto[]; - @ApiPropertyOptional({ description: 'Percentage of income', type: FinancialReportPercentageDto }) + @ApiPropertyOptional({ + description: 'Percentage of income', + type: FinancialReportPercentageDto, + }) percentage_income?: FinancialReportPercentageDto; - @ApiPropertyOptional({ description: 'Percentage of expense', type: FinancialReportPercentageDto }) + @ApiPropertyOptional({ + description: 'Percentage of expense', + type: FinancialReportPercentageDto, + }) percentage_expense?: FinancialReportPercentageDto; - @ApiPropertyOptional({ description: 'Percentage of row', type: FinancialReportPercentageDto }) + @ApiPropertyOptional({ + description: 'Percentage of row', + type: FinancialReportPercentageDto, + }) percentage_row?: FinancialReportPercentageDto; - @ApiPropertyOptional({ description: 'Percentage of column', type: FinancialReportPercentageDto }) + @ApiPropertyOptional({ + description: 'Percentage of column', + type: FinancialReportPercentageDto, + }) percentage_column?: FinancialReportPercentageDto; - @ApiPropertyOptional({ description: 'Previous period total', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Previous period total', + type: FinancialReportTotalDto, + }) previous_period?: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Previous period change', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Previous period change', + type: FinancialReportTotalDto, + }) previous_period_change?: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Previous period percentage', type: FinancialReportPercentageDto }) + @ApiPropertyOptional({ + description: 'Previous period percentage', + type: FinancialReportPercentageDto, + }) previous_period_percentage?: FinancialReportPercentageDto; - @ApiPropertyOptional({ description: 'Previous year total', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Previous year total', + type: FinancialReportTotalDto, + }) previous_year?: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Previous year change', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Previous year change', + type: FinancialReportTotalDto, + }) previous_year_change?: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Previous year percentage', type: FinancialReportPercentageDto }) + @ApiPropertyOptional({ + description: 'Previous year percentage', + type: FinancialReportPercentageDto, + }) previous_year_percentage?: FinancialReportPercentageDto; @ApiPropertyOptional({ description: 'Account code' }) @@ -65,7 +103,10 @@ export class ProfitLossSheetDataNodeDto { @ApiPropertyOptional({ description: 'Display index', type: Number }) index?: number; - @ApiPropertyOptional({ description: 'Child nodes', type: () => [ProfitLossSheetDataNodeDto] }) + @ApiPropertyOptional({ + description: 'Child nodes', + type: () => [ProfitLossSheetDataNodeDto], + }) children?: ProfitLossSheetDataNodeDto[]; } @@ -81,10 +122,16 @@ export class ProfitLossSheetMetaDto extends FinancialReportMetaDto { } export class ProfitLossSheetQueryResponseDto { - @ApiProperty({ description: 'Column display type', enum: ['total', 'date_periods'] }) + @ApiProperty({ + description: 'Column display type', + enum: ['total', 'date_periods'], + }) display_columns_type: string; - @ApiProperty({ description: 'Column grouping', enum: ['day', 'month', 'year', 'quarter'] }) + @ApiProperty({ + description: 'Column grouping', + enum: ['day', 'month', 'year', 'quarter'], + }) display_columns_by: string; @ApiProperty({ description: 'Start date' }) @@ -93,7 +140,10 @@ export class ProfitLossSheetQueryResponseDto { @ApiProperty({ description: 'End date' }) to_date: string; - @ApiProperty({ description: 'Number format settings', type: NumberFormatQueryDto }) + @ApiProperty({ + description: 'Number format settings', + type: NumberFormatQueryDto, + }) number_format: NumberFormatQueryDto; @ApiProperty({ description: 'Exclude zero balance accounts' }) @@ -140,10 +190,16 @@ export class ProfitLossSheetQueryResponseDto { } export class ProfitLossSheetResponseDto { - @ApiProperty({ description: 'Query parameters used to generate the report', type: ProfitLossSheetQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: ProfitLossSheetQueryResponseDto, + }) query: ProfitLossSheetQueryResponseDto; - @ApiProperty({ description: 'Hierarchical profit/loss data', type: [ProfitLossSheetDataNodeDto] }) + @ApiProperty({ + description: 'Hierarchical profit/loss data', + type: [ProfitLossSheetDataNodeDto], + }) data: ProfitLossSheetDataNodeDto[]; @ApiProperty({ description: 'Report metadata', type: ProfitLossSheetMetaDto }) @@ -159,10 +215,16 @@ export { } from '../../dtos/FinancialReportResponse.dto'; export class ProfitLossSheetTableResponseDto { - @ApiProperty({ description: 'Table data structure', type: () => FinancialTableDataDto }) + @ApiProperty({ + description: 'Table data structure', + type: () => FinancialTableDataDto, + }) table: FinancialTableDataDto; - @ApiProperty({ description: 'Query parameters used to generate the report', type: ProfitLossSheetQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: ProfitLossSheetQueryResponseDto, + }) query: ProfitLossSheetQueryResponseDto; @ApiProperty({ description: 'Report metadata', type: ProfitLossSheetMetaDto }) diff --git a/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItems.controller.ts b/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItems.controller.ts index 66c223a1e..ec5917083 100644 --- a/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItems.controller.ts +++ b/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItems.controller.ts @@ -2,7 +2,13 @@ import { Response } from 'express'; import { Controller, Get, Headers, Query, Res } from '@nestjs/common'; import { PurchasesByItemsApplication } from './PurchasesByItemsApplication'; import { AcceptType } from '@/constants/accept-type'; -import { ApiExtraModels, ApiOperation, ApiResponse, ApiTags, getSchemaPath } from '@nestjs/swagger'; +import { + ApiExtraModels, + ApiOperation, + ApiResponse, + ApiTags, + getSchemaPath, +} from '@nestjs/swagger'; import { PurchasesByItemsQueryDto } from './PurchasesByItemsQuery.dto'; import { PurchasesByItemsResponseDto, diff --git a/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItems.service.ts b/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItems.service.ts index 2acc845bd..8e414e772 100644 --- a/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItems.service.ts +++ b/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItems.service.ts @@ -80,7 +80,10 @@ export class PurchasesByItemsService { filter, inventoryItems, inventoryTransactions, - { baseCurrency: tenantMetadata.baseCurrency, dateFormat: meta.dateFormat }, + { + baseCurrency: tenantMetadata.baseCurrency, + dateFormat: meta.dateFormat, + }, ); const purchasesByItemsData = purchasesByItemsInstance.reportData(); diff --git a/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItems.ts b/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItems.ts index f8f50f1e0..6c656c5a5 100644 --- a/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItems.ts +++ b/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItems.ts @@ -11,9 +11,12 @@ import { FinancialSheet } from '../../common/FinancialSheet'; import { transformToMapBy } from '@/utils/transform-to-map-by'; import { Item } from '@/modules/Items/models/Item'; import { InventoryTransaction } from '@/modules/InventoryCost/models/InventoryTransaction'; -import { IFinancialReportMeta, DEFAULT_REPORT_META } from '../../types/Report.types'; +import { + IFinancialReportMeta, + DEFAULT_REPORT_META, +} from '../../types/Report.types'; -export class PurchasesByItems extends FinancialSheet{ +export class PurchasesByItems extends FinancialSheet { readonly baseCurrency: string; readonly items: Item[]; readonly itemsTransactions: Map; @@ -111,13 +114,13 @@ export class PurchasesByItems extends FinancialSheet{ quantityPurchased: meta.quantity, purchaseCost: meta.cost, averageCostPrice: meta.average, - + quantityPurchasedFormatted: this.formatNumber(meta.quantity, { money: false, }), purchaseCostFormatted: this.formatNumber(meta.cost), averageCostPriceFormatted: this.formatNumber(meta.average), - + currencyCode: this.baseCurrency, }; }; @@ -155,7 +158,7 @@ export class PurchasesByItems extends FinancialSheet{ private itemsSection = (): IPurchasesByItemsItem[] => { return R.compose( R.when(this.isItemsPostFilter, this.itemsFilter), - this.itemsMapper + this.itemsMapper, )(this.items); }; diff --git a/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItemsMeta.ts b/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItemsMeta.ts index 80879ceb3..37fc4b9da 100644 --- a/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItemsMeta.ts +++ b/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItemsMeta.ts @@ -8,9 +8,7 @@ import { @Injectable() export class PurchasesByItemsMeta { - constructor( - private financialSheetMetaModel: FinancialSheetMeta, - ) {} + constructor(private financialSheetMetaModel: FinancialSheetMeta) {} /** * Retrieve the purchases by items meta. @@ -18,11 +16,13 @@ export class PurchasesByItemsMeta { * @returns {IPurchasesByItemsSheetMeta} */ public async meta( - query: IPurchasesByItemsReportQuery + query: IPurchasesByItemsReportQuery, ): Promise { const commonMeta = await this.financialSheetMetaModel.meta(); const formattedToDate = moment(query.toDate).format(commonMeta.dateFormat); - const formattedFromDate = moment(query.fromDate).format(commonMeta.dateFormat); + const formattedFromDate = moment(query.fromDate).format( + commonMeta.dateFormat, + ); const formattedDateRange = `From ${formattedFromDate} | To ${formattedToDate}`; return { diff --git a/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItemsPdf.ts b/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItemsPdf.ts index 3190f64c4..763a4f5fa 100644 --- a/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItemsPdf.ts +++ b/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItemsPdf.ts @@ -16,9 +16,7 @@ export class PurchasesByItemsPdf { * @param {IBalanceSheetQuery} query - Balance sheet query. * @returns {Promise} */ - public async pdf( - query: IPurchasesByItemsReportQuery, - ): Promise { + public async pdf(query: IPurchasesByItemsReportQuery): Promise { const table = await this.purchasesByItemsTable.table(query); return this.tableSheetPdf.convertToPdf( diff --git a/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItemsResponse.dto.ts b/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItemsResponse.dto.ts index 7bc34b93a..65fcc6f92 100644 --- a/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItemsResponse.dto.ts +++ b/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItemsResponse.dto.ts @@ -22,7 +22,10 @@ export class PurchasesByItemDto { @ApiProperty({ description: 'Quantity purchased', type: Number }) quantity: number; - @ApiProperty({ description: 'Total purchases amount', type: FinancialReportTotalDto }) + @ApiProperty({ + description: 'Total purchases amount', + type: FinancialReportTotalDto, + }) total: FinancialReportTotalDto; @ApiPropertyOptional({ description: 'Average cost', type: Number }) @@ -47,7 +50,10 @@ export class PurchasesByItemsQueryResponseDto { @ApiProperty({ description: 'End date' }) toDate: string; - @ApiProperty({ description: 'Number format settings', type: NumberFormatQueryDto }) + @ApiProperty({ + description: 'Number format settings', + type: NumberFormatQueryDto, + }) numberFormat: NumberFormatQueryDto; @ApiProperty({ description: 'Item IDs to include', type: [Number] }) @@ -58,13 +64,22 @@ export class PurchasesByItemsQueryResponseDto { } export class PurchasesByItemsResponseDto { - @ApiProperty({ description: 'Query parameters used to generate the report', type: PurchasesByItemsQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: PurchasesByItemsQueryResponseDto, + }) query: PurchasesByItemsQueryResponseDto; - @ApiProperty({ description: 'Purchases by items', type: [PurchasesByItemDto] }) + @ApiProperty({ + description: 'Purchases by items', + type: [PurchasesByItemDto], + }) data: PurchasesByItemDto[]; - @ApiProperty({ description: 'Report metadata', type: PurchasesByItemsMetaDto }) + @ApiProperty({ + description: 'Report metadata', + type: PurchasesByItemsMetaDto, + }) meta: PurchasesByItemsMetaDto; } @@ -77,12 +92,21 @@ export { } from '../../dtos/FinancialReportResponse.dto'; export class PurchasesByItemsTableResponseDto { - @ApiProperty({ description: 'Table data structure', type: () => FinancialTableDataDto }) + @ApiProperty({ + description: 'Table data structure', + type: () => FinancialTableDataDto, + }) table: FinancialTableDataDto; - @ApiProperty({ description: 'Query parameters used to generate the report', type: PurchasesByItemsQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: PurchasesByItemsQueryResponseDto, + }) query: PurchasesByItemsQueryResponseDto; - @ApiProperty({ description: 'Report metadata', type: PurchasesByItemsMetaDto }) + @ApiProperty({ + description: 'Report metadata', + type: PurchasesByItemsMetaDto, + }) meta: PurchasesByItemsMetaDto; } diff --git a/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItemsTable.ts b/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItemsTable.ts index 696c883e5..19713d67b 100644 --- a/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItemsTable.ts +++ b/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/PurchasesByItemsTable.ts @@ -5,7 +5,11 @@ import { IPurchasesByItemsSheetData, IPurchasesByItemsTotal, } from './types/PurchasesByItems.types'; -import { ITableColumn, ITableColumnAccessor, ITableRow } from '../../types/Table.types'; +import { + ITableColumn, + ITableColumnAccessor, + ITableRow, +} from '../../types/Table.types'; import { FinancialTable } from '../../common/FinancialTable'; import { FinancialSheetStructure } from '../../common/FinancialSheetStructure'; import { FinancialSheet } from '../../common/FinancialSheet'; @@ -13,7 +17,7 @@ import { tableRowMapper } from '../../utils/Table.utils'; export class PurchasesByItemsTable extends R.compose( FinancialTable, - FinancialSheetStructure + FinancialSheetStructure, )(FinancialSheet) { private data: IPurchasesByItemsSheetData; @@ -105,7 +109,7 @@ export class PurchasesByItemsTable extends R.compose( const totalRow = this.totalNodeMap(this.data.total); return R.compose( - R.when(R.always(R.not(R.isEmpty(itemsRows))), R.append(totalRow)) + R.when(R.always(R.not(R.isEmpty(itemsRows))), R.append(totalRow)), )(itemsRows) as ITableRow[]; } } diff --git a/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/types/PurchasesByItems.types.ts b/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/types/PurchasesByItems.types.ts index c2ced6cdf..e62132493 100644 --- a/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/types/PurchasesByItems.types.ts +++ b/packages/server/src/modules/FinancialStatements/modules/PurchasesByItems/types/PurchasesByItems.types.ts @@ -29,7 +29,7 @@ export interface IPurchasesByItemsItem { averageCostPrice: number; averageCostPriceFormatted: string; - + quantityPurchased: number; quantityPurchasedFormatted: string; diff --git a/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItems.controller.ts b/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItems.controller.ts index 16904db27..f27df8770 100644 --- a/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItems.controller.ts +++ b/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItems.controller.ts @@ -10,7 +10,13 @@ import { import { AcceptType } from '@/constants/accept-type'; import { SalesByItemsApplication } from './SalesByItemsApplication'; import { Response } from 'express'; -import { ApiExtraModels, ApiOperation, ApiResponse, ApiTags, getSchemaPath } from '@nestjs/swagger'; +import { + ApiExtraModels, + ApiOperation, + ApiResponse, + ApiTags, + getSchemaPath, +} from '@nestjs/swagger'; import { SalesByItemsQueryDto } from './SalesByItemsQuery.dto'; import { SalesByItemsResponseDto, diff --git a/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItems.module.ts b/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItems.module.ts index e1e769b0d..5693950ff 100644 --- a/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItems.module.ts +++ b/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItems.module.ts @@ -18,12 +18,9 @@ import { SalesByItemsController } from './SalesByItems.controller'; SalesByItemsReportService, SalesByItemsExport, SalesByItemsMeta, - TenancyContext + TenancyContext, ], controllers: [SalesByItemsController], - imports: [ - FinancialSheetCommonModule, - InventoryCostModule - ], + imports: [FinancialSheetCommonModule, InventoryCostModule], }) export class SalesByItemsModule {} diff --git a/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItems.ts b/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItems.ts index 7328994e1..461957e7a 100644 --- a/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItems.ts +++ b/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItems.ts @@ -12,7 +12,10 @@ import { Item } from '@/modules/Items/models/Item'; import { transformToMap } from '@/utils/transform-to-key'; import { allPassedConditionsPass } from '@/utils/all-conditions-passed'; import { InventoryTransaction } from '@/modules/InventoryCost/models/InventoryTransaction'; -import { IFinancialReportMeta, DEFAULT_REPORT_META } from '../../types/Report.types'; +import { + IFinancialReportMeta, + DEFAULT_REPORT_META, +} from '../../types/Report.types'; export class SalesByItemsReport extends FinancialSheet { readonly baseCurrency: string; diff --git a/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItems.types.ts b/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItems.types.ts index 93163a3f3..462727dea 100644 --- a/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItems.types.ts +++ b/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItems.types.ts @@ -1,6 +1,6 @@ -import { IFinancialSheetCommonMeta } from "../../types/Report.types"; -import { INumberFormatQuery } from "../../types/Report.types"; -import { IFinancialTable } from "../../types/Table.types"; +import { IFinancialSheetCommonMeta } from '../../types/Report.types'; +import { INumberFormatQuery } from '../../types/Report.types'; +import { IFinancialTable } from '../../types/Table.types'; export interface ISalesByItemsReportQuery { fromDate: Date | string; diff --git a/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsApplication.ts b/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsApplication.ts index c47ccfebf..89ebfeef1 100644 --- a/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsApplication.ts +++ b/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsApplication.ts @@ -23,9 +23,7 @@ export class SalesByItemsApplication { * @param {ISalesByItemsReportQuery} filter - Sales by items report query. * @returns {Promise} */ - public sheet( - filter: ISalesByItemsReportQuery, - ): Promise { + public sheet(filter: ISalesByItemsReportQuery): Promise { return this.salesByItemsSheet.salesByItems(filter); } @@ -34,9 +32,7 @@ export class SalesByItemsApplication { * @param {ISalesByItemsReportQuery} filter - Sales by items report query. * @returns {Promise} */ - public table( - filter: ISalesByItemsReportQuery, - ): Promise { + public table(filter: ISalesByItemsReportQuery): Promise { return this.salesByItemsTable.table(filter); } @@ -45,9 +41,7 @@ export class SalesByItemsApplication { * @param {ISalesByItemsReportQuery} filter - Sales by items report query. * @returns {Promise} */ - public csv( - filter: ISalesByItemsReportQuery, - ): Promise { + public csv(filter: ISalesByItemsReportQuery): Promise { return this.salesByItemsExport.csv(filter); } @@ -56,9 +50,7 @@ export class SalesByItemsApplication { * @param {ISalesByItemsReportQuery} filter - Sales by items report query. * @returns {Promise} */ - public xlsx( - filter: ISalesByItemsReportQuery, - ): Promise { + public xlsx(filter: ISalesByItemsReportQuery): Promise { return this.salesByItemsExport.xlsx(filter); } @@ -67,9 +59,7 @@ export class SalesByItemsApplication { * @param {ISalesByItemsReportQuery} filter - Sales by items report query. * @returns {Promise} */ - public pdf( - query: ISalesByItemsReportQuery, - ): Promise { + public pdf(query: ISalesByItemsReportQuery): Promise { return this.salesByItemsPdf.pdf(query); } } diff --git a/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsMeta.ts b/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsMeta.ts index 4e918df3a..13d304e45 100644 --- a/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsMeta.ts +++ b/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsMeta.ts @@ -19,7 +19,9 @@ export class SalesByItemsMeta { ): Promise { const commonMeta = await this.financialSheetMeta.meta(); const formattedToDate = moment(query.toDate).format(commonMeta.dateFormat); - const formattedFromDate = moment(query.fromDate).format(commonMeta.dateFormat); + const formattedFromDate = moment(query.fromDate).format( + commonMeta.dateFormat, + ); const formattedDateRange = `From ${formattedFromDate} | To ${formattedToDate}`; const sheetName = 'Sales By Items'; diff --git a/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsPdfInjectable.ts b/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsPdfInjectable.ts index 2c66d8672..e7f776da8 100644 --- a/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsPdfInjectable.ts +++ b/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsPdfInjectable.ts @@ -9,16 +9,14 @@ export class SalesByItemsPdfInjectable { constructor( private readonly salesByItemsTable: SalesByItemsTableInjectable, private readonly tableSheetPdf: TableSheetPdf, - ) { } + ) {} /** * Retrieves the sales by items sheet in pdf format. * @param {ISalesByItemsReportQuery} query - The query to apply to the report. * @returns {Promise} */ - public async pdf( - query: ISalesByItemsReportQuery, - ): Promise { + public async pdf(query: ISalesByItemsReportQuery): Promise { const table = await this.salesByItemsTable.table(query); return this.tableSheetPdf.convertToPdf( diff --git a/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsResponse.dto.ts b/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsResponse.dto.ts index 2634542de..4fc38bd44 100644 --- a/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsResponse.dto.ts +++ b/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsResponse.dto.ts @@ -22,7 +22,10 @@ export class SalesByItemDto { @ApiProperty({ description: 'Quantity sold', type: Number }) quantity: number; - @ApiProperty({ description: 'Total sales amount', type: FinancialReportTotalDto }) + @ApiProperty({ + description: 'Total sales amount', + type: FinancialReportTotalDto, + }) total: FinancialReportTotalDto; @ApiPropertyOptional({ description: 'Average price', type: Number }) @@ -56,7 +59,10 @@ export class SalesByItemsQueryResponseDto { @ApiProperty({ description: 'End date' }) toDate: string; - @ApiProperty({ description: 'Number format settings', type: NumberFormatQueryDto }) + @ApiProperty({ + description: 'Number format settings', + type: NumberFormatQueryDto, + }) numberFormat: NumberFormatQueryDto; @ApiProperty({ description: 'Item IDs to include', type: [Number] }) @@ -67,7 +73,10 @@ export class SalesByItemsQueryResponseDto { } export class SalesByItemsResponseDto { - @ApiProperty({ description: 'Query parameters used to generate the report', type: SalesByItemsQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: SalesByItemsQueryResponseDto, + }) query: SalesByItemsQueryResponseDto; @ApiProperty({ description: 'Sales by items', type: [SalesByItemDto] }) @@ -86,10 +95,16 @@ export { } from '../../dtos/FinancialReportResponse.dto'; export class SalesByItemsTableResponseDto { - @ApiProperty({ description: 'Table data structure', type: () => FinancialTableDataDto }) + @ApiProperty({ + description: 'Table data structure', + type: () => FinancialTableDataDto, + }) table: FinancialTableDataDto; - @ApiProperty({ description: 'Query parameters used to generate the report', type: SalesByItemsQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: SalesByItemsQueryResponseDto, + }) query: SalesByItemsQueryResponseDto; @ApiProperty({ description: 'Report metadata', type: SalesByItemsMetaDto }) diff --git a/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsService.ts b/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsService.ts index 1844312f0..486b45954 100644 --- a/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsService.ts +++ b/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsService.ts @@ -75,7 +75,10 @@ export class SalesByItemsReportService { filter, inventoryItems, inventoryTransactions, - { baseCurrency: tenantMetadata.baseCurrency, dateFormat: meta.dateFormat }, + { + baseCurrency: tenantMetadata.baseCurrency, + dateFormat: meta.dateFormat, + }, ); const salesByItemsData = sheet.reportData(); diff --git a/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsTable.ts b/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsTable.ts index bd7a445bb..d999731fe 100644 --- a/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsTable.ts +++ b/packages/server/src/modules/FinancialStatements/modules/SalesByItems/SalesByItemsTable.ts @@ -83,7 +83,7 @@ export class SalesByItemsTable extends R.pipe( const totalRow = this.totalMap(this.data.total); return R.compose( - R.when(R.always(R.not(R.isEmpty(itemsRows))), R.append(totalRow)) + R.when(R.always(R.not(R.isEmpty(itemsRows))), R.append(totalRow)), )([...itemsRows]) as ITableRow[]; } diff --git a/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummary.controller.ts b/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummary.controller.ts index 51c9ec2ea..e6e8d1848 100644 --- a/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummary.controller.ts +++ b/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummary.controller.ts @@ -20,7 +20,10 @@ import { ApiCommonHeaders } from '@/common/decorators/ApiCommonHeaders'; @Controller('/reports/sales-tax-liability-summary') @ApiTags('Reports') @ApiCommonHeaders() -@ApiExtraModels(SalesTaxLiabilitySummaryResponseDto, SalesTaxLiabilitySummaryTableResponseDto) +@ApiExtraModels( + SalesTaxLiabilitySummaryResponseDto, + SalesTaxLiabilitySummaryTableResponseDto, +) export class SalesTaxLiabilitySummaryController { constructor( private readonly salesTaxLiabilitySummaryApp: SalesTaxLiabilitySummaryApplication, @@ -35,7 +38,9 @@ export class SalesTaxLiabilitySummaryController { schema: { $ref: getSchemaPath(SalesTaxLiabilitySummaryResponseDto) }, }, [AcceptType.ApplicationJsonTable]: { - schema: { $ref: getSchemaPath(SalesTaxLiabilitySummaryTableResponseDto) }, + schema: { + $ref: getSchemaPath(SalesTaxLiabilitySummaryTableResponseDto), + }, }, }, }) diff --git a/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummary.ts b/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummary.ts index 9fe3e02c8..523a64149 100644 --- a/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummary.ts +++ b/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummary.ts @@ -10,7 +10,10 @@ import { FinancialSheet } from '../../common/FinancialSheet'; import { ModelObject } from 'objection'; import { TaxRateModel } from '@/modules/TaxRates/models/TaxRate.model'; import { SalesTaxLiabilitySummaryRepository } from './SalesTaxLiabilitySummaryRepository'; -import { IFinancialReportMeta, DEFAULT_REPORT_META } from '../../types/Report.types'; +import { + IFinancialReportMeta, + DEFAULT_REPORT_META, +} from '../../types/Report.types'; export class SalesTaxLiabilitySummary extends FinancialSheet { private query: SalesTaxLiabilitySummaryQuery; diff --git a/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummaryApplication.ts b/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummaryApplication.ts index 804da12f8..6afa30793 100644 --- a/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummaryApplication.ts +++ b/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummaryApplication.ts @@ -1,4 +1,3 @@ - import { SalesTaxLiabilitySummaryTableInjectable } from './SalesTaxLiabilitySummaryTableInjectable'; import { SalesTaxLiabilitySummaryExportInjectable } from './SalesTaxLiabilitySummaryExportInjectable'; import { SalesTaxLiabilitySummaryService } from './SalesTaxLiabilitySummaryService'; @@ -17,7 +16,7 @@ export class SalesTaxLiabilitySummaryApplication { /** * Retrieves the sales tax liability summary in json format. - * @param {SalesTaxLiabilitySummaryQuery} query - + * @param {SalesTaxLiabilitySummaryQuery} query - * @returns {Promise} */ public sheet(query: SalesTaxLiabilitySummaryQuery) { diff --git a/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummaryMeta.ts b/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummaryMeta.ts index 51b6168a2..84c9d4363 100644 --- a/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummaryMeta.ts +++ b/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummaryMeta.ts @@ -15,7 +15,9 @@ export class SalesTaxLiabilitySummaryMeta { public async meta(query: SalesTaxLiabilitySummaryQuery) { const commonMeta = await this.financialSheetMeta.meta(); const formattedToDate = moment(query.toDate).format(commonMeta.dateFormat); - const formattedFromDate = moment(query.fromDate).format(commonMeta.dateFormat); + const formattedFromDate = moment(query.fromDate).format( + commonMeta.dateFormat, + ); const formattedDateRange = `From ${formattedFromDate} | To ${formattedToDate}`; const sheetName = 'Sales Tax Liability Summary'; diff --git a/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummaryRepository.ts b/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummaryRepository.ts index 01cca1c24..c671b91e5 100644 --- a/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummaryRepository.ts +++ b/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummaryRepository.ts @@ -17,7 +17,9 @@ export class SalesTaxLiabilitySummaryRepository { private readonly taxRateModel: TenantModelProxy; @Inject(AccountTransaction.name) - private readonly accountTransactionModel: TenantModelProxy; + private readonly accountTransactionModel: TenantModelProxy< + typeof AccountTransaction + >; @Inject(Account.name) private readonly accountModel: TenantModelProxy; diff --git a/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummaryResponse.dto.ts b/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummaryResponse.dto.ts index 5de510434..38a5ef0dd 100644 --- a/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummaryResponse.dto.ts +++ b/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummaryResponse.dto.ts @@ -19,10 +19,16 @@ export class TaxRateSummaryDto { @ApiProperty({ description: 'Taxable amount', type: FinancialReportTotalDto }) taxableAmount: FinancialReportTotalDto; - @ApiProperty({ description: 'Tax amount collected', type: FinancialReportTotalDto }) + @ApiProperty({ + description: 'Tax amount collected', + type: FinancialReportTotalDto, + }) taxAmount: FinancialReportTotalDto; - @ApiProperty({ description: 'Total sales (including tax)', type: FinancialReportTotalDto }) + @ApiProperty({ + description: 'Total sales (including tax)', + type: FinancialReportTotalDto, + }) totalSales: FinancialReportTotalDto; } @@ -44,18 +50,27 @@ export class SalesTaxLiabilitySummaryQueryResponseDto { @ApiProperty({ description: 'End date' }) toDate: string; - @ApiProperty({ description: 'Number format settings', type: NumberFormatQueryDto }) + @ApiProperty({ + description: 'Number format settings', + type: NumberFormatQueryDto, + }) numberFormat: NumberFormatQueryDto; } export class SalesTaxLiabilitySummaryResponseDto { - @ApiProperty({ description: 'Query parameters used to generate the report', type: SalesTaxLiabilitySummaryQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: SalesTaxLiabilitySummaryQueryResponseDto, + }) query: SalesTaxLiabilitySummaryQueryResponseDto; @ApiProperty({ description: 'Tax rate summaries', type: [TaxRateSummaryDto] }) data: TaxRateSummaryDto[]; - @ApiProperty({ description: 'Report metadata', type: SalesTaxLiabilitySummaryMetaDto }) + @ApiProperty({ + description: 'Report metadata', + type: SalesTaxLiabilitySummaryMetaDto, + }) meta: SalesTaxLiabilitySummaryMetaDto; } @@ -68,12 +83,21 @@ export { } from '../../dtos/FinancialReportResponse.dto'; export class SalesTaxLiabilitySummaryTableResponseDto { - @ApiProperty({ description: 'Table data structure', type: () => FinancialTableDataDto }) + @ApiProperty({ + description: 'Table data structure', + type: () => FinancialTableDataDto, + }) table: FinancialTableDataDto; - @ApiProperty({ description: 'Query parameters used to generate the report', type: SalesTaxLiabilitySummaryQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: SalesTaxLiabilitySummaryQueryResponseDto, + }) query: SalesTaxLiabilitySummaryQueryResponseDto; - @ApiProperty({ description: 'Report metadata', type: SalesTaxLiabilitySummaryMetaDto }) + @ApiProperty({ + description: 'Report metadata', + type: SalesTaxLiabilitySummaryMetaDto, + }) meta: SalesTaxLiabilitySummaryMetaDto; } diff --git a/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummaryService.ts b/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummaryService.ts index 9cf555a88..994358803 100644 --- a/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummaryService.ts +++ b/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabilitySummaryService.ts @@ -30,7 +30,10 @@ export class SalesTaxLiabilitySummaryService { const taxLiabilitySummary = new SalesTaxLiabilitySummary( query, this.repository, - { baseCurrency: tenantMetadata.baseCurrency, dateFormat: meta.dateFormat }, + { + baseCurrency: tenantMetadata.baseCurrency, + dateFormat: meta.dateFormat, + }, ); return { diff --git a/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabiltiySummaryPdf.ts b/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabiltiySummaryPdf.ts index f5a2d31ed..07819910f 100644 --- a/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabiltiySummaryPdf.ts +++ b/packages/server/src/modules/FinancialStatements/modules/SalesTaxLiabilitySummary/SalesTaxLiabiltiySummaryPdf.ts @@ -8,7 +8,7 @@ export class SalesTaxLiabiltiySummaryPdf { constructor( private readonly salesTaxLiabiltiySummaryTable: SalesTaxLiabilitySummaryTableInjectable, private readonly tableSheetPdf: TableSheetPdf, - ) { } + ) {} /** * Converts the given sales tax liability summary table to pdf. @@ -16,9 +16,7 @@ export class SalesTaxLiabiltiySummaryPdf { * @returns {Promise} */ public async pdf(query: SalesTaxLiabilitySummaryQuery): Promise { - const table = await this.salesTaxLiabiltiySummaryTable.table( - query, - ); + const table = await this.salesTaxLiabiltiySummaryTable.table(query); return this.tableSheetPdf.convertToPdf( table.table, table.meta.organizationName, diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByContact/TransactionsByContact.types.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByContact/TransactionsByContact.types.ts index 957bc2828..392a94159 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByContact/TransactionsByContact.types.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByContact/TransactionsByContact.types.ts @@ -1,5 +1,4 @@ -import { INumberFormatQuery } from "../../types/Report.types"; - +import { INumberFormatQuery } from '../../types/Report.types'; export interface ITransactionsByContactsAmount { amount: number; @@ -8,26 +7,26 @@ export interface ITransactionsByContactsAmount { } export interface ITransactionsByContactsTransaction { - date: string|Date, + date: string | Date; credit: ITransactionsByContactsAmount; debit: ITransactionsByContactsAmount; - accountName: string, + accountName: string; runningBalance: ITransactionsByContactsAmount; currencyCode: string; transactionType: string; transactionNumber: string; - createdAt: string|Date, -}; + createdAt: string | Date; +} export interface ITransactionsByContactsContact { - openingBalance: ITransactionsByContactsAmount, - closingBalance: ITransactionsByContactsAmount, - transactions: ITransactionsByContactsTransaction[], + openingBalance: ITransactionsByContactsAmount; + closingBalance: ITransactionsByContactsAmount; + transactions: ITransactionsByContactsTransaction[]; } export interface ITransactionsByContactsFilter { - fromDate: Date|string; - toDate: Date|string; + fromDate: Date | string; + toDate: Date | string; numberFormat: INumberFormatQuery; noneTransactions: boolean; noneZero: boolean; diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomer.controller.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomer.controller.ts index 4ddf615ed..551f3e6b7 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomer.controller.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomer.controller.ts @@ -1,5 +1,11 @@ import { Controller, Get, Headers, Query, Res } from '@nestjs/common'; -import { ApiExtraModels, ApiOperation, ApiResponse, ApiTags, getSchemaPath } from '@nestjs/swagger'; +import { + ApiExtraModels, + ApiOperation, + ApiResponse, + ApiTags, + getSchemaPath, +} from '@nestjs/swagger'; import { TransactionsByCustomerResponseDto, TransactionsByCustomerTableResponseDto, @@ -14,7 +20,10 @@ import { ApiCommonHeaders } from '@/common/decorators/ApiCommonHeaders'; @Controller('/reports/transactions-by-customers') @ApiTags('Reports') @ApiCommonHeaders() -@ApiExtraModels(TransactionsByCustomerResponseDto, TransactionsByCustomerTableResponseDto) +@ApiExtraModels( + TransactionsByCustomerResponseDto, + TransactionsByCustomerTableResponseDto, +) export class TransactionsByCustomerController { constructor( private readonly transactionsByCustomersApp: TransactionsByCustomerApplication, diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomer.types.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomer.types.ts index ccaa3616f..2c1513919 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomer.types.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomer.types.ts @@ -1,4 +1,3 @@ - import { IFinancialSheetCommonMeta } from '../../types/Report.types'; import { IFinancialTable } from '../../types/Table.types'; import { @@ -41,7 +40,7 @@ export interface ITransactionsByCustomersTable extends IFinancialTable { export interface ITransactionsByCustomersService { transactionsByCustomers( tenantId: number, - filter: ITransactionsByCustomersFilter + filter: ITransactionsByCustomersFilter, ): Promise; } export interface ITransactionsByCustomersMeta diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomerResponse.dto.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomerResponse.dto.ts index c3afbf30a..69797d779 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomerResponse.dto.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomerResponse.dto.ts @@ -28,10 +28,16 @@ export class CustomerTransactionDto { @ApiPropertyOptional({ description: 'Transaction description' }) description?: string; - @ApiProperty({ description: 'Transaction amount', type: FinancialReportTotalDto }) + @ApiProperty({ + description: 'Transaction amount', + type: FinancialReportTotalDto, + }) amount: FinancialReportTotalDto; - @ApiProperty({ description: 'Running balance', type: FinancialReportTotalDto }) + @ApiProperty({ + description: 'Running balance', + type: FinancialReportTotalDto, + }) runningBalance: FinancialReportTotalDto; } @@ -42,19 +48,34 @@ export class CustomerWithTransactionsDto { @ApiProperty({ description: 'Customer name' }) customerName: string; - @ApiPropertyOptional({ description: 'Opening balance', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Opening balance', + type: FinancialReportTotalDto, + }) openingBalance?: FinancialReportTotalDto; - @ApiProperty({ description: 'Customer transactions', type: [CustomerTransactionDto] }) + @ApiProperty({ + description: 'Customer transactions', + type: [CustomerTransactionDto], + }) transactions: CustomerTransactionDto[]; - @ApiProperty({ description: 'Closing balance', type: FinancialReportTotalDto }) + @ApiProperty({ + description: 'Closing balance', + type: FinancialReportTotalDto, + }) closingBalance: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Total debit', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Total debit', + type: FinancialReportTotalDto, + }) totalDebit?: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Total credit', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Total credit', + type: FinancialReportTotalDto, + }) totalCredit?: FinancialReportTotalDto; } @@ -76,7 +97,10 @@ export class TransactionsByCustomerQueryResponseDto { @ApiProperty({ description: 'End date' }) toDate: string; - @ApiProperty({ description: 'Number format settings', type: NumberFormatQueryDto }) + @ApiProperty({ + description: 'Number format settings', + type: NumberFormatQueryDto, + }) numberFormat: NumberFormatQueryDto; @ApiProperty({ description: 'Customer IDs to include', type: [Number] }) @@ -87,13 +111,22 @@ export class TransactionsByCustomerQueryResponseDto { } export class TransactionsByCustomerResponseDto { - @ApiProperty({ description: 'Query parameters used to generate the report', type: TransactionsByCustomerQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: TransactionsByCustomerQueryResponseDto, + }) query: TransactionsByCustomerQueryResponseDto; - @ApiProperty({ description: 'Customers with transactions', type: [CustomerWithTransactionsDto] }) + @ApiProperty({ + description: 'Customers with transactions', + type: [CustomerWithTransactionsDto], + }) data: CustomerWithTransactionsDto[]; - @ApiProperty({ description: 'Report metadata', type: TransactionsByCustomerMetaDto }) + @ApiProperty({ + description: 'Report metadata', + type: TransactionsByCustomerMetaDto, + }) meta: TransactionsByCustomerMetaDto; } @@ -106,12 +139,21 @@ export { } from '../../dtos/FinancialReportResponse.dto'; export class TransactionsByCustomerTableResponseDto { - @ApiProperty({ description: 'Table data structure', type: () => FinancialTableDataDto }) + @ApiProperty({ + description: 'Table data structure', + type: () => FinancialTableDataDto, + }) table: FinancialTableDataDto; - @ApiProperty({ description: 'Query parameters used to generate the report', type: TransactionsByCustomerQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: TransactionsByCustomerQueryResponseDto, + }) query: TransactionsByCustomerQueryResponseDto; - @ApiProperty({ description: 'Report metadata', type: TransactionsByCustomerMetaDto }) + @ApiProperty({ + description: 'Report metadata', + type: TransactionsByCustomerMetaDto, + }) meta: TransactionsByCustomerMetaDto; } diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomers.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomers.ts index cdbea1cce..11f013755 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomers.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomers.ts @@ -12,7 +12,10 @@ import { TransactionsByContact } from '../TransactionsByContact/TransactionsByCo import { Customer } from '@/modules/Customers/models/Customer'; import { INumberFormatQuery } from '../../types/Report.types'; import { TransactionsByCustomersRepository } from './TransactionsByCustomersRepository'; -import { IFinancialReportMeta, DEFAULT_REPORT_META } from '../../types/Report.types'; +import { + IFinancialReportMeta, + DEFAULT_REPORT_META, +} from '../../types/Report.types'; const CUSTOMER_NORMAL = 'debit'; @@ -53,7 +56,7 @@ export class TransactionsByCustomers extends TransactionsByContact { */ private customerTransactions( customerId: number, - openingBalance: number + openingBalance: number, ): ITransactionsByCustomersTransaction[] { const ledger = this.repository.ledger .whereContactId(customerId) @@ -64,7 +67,7 @@ export class TransactionsByCustomers extends TransactionsByContact { return R.compose( R.curry(this.contactTransactionRunningBalance)(openingBalance, 'debit'), - R.map(this.contactTransactionMapper.bind(this)) + R.map(this.contactTransactionMapper.bind(this)), ).bind(this)(ledgerEntries); } @@ -74,13 +77,13 @@ export class TransactionsByCustomers extends TransactionsByContact { * @returns {ITransactionsByCustomersCustomer} */ private customerMapper( - customer: ModelObject + customer: ModelObject, ): ITransactionsByCustomersCustomer { const openingBalance = this.getContactOpeningBalance(customer.id); const transactions = this.customerTransactions(customer.id, openingBalance); const closingBalance = this.getCustomerClosingBalance( transactions, - openingBalance + openingBalance, ); const currencyCode = this.baseCurrency; @@ -100,12 +103,12 @@ export class TransactionsByCustomers extends TransactionsByContact { */ private getCustomerClosingBalance( customerTransactions: ITransactionsByCustomersTransaction[], - openingBalance: number + openingBalance: number, ): number { return this.getContactClosingBalance( customerTransactions, CUSTOMER_NORMAL, - openingBalance + openingBalance, ); } @@ -123,11 +126,11 @@ export class TransactionsByCustomers extends TransactionsByContact { * @returns {ITransactionsByCustomersCustomer[]} */ private customersMapper( - customers: ModelObject[] + customers: ModelObject[], ): ITransactionsByCustomersCustomer[] { return R.compose( R.when(this.isCustomersPostFilter, this.contactsFilter), - R.map(this.customerMapper.bind(this)) + R.map(this.customerMapper.bind(this)), ).bind(this)(customers); } diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomersMeta.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomersMeta.ts index 41f1b131e..ec6642784 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomersMeta.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomersMeta.ts @@ -21,7 +21,9 @@ export class TransactionsByCustomersMeta { const commonMeta = await this.financialSheetMeta.meta(); const formattedToDate = moment(query.toDate).format(commonMeta.dateFormat); - const formattedFromDate = moment(query.fromDate).format(commonMeta.dateFormat); + const formattedFromDate = moment(query.fromDate).format( + commonMeta.dateFormat, + ); const formattedDateRange = `From ${formattedFromDate} | To ${formattedToDate}`; return { diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomersPdf.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomersPdf.ts index a380fdfad..df75444ed 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomersPdf.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByCustomer/TransactionsByCustomersPdf.ts @@ -6,7 +6,7 @@ export class TransactionsByCustomersPdf { constructor( private readonly transactionsByCustomersTable: TransactionsByCustomersTableInjectable, private readonly tableSheetPdf: TableSheetPdf, - ) { } + ) {} /** * Retrieves the transactions by customers in PDF format. diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionByReference.module.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionByReference.module.ts index 26810a397..9cc11b99e 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionByReference.module.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionByReference.module.ts @@ -13,8 +13,8 @@ import { AccountsModule } from '@/modules/Accounts/Accounts.module'; TransactionsByReferenceRepository, TransactionsByReferenceApplication, TransactionsByReferenceService, - TenancyContext + TenancyContext, ], controllers: [TransactionsByReferenceController], }) -export class TransactionsByReferenceModule { } +export class TransactionsByReferenceModule {} diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionsByReference.controller.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionsByReference.controller.ts index cad2f1cd4..f895bc176 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionsByReference.controller.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionsByReference.controller.ts @@ -8,7 +8,7 @@ import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; export class TransactionsByReferenceController { constructor( private readonly transactionsByReferenceApp: TransactionsByReferenceApplication, - ) { } + ) {} @Get() @ApiResponse({ status: 200, description: 'Transactions by reference' }) diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionsByReference.service.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionsByReference.service.ts index 3136a61c4..48a9f8bce 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionsByReference.service.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionsByReference.service.ts @@ -1,7 +1,5 @@ import { BadRequestException, Injectable } from '@nestjs/common'; -import { - ITransactionsByReferencePojo, -} from './TransactionsByReference.types'; +import { ITransactionsByReferencePojo } from './TransactionsByReference.types'; import { TransactionsByReferenceRepository } from './TransactionsByReferenceRepository'; import { TransactionsByReference } from './TransactionsByReferenceReport'; import { getTransactionsByReferenceQuery } from './_utils'; @@ -12,8 +10,8 @@ import { TransactionsByReferenceQueryDto } from './TransactionsByReferenceQuery. export class TransactionsByReferenceService { constructor( private readonly repository: TransactionsByReferenceRepository, - private readonly tenancyContext: TenancyContext - ) { } + private readonly tenancyContext: TenancyContext, + ) {} /** * Retrieve accounts transactions by given reference id and type. @@ -21,7 +19,7 @@ export class TransactionsByReferenceService { * @returns {Promise} */ public async getTransactionsByReference( - query: TransactionsByReferenceQueryDto + query: TransactionsByReferenceQueryDto, ): Promise { const filter = { ...getTransactionsByReferenceQuery(), @@ -32,14 +30,13 @@ export class TransactionsByReferenceService { // Retrieve the accounts transactions of the given reference. const transactions = await this.repository.getTransactions( query.referenceId, - filter.referenceType + filter.referenceType, ); // Transactions by reference report. - const report = new TransactionsByReference( - transactions, - filter, - { baseCurrency: tenantMetadata.baseCurrency, dateFormat: tenantMetadata.dateFormat } - ); + const report = new TransactionsByReference(transactions, filter, { + baseCurrency: tenantMetadata.baseCurrency, + dateFormat: tenantMetadata.dateFormat, + }); return { transactions: report.reportData(), diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionsByReference.types.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionsByReference.types.ts index 8f942daef..2825b3333 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionsByReference.types.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionsByReference.types.ts @@ -35,7 +35,6 @@ export interface ITransactionsByReferenceTransaction { accountId: number; } - export interface ITransactionsByReferencePojo { transactions: ITransactionsByReferenceTransaction[]; } diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionsByReferenceApplication.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionsByReferenceApplication.ts index cb0d83f52..c76ab97c5 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionsByReferenceApplication.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionsByReferenceApplication.ts @@ -6,7 +6,7 @@ import { TransactionsByReferenceQueryDto } from './TransactionsByReferenceQuery. export class TransactionsByReferenceApplication { constructor( private readonly transactionsByReferenceService: TransactionsByReferenceService, - ) { } + ) {} /** * Retrieve accounts transactions by given reference id and type. diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionsByReferenceReport.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionsByReferenceReport.ts index 56ed35cbd..31f6d8330 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionsByReferenceReport.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/TransactionsByReferenceReport.ts @@ -1,10 +1,12 @@ -import { - ITransactionsByReferenceTransaction, -} from './TransactionsByReference.types'; +import { ITransactionsByReferenceTransaction } from './TransactionsByReference.types'; import { FinancialSheet } from '../../common/FinancialSheet'; import { ModelObject } from 'objection'; import { AccountTransaction } from '@/modules/Accounts/models/AccountTransaction.model'; -import { INumberFormatQuery, IFinancialReportMeta, DEFAULT_REPORT_META } from '../../types/Report.types'; +import { + INumberFormatQuery, + IFinancialReportMeta, + DEFAULT_REPORT_META, +} from '../../types/Report.types'; import { TransactionsByReferenceQueryDto } from './TransactionsByReferenceQuery.dto'; export class TransactionsByReference extends FinancialSheet { @@ -39,7 +41,7 @@ export class TransactionsByReference extends FinancialSheet { * @returns {ITransactionsByReferenceTransaction} */ private transactionMapper = ( - transaction: ModelObject + transaction: ModelObject, ): ITransactionsByReferenceTransaction => { return { date: this.getDateMeta(transaction.date), @@ -67,7 +69,7 @@ export class TransactionsByReference extends FinancialSheet { * @returns {ITransactionsByReferenceTransaction} */ private transactionsMapper = ( - transactions: ModelObject[] + transactions: ModelObject[], ): ITransactionsByReferenceTransaction[] => { return transactions.map(this.transactionMapper); }; diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/_utils.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/_utils.ts index ab88109cc..ae88a0cbc 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/_utils.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByReference/_utils.ts @@ -1,6 +1,3 @@ - - - export const getTransactionsByReferenceQuery = () => ({ numberFormat: { precision: 2, @@ -9,4 +6,4 @@ export const getTransactionsByReferenceQuery = () => ({ formatMoney: 'total', negativeFormat: 'mines', }, -}) \ No newline at end of file +}); diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendor.controller.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendor.controller.ts index 7705d82cd..470abbedc 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendor.controller.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendor.controller.ts @@ -3,7 +3,13 @@ import { ITransactionsByVendorsFilter } from './TransactionsByVendor.types'; import { AcceptType } from '@/constants/accept-type'; import { Response } from 'express'; import { TransactionsByVendorApplication } from './TransactionsByVendorApplication'; -import { ApiExtraModels, ApiOperation, ApiResponse, ApiTags, getSchemaPath } from '@nestjs/swagger'; +import { + ApiExtraModels, + ApiOperation, + ApiResponse, + ApiTags, + getSchemaPath, +} from '@nestjs/swagger'; import { TransactionsByVendorResponseDto, TransactionsByVendorTableResponseDto, @@ -14,7 +20,10 @@ import { ApiCommonHeaders } from '@/common/decorators/ApiCommonHeaders'; @Controller('/reports/transactions-by-vendors') @ApiTags('Reports') @ApiCommonHeaders() -@ApiExtraModels(TransactionsByVendorResponseDto, TransactionsByVendorTableResponseDto) +@ApiExtraModels( + TransactionsByVendorResponseDto, + TransactionsByVendorTableResponseDto, +) export class TransactionsByVendorController { constructor( private readonly transactionsByVendorsApp: TransactionsByVendorApplication, diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendor.module.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendor.module.ts index d5c2c0e84..38e7d9411 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendor.module.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendor.module.ts @@ -13,7 +13,7 @@ import { AccountsModule } from '@/modules/Accounts/Accounts.module'; @Module({ imports: [FinancialSheetCommonModule, AccountsModule], - controllers: [TransactionsByVendorController,], + controllers: [TransactionsByVendorController], providers: [ TransactionsByVendorsInjectable, TransactionsByVendorRepository, @@ -22,7 +22,7 @@ import { AccountsModule } from '@/modules/Accounts/Accounts.module'; TransactionsByVendorExportInjectable, TransactionsByVendorsPdf, TransactionsByVendorApplication, - TenancyContext + TenancyContext, ], exports: [TransactionsByVendorApplication], }) diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendor.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendor.ts index 5f859fe5e..631838a0e 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendor.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendor.ts @@ -12,7 +12,10 @@ import { TransactionsByContact } from '../TransactionsByContact/TransactionsByCo import { Vendor } from '@/modules/Vendors/models/Vendor'; import { INumberFormatQuery } from '../../types/Report.types'; import { TransactionsByVendorRepository } from './TransactionsByVendorRepository'; -import { IFinancialReportMeta, DEFAULT_REPORT_META } from '../../types/Report.types'; +import { + IFinancialReportMeta, + DEFAULT_REPORT_META, +} from '../../types/Report.types'; const VENDOR_NORMAL = 'credit'; @@ -21,7 +24,7 @@ export class TransactionsByVendor extends TransactionsByContact { public readonly filter: ITransactionsByVendorsFilter; public readonly numberFormat: INumberFormatQuery; public readonly i18n: I18nService; - + /** * Constructor method. * @param {TransactionsByVendorRepository} transactionsByVendorRepository - Transactions by vendor repository. diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendor.types.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendor.types.ts index c291722d1..cae9d75a9 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendor.types.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendor.types.ts @@ -1,4 +1,3 @@ - import { IFinancialSheetCommonMeta } from '../../types/Report.types'; import { IFinancialTable } from '../../types/Table.types'; import { @@ -36,7 +35,7 @@ export interface ITransactionsByVendorsStatement { export interface ITransactionsByVendorsService { transactionsByVendors( tenantId: number, - filter: ITransactionsByVendorsFilter + filter: ITransactionsByVendorsFilter, ): Promise; } diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorApplication.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorApplication.ts index c7650e15c..60d1b1b19 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorApplication.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorApplication.ts @@ -24,11 +24,9 @@ export class TransactionsByVendorApplication { * @returns {Promise} */ public sheet( - query: ITransactionsByVendorsFilter + query: ITransactionsByVendorsFilter, ): Promise { - return this.transactionsByVendorSheet.transactionsByVendors( - query - ); + return this.transactionsByVendorSheet.transactionsByVendors(query); } /** @@ -37,7 +35,7 @@ export class TransactionsByVendorApplication { * @returns {Promise} */ public table( - query: ITransactionsByVendorsFilter + query: ITransactionsByVendorsFilter, ): Promise { return this.transactionsByVendorTable.table(query); } @@ -47,9 +45,7 @@ export class TransactionsByVendorApplication { * @param {ITransactionsByVendorsFilter} query * @returns {Promise} */ - public csv( - query: ITransactionsByVendorsFilter - ): Promise { + public csv(query: ITransactionsByVendorsFilter): Promise { return this.transactionsByVendorExport.csv(query); } @@ -58,9 +54,7 @@ export class TransactionsByVendorApplication { * @param {ITransactionsByVendorsFilter} query * @returns {Promise} */ - public xlsx( - query: ITransactionsByVendorsFilter - ): Promise { + public xlsx(query: ITransactionsByVendorsFilter): Promise { return this.transactionsByVendorExport.xlsx(query); } diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorExportInjectable.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorExportInjectable.ts index 89a7b11e4..8dd2345bf 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorExportInjectable.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorExportInjectable.ts @@ -14,9 +14,7 @@ export class TransactionsByVendorExportInjectable { * @param {ITransactionsByVendorsFilter} query * @returns {Promise} */ - public async xlsx( - query: ITransactionsByVendorsFilter - ): Promise { + public async xlsx(query: ITransactionsByVendorsFilter): Promise { const table = await this.transactionsByVendorTable.table(query); const tableSheet = new TableSheet(table.table); @@ -30,9 +28,7 @@ export class TransactionsByVendorExportInjectable { * @param {ICashFlowStatementQuery} query * @returns {Promise} */ - public async csv( - query: ITransactionsByVendorsFilter - ): Promise { + public async csv(query: ITransactionsByVendorsFilter): Promise { const table = await this.transactionsByVendorTable.table(query); const tableSheet = new TableSheet(table.table); diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorInjectable.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorInjectable.ts index 30a191fa1..2107f2665 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorInjectable.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorInjectable.ts @@ -1,9 +1,7 @@ import { Injectable } from '@nestjs/common'; import { I18nService } from 'nestjs-i18n'; import { EventEmitter2 } from '@nestjs/event-emitter'; -import { - ITransactionsByVendorsStatement, -} from './TransactionsByVendor.types'; +import { ITransactionsByVendorsStatement } from './TransactionsByVendor.types'; import { TransactionsByVendor } from './TransactionsByVendor'; import { TransactionsByVendorRepository } from './TransactionsByVendorRepository'; import { TransactionsByVendorMeta } from './TransactionsByVendorMeta'; @@ -18,7 +16,7 @@ export class TransactionsByVendorsInjectable { private readonly transactionsByVendorMeta: TransactionsByVendorMeta, private readonly eventPublisher: EventEmitter2, private readonly i18n: I18nService, - ) { } + ) {} /** * Retrieve transactions by by the customers. diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorMeta.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorMeta.ts index 4af3dcd65..df4b104ae 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorMeta.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorMeta.ts @@ -8,21 +8,21 @@ import { FinancialSheetMeta } from '../../common/FinancialSheetMeta'; @Injectable() export class TransactionsByVendorMeta { - constructor( - private readonly financialSheetMeta: FinancialSheetMeta, - ) {} + constructor(private readonly financialSheetMeta: FinancialSheetMeta) {} /** * Retrieves the transactions by vendor meta. * @returns {Promise} */ public async meta( - query: ITransactionsByVendorsFilter + query: ITransactionsByVendorsFilter, ): Promise { const commonMeta = await this.financialSheetMeta.meta(); const formattedToDate = moment(query.toDate).format(commonMeta.dateFormat); - const formattedFromDate = moment(query.fromDate).format(commonMeta.dateFormat); + const formattedFromDate = moment(query.fromDate).format( + commonMeta.dateFormat, + ); const formattedDateRange = `From ${formattedFromDate} | To ${formattedToDate}`; const sheetName = 'Transactions By Vendor'; diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorPdf.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorPdf.ts index a16f56960..4fff154d9 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorPdf.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorPdf.ts @@ -9,7 +9,7 @@ export class TransactionsByVendorsPdf { constructor( private readonly transactionsByVendorTable: TransactionsByVendorTableInjectable, private readonly tableSheetPdf: TableSheetPdf, - ) { } + ) {} /** * Converts the given balance sheet table to pdf. diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorResponse.dto.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorResponse.dto.ts index a3b2502b1..9426bcb86 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorResponse.dto.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorResponse.dto.ts @@ -28,10 +28,16 @@ export class VendorTransactionDto { @ApiPropertyOptional({ description: 'Transaction description' }) description?: string; - @ApiProperty({ description: 'Transaction amount', type: FinancialReportTotalDto }) + @ApiProperty({ + description: 'Transaction amount', + type: FinancialReportTotalDto, + }) amount: FinancialReportTotalDto; - @ApiProperty({ description: 'Running balance', type: FinancialReportTotalDto }) + @ApiProperty({ + description: 'Running balance', + type: FinancialReportTotalDto, + }) runningBalance: FinancialReportTotalDto; } @@ -42,19 +48,34 @@ export class VendorWithTransactionsDto { @ApiProperty({ description: 'Vendor name' }) vendorName: string; - @ApiPropertyOptional({ description: 'Opening balance', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Opening balance', + type: FinancialReportTotalDto, + }) openingBalance?: FinancialReportTotalDto; - @ApiProperty({ description: 'Vendor transactions', type: [VendorTransactionDto] }) + @ApiProperty({ + description: 'Vendor transactions', + type: [VendorTransactionDto], + }) transactions: VendorTransactionDto[]; - @ApiProperty({ description: 'Closing balance', type: FinancialReportTotalDto }) + @ApiProperty({ + description: 'Closing balance', + type: FinancialReportTotalDto, + }) closingBalance: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Total debit', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Total debit', + type: FinancialReportTotalDto, + }) totalDebit?: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Total credit', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Total credit', + type: FinancialReportTotalDto, + }) totalCredit?: FinancialReportTotalDto; } @@ -76,7 +97,10 @@ export class TransactionsByVendorQueryResponseDto { @ApiProperty({ description: 'End date' }) toDate: string; - @ApiProperty({ description: 'Number format settings', type: NumberFormatQueryDto }) + @ApiProperty({ + description: 'Number format settings', + type: NumberFormatQueryDto, + }) numberFormat: NumberFormatQueryDto; @ApiProperty({ description: 'Vendor IDs to include', type: [Number] }) @@ -87,13 +111,22 @@ export class TransactionsByVendorQueryResponseDto { } export class TransactionsByVendorResponseDto { - @ApiProperty({ description: 'Query parameters used to generate the report', type: TransactionsByVendorQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: TransactionsByVendorQueryResponseDto, + }) query: TransactionsByVendorQueryResponseDto; - @ApiProperty({ description: 'Vendors with transactions', type: [VendorWithTransactionsDto] }) + @ApiProperty({ + description: 'Vendors with transactions', + type: [VendorWithTransactionsDto], + }) data: VendorWithTransactionsDto[]; - @ApiProperty({ description: 'Report metadata', type: TransactionsByVendorMetaDto }) + @ApiProperty({ + description: 'Report metadata', + type: TransactionsByVendorMetaDto, + }) meta: TransactionsByVendorMetaDto; } @@ -106,12 +139,21 @@ export { } from '../../dtos/FinancialReportResponse.dto'; export class TransactionsByVendorTableResponseDto { - @ApiProperty({ description: 'Table data structure', type: () => FinancialTableDataDto }) + @ApiProperty({ + description: 'Table data structure', + type: () => FinancialTableDataDto, + }) table: FinancialTableDataDto; - @ApiProperty({ description: 'Query parameters used to generate the report', type: TransactionsByVendorQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: TransactionsByVendorQueryResponseDto, + }) query: TransactionsByVendorQueryResponseDto; - @ApiProperty({ description: 'Report metadata', type: TransactionsByVendorMetaDto }) + @ApiProperty({ + description: 'Report metadata', + type: TransactionsByVendorMetaDto, + }) meta: TransactionsByVendorMetaDto; } diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorTableInjectable.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorTableInjectable.ts index 436ad39f5..3bb185580 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorTableInjectable.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/TransactionsByVendorTableInjectable.ts @@ -1,7 +1,5 @@ import { TransactionsByVendorsTable } from './TransactionsByVendorTable'; -import { - ITransactionsByVendorTable, -} from './TransactionsByVendor.types'; +import { ITransactionsByVendorTable } from './TransactionsByVendor.types'; import { TransactionsByVendorsInjectable } from './TransactionsByVendorInjectable'; import { Injectable } from '@nestjs/common'; import { I18nService } from 'nestjs-i18n'; @@ -11,8 +9,8 @@ import { TransactionsByVendorQueryDto } from './TransactionsByVendorQuery.dto'; export class TransactionsByVendorTableInjectable { constructor( private readonly transactionsByVendor: TransactionsByVendorsInjectable, - private readonly i18n: I18nService - ) { } + private readonly i18n: I18nService, + ) {} /** * Retrieves the transactions by vendor in table format. @@ -20,12 +18,14 @@ export class TransactionsByVendorTableInjectable { * @returns {Promise} */ public async table( - query: TransactionsByVendorQueryDto + query: TransactionsByVendorQueryDto, ): Promise { - const sheet = await this.transactionsByVendor.transactionsByVendors( - query + const sheet = await this.transactionsByVendor.transactionsByVendors(query); + const table = new TransactionsByVendorsTable( + sheet.data, + this.i18n, + sheet.meta.dateFormat, ); - const table = new TransactionsByVendorsTable(sheet.data, this.i18n, sheet.meta.dateFormat); return { table: { diff --git a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/utils.ts b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/utils.ts index 4789e3bd3..478df81b3 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/utils.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TransactionsByVendor/utils.ts @@ -1,4 +1,3 @@ - import * as moment from 'moment'; export const getTransactionsByVendorDefaultQuery = () => { @@ -19,4 +18,4 @@ export const getTransactionsByVendorDefaultQuery = () => { noneTransactions: true, vendorsIds: [], }; -} \ No newline at end of file +}; diff --git a/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheet.module.ts b/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheet.module.ts index bfca7a955..1a1d4703e 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheet.module.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheet.module.ts @@ -21,7 +21,7 @@ import { AccountsModule } from '@/modules/Accounts/Accounts.module'; TrialBalanceSheetMeta, TrialBalanceSheetRepository, TenancyContext, - TrialBalanceSheetPdfInjectable + TrialBalanceSheetPdfInjectable, ], controllers: [TrialBalanceSheetController], }) diff --git a/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheet.ts b/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheet.ts index ba470fee8..ae143dae4 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheet.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheet.ts @@ -12,7 +12,10 @@ import { Account } from '@/modules/Accounts/models/Account.model'; import { allPassedConditionsPass } from '@/utils/all-conditions-passed'; import { ModelObject } from 'objection'; import { flatToNestedArray } from '@/utils/flat-to-nested-array'; -import { IFinancialReportMeta, DEFAULT_REPORT_META } from '../../types/Report.types'; +import { + IFinancialReportMeta, + DEFAULT_REPORT_META, +} from '../../types/Report.types'; export class TrialBalanceSheet extends FinancialSheet { /** @@ -99,9 +102,7 @@ export class TrialBalanceSheet extends FinancialSheet { * @param {IAccount} account * @return {ITrialBalanceAccount} */ - private accountTransformer = ( - account: Account - ): ITrialBalanceAccount => { + private accountTransformer = (account: Account): ITrialBalanceAccount => { const debit = this.getClosingAccountDebit(account.id); const credit = this.getClosingAccountCredit(account.id); const balance = this.getClosingAccountTotal(account.id); @@ -150,7 +151,7 @@ export class TrialBalanceSheet extends FinancialSheet { * @returns {ITrialBalanceAccount[]} */ private accountsFilter = ( - accountsNodes: ITrialBalanceAccount[] + accountsNodes: ITrialBalanceAccount[], ): ITrialBalanceAccount[] => { return accountsNodes.filter(this.accountFilter); }; @@ -161,7 +162,7 @@ export class TrialBalanceSheet extends FinancialSheet { * @returns {ITrialBalanceAccount[]} */ private accountsMapper = ( - accountsNodes: ModelObject[] + accountsNodes: ModelObject[], ): ITrialBalanceAccount[] => { return accountsNodes.map(this.accountTransformer); }; @@ -172,14 +173,16 @@ export class TrialBalanceSheet extends FinancialSheet { * @returns {boolean} */ private filterNoneTransactions = ( - accountNode: ITrialBalanceAccount + accountNode: ITrialBalanceAccount, ): boolean => { - const depsAccountsIds = - this.repository.accountsDepGraph.dependenciesOf(accountNode.id); - - const accountLedger = this.repository.totalAccountsLedger.whereAccountsIds( - [accountNode.id, ...depsAccountsIds] + const depsAccountsIds = this.repository.accountsDepGraph.dependenciesOf( + accountNode.id, ); + + const accountLedger = this.repository.totalAccountsLedger.whereAccountsIds([ + accountNode.id, + ...depsAccountsIds, + ]); return !accountLedger.isEmpty(); }; @@ -207,7 +210,7 @@ export class TrialBalanceSheet extends FinancialSheet { * @returns {ITrialBalanceAccount[]} */ private nestedAccountsNode = ( - flattenAccounts: ITrialBalanceAccount[] + flattenAccounts: ITrialBalanceAccount[], ): ITrialBalanceAccount[] => { return flatToNestedArray(flattenAccounts, { id: 'id', @@ -221,7 +224,7 @@ export class TrialBalanceSheet extends FinancialSheet { * @return {ITrialBalanceTotal} */ private tatalSection( - accountsBalances: ITrialBalanceAccount[] + accountsBalances: ITrialBalanceAccount[], ): ITrialBalanceTotal { const credit = sumBy(accountsBalances, 'credit'); const debit = sumBy(accountsBalances, 'debit'); @@ -248,7 +251,7 @@ export class TrialBalanceSheet extends FinancialSheet { return R.compose( this.accountsFilter, this.nestedAccountsNode, - this.accountsMapper + this.accountsMapper, )(accounts); } diff --git a/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheet.types.ts b/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheet.types.ts index 5c663e1d9..1fe806066 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheet.types.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheet.types.ts @@ -1,5 +1,8 @@ -import { IFinancialSheetCommonMeta, INumberFormatQuery } from "../../types/Report.types"; -import { IFinancialTable } from "../../types/Table.types"; +import { + IFinancialSheetCommonMeta, + INumberFormatQuery, +} from '../../types/Report.types'; +import { IFinancialTable } from '../../types/Table.types'; export interface ITrialBalanceSheetQuery { fromDate: Date | string; diff --git a/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheetInjectable.ts b/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheetInjectable.ts index dd21a7e16..7c5bb6028 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheetInjectable.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheetInjectable.ts @@ -46,7 +46,10 @@ export class TrialBalanceSheetService { const trialBalanceInstance = new TrialBalanceSheet( filter, this.trialBalanceSheetRepository, - { baseCurrency: tenantMetadata.baseCurrency, dateFormat: meta.dateFormat }, + { + baseCurrency: tenantMetadata.baseCurrency, + dateFormat: meta.dateFormat, + }, ); // Trial balance sheet data. const trialBalanceSheetData = trialBalanceInstance.reportData(); diff --git a/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheetMeta.ts b/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheetMeta.ts index 3fc4a491e..2fb7fb6a4 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheetMeta.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheetMeta.ts @@ -1,5 +1,8 @@ import * as moment from 'moment'; -import { ITrialBalanceSheetMeta, ITrialBalanceSheetQuery } from './TrialBalanceSheet.types'; +import { + ITrialBalanceSheetMeta, + ITrialBalanceSheetQuery, +} from './TrialBalanceSheet.types'; import { Injectable } from '@nestjs/common'; import { FinancialSheetMeta } from '../../common/FinancialSheetMeta'; @Injectable() @@ -12,11 +15,13 @@ export class TrialBalanceSheetMeta { * @returns {Promise} */ public async meta( - query: ITrialBalanceSheetQuery + query: ITrialBalanceSheetQuery, ): Promise { const commonMeta = await this.financialSheetMeta.meta(); - const formattedFromDate = moment(query.fromDate).format(commonMeta.dateFormat); + const formattedFromDate = moment(query.fromDate).format( + commonMeta.dateFormat, + ); const formattedToDate = moment(query.toDate).format(commonMeta.dateFormat); const formattedDateRange = `From ${formattedFromDate} to ${formattedToDate}`; diff --git a/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheetPdfInjectsable.ts b/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheetPdfInjectsable.ts index 2b06ee4cd..a09360c89 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheetPdfInjectsable.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheetPdfInjectsable.ts @@ -9,7 +9,7 @@ export class TrialBalanceSheetPdfInjectable { constructor( private readonly trialBalanceSheetTable: TrialBalanceSheetTableInjectable, private readonly tableSheetPdf: TableSheetPdf, - ) { } + ) {} /** * Converts the given trial balance sheet table to pdf. diff --git a/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheetResponse.dto.ts b/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheetResponse.dto.ts index faa33cd15..fc0292f15 100644 --- a/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheetResponse.dto.ts +++ b/packages/server/src/modules/FinancialStatements/modules/TrialBalanceSheet/TrialBalanceSheetResponse.dto.ts @@ -15,28 +15,52 @@ export class TrialBalanceSheetAccountDto { @ApiProperty({ description: 'Account code' }) code: string; - @ApiPropertyOptional({ description: 'Opening balance', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Opening balance', + type: FinancialReportTotalDto, + }) openingBalance?: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Closing balance', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Closing balance', + type: FinancialReportTotalDto, + }) closingBalance?: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Debit total', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Debit total', + type: FinancialReportTotalDto, + }) debitTotal?: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Credit total', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Credit total', + type: FinancialReportTotalDto, + }) creditTotal?: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Debit/change', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Debit/change', + type: FinancialReportTotalDto, + }) debit?: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Credit/change', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Credit/change', + type: FinancialReportTotalDto, + }) credit?: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Period balance', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Period balance', + type: FinancialReportTotalDto, + }) periodBalance?: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Account normal', enum: ['debit', 'credit'] }) + @ApiPropertyOptional({ + description: 'Account normal', + enum: ['debit', 'credit'], + }) accountNormal?: string; @ApiPropertyOptional({ description: 'Account index', type: Number }) @@ -85,21 +109,36 @@ export class TrialBalanceSheetQueryResponseDto { @ApiProperty({ description: 'Accounting basis', enum: ['cash', 'accrual'] }) basis: string; - @ApiProperty({ description: 'Column display type', enum: ['total', 'date_periods'] }) + @ApiProperty({ + description: 'Column display type', + enum: ['total', 'date_periods'], + }) displayColumnsType: string; - @ApiProperty({ description: 'Column grouping', enum: ['day', 'month', 'year', 'quarter'] }) + @ApiProperty({ + description: 'Column grouping', + enum: ['day', 'month', 'year', 'quarter'], + }) displayColumnsBy: string; } export class TrialBalanceSheetResponseDto { - @ApiProperty({ description: 'Query parameters used to generate the report', type: TrialBalanceSheetQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: TrialBalanceSheetQueryResponseDto, + }) query: TrialBalanceSheetQueryResponseDto; - @ApiProperty({ description: 'Trial balance sheet data', type: [TrialBalanceSheetAccountDto] }) + @ApiProperty({ + description: 'Trial balance sheet data', + type: [TrialBalanceSheetAccountDto], + }) data: TrialBalanceSheetAccountDto[]; - @ApiProperty({ description: 'Report metadata', type: TrialBalanceSheetMetaDto }) + @ApiProperty({ + description: 'Report metadata', + type: TrialBalanceSheetMetaDto, + }) meta: TrialBalanceSheetMetaDto; } @@ -112,12 +151,21 @@ export { } from '../../dtos/FinancialReportResponse.dto'; export class TrialBalanceSheetTableResponseDto { - @ApiProperty({ description: 'Table data structure', type: () => FinancialTableDataDto }) + @ApiProperty({ + description: 'Table data structure', + type: () => FinancialTableDataDto, + }) table: FinancialTableDataDto; - @ApiProperty({ description: 'Query parameters used to generate the report', type: TrialBalanceSheetQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: TrialBalanceSheetQueryResponseDto, + }) query: TrialBalanceSheetQueryResponseDto; - @ApiProperty({ description: 'Report metadata', type: TrialBalanceSheetMetaDto }) + @ApiProperty({ + description: 'Report metadata', + type: TrialBalanceSheetMetaDto, + }) meta: TrialBalanceSheetMetaDto; } diff --git a/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummary.controller.ts b/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummary.controller.ts index cb21f4f19..ec21cd220 100644 --- a/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummary.controller.ts +++ b/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummary.controller.ts @@ -21,7 +21,10 @@ import { ApiCommonHeaders } from '@/common/decorators/ApiCommonHeaders'; @Controller('/reports/vendor-balance-summary') @ApiTags('Reports') @ApiCommonHeaders() -@ApiExtraModels(VendorBalanceSummaryResponseDto, VendorBalanceSummaryTableResponseDto) +@ApiExtraModels( + VendorBalanceSummaryResponseDto, + VendorBalanceSummaryTableResponseDto, +) export class VendorBalanceSummaryController { constructor( private readonly vendorBalanceSummaryApp: VendorBalanceSummaryApplication, diff --git a/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummary.module.ts b/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummary.module.ts index 6475bea39..c654958bf 100644 --- a/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummary.module.ts +++ b/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummary.module.ts @@ -18,7 +18,7 @@ import { FinancialSheetCommonModule } from '../../common/FinancialSheetCommon.mo VendorBalanceSummaryPdf, VendorBalanceSummaryApplication, VendorBalanceSummaryRepository, - VendorBalanceSummaryMeta + VendorBalanceSummaryMeta, ], controllers: [VendorBalanceSummaryController], }) diff --git a/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummary.ts b/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummary.ts index 287c843da..671036972 100644 --- a/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummary.ts +++ b/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummary.ts @@ -8,7 +8,11 @@ import { } from './VendorBalanceSummary.types'; import { ContactBalanceSummaryReport } from '../ContactBalanceSummary/ContactBalanceSummary'; import { Vendor } from '@/modules/Vendors/models/Vendor'; -import { INumberFormatQuery, IFinancialReportMeta, DEFAULT_REPORT_META } from '../../types/Report.types'; +import { + INumberFormatQuery, + IFinancialReportMeta, + DEFAULT_REPORT_META, +} from '../../types/Report.types'; import { VendorBalanceSummaryRepository } from './VendorBalanceSummaryRepository'; import { Ledger } from '@/modules/Ledger/Ledger'; @@ -21,8 +25,8 @@ export class VendorBalanceSummaryReport extends ContactBalanceSummaryReport { /** * Constructor method. - * @param {VendorBalanceSummaryRepository} repository - - * @param {IVendorBalanceSummaryQuery} filter - + * @param {VendorBalanceSummaryRepository} repository - + * @param {IVendorBalanceSummaryQuery} filter - */ constructor( repository: VendorBalanceSummaryRepository, @@ -38,7 +42,6 @@ export class VendorBalanceSummaryReport extends ContactBalanceSummaryReport { this.filter = filter; this.numberFormat = this.filter.numberFormat; this.dateFormat = meta.dateFormat || DEFAULT_REPORT_META.dateFormat; - } /** diff --git a/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummaryPdf.ts b/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummaryPdf.ts index 55335def9..f367fa0fd 100644 --- a/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummaryPdf.ts +++ b/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummaryPdf.ts @@ -9,16 +9,14 @@ export class VendorBalanceSummaryPdf { constructor( private readonly vendorBalanceSummaryTable: VendorBalanceSummaryTableInjectable, private readonly tableSheetPdf: TableSheetPdf, - ) { } + ) {} /** * Retrieves the sales by items sheet in pdf format. * @param {IVendorBalanceSummaryQuery} query - Query. * @returns {Promise} */ - public async pdf( - query: IVendorBalanceSummaryQuery, - ): Promise { + public async pdf(query: IVendorBalanceSummaryQuery): Promise { const table = await this.vendorBalanceSummaryTable.table(query); return this.tableSheetPdf.convertToPdf( diff --git a/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummaryResponse.dto.ts b/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummaryResponse.dto.ts index 4a3957e19..a389357b1 100644 --- a/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummaryResponse.dto.ts +++ b/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummaryResponse.dto.ts @@ -13,16 +13,28 @@ export class VendorBalanceDto { @ApiProperty({ description: 'Vendor name' }) vendorName: string; - @ApiPropertyOptional({ description: 'Opening balance', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Opening balance', + type: FinancialReportTotalDto, + }) openingBalance?: FinancialReportTotalDto; - @ApiProperty({ description: 'Closing balance', type: FinancialReportTotalDto }) + @ApiProperty({ + description: 'Closing balance', + type: FinancialReportTotalDto, + }) closingBalance: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Total debit', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Total debit', + type: FinancialReportTotalDto, + }) totalDebit?: FinancialReportTotalDto; - @ApiPropertyOptional({ description: 'Total credit', type: FinancialReportTotalDto }) + @ApiPropertyOptional({ + description: 'Total credit', + type: FinancialReportTotalDto, + }) totalCredit?: FinancialReportTotalDto; } @@ -38,7 +50,10 @@ export class VendorBalanceSummaryQueryResponseDto { @ApiProperty({ description: 'As-of date' }) asDate: string; - @ApiProperty({ description: 'Number format settings', type: NumberFormatQueryDto }) + @ApiProperty({ + description: 'Number format settings', + type: NumberFormatQueryDto, + }) numberFormat: NumberFormatQueryDto; @ApiProperty({ description: 'Vendor IDs to include', type: [Number] }) @@ -52,13 +67,19 @@ export class VendorBalanceSummaryQueryResponseDto { } export class VendorBalanceSummaryResponseDto { - @ApiProperty({ description: 'Query parameters used to generate the report', type: VendorBalanceSummaryQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: VendorBalanceSummaryQueryResponseDto, + }) query: VendorBalanceSummaryQueryResponseDto; @ApiProperty({ description: 'Vendor balances', type: [VendorBalanceDto] }) data: VendorBalanceDto[]; - @ApiProperty({ description: 'Report metadata', type: VendorBalanceSummaryMetaDto }) + @ApiProperty({ + description: 'Report metadata', + type: VendorBalanceSummaryMetaDto, + }) meta: VendorBalanceSummaryMetaDto; } @@ -71,12 +92,21 @@ export { } from '../../dtos/FinancialReportResponse.dto'; export class VendorBalanceSummaryTableResponseDto { - @ApiProperty({ description: 'Table data structure', type: () => FinancialTableDataDto }) + @ApiProperty({ + description: 'Table data structure', + type: () => FinancialTableDataDto, + }) table: FinancialTableDataDto; - @ApiProperty({ description: 'Query parameters used to generate the report', type: VendorBalanceSummaryQueryResponseDto }) + @ApiProperty({ + description: 'Query parameters used to generate the report', + type: VendorBalanceSummaryQueryResponseDto, + }) query: VendorBalanceSummaryQueryResponseDto; - @ApiProperty({ description: 'Report metadata', type: VendorBalanceSummaryMetaDto }) + @ApiProperty({ + description: 'Report metadata', + type: VendorBalanceSummaryMetaDto, + }) meta: VendorBalanceSummaryMetaDto; } diff --git a/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummaryService.ts b/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummaryService.ts index c1203c19d..bbbb04491 100644 --- a/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummaryService.ts +++ b/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummaryService.ts @@ -20,7 +20,7 @@ export class VendorBalanceSummaryService { /** * Retrieve the statment of customer balance summary report. - * @param {IVendorBalanceSummaryQuery} query - + * @param {IVendorBalanceSummaryQuery} query - * @return {Promise} */ public async vendorBalanceSummary( @@ -38,7 +38,10 @@ export class VendorBalanceSummaryService { const reportInstance = new VendorBalanceSummaryReport( this.vendorBalanceSummaryRepository, filter, - { baseCurrency: this.vendorBalanceSummaryRepository.baseCurrency, dateFormat: meta.dateFormat }, + { + baseCurrency: this.vendorBalanceSummaryRepository.baseCurrency, + dateFormat: meta.dateFormat, + }, ); // Triggers `onVendorBalanceSummaryViewed` event. diff --git a/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummaryTableInjectable.ts b/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummaryTableInjectable.ts index f9e634096..1bd6924c5 100644 --- a/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummaryTableInjectable.ts +++ b/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummaryTableInjectable.ts @@ -11,7 +11,7 @@ import { I18nService } from 'nestjs-i18n'; export class VendorBalanceSummaryTableInjectable { constructor( private readonly vendorBalanceSummarySheet: VendorBalanceSummaryService, - private readonly i18n: I18nService + private readonly i18n: I18nService, ) {} /** @@ -23,9 +23,7 @@ export class VendorBalanceSummaryTableInjectable { query: IVendorBalanceSummaryQuery, ): Promise { const { data, meta } = - await this.vendorBalanceSummarySheet.vendorBalanceSummary( - query, - ); + await this.vendorBalanceSummarySheet.vendorBalanceSummary(query); const table = new VendorBalanceSummaryTable(data, query, this.i18n); return { diff --git a/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummaryTableRows.ts b/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummaryTableRows.ts index a8016f598..1ad75e3e5 100644 --- a/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummaryTableRows.ts +++ b/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/VendorBalanceSummaryTableRows.ts @@ -32,7 +32,7 @@ export class VendorBalanceSummaryTable { constructor( report: IVendorBalanceSummaryData, query: IVendorBalanceSummaryQuery, - i18n: I18nService + i18n: I18nService, ) { this.report = report; this.query = query; @@ -65,8 +65,8 @@ export class VendorBalanceSummaryTable { R.concat(columns), R.when( R.always(this.query.percentageColumn), - R.concat(this.getPercentageColumnsAccessor()) - ) + R.concat(this.getPercentageColumnsAccessor()), + ), )([]); }; @@ -76,7 +76,7 @@ export class VendorBalanceSummaryTable { * @returns {ITableRow[]} */ private vendorsTransformer = ( - vendors: IVendorBalanceSummaryVendor[] + vendors: IVendorBalanceSummaryVendor[], ): ITableRow[] => { const columns = this.getVendorColumnsAccessor(); @@ -98,8 +98,8 @@ export class VendorBalanceSummaryTable { R.concat(columns), R.when( R.always(this.query.percentageColumn), - R.concat(this.getPercentageColumnsAccessor()) - ) + R.concat(this.getPercentageColumnsAccessor()), + ), )([]) as IColumnMapperMeta[]; }; @@ -146,7 +146,7 @@ export class VendorBalanceSummaryTable { R.append({ key: 'percentage_of_column', label: this.i18n.t('contact_summary_balance.percentage_column'), - }) + }), ), R.concat(columns), )([]) as ITableColumn[]; diff --git a/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/utils.ts b/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/utils.ts index 0c62f8727..2ff46bf17 100644 --- a/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/utils.ts +++ b/packages/server/src/modules/FinancialStatements/modules/VendorBalanceSummary/utils.ts @@ -14,4 +14,4 @@ export const getVendorBalanceSummaryDefaultQuery = () => { noneZero: false, noneTransactions: true, }; -} \ No newline at end of file +}; diff --git a/packages/server/src/modules/FinancialStatements/types/Report.types.ts b/packages/server/src/modules/FinancialStatements/types/Report.types.ts index 9327c2a67..41822438e 100644 --- a/packages/server/src/modules/FinancialStatements/types/Report.types.ts +++ b/packages/server/src/modules/FinancialStatements/types/Report.types.ts @@ -93,9 +93,9 @@ interface FinancialDateMeta { } interface IFinancialSheetTotal { - amount: number; - formattedAmount: string; - currencyCode: string; + amount: number; + formattedAmount: string; + currencyCode: string; } interface IFinancialSheetPercentage { @@ -126,4 +126,4 @@ export interface IFinancialCommonHorizDatePeriodNode { fromDate: FinancialDateMeta; toDate: FinancialDateMeta; total: IFinancialSheetTotal; -} \ No newline at end of file +} diff --git a/packages/server/src/modules/FinancialStatements/utils/Table.utils.ts b/packages/server/src/modules/FinancialStatements/utils/Table.utils.ts index ae2c63aeb..5fdd061c0 100644 --- a/packages/server/src/modules/FinancialStatements/utils/Table.utils.ts +++ b/packages/server/src/modules/FinancialStatements/utils/Table.utils.ts @@ -4,7 +4,7 @@ import { IColumnMapperMeta, ITableRow } from '../types/Table.types'; export function tableMapper( data: Object[], columns: IColumnMapperMeta[], - rowsMeta + rowsMeta, ): ITableRow[] { return data.map((object) => tableRowMapper(object, columns, rowsMeta)); } @@ -18,7 +18,7 @@ function getAccessor(object, accessor) { export function tableRowMapper( object: Object, columns: IColumnMapperMeta[], - rowMeta + rowMeta, ): ITableRow { const cells = columns.map((column) => ({ key: column.key, diff --git a/packages/server/src/modules/Import/Import.controller.ts b/packages/server/src/modules/Import/Import.controller.ts index 61567932a..466bd26f2 100644 --- a/packages/server/src/modules/Import/Import.controller.ts +++ b/packages/server/src/modules/Import/Import.controller.ts @@ -22,7 +22,7 @@ import { ApiCommonHeaders } from '@/common/decorators/ApiCommonHeaders'; @ApiTags('Import') @ApiCommonHeaders() export class ImportController { - constructor(private readonly importResourceApp: ImportResourceApplication) { } + constructor(private readonly importResourceApp: ImportResourceApplication) {} /** * Imports xlsx/csv to the given resource type. diff --git a/packages/server/src/modules/Import/Import.module.ts b/packages/server/src/modules/Import/Import.module.ts index bc01e4c7c..b47749438 100644 --- a/packages/server/src/modules/Import/Import.module.ts +++ b/packages/server/src/modules/Import/Import.module.ts @@ -41,7 +41,7 @@ const models = [InjectSystemModel(ImportModel)]; ImportFileDataTransformer, ImportFileCommon, ImportableRegistry, - ImportDeleteExpiredFilesJobs + ImportDeleteExpiredFilesJobs, ], controllers: [ImportController], exports: [ImportAls, ...models], diff --git a/packages/server/src/modules/Import/ImportFileCommon.ts b/packages/server/src/modules/Import/ImportFileCommon.ts index aa5aef661..345bfbb85 100644 --- a/packages/server/src/modules/Import/ImportFileCommon.ts +++ b/packages/server/src/modules/Import/ImportFileCommon.ts @@ -22,7 +22,7 @@ export class ImportFileCommon { private readonly importFileValidator: ImportFileDataValidator, private readonly resource: ResourceService, private readonly importableRegistry: ImportableRegistry, - ) { } + ) {} /** * Imports the given parsed data to the resource storage through registered importable service. diff --git a/packages/server/src/modules/Import/ImportFileDataTransformer.ts b/packages/server/src/modules/Import/ImportFileDataTransformer.ts index b89edd011..e05c5bf3e 100644 --- a/packages/server/src/modules/Import/ImportFileDataTransformer.ts +++ b/packages/server/src/modules/Import/ImportFileDataTransformer.ts @@ -16,9 +16,7 @@ import { CurrencyParsingDTOs } from './_constants'; @Injectable() export class ImportFileDataTransformer { - constructor( - private readonly resource: ResourceService, - ) { } + constructor(private readonly resource: ResourceService) {} /** * Parses the given sheet data before passing to the service layer. @@ -30,7 +28,7 @@ export class ImportFileDataTransformer { importFile: any, importableFields: ResourceMetaFieldsMap, data: Record[], - trx?: Knex.Transaction + trx?: Knex.Transaction, ): Promise[]> { // Sanitize the sheet data. const sanitizedData = sanitizeSheetData(data); @@ -38,17 +36,17 @@ export class ImportFileDataTransformer { // Map the sheet columns key with the given map. const mappedDTOs = this.mapSheetColumns( sanitizedData, - importFile.mappingParsed + importFile.mappingParsed, ); // Parse the mapped sheet values. const parsedValues = await this.parseExcelValues( importableFields, mappedDTOs, - trx + trx, ); const aggregateValues = this.aggregateParsedValues( importFile.resource, - parsedValues + parsedValues, ); return aggregateValues; } @@ -61,7 +59,7 @@ export class ImportFileDataTransformer { */ public aggregateParsedValues( resourceName: string, - parsedData: Record[] + parsedData: Record[], ): Record[] { let _value = parsedData; const meta = this.resource.getResourceMeta(resourceName); @@ -70,11 +68,11 @@ export class ImportFileDataTransformer { _value = aggregate( _value, meta.importAggregateBy, - meta.importAggregateOn + meta.importAggregateOn, ); } return _value; - }; + } /** * Maps the columns of the imported data based on the provided mapping attributes. @@ -84,7 +82,7 @@ export class ImportFileDataTransformer { */ public mapSheetColumns( body: Record[], - map: ImportMappingAttr[] + map: ImportMappingAttr[], ): Record[] { return body.map((item) => { const newItem = {}; @@ -107,7 +105,7 @@ export class ImportFileDataTransformer { public async parseExcelValues( fields: ResourceMetaFieldsMap, valueDTOs: Record[], - trx?: Knex.Transaction + trx?: Knex.Transaction, ): Promise[]> { // Create a model resolver function that uses ResourceService const modelResolver = (modelName: string) => { @@ -120,7 +118,7 @@ export class ImportFileDataTransformer { // Clean up the undefined keys that not exist in resource fields. const _valueDTO = pickBy( valueDTO, - (value, key) => !isUndefined(fields[getFieldKey(key)]) + (value, key) => !isUndefined(fields[getFieldKey(key)]), ); // Keys of mapped values. key structure: `group.key` or `key`. const keys = Object.keys(_valueDTO); @@ -135,7 +133,7 @@ export class ImportFileDataTransformer { set(acc, parsedKey, parsedValue); return acc; }, - {} + {}, ); }; return bluebird.map(valueDTOs, parseAsync, { diff --git a/packages/server/src/modules/Import/ImportFileDataValidator.ts b/packages/server/src/modules/Import/ImportFileDataValidator.ts index 141398045..093e40bd1 100644 --- a/packages/server/src/modules/Import/ImportFileDataValidator.ts +++ b/packages/server/src/modules/Import/ImportFileDataValidator.ts @@ -25,7 +25,7 @@ export class ImportFileDataValidator { */ public async validateData( importableFields: ResourceMetaFieldsMap, - data: Record + data: Record, ): Promise { const YupSchema = convertFieldsToYupValidation(importableFields); const _data = { ...data }; diff --git a/packages/server/src/modules/Import/ImportFilePreview.ts b/packages/server/src/modules/Import/ImportFilePreview.ts index 345c74ff5..daa0034c8 100644 --- a/packages/server/src/modules/Import/ImportFilePreview.ts +++ b/packages/server/src/modules/Import/ImportFilePreview.ts @@ -12,7 +12,7 @@ export class ImportFilePreview { private readonly importAls: ImportAls, @Inject(TENANCY_DB_CONNECTION) - private readonly tenantKnex: () => Knex + private readonly tenantKnex: () => Knex, ) {} /** @@ -32,7 +32,9 @@ export class ImportFilePreview { * @returns {Promise} */ public async previewAlsRun(importId: string): Promise { - const trx = await this.tenantKnex().transaction({ isolationLevel: 'read uncommitted' }); + const trx = await this.tenantKnex().transaction({ + isolationLevel: 'read uncommitted', + }); const meta = await this.importFile.import(importId, trx); diff --git a/packages/server/src/modules/Import/ImportFileProcessCommit.ts b/packages/server/src/modules/Import/ImportFileProcessCommit.ts index e51b2632b..af52539b7 100644 --- a/packages/server/src/modules/Import/ImportFileProcessCommit.ts +++ b/packages/server/src/modules/Import/ImportFileProcessCommit.ts @@ -1,6 +1,9 @@ import { Knex } from 'knex'; import { EventEmitter2 } from '@nestjs/event-emitter'; -import { IImportFileCommitedEventPayload, ImportFilePreviewPOJO } from './interfaces'; +import { + IImportFileCommitedEventPayload, + ImportFilePreviewPOJO, +} from './interfaces'; import { ImportFileProcess } from './ImportFileProcess'; import { ImportAls } from './ImportALS'; import { Inject, Injectable } from '@nestjs/common'; diff --git a/packages/server/src/modules/Import/ImportFileUpload.ts b/packages/server/src/modules/Import/ImportFileUpload.ts index c8c309282..dfe5d1809 100644 --- a/packages/server/src/modules/Import/ImportFileUpload.ts +++ b/packages/server/src/modules/Import/ImportFileUpload.ts @@ -24,7 +24,7 @@ export class ImportFileUploadService { @Inject(ImportModel.name) private readonly importModel: typeof ImportModel, - ) { } + ) {} /** * Imports the specified file for the given resource. @@ -84,7 +84,10 @@ export class ImportFileUploadService { } catch (error) { throw error; } - const _params = await this.importFileCommon.transformParams(resource, params); + const _params = await this.importFileCommon.transformParams( + resource, + params, + ); const paramsStringified = JSON.stringify(_params); const tenant = await this.tenancyContext.getTenant(); diff --git a/packages/server/src/modules/Import/ImportMulter.utils.ts b/packages/server/src/modules/Import/ImportMulter.utils.ts index 162c8c182..1c7b7a035 100644 --- a/packages/server/src/modules/Import/ImportMulter.utils.ts +++ b/packages/server/src/modules/Import/ImportMulter.utils.ts @@ -35,4 +35,4 @@ export const uploadImportFileMulterOptions = { storage, limits: { fileSize: 5 * 1024 * 1024 }, // fileFilter: allowSheetExtensions, -}; \ No newline at end of file +}; diff --git a/packages/server/src/modules/Import/ImportSample.ts b/packages/server/src/modules/Import/ImportSample.ts index 13e8c8280..4c55b5d65 100644 --- a/packages/server/src/modules/Import/ImportSample.ts +++ b/packages/server/src/modules/Import/ImportSample.ts @@ -6,11 +6,7 @@ import { ImportableRegistry } from './ImportableRegistry'; @Injectable() export class ImportSampleService { - constructor( - private readonly importableRegistry: ImportableRegistry, - ) { - - } + constructor(private readonly importableRegistry: ImportableRegistry) {} /** * Retrieves the sample sheet of the given resource. * @param {string} resource @@ -19,7 +15,7 @@ export class ImportSampleService { */ public async sample( resource: string, - format: 'csv' | 'xlsx' + format: 'csv' | 'xlsx', ): Promise { const _resource = sanitizeResourceName(resource); const importable = await this.importableRegistry.getImportable(_resource); @@ -30,7 +26,6 @@ export class ImportSampleService { const worksheet = XLSX.utils.json_to_sheet(data); XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1'); - // Determine the output format if (format === 'csv') { const csvOutput = XLSX.utils.sheet_to_csv(worksheet); diff --git a/packages/server/src/modules/Import/Importable.ts b/packages/server/src/modules/Import/Importable.ts index 7a6c4d9e8..60a0a5b97 100644 --- a/packages/server/src/modules/Import/Importable.ts +++ b/packages/server/src/modules/Import/Importable.ts @@ -11,7 +11,7 @@ export abstract class Importable { */ public importable(createDTO: any, trx?: Knex.Transaction) { throw new Error( - 'The `importable` function is not defined in service importable.' + 'The `importable` function is not defined in service importable.', ); } @@ -57,9 +57,7 @@ export abstract class Importable { * @param {Record} * @returns {Promise} - True means passed and false failed. */ - public async validateParams( - params: Record - ): Promise {} + public async validateParams(params: Record): Promise {} /** * Transformes the import params before storing them. @@ -68,4 +66,4 @@ export abstract class Importable { public transformParams(parmas: Record) { return parmas; } -} \ No newline at end of file +} diff --git a/packages/server/src/modules/Import/ImportableRegistry.ts b/packages/server/src/modules/Import/ImportableRegistry.ts index c118d6fbd..09ffb3ef0 100644 --- a/packages/server/src/modules/Import/ImportableRegistry.ts +++ b/packages/server/src/modules/Import/ImportableRegistry.ts @@ -6,7 +6,7 @@ import { ContextIdFactory, ModuleRef } from '@nestjs/core'; @Injectable() export class ImportableRegistry { - constructor(private readonly moduleRef: ModuleRef) { } + constructor(private readonly moduleRef: ModuleRef) {} /** * Retrieves the importable service instance of the given resource name. * @param {string} name @@ -23,9 +23,13 @@ export class ImportableRegistry { } const contextId = ContextIdFactory.create(); - const importableInstance = await this.moduleRef.resolve(importable, contextId, { - strict: false, - }); + const importableInstance = await this.moduleRef.resolve( + importable, + contextId, + { + strict: false, + }, + ); return importableInstance; } diff --git a/packages/server/src/modules/Import/_constants.ts b/packages/server/src/modules/Import/_constants.ts index 1e9d37cbf..451a2433c 100644 --- a/packages/server/src/modules/Import/_constants.ts +++ b/packages/server/src/modules/Import/_constants.ts @@ -1,3 +1 @@ - - -export const CurrencyParsingDTOs = 10; \ No newline at end of file +export const CurrencyParsingDTOs = 10; diff --git a/packages/server/src/modules/Import/_utils.spec.ts b/packages/server/src/modules/Import/_utils.spec.ts index 9665e5cca..03bd36505 100644 --- a/packages/server/src/modules/Import/_utils.spec.ts +++ b/packages/server/src/modules/Import/_utils.spec.ts @@ -284,4 +284,3 @@ describe('aggregate', () => { }); }); }); - diff --git a/packages/server/src/modules/Import/_utils.ts b/packages/server/src/modules/Import/_utils.ts index e9e836c42..185c3fa4b 100644 --- a/packages/server/src/modules/Import/_utils.ts +++ b/packages/server/src/modules/Import/_utils.ts @@ -253,28 +253,28 @@ export const getResourceColumns = (resourceColumns: { }) => { const mapColumn = (group: string) => - ([fieldKey, { name, importHint, required, order, ...field }]: [ - string, - IModelMetaField2, - ]) => { - const extra: Record = {}; - const key = fieldKey; + ([fieldKey, { name, importHint, required, order, ...field }]: [ + string, + IModelMetaField2, + ]) => { + const extra: Record = {}; + const key = fieldKey; - if (group) { - extra.group = group; - } - if (field.fieldType === 'collection') { - extra.fields = mapColumns(field.fields, key); - } - return { - key, - name, - required, - hint: importHint, - order, - ...extra, - }; + if (group) { + extra.group = group; + } + if (field.fieldType === 'collection') { + extra.fields = mapColumns(field.fields, key); + } + return { + key, + name, + required, + hint: importHint, + order, + ...extra, }; + }; const sortColumn = (a, b) => a.order && b.order ? a.order - b.order : a.order ? -1 : b.order ? 1 : 0; @@ -288,50 +288,54 @@ export type ModelResolver = (modelName: string) => any; // Prases the given object value based on the field key type. export const valueParser = - (fields: ResourceMetaFieldsMap, modelResolver: ModelResolver, trx?: Knex.Transaction) => - async (value: any, key: string, group = '') => { - let _value = value; + ( + fields: ResourceMetaFieldsMap, + modelResolver: ModelResolver, + trx?: Knex.Transaction, + ) => + async (value: any, key: string, group = '') => { + let _value = value; - const fieldKey = key.includes('.') ? key.split('.')[0] : key; - const field = group ? fields[group]?.fields[fieldKey] : fields[fieldKey]; + const fieldKey = key.includes('.') ? key.split('.')[0] : key; + const field = group ? fields[group]?.fields[fieldKey] : fields[fieldKey]; - // Parses the boolean value. - if (field.fieldType === 'boolean') { - _value = parseBoolean(value); + // Parses the boolean value. + if (field.fieldType === 'boolean') { + _value = parseBoolean(value); - // Parses the enumeration value. - } else if (field.fieldType === 'enumeration') { - const option = get(field, 'options', []).find( - (option) => option.label?.toLowerCase() === value?.toLowerCase(), - ); - _value = get(option, 'key'); - // Parses the numeric value. - } else if (field.fieldType === 'number') { - _value = multiNumberParse(value); - // Parses the relation value. - } else if (field.fieldType === 'relation') { - const RelationModel = modelResolver(field.relationModel); + // Parses the enumeration value. + } else if (field.fieldType === 'enumeration') { + const option = get(field, 'options', []).find( + (option) => option.label?.toLowerCase() === value?.toLowerCase(), + ); + _value = get(option, 'key'); + // Parses the numeric value. + } else if (field.fieldType === 'number') { + _value = multiNumberParse(value); + // Parses the relation value. + } else if (field.fieldType === 'relation') { + const RelationModel = modelResolver(field.relationModel); - if (!RelationModel) { - throw new Error(`The relation model of ${key} field is not exist.`); - } - const relationQuery = RelationModel.query(trx); - const relationKeys = castArray(field?.relationImportMatch); - - relationQuery.where(function () { - relationKeys.forEach((relationKey: string) => { - this.orWhereRaw('LOWER(??) = LOWER(?)', [relationKey, value]); - }); - }); - const result = await relationQuery.first(); - _value = get(result, 'id'); - } else if (field.fieldType === 'collection') { - const ObjectFieldKey = key.includes('.') ? key.split('.')[1] : key; - const _valueParser = valueParser(fields, modelResolver); - _value = await _valueParser(value, ObjectFieldKey, fieldKey); + if (!RelationModel) { + throw new Error(`The relation model of ${key} field is not exist.`); } - return _value; - }; + const relationQuery = RelationModel.query(trx); + const relationKeys = castArray(field?.relationImportMatch); + + relationQuery.where(function () { + relationKeys.forEach((relationKey: string) => { + this.orWhereRaw('LOWER(??) = LOWER(?)', [relationKey, value]); + }); + }); + const result = await relationQuery.first(); + _value = get(result, 'id'); + } else if (field.fieldType === 'collection') { + const ObjectFieldKey = key.includes('.') ? key.split('.')[1] : key; + const _valueParser = valueParser(fields, modelResolver); + _value = await _valueParser(value, ObjectFieldKey, fieldKey); + } + return _value; + }; /** * Parses the field key and detarmines the key path. diff --git a/packages/server/src/modules/Import/decorators/Import.decorator.ts b/packages/server/src/modules/Import/decorators/Import.decorator.ts index 6134041b1..9bb96b07f 100644 --- a/packages/server/src/modules/Import/decorators/Import.decorator.ts +++ b/packages/server/src/modules/Import/decorators/Import.decorator.ts @@ -1,7 +1,7 @@ -import { Global } from "@nestjs/common"; +import { Global } from '@nestjs/common'; const importableModels = new Map(); -const importableService = new Map() +const importableService = new Map(); /** * Decorator that marks a model as exportable and registers its metadata. @@ -31,7 +31,6 @@ export function getImportableModelMeta(modelName: string): boolean | undefined { return importableModels.get(modelName); } - export function getImportableService(modelName: string) { return importableService.get(modelName); -} \ No newline at end of file +} diff --git a/packages/server/src/modules/Import/interfaces.ts b/packages/server/src/modules/Import/interfaces.ts index 3c597d1dd..d397577b4 100644 --- a/packages/server/src/modules/Import/interfaces.ts +++ b/packages/server/src/modules/Import/interfaces.ts @@ -1,5 +1,5 @@ -import { IModelMetaField2 } from "@/interfaces/Model"; -import { ImportModelShape } from "./models/Import"; +import { IModelMetaField2 } from '@/interfaces/Model'; +import { ImportModelShape } from './models/Import'; export interface ImportMappingAttr { from: string; @@ -76,8 +76,7 @@ export const ImportDateFormats = [ 'dd/MMM/yyyy', ]; - export interface IImportFileCommitedEventPayload { importId: string; meta: ImportFilePreviewPOJO; -} \ No newline at end of file +} diff --git a/packages/server/src/modules/Import/sheet_utils.ts b/packages/server/src/modules/Import/sheet_utils.ts index 6fecb5425..04c04b0e9 100644 --- a/packages/server/src/modules/Import/sheet_utils.ts +++ b/packages/server/src/modules/Import/sheet_utils.ts @@ -35,7 +35,7 @@ export function extractSheetColumns(worksheet: XLSX.WorkSheet): Array { * @returns {Array>} */ export function parseSheetToJson( - worksheet: XLSX.WorkSheet + worksheet: XLSX.WorkSheet, ): Array> { return XLSX.utils.sheet_to_json(worksheet, {}); } @@ -45,7 +45,7 @@ export function parseSheetToJson( * @param {Buffer} buffer */ export function parseSheetData( - buffer: Buffer + buffer: Buffer, ): [Array>, string[]] { const worksheet = parseFirstSheet(buffer); diff --git a/packages/server/src/modules/InventoryAdjutments/InventoryAdjustmentTransformer.ts b/packages/server/src/modules/InventoryAdjutments/InventoryAdjustmentTransformer.ts index 4bb28f920..efd30df6b 100644 --- a/packages/server/src/modules/InventoryAdjutments/InventoryAdjustmentTransformer.ts +++ b/packages/server/src/modules/InventoryAdjutments/InventoryAdjustmentTransformer.ts @@ -1,5 +1,5 @@ -import { Transformer } from "../Transformer/Transformer"; -import { InventoryAdjustment } from "./models/InventoryAdjustment"; +import { Transformer } from '../Transformer/Transformer'; +import { InventoryAdjustment } from './models/InventoryAdjustment'; export class InventoryAdjustmentTransformer extends Transformer { /** diff --git a/packages/server/src/modules/InventoryAdjutments/InventoryAdjustments.controller.ts b/packages/server/src/modules/InventoryAdjutments/InventoryAdjustments.controller.ts index ed4f79962..eb6b622fa 100644 --- a/packages/server/src/modules/InventoryAdjutments/InventoryAdjustments.controller.ts +++ b/packages/server/src/modules/InventoryAdjutments/InventoryAdjustments.controller.ts @@ -42,7 +42,10 @@ export class InventoryAdjustmentsController { ) {} @Post('quick') - @RequirePermission(InventoryAdjustmentAction.CREATE, AbilitySubject.InventoryAdjustment) + @RequirePermission( + InventoryAdjustmentAction.CREATE, + AbilitySubject.InventoryAdjustment, + ) @ApiOperation({ summary: 'Create a quick inventory adjustment.' }) @ApiResponse({ status: 200, @@ -57,7 +60,10 @@ export class InventoryAdjustmentsController { } @Delete(':id') - @RequirePermission(InventoryAdjustmentAction.DELETE, AbilitySubject.InventoryAdjustment) + @RequirePermission( + InventoryAdjustmentAction.DELETE, + AbilitySubject.InventoryAdjustment, + ) @ApiOperation({ summary: 'Delete the given inventory adjustment.' }) @ApiResponse({ status: 200, @@ -72,7 +78,10 @@ export class InventoryAdjustmentsController { } @Get() - @RequirePermission(InventoryAdjustmentAction.VIEW, AbilitySubject.InventoryAdjustment) + @RequirePermission( + InventoryAdjustmentAction.VIEW, + AbilitySubject.InventoryAdjustment, + ) @ApiOperation({ summary: 'Retrieves the inventory adjustments.' }) @ApiResponse({ status: 200, @@ -90,7 +99,10 @@ export class InventoryAdjustmentsController { } @Get(':id') - @RequirePermission(InventoryAdjustmentAction.VIEW, AbilitySubject.InventoryAdjustment) + @RequirePermission( + InventoryAdjustmentAction.VIEW, + AbilitySubject.InventoryAdjustment, + ) @ApiOperation({ summary: 'Retrieves the inventory adjustment details.' }) @ApiResponse({ status: 200, @@ -107,7 +119,10 @@ export class InventoryAdjustmentsController { } @Put(':id/publish') - @RequirePermission(InventoryAdjustmentAction.EDIT, AbilitySubject.InventoryAdjustment) + @RequirePermission( + InventoryAdjustmentAction.EDIT, + AbilitySubject.InventoryAdjustment, + ) @ApiOperation({ summary: 'Publish the given inventory adjustment.' }) @ApiResponse({ status: 200, diff --git a/packages/server/src/modules/InventoryAdjutments/inventory/InventoryAdjustmentInventoryTransactions.ts b/packages/server/src/modules/InventoryAdjutments/inventory/InventoryAdjustmentInventoryTransactions.ts index 3c6305b7f..88f57e17e 100644 --- a/packages/server/src/modules/InventoryAdjutments/inventory/InventoryAdjustmentInventoryTransactions.ts +++ b/packages/server/src/modules/InventoryAdjutments/inventory/InventoryAdjustmentInventoryTransactions.ts @@ -1,15 +1,15 @@ -import { Injectable } from "@nestjs/common"; -import { Knex } from "knex"; -import { InventoryAdjustment } from "../models/InventoryAdjustment"; -import { InventoryTransaction } from "@/modules/InventoryCost/models/InventoryTransaction"; -import { InventoryTransactionsService } from "@/modules/InventoryCost/commands/InventoryTransactions.service"; +import { Injectable } from '@nestjs/common'; +import { Knex } from 'knex'; +import { InventoryAdjustment } from '../models/InventoryAdjustment'; +import { InventoryTransaction } from '@/modules/InventoryCost/models/InventoryTransaction'; +import { InventoryTransactionsService } from '@/modules/InventoryCost/commands/InventoryTransactions.service'; @Injectable() export class InventoryAdjustmentInventoryTransactions { constructor( - private readonly inventoryService: InventoryTransactionsService + private readonly inventoryService: InventoryTransactionsService, ) {} - + /** * Writes the inventory transactions from the inventory adjustment transaction. * @param {number} tenantId - @@ -21,7 +21,7 @@ export class InventoryAdjustmentInventoryTransactions { public async writeInventoryTransactions( inventoryAdjustment: InventoryAdjustment, override: boolean = false, - trx?: Knex.Transaction + trx?: Knex.Transaction, ): Promise { const commonTransaction = { direction: inventoryAdjustment.inventoryDirection, @@ -48,7 +48,7 @@ export class InventoryAdjustmentInventoryTransactions { await this.inventoryService.recordInventoryTransactions( inventoryTransactions, override, - trx + trx, ); } @@ -58,13 +58,12 @@ export class InventoryAdjustmentInventoryTransactions { */ async revertInventoryTransactions( inventoryAdjustmentId: number, - trx?: Knex.Transaction + trx?: Knex.Transaction, ): Promise<{ oldInventoryTransactions: InventoryTransaction[] }> { return this.inventoryService.deleteInventoryTransactions( inventoryAdjustmentId, 'InventoryAdjustment', - trx + trx, ); } - -} \ No newline at end of file +} diff --git a/packages/server/src/modules/InventoryAdjutments/models/InventoryAdjustment.meta.ts b/packages/server/src/modules/InventoryAdjutments/models/InventoryAdjustment.meta.ts index ff979bae4..5d0e0598f 100644 --- a/packages/server/src/modules/InventoryAdjutments/models/InventoryAdjustment.meta.ts +++ b/packages/server/src/modules/InventoryAdjutments/models/InventoryAdjustment.meta.ts @@ -104,4 +104,4 @@ export const InventoryAdjustmentMeta = { fieldType: 'date', }, }, -}; \ No newline at end of file +}; diff --git a/packages/server/src/modules/InventoryAdjutments/subscribers/InventoryAdjustmentGL.subscriber.ts b/packages/server/src/modules/InventoryAdjutments/subscribers/InventoryAdjustmentGL.subscriber.ts index 8eb64be68..bf513a517 100644 --- a/packages/server/src/modules/InventoryAdjutments/subscribers/InventoryAdjustmentGL.subscriber.ts +++ b/packages/server/src/modules/InventoryAdjutments/subscribers/InventoryAdjustmentGL.subscriber.ts @@ -16,7 +16,7 @@ export class InventoryAdjustmentsGLSubscriber { /** * Handles writing increment inventory adjustment GL entries. - * @param {IInventoryAdjustmentEventCreatedPayload} payload - + * @param {IInventoryAdjustmentEventCreatedPayload} payload - */ @OnEvent(events.inventoryAdjustment.onQuickCreated) @OnEvent(events.inventoryAdjustment.onPublished) diff --git a/packages/server/src/modules/InventoryCost/models/InventoryTransactionMeta.ts b/packages/server/src/modules/InventoryCost/models/InventoryTransactionMeta.ts index 1da927d24..9cd8c9a10 100644 --- a/packages/server/src/modules/InventoryCost/models/InventoryTransactionMeta.ts +++ b/packages/server/src/modules/InventoryCost/models/InventoryTransactionMeta.ts @@ -32,9 +32,9 @@ export class InventoryTransactionMeta extends BaseModel { modelClass: InventoryTransaction, join: { from: 'inventory_transaction_meta.inventoryTransactionId', - to: 'inventory_transactions.inventoryTransactionId' - } - } + to: 'inventory_transactions.inventoryTransactionId', + }, + }, }; } } diff --git a/packages/server/src/modules/InventoryCost/processors/ComputeItemCost.processor.ts b/packages/server/src/modules/InventoryCost/processors/ComputeItemCost.processor.ts index 93cceaef9..5048e6fef 100644 --- a/packages/server/src/modules/InventoryCost/processors/ComputeItemCost.processor.ts +++ b/packages/server/src/modules/InventoryCost/processors/ComputeItemCost.processor.ts @@ -44,7 +44,7 @@ export class ComputeItemCostProcessor extends WorkerHost { console.log(`[info] Compute item cost for item ${itemId} started`, { payload: job.data, - jobId: job.id + jobId: job.id, }); this.clsService.set('organizationId', organizationId); this.clsService.set('userId', userId); @@ -59,15 +59,28 @@ export class ComputeItemCostProcessor extends WorkerHost { events.inventory.onComputeItemCostJobCompleted, { startingDate: startingDateObj, itemId, organizationId, userId }, ); - console.log(`[info] Compute item cost for item ${itemId} completed successfully`); + console.log( + `[info] Compute item cost for item ${itemId} completed successfully`, + ); } catch (error) { - console.error(`[error] Error computing item cost for item ${itemId}:`, error); - console.error('Error stack:', error instanceof Error ? error.stack : 'No stack trace'); + console.error( + `[error] Error computing item cost for item ${itemId}:`, + error, + ); + console.error( + 'Error stack:', + error instanceof Error ? error.stack : 'No stack trace', + ); // Reset cost_compute_running when job fails so it does not stay true indefinitely try { - await this.inventoryComputeCostService.markItemsCostComputeRunning(false); + await this.inventoryComputeCostService.markItemsCostComputeRunning( + false, + ); } catch (markError) { - console.error('[error] Failed to mark cost compute as not running:', markError); + console.error( + '[error] Failed to mark cost compute as not running:', + markError, + ); } throw error; } diff --git a/packages/server/src/modules/InventoryCost/subscribers/InventoryCost.subscriber.ts b/packages/server/src/modules/InventoryCost/subscribers/InventoryCost.subscriber.ts index 3db905de1..02df9dec1 100644 --- a/packages/server/src/modules/InventoryCost/subscribers/InventoryCost.subscriber.ts +++ b/packages/server/src/modules/InventoryCost/subscribers/InventoryCost.subscriber.ts @@ -20,7 +20,7 @@ export class InventoryCostSubscriber { private readonly itemsQuantitySync: InventoryItemsQuantitySyncService, private readonly inventoryService: InventoryComputeCostService, private readonly importAls: ImportAls, - ) { } + ) {} /** * Sync inventory items quantity once inventory transactions created. @@ -60,7 +60,7 @@ export class InventoryCostSubscriber { * Marks items cost compute running state. */ @OnEvent(events.inventory.onInventoryTransactionsCreated) - async markGlobalSettingsComputeItems({ }) { + async markGlobalSettingsComputeItems({}) { await this.inventoryService.markItemsCostComputeRunning(true); } @@ -68,7 +68,7 @@ export class InventoryCostSubscriber { * Marks items cost compute as completed. */ @OnEvent(events.inventory.onInventoryCostEntriesWritten) - async markGlobalSettingsComputeItemsCompeted({ }) { + async markGlobalSettingsComputeItemsCompeted({}) { await this.inventoryService.markItemsCostComputeRunning(false); } @@ -81,9 +81,8 @@ export class InventoryCostSubscriber { startingDate, }: IComputeItemCostJobCompletedPayload) { // Convert startingDate to Date if it's a string - const startingDateObj = startingDate instanceof Date - ? startingDate - : new Date(startingDate); + const startingDateObj = + startingDate instanceof Date ? startingDate : new Date(startingDate); // Write GL entries for inventory cost lots after cost computation completes await this.saleInvoicesCost.writeCostLotsGLEntries(startingDateObj); diff --git a/packages/server/src/modules/ItemCategories/BulkDeleteItemCategories.service.ts b/packages/server/src/modules/ItemCategories/BulkDeleteItemCategories.service.ts index 30e608d52..3bd3c8df1 100644 --- a/packages/server/src/modules/ItemCategories/BulkDeleteItemCategories.service.ts +++ b/packages/server/src/modules/ItemCategories/BulkDeleteItemCategories.service.ts @@ -8,7 +8,7 @@ import { DeleteItemCategoryService } from './commands/DeleteItemCategory.service export class BulkDeleteItemCategoriesService { constructor( private readonly deleteItemCategoryService: DeleteItemCategoryService, - ) { } + ) {} async bulkDeleteItemCategories( itemCategoryIds: number | Array, @@ -27,4 +27,3 @@ export class BulkDeleteItemCategoriesService { } } } - diff --git a/packages/server/src/modules/ItemCategories/ItemCategoriesExportable.ts b/packages/server/src/modules/ItemCategories/ItemCategoriesExportable.ts index 1ca2f862e..1ac5e7180 100644 --- a/packages/server/src/modules/ItemCategories/ItemCategoriesExportable.ts +++ b/packages/server/src/modules/ItemCategories/ItemCategoriesExportable.ts @@ -19,7 +19,7 @@ export class ItemCategoriesExportable extends Exportable { */ public exportable(query: Partial) { const parsedQuery = { - ...query + ...query, } as IItemCategoriesFilter; return this.itemCategoryApp diff --git a/packages/server/src/modules/ItemCategories/ItemCategoriesImportable.ts b/packages/server/src/modules/ItemCategories/ItemCategoriesImportable.ts index 2266c157a..6ed3d16ac 100644 --- a/packages/server/src/modules/ItemCategories/ItemCategoriesImportable.ts +++ b/packages/server/src/modules/ItemCategories/ItemCategoriesImportable.ts @@ -16,7 +16,7 @@ export class ItemCategoriesImportable extends Importable { /** * Importing to create new item category service. - * @param {CreateItemCategoryDto} createDTO + * @param {CreateItemCategoryDto} createDTO * @param {Knex.Transaction} trx */ public async importable( diff --git a/packages/server/src/modules/ItemCategories/ItemCategory.application.ts b/packages/server/src/modules/ItemCategories/ItemCategory.application.ts index 9e790a8bd..43049ff8a 100644 --- a/packages/server/src/modules/ItemCategories/ItemCategory.application.ts +++ b/packages/server/src/modules/ItemCategories/ItemCategory.application.ts @@ -1,14 +1,15 @@ import { Injectable } from '@nestjs/common'; -import { - IItemCategoryOTD, -} from './ItemCategory.interfaces'; +import { IItemCategoryOTD } from './ItemCategory.interfaces'; import { GetItemCategoriesQueryDto } from './dtos/GetItemCategoriesQuery.dto'; import { CreateItemCategoryService } from './commands/CreateItemCategory.service'; import { DeleteItemCategoryService } from './commands/DeleteItemCategory.service'; import { EditItemCategoryService } from './commands/EditItemCategory.service'; import { GetItemCategoryService } from './queries/GetItemCategory.service'; import { GetItemCategoriesService } from './queries/GetItemCategories.service'; -import { CreateItemCategoryDto, EditItemCategoryDto } from './dtos/ItemCategory.dto'; +import { + CreateItemCategoryDto, + EditItemCategoryDto, +} from './dtos/ItemCategory.dto'; import { Knex } from 'knex'; @Injectable() diff --git a/packages/server/src/modules/ItemCategories/ItemCategory.module.ts b/packages/server/src/modules/ItemCategories/ItemCategory.module.ts index c5cec3989..041ad9145 100644 --- a/packages/server/src/modules/ItemCategories/ItemCategory.module.ts +++ b/packages/server/src/modules/ItemCategories/ItemCategory.module.ts @@ -30,9 +30,6 @@ import { ItemCategoriesImportable } from './ItemCategoriesImportable'; ItemCategoriesExportable, ItemCategoriesImportable, ], - exports: [ - ItemCategoriesExportable, - ItemCategoriesImportable, - ], + exports: [ItemCategoriesExportable, ItemCategoriesImportable], }) export class ItemCategoryModule {} diff --git a/packages/server/src/modules/ItemCategories/ValidateBulkDeleteItemCategories.service.ts b/packages/server/src/modules/ItemCategories/ValidateBulkDeleteItemCategories.service.ts index d66239175..56a9dbd6b 100644 --- a/packages/server/src/modules/ItemCategories/ValidateBulkDeleteItemCategories.service.ts +++ b/packages/server/src/modules/ItemCategories/ValidateBulkDeleteItemCategories.service.ts @@ -11,7 +11,9 @@ export class ValidateBulkDeleteItemCategoriesService { private readonly tenantKnex: () => Knex, ) {} - public async validateBulkDeleteItemCategories(itemCategoryIds: number[]): Promise<{ + public async validateBulkDeleteItemCategories( + itemCategoryIds: number[], + ): Promise<{ deletableCount: number; nonDeletableCount: number; deletableIds: number[]; @@ -51,4 +53,3 @@ export class ValidateBulkDeleteItemCategoriesService { } } } - diff --git a/packages/server/src/modules/ItemCategories/models/ItemCategory.meta.ts b/packages/server/src/modules/ItemCategories/models/ItemCategory.meta.ts index 8d14fc9d1..7076f7330 100644 --- a/packages/server/src/modules/ItemCategories/models/ItemCategory.meta.ts +++ b/packages/server/src/modules/ItemCategories/models/ItemCategory.meta.ts @@ -1,5 +1,3 @@ - - export const ItemCategoryMeta = { defaultFilterField: 'name', defaultSort: { @@ -61,4 +59,4 @@ export const ItemCategoryMeta = { fieldType: 'text', }, }, -}; \ No newline at end of file +}; diff --git a/packages/server/src/modules/Items/BulkDeleteItems.service.ts b/packages/server/src/modules/Items/BulkDeleteItems.service.ts index 3235987f8..7c1d0d1fa 100644 --- a/packages/server/src/modules/Items/BulkDeleteItems.service.ts +++ b/packages/server/src/modules/Items/BulkDeleteItems.service.ts @@ -6,7 +6,7 @@ import { DeleteItemService } from './DeleteItem.service'; @Injectable() export class BulkDeleteItemsService { - constructor(private readonly deleteItemService: DeleteItemService) { } + constructor(private readonly deleteItemService: DeleteItemService) {} /** * Deletes multiple items. @@ -38,4 +38,3 @@ export class BulkDeleteItemsService { } } } - diff --git a/packages/server/src/modules/Items/DeleteItem.service.ts b/packages/server/src/modules/Items/DeleteItem.service.ts index abb0d2e03..141699dc4 100644 --- a/packages/server/src/modules/Items/DeleteItem.service.ts +++ b/packages/server/src/modules/Items/DeleteItem.service.ts @@ -25,7 +25,7 @@ export class DeleteItemService { @Inject(Item.name) private readonly itemModel: TenantModelProxy, - ) { } + ) {} /** * Delete the given item from the storage. diff --git a/packages/server/src/modules/Items/Item.controller.ts b/packages/server/src/modules/Items/Item.controller.ts index 1c49978a9..6be2e31f2 100644 --- a/packages/server/src/modules/Items/Item.controller.ts +++ b/packages/server/src/modules/Items/Item.controller.ts @@ -160,7 +160,8 @@ export class ItemsController extends TenantController { }) @ApiResponse({ status: 400, - description: 'Validation error. Possible error types: ITEM_NAME_EXISTS, INVENTORY_ACCOUNT_CANNOT_MODIFIED, TYPE_CANNOT_CHANGE_WITH_ITEM_HAS_TRANSACTIONS, etc.', + description: + 'Validation error. Possible error types: ITEM_NAME_EXISTS, INVENTORY_ACCOUNT_CANNOT_MODIFIED, TYPE_CANNOT_CHANGE_WITH_ITEM_HAS_TRANSACTIONS, etc.', schema: { $ref: getSchemaPath(ItemApiErrorResponseDto), }, @@ -227,7 +228,8 @@ export class ItemsController extends TenantController { }) @ApiResponse({ status: 400, - description: 'Validation error. Possible error types: ITEM_NAME_EXISTS, ITEM_CATEOGRY_NOT_FOUND, COST_ACCOUNT_NOT_COGS, SELL_ACCOUNT_NOT_INCOME, INVENTORY_ACCOUNT_NOT_INVENTORY, INCOME_ACCOUNT_REQUIRED_WITH_SELLABLE_ITEM, COST_ACCOUNT_REQUIRED_WITH_PURCHASABLE_ITEM, etc.', + description: + 'Validation error. Possible error types: ITEM_NAME_EXISTS, ITEM_CATEOGRY_NOT_FOUND, COST_ACCOUNT_NOT_COGS, SELL_ACCOUNT_NOT_INCOME, INVENTORY_ACCOUNT_NOT_INVENTORY, INCOME_ACCOUNT_REQUIRED_WITH_SELLABLE_ITEM, COST_ACCOUNT_REQUIRED_WITH_PURCHASABLE_ITEM, etc.', schema: { $ref: getSchemaPath(ItemApiErrorResponseDto), }, @@ -250,7 +252,8 @@ export class ItemsController extends TenantController { }) @ApiResponse({ status: 400, - description: 'Cannot delete item. Possible error types: ITEM_HAS_ASSOCIATED_TRANSACTINS, ITEM_HAS_ASSOCIATED_INVENTORY_ADJUSTMENT, etc.', + description: + 'Cannot delete item. Possible error types: ITEM_HAS_ASSOCIATED_TRANSACTINS, ITEM_HAS_ASSOCIATED_INVENTORY_ADJUSTMENT, etc.', schema: { $ref: getSchemaPath(ItemApiErrorResponseDto), }, @@ -429,5 +432,4 @@ export class ItemsController extends TenantController { const itemId = parseInt(id, 10); return this.itemsApplication.getItemReceiptsTransactions(itemId); } - } diff --git a/packages/server/src/modules/Items/Item.schema.ts b/packages/server/src/modules/Items/Item.schema.ts index 87f2fcd5a..50d4f1cd4 100644 --- a/packages/server/src/modules/Items/Item.schema.ts +++ b/packages/server/src/modules/Items/Item.schema.ts @@ -107,6 +107,5 @@ export const createItemSchema = z }, ); - export type createItemDTO = z.infer; -export type editItemDTOSchema = z.infer; \ No newline at end of file +export type editItemDTOSchema = z.infer; diff --git a/packages/server/src/modules/Items/Items.module.ts b/packages/server/src/modules/Items/Items.module.ts index b18e8dad8..f561b4a35 100644 --- a/packages/server/src/modules/Items/Items.module.ts +++ b/packages/server/src/modules/Items/Items.module.ts @@ -49,4 +49,4 @@ import { ValidateBulkDeleteItemsService } from './ValidateBulkDeleteItems.servic ], exports: [ItemsEntriesService, ItemsExportable, ItemsImportable], }) -export class ItemsModule { } +export class ItemsModule {} diff --git a/packages/server/src/modules/Items/ItemsApplication.service.ts b/packages/server/src/modules/Items/ItemsApplication.service.ts index 6e41d7b53..e613c27dd 100644 --- a/packages/server/src/modules/Items/ItemsApplication.service.ts +++ b/packages/server/src/modules/Items/ItemsApplication.service.ts @@ -29,7 +29,7 @@ export class ItemsApplicationService { private readonly itemTransactionsService: ItemTransactionsService, private readonly bulkDeleteItemsService: BulkDeleteItemsService, private readonly validateBulkDeleteItemsService: ValidateBulkDeleteItemsService, - ) { } + ) {} /** * Creates a new item. diff --git a/packages/server/src/modules/Items/ItemsEntries.service.ts b/packages/server/src/modules/Items/ItemsEntries.service.ts index 61e5e387c..4b902e087 100644 --- a/packages/server/src/modules/Items/ItemsEntries.service.ts +++ b/packages/server/src/modules/Items/ItemsEntries.service.ts @@ -28,7 +28,7 @@ export class ItemsEntriesService { @Inject(ItemEntry.name) private readonly itemEntryModel: TenantModelProxy, - ) { } + ) {} /** * Retrieve the inventory items entries of the reference id and type. @@ -84,7 +84,9 @@ export class ItemsEntriesService { * @param {IItemEntryDTO[]} itemEntries - Items entries. * @returns {Promise} */ - public async validateItemsIdsExistance(itemEntries: Array<{ itemId: number }>) { + public async validateItemsIdsExistance( + itemEntries: Array<{ itemId: number }>, + ) { const itemsIds = itemEntries.map((e) => e.itemId); const foundItems = await this.itemModel().query().whereIn('id', itemsIds); @@ -130,9 +132,7 @@ export class ItemsEntriesService { * Validate the entries items that not purchase-able. * @param {IItemEntryDTO[]} itemEntries - */ - public async validateNonPurchasableEntriesItems( - itemEntries: ItemEntryDto[], - ) { + public async validateNonPurchasableEntriesItems(itemEntries: ItemEntryDto[]) { const itemsIds = itemEntries.map((e: ItemEntryDto) => e.itemId); const purchasbleItems = await this.itemModel() .query() diff --git a/packages/server/src/modules/Items/ItemsExportable.service.ts b/packages/server/src/modules/Items/ItemsExportable.service.ts index 6a1474bff..dffa94b35 100644 --- a/packages/server/src/modules/Items/ItemsExportable.service.ts +++ b/packages/server/src/modules/Items/ItemsExportable.service.ts @@ -10,9 +10,7 @@ import { Item } from './models/Item'; @ExportableService({ name: Item.name }) @Global() export class ItemsExportable extends Exportable { - constructor( - private readonly itemsApplication: ItemsApplicationService, - ) { + constructor(private readonly itemsApplication: ItemsApplicationService) { super(); } @@ -33,4 +31,4 @@ export class ItemsExportable extends Exportable { .getItems(parsedQuery) .then((output) => output.items); } -} \ No newline at end of file +} diff --git a/packages/server/src/modules/Items/ItemsImportable.service.ts b/packages/server/src/modules/Items/ItemsImportable.service.ts index d5bc5aecc..de8c1916b 100644 --- a/packages/server/src/modules/Items/ItemsImportable.service.ts +++ b/packages/server/src/modules/Items/ItemsImportable.service.ts @@ -10,9 +10,7 @@ import { Item } from './models/Item'; @Injectable() @ImportableService({ name: Item.name }) export class ItemsImportable extends Importable { - constructor( - private readonly createItemService: CreateItemService, - ) { + constructor(private readonly createItemService: CreateItemService) { super(); } @@ -24,7 +22,7 @@ export class ItemsImportable extends Importable { */ public async importable( createDTO: CreateItemDto, - trx?: Knex.Transaction + trx?: Knex.Transaction, ): Promise { await this.createItemService.createItem(createDTO, trx); } @@ -35,4 +33,4 @@ export class ItemsImportable extends Importable { public sampleData(): any[] { return ItemsSampleData; } -} \ No newline at end of file +} diff --git a/packages/server/src/modules/Items/ServiceError.ts b/packages/server/src/modules/Items/ServiceError.ts index 88f9566bb..3abaaf1f5 100644 --- a/packages/server/src/modules/Items/ServiceError.ts +++ b/packages/server/src/modules/Items/ServiceError.ts @@ -6,7 +6,12 @@ export class ServiceError extends Error { payload: any; httpStatus: HttpStatus; - constructor(errorType: string, message?: string, payload?: any, httpStatus?: HttpStatus) { + constructor( + errorType: string, + message?: string, + payload?: any, + httpStatus?: HttpStatus, + ) { super(message); this.errorType = errorType; diff --git a/packages/server/src/modules/Items/ValidateBulkDeleteItems.service.ts b/packages/server/src/modules/Items/ValidateBulkDeleteItems.service.ts index 45f7e6c8d..f633af1f6 100644 --- a/packages/server/src/modules/Items/ValidateBulkDeleteItems.service.ts +++ b/packages/server/src/modules/Items/ValidateBulkDeleteItems.service.ts @@ -10,7 +10,7 @@ export class ValidateBulkDeleteItemsService { private readonly deleteItemService: DeleteItemService, @Inject(TENANCY_DB_CONNECTION) private readonly tenantKnex: () => Knex, - ) { } + ) {} /** * Validates which items from the provided IDs can be deleted. @@ -71,4 +71,3 @@ export class ValidateBulkDeleteItemsService { } } } - diff --git a/packages/server/src/modules/Items/dtos/BulkDeleteItems.dto.ts b/packages/server/src/modules/Items/dtos/BulkDeleteItems.dto.ts index 9a1a471a8..99f000e19 100644 --- a/packages/server/src/modules/Items/dtos/BulkDeleteItems.dto.ts +++ b/packages/server/src/modules/Items/dtos/BulkDeleteItems.dto.ts @@ -22,7 +22,9 @@ export class BulkDeleteItemsDto { @IsOptional() @IsBoolean() - @Transform(({ value, obj }) => parseBoolean(value ?? obj?.skip_undeletable, false)) + @Transform(({ value, obj }) => + parseBoolean(value ?? obj?.skip_undeletable, false), + ) @ApiPropertyOptional({ description: 'When true, undeletable items will be skipped and only deletable ones removed.', @@ -59,4 +61,3 @@ export class ValidateBulkDeleteItemsResponseDto { }) nonDeletableIds: number[]; } - diff --git a/packages/server/src/modules/Items/dtos/ItemErrorResponse.dto.ts b/packages/server/src/modules/Items/dtos/ItemErrorResponse.dto.ts index 69ed391d7..06552ffe5 100644 --- a/packages/server/src/modules/Items/dtos/ItemErrorResponse.dto.ts +++ b/packages/server/src/modules/Items/dtos/ItemErrorResponse.dto.ts @@ -7,61 +7,61 @@ import { ApiProperty } from '@nestjs/swagger'; export enum ItemErrorType { /** Item name already exists in the system */ ItemNameExists = 'ITEM_NAME_EXISTS', - + /** Item category was not found */ ItemCategoryNotFound = 'ITEM_CATEOGRY_NOT_FOUND', - + /** Cost account is not a Cost of Goods Sold account */ CostAccountNotCogs = 'COST_ACCOUNT_NOT_COGS', - + /** Cost account was not found */ CostAccountNotFound = 'COST_ACCOUNT_NOT_FOUMD', - + /** Sell account was not found */ SellAccountNotFound = 'SELL_ACCOUNT_NOT_FOUND', - + /** Sell account is not an income account */ SellAccountNotIncome = 'SELL_ACCOUNT_NOT_INCOME', - + /** Inventory account was not found */ InventoryAccountNotFound = 'INVENTORY_ACCOUNT_NOT_FOUND', - + /** Account is not an inventory type account */ InventoryAccountNotInventory = 'INVENTORY_ACCOUNT_NOT_INVENTORY', - + /** Multiple items have associated transactions */ ItemsHaveAssociatedTransactions = 'ITEMS_HAVE_ASSOCIATED_TRANSACTIONS', - + /** Item has associated transactions (singular) */ ItemHasAssociatedTransactions = 'ITEM_HAS_ASSOCIATED_TRANSACTINS', - + /** Item has associated inventory adjustments */ ItemHasAssociatedInventoryAdjustment = 'ITEM_HAS_ASSOCIATED_INVENTORY_ADJUSTMENT', - + /** Cannot change item type to inventory */ ItemCannotChangeInventoryType = 'ITEM_CANNOT_CHANGE_INVENTORY_TYPE', - + /** Cannot change type when item has transactions */ TypeCannotChangeWithItemHasTransactions = 'TYPE_CANNOT_CHANGE_WITH_ITEM_HAS_TRANSACTIONS', - + /** Inventory account cannot be modified */ InventoryAccountCannotModified = 'INVENTORY_ACCOUNT_CANNOT_MODIFIED', - + /** Purchase tax rate was not found */ PurchaseTaxRateNotFound = 'PURCHASE_TAX_RATE_NOT_FOUND', - + /** Sell tax rate was not found */ SellTaxRateNotFound = 'SELL_TAX_RATE_NOT_FOUND', - + /** Income account is required for sellable items */ IncomeAccountRequiredWithSellableItem = 'INCOME_ACCOUNT_REQUIRED_WITH_SELLABLE_ITEM', - + /** Cost account is required for purchasable items */ CostAccountRequiredWithPurchasableItem = 'COST_ACCOUNT_REQUIRED_WITH_PURCHASABLE_ITEM', - + /** Item not found */ NotFound = 'NOT_FOUND', - + /** Items not found */ ItemsNotFound = 'ITEMS_NOT_FOUND', } diff --git a/packages/server/src/modules/Items/listeners/ItemCreated.listener.ts b/packages/server/src/modules/Items/listeners/ItemCreated.listener.ts index 679f80b97..904e0a3a6 100644 --- a/packages/server/src/modules/Items/listeners/ItemCreated.listener.ts +++ b/packages/server/src/modules/Items/listeners/ItemCreated.listener.ts @@ -4,10 +4,9 @@ import { ItemCreatedEvent } from '../events/ItemCreated.event'; @Injectable() export class ItemCreatedListener { - @OnEvent('order.created') handleItemCreatedEvent(event: ItemCreatedEvent) { // handle and process "OrderCreatedEvent" event console.log(event); } -} \ No newline at end of file +} diff --git a/packages/server/src/modules/Items/models/Item.meta.ts b/packages/server/src/modules/Items/models/Item.meta.ts index 0c2446972..982a1daca 100644 --- a/packages/server/src/modules/Items/models/Item.meta.ts +++ b/packages/server/src/modules/Items/models/Item.meta.ts @@ -1,4 +1,3 @@ - export const ItemMeta = { importable: true, exportable: true, @@ -307,4 +306,4 @@ export const ItemMeta = { fieldType: 'boolean', }, }, -}; \ No newline at end of file +}; diff --git a/packages/server/src/modules/Ledger/JournalEntry.ts b/packages/server/src/modules/Ledger/JournalEntry.ts index bd0ac2634..93a64f85b 100644 --- a/packages/server/src/modules/Ledger/JournalEntry.ts +++ b/packages/server/src/modules/Ledger/JournalEntry.ts @@ -1,8 +1,8 @@ -import { ILedgerEntry } from "./types/Ledger.types"; +import { ILedgerEntry } from './types/Ledger.types'; export class JournalEntry { entry: ILedgerEntry; - + constructor(entry: ILedgerEntry) { const defaults = { credit: 0, diff --git a/packages/server/src/modules/Ledger/Ledger.module.ts b/packages/server/src/modules/Ledger/Ledger.module.ts index 1f8bd166b..14fe0bca5 100644 --- a/packages/server/src/modules/Ledger/Ledger.module.ts +++ b/packages/server/src/modules/Ledger/Ledger.module.ts @@ -15,13 +15,13 @@ import { AccountsModule } from '../Accounts/Accounts.module'; LedgerRevertService, LedgerContactsBalanceStorage, LedegrAccountsStorage, - TenancyContext + TenancyContext, ], exports: [ LedgerStorageService, LedgerEntriesStorageService, LedgerRevertService, - LedegrAccountsStorage + LedegrAccountsStorage, ], }) export class LedgerModule {} diff --git a/packages/server/src/modules/Ledger/Ledger.ts b/packages/server/src/modules/Ledger/Ledger.ts index 711c10b1c..f74efdbc9 100644 --- a/packages/server/src/modules/Ledger/Ledger.ts +++ b/packages/server/src/modules/Ledger/Ledger.ts @@ -229,7 +229,9 @@ export class Ledger implements ILedger { * @param {IAccountTransaction[]} entries * @returns {ILedgerEntry[]} */ - static mappingTransactions(entries: ModelObject[]): ILedgerEntry[] { + static mappingTransactions( + entries: ModelObject[], + ): ILedgerEntry[] { return entries.map(this.mapTransaction); } diff --git a/packages/server/src/modules/Ledger/utils.ts b/packages/server/src/modules/Ledger/utils.ts index 772c94e89..a80461d61 100644 --- a/packages/server/src/modules/Ledger/utils.ts +++ b/packages/server/src/modules/Ledger/utils.ts @@ -1,9 +1,9 @@ import * as moment from 'moment'; -import { AccountTransaction } from "../Accounts/models/AccountTransaction.model"; -import { ILedgerEntry } from "./types/Ledger.types"; +import { AccountTransaction } from '../Accounts/models/AccountTransaction.model'; +import { ILedgerEntry } from './types/Ledger.types'; export const transformLedgerEntryToTransaction = ( - entry: ILedgerEntry + entry: ILedgerEntry, ): Partial => { return { date: moment(entry.date).toDate(), diff --git a/packages/server/src/modules/Loops/LoopsEvents.subscriber.ts b/packages/server/src/modules/Loops/LoopsEvents.subscriber.ts index 7d19f311a..c41674f08 100644 --- a/packages/server/src/modules/Loops/LoopsEvents.subscriber.ts +++ b/packages/server/src/modules/Loops/LoopsEvents.subscriber.ts @@ -8,15 +8,12 @@ import { events } from '@/common/events/events'; @Injectable() export class LoopsEventsSubscriber { - constructor( private readonly configService: ConfigService, @Inject(SystemUser.name) - private readonly systemUserModel: typeof SystemUser - ) { - - } + private readonly systemUserModel: typeof SystemUser, + ) {} /** * Once the user verified sends the event to the Loops. * @param {IAuthSignUpVerifiedEventPayload} param0 @@ -27,7 +24,7 @@ export class LoopsEventsSubscriber { userId, }: IAuthSignUpVerifiedEventPayload) { const apiKey = this.configService.get('loops.apiKey'); - + // Can't continue since the Loops the api key is not configured. if (!apiKey) { return; diff --git a/packages/server/src/modules/Mail/Mail.constants.ts b/packages/server/src/modules/Mail/Mail.constants.ts index 473e50b5d..85883ceac 100644 --- a/packages/server/src/modules/Mail/Mail.constants.ts +++ b/packages/server/src/modules/Mail/Mail.constants.ts @@ -1 +1 @@ -export const MAIL_TRANSPORTER_PROVIDER = 'MAIL_TRANSPORTER'; \ No newline at end of file +export const MAIL_TRANSPORTER_PROVIDER = 'MAIL_TRANSPORTER'; diff --git a/packages/server/src/modules/MailNotification/dtos/CommonMailOptions.dto.ts b/packages/server/src/modules/MailNotification/dtos/CommonMailOptions.dto.ts index 054f0f7db..5ed728b94 100644 --- a/packages/server/src/modules/MailNotification/dtos/CommonMailOptions.dto.ts +++ b/packages/server/src/modules/MailNotification/dtos/CommonMailOptions.dto.ts @@ -1,5 +1,11 @@ -import { ArrayMinSize, IsArray, IsNotEmpty, IsObject, IsString } from "class-validator"; -import { AddressItem } from "../MailNotification.types"; +import { + ArrayMinSize, + IsArray, + IsNotEmpty, + IsObject, + IsString, +} from 'class-validator'; +import { AddressItem } from '../MailNotification.types'; export class CommonMailOptionsDto { @IsArray() @@ -34,4 +40,4 @@ export class CommonMailOptionsDto { @IsArray() fromOptions: Array; -} \ No newline at end of file +} diff --git a/packages/server/src/modules/MailNotification/utils.ts b/packages/server/src/modules/MailNotification/utils.ts index b4a24027d..d67525e62 100644 --- a/packages/server/src/modules/MailNotification/utils.ts +++ b/packages/server/src/modules/MailNotification/utils.ts @@ -10,7 +10,7 @@ import { ServiceError } from '../Items/ServiceError'; */ export function parseMailOptions( mailOptions: CommonMailOptions, - overridedOptions: Partial + overridedOptions: Partial, ): CommonMailOptions { const mergedMessageOptions = { ...mailOptions, @@ -29,7 +29,7 @@ export function parseMailOptions( } export function validateRequiredMailOptions( - mailOptions: Partial + mailOptions: Partial, ) { if (isEmpty(mailOptions.from)) { throw new ServiceError(ERRORS.MAIL_FROM_NOT_FOUND); @@ -47,7 +47,7 @@ export function validateRequiredMailOptions( export const mergeAndValidateMailOptions = ( mailOptions: CommonMailOptions, - overridedOptions: Partial + overridedOptions: Partial, ): CommonMailOptions => { const parsedMessageOptions = parseMailOptions(mailOptions, overridedOptions); validateRequiredMailOptions(parsedMessageOptions); diff --git a/packages/server/src/modules/MailTenancy/MailTenancy.service.ts b/packages/server/src/modules/MailTenancy/MailTenancy.service.ts index 3720f7bc9..00e56480c 100644 --- a/packages/server/src/modules/MailTenancy/MailTenancy.service.ts +++ b/packages/server/src/modules/MailTenancy/MailTenancy.service.ts @@ -6,7 +6,7 @@ import { ConfigService } from '@nestjs/config'; export class MailTenancy { constructor( private readonly tenancyContext: TenancyContext, - private readonly config: ConfigService + private readonly config: ConfigService, ) {} /** @@ -21,7 +21,7 @@ export class MailTenancy { mail: from, label: tenantMetadata.name, primary: true, - } - ].filter((item) => item.mail) + }, + ].filter((item) => item.mail); } -} \ No newline at end of file +} diff --git a/packages/server/src/modules/ManualJournals/BulkDeleteManualJournals.service.ts b/packages/server/src/modules/ManualJournals/BulkDeleteManualJournals.service.ts index 4684aea65..84a6ee1c0 100644 --- a/packages/server/src/modules/ManualJournals/BulkDeleteManualJournals.service.ts +++ b/packages/server/src/modules/ManualJournals/BulkDeleteManualJournals.service.ts @@ -8,7 +8,7 @@ import { DeleteManualJournalService } from './commands/DeleteManualJournal.servi export class BulkDeleteManualJournalsService { constructor( private readonly deleteManualJournalService: DeleteManualJournalService, - ) { } + ) {} async bulkDeleteManualJournals( manualJournalIds: number | Array, @@ -37,4 +37,3 @@ export class BulkDeleteManualJournalsService { } } } - diff --git a/packages/server/src/modules/ManualJournals/ManualJournals.controller.ts b/packages/server/src/modules/ManualJournals/ManualJournals.controller.ts index 34b906f50..3600c078d 100644 --- a/packages/server/src/modules/ManualJournals/ManualJournals.controller.ts +++ b/packages/server/src/modules/ManualJournals/ManualJournals.controller.ts @@ -43,7 +43,7 @@ import { ManualJournalAction } from './types/ManualJournals.types'; @ApiCommonHeaders() @UseGuards(AuthorizationGuard, PermissionGuard) export class ManualJournalsController { - constructor(private manualJournalsApplication: ManualJournalsApplication) { } + constructor(private manualJournalsApplication: ManualJournalsApplication) {} @Post('validate-bulk-delete') @RequirePermission(ManualJournalAction.Delete, AbilitySubject.ManualJournal) diff --git a/packages/server/src/modules/ManualJournals/ManualJournalsApplication.service.ts b/packages/server/src/modules/ManualJournals/ManualJournalsApplication.service.ts index 030c04cb9..94bad3d90 100644 --- a/packages/server/src/modules/ManualJournals/ManualJournalsApplication.service.ts +++ b/packages/server/src/modules/ManualJournals/ManualJournalsApplication.service.ts @@ -25,7 +25,7 @@ export class ManualJournalsApplication { private getManualJournalsService: GetManualJournals, private bulkDeleteManualJournalsService: BulkDeleteManualJournalsService, private validateBulkDeleteManualJournalsService: ValidateBulkDeleteManualJournalsService, - ) { } + ) {} /** * Make journal entries. diff --git a/packages/server/src/modules/ManualJournals/ValidateBulkDeleteManualJournals.service.ts b/packages/server/src/modules/ManualJournals/ValidateBulkDeleteManualJournals.service.ts index 3d275cabb..f8fe8a9f1 100644 --- a/packages/server/src/modules/ManualJournals/ValidateBulkDeleteManualJournals.service.ts +++ b/packages/server/src/modules/ManualJournals/ValidateBulkDeleteManualJournals.service.ts @@ -53,4 +53,3 @@ export class ValidateBulkDeleteManualJournalsService { } } } - diff --git a/packages/server/src/modules/ManualJournals/commands/AutoIncrementManualJournal.service.ts b/packages/server/src/modules/ManualJournals/commands/AutoIncrementManualJournal.service.ts index f72dd6ebe..7251ac09c 100644 --- a/packages/server/src/modules/ManualJournals/commands/AutoIncrementManualJournal.service.ts +++ b/packages/server/src/modules/ManualJournals/commands/AutoIncrementManualJournal.service.ts @@ -4,20 +4,20 @@ import { AutoIncrementOrdersService } from '@/modules/AutoIncrementOrders/AutoIn @Injectable() export class AutoIncrementManualJournal { /** - * - * @param autoIncrementOrdersService + * + * @param autoIncrementOrdersService */ constructor( - private readonly autoIncrementOrdersService: AutoIncrementOrdersService + private readonly autoIncrementOrdersService: AutoIncrementOrdersService, ) {} /** - * + * * @returns {boolean} */ public autoIncrementEnabled = () => { return this.autoIncrementOrdersService.autoIncrementEnabled( - 'manual_journals' + 'manual_journals', ); }; @@ -27,7 +27,7 @@ export class AutoIncrementManualJournal { */ public getNextJournalNumber = (): Promise => { return this.autoIncrementOrdersService.getNextTransactionNumber( - 'manual_journals' + 'manual_journals', ); }; @@ -37,7 +37,7 @@ export class AutoIncrementManualJournal { */ public incrementNextJournalNumber = () => { return this.autoIncrementOrdersService.incrementSettingsNextNumber( - 'manual_journals' + 'manual_journals', ); }; } diff --git a/packages/server/src/modules/ManualJournals/commands/ManualJournalExportable.ts b/packages/server/src/modules/ManualJournals/commands/ManualJournalExportable.ts index 1afe280d1..1bb68396f 100644 --- a/packages/server/src/modules/ManualJournals/commands/ManualJournalExportable.ts +++ b/packages/server/src/modules/ManualJournals/commands/ManualJournalExportable.ts @@ -17,7 +17,7 @@ export class ManualJournalsExportable extends Exportable { /** * Retrieves the manual journals data to exportable sheet. - * @param {IManualJournalsFilter} query - + * @param {IManualJournalsFilter} query - */ public exportable(query: IManualJournalsFilter) { const parsedQuery = { diff --git a/packages/server/src/modules/ManualJournals/constants.ts b/packages/server/src/modules/ManualJournals/constants.ts index 825c1ddbb..34b90564a 100644 --- a/packages/server/src/modules/ManualJournals/constants.ts +++ b/packages/server/src/modules/ManualJournals/constants.ts @@ -45,7 +45,12 @@ export const ManualJournalDefaultViews = [ slug: 'published', rolesLogicExpression: '1', roles: [ - { index: 1, fieldKey: 'status', comparator: 'equals', value: 'published' }, + { + index: 1, + fieldKey: 'status', + comparator: 'equals', + value: 'published', + }, ], columns: DEFAULT_VIEW_COLUMNS, }, diff --git a/packages/server/src/modules/ManualJournals/dtos/ManualJournal.dto.ts b/packages/server/src/modules/ManualJournals/dtos/ManualJournal.dto.ts index 957ad6510..fbb6e19c8 100644 --- a/packages/server/src/modules/ManualJournals/dtos/ManualJournal.dto.ts +++ b/packages/server/src/modules/ManualJournals/dtos/ManualJournal.dto.ts @@ -122,7 +122,10 @@ export class CommandManualJournalDto { @IsBoolean() publish?: boolean; - @ApiProperty({ description: 'Journal entries', type: [ManualJournalEntryDto] }) + @ApiProperty({ + description: 'Journal entries', + type: [ManualJournalEntryDto], + }) @IsArray() @ValidateNested({ each: true }) @Type(() => ManualJournalEntryDto) @@ -133,8 +136,8 @@ export class CommandManualJournalDto { @IsArray() @ValidateNested({ each: true }) @Type(() => AttachmentDto) - attachments?: AttachmentDto[]; + attachments?: AttachmentDto[]; } export class CreateManualJournalDto extends CommandManualJournalDto {} -export class EditManualJournalDto extends CommandManualJournalDto {} \ No newline at end of file +export class EditManualJournalDto extends CommandManualJournalDto {} diff --git a/packages/server/src/modules/ManualJournals/models/ManualJournal.meta.ts b/packages/server/src/modules/ManualJournals/models/ManualJournal.meta.ts index 352dccd26..d17ca0cc0 100644 --- a/packages/server/src/modules/ManualJournals/models/ManualJournal.meta.ts +++ b/packages/server/src/modules/ManualJournals/models/ManualJournal.meta.ts @@ -227,4 +227,4 @@ function StatusFieldSortQuery(query, role) { */ function StatusFieldFilterQuery(query, role) { query.modify('filterByStatus', role.value); -} \ No newline at end of file +} diff --git a/packages/server/src/modules/ManualJournals/types/ManualJournals.types.ts b/packages/server/src/modules/ManualJournals/types/ManualJournals.types.ts index 06bcb087b..22a0fb142 100644 --- a/packages/server/src/modules/ManualJournals/types/ManualJournals.types.ts +++ b/packages/server/src/modules/ManualJournals/types/ManualJournals.types.ts @@ -14,7 +14,7 @@ export interface IManualJournalEntryDTO { accountId: number; note: string; contactId?: number; - branchId?: number + branchId?: number; projectId?: number; } diff --git a/packages/server/src/modules/Metable/MetableStore.ts b/packages/server/src/modules/Metable/MetableStore.ts index f3866a588..2225e1c8c 100644 --- a/packages/server/src/modules/Metable/MetableStore.ts +++ b/packages/server/src/modules/Metable/MetableStore.ts @@ -23,7 +23,7 @@ export class MetableStore implements IMetableStore { */ setExtraColumns(columns: string[]): void { this.extraColumns = columns; -} + } /** * Find the given metadata key. @@ -36,7 +36,8 @@ export class MetableStore implements IMetableStore { return this.metadata.find((meta: IMetadata) => { const isSameKey = meta.key === key; const sameExtraColumns = this.extraColumns.some( - (extraColumn: string) => extraColumns[extraColumn] === meta[extraColumn] + (extraColumn: string) => + extraColumns[extraColumn] === meta[extraColumn], ); const isSameExtraColumns = sameExtraColumns || isEmpty(extraColumns); @@ -52,7 +53,7 @@ export class MetableStore implements IMetableStore { return this.metadata .filter((meta: IMetadata) => !meta._markAsDeleted) .map((meta: IMetadata) => - omit(meta, itemsStartWith(Object.keys(meta), '_')) + omit(meta, itemsStartWith(Object.keys(meta), '_')), ); } @@ -66,8 +67,8 @@ export class MetableStore implements IMetableStore { return metadata ? metadata.value : typeof defaultValue !== 'undefined' - ? defaultValue - : null; + ? defaultValue + : null; } /** @@ -142,7 +143,7 @@ export class MetableStore implements IMetableStore { */ static formatMetaValue( value: string | boolean | number, - valueType: string + valueType: string, ): string | number | boolean { let parsedValue; diff --git a/packages/server/src/modules/Miscellaneous/Miscellaneous.constants.ts b/packages/server/src/modules/Miscellaneous/Miscellaneous.constants.ts index 5db70ccbe..5ae4630c9 100644 --- a/packages/server/src/modules/Miscellaneous/Miscellaneous.constants.ts +++ b/packages/server/src/modules/Miscellaneous/Miscellaneous.constants.ts @@ -8,4 +8,4 @@ export const DATE_FORMATS = [ 'DD MMM YYYY', 'DD MMMM YYYY', 'MMMM DD, YYYY', -]; \ No newline at end of file +]; diff --git a/packages/server/src/modules/Miscellaneous/Miscellaneous.controller.ts b/packages/server/src/modules/Miscellaneous/Miscellaneous.controller.ts index ab42e603a..ee4b2e5d4 100644 --- a/packages/server/src/modules/Miscellaneous/Miscellaneous.controller.ts +++ b/packages/server/src/modules/Miscellaneous/Miscellaneous.controller.ts @@ -1,6 +1,11 @@ import { Controller, Get } from '@nestjs/common'; import { GetDateFormatsService } from './queries/GetDateFormats.service'; -import { ApiExtraModels, ApiResponse, ApiTags, getSchemaPath } from '@nestjs/swagger'; +import { + ApiExtraModels, + ApiResponse, + ApiTags, + getSchemaPath, +} from '@nestjs/swagger'; import { DateFormatResponseDto } from './dtos/DateFormatResponse.dto'; @Controller('/') diff --git a/packages/server/src/modules/Organization/Organization.constants.ts b/packages/server/src/modules/Organization/Organization.constants.ts index e3252fa58..4361b42cf 100644 --- a/packages/server/src/modules/Organization/Organization.constants.ts +++ b/packages/server/src/modules/Organization/Organization.constants.ts @@ -36,5 +36,5 @@ export const ERRORS = { TENANT_DB_NOT_BUILT: 'tenant_db_not_built', TENANT_IS_BUILDING: 'TENANT_IS_BUILDING', BASE_CURRENCY_MUTATE_LOCKED: 'BASE_CURRENCY_MUTATE_LOCKED', - TENANT_UPGRADE_IS_RUNNING: 'TENANT_UPGRADE_IS_RUNNING' + TENANT_UPGRADE_IS_RUNNING: 'TENANT_UPGRADE_IS_RUNNING', }; diff --git a/packages/server/src/modules/Organization/Organization/constants.ts b/packages/server/src/modules/Organization/Organization/constants.ts index a1c0bd6f7..0426a0f86 100644 --- a/packages/server/src/modules/Organization/Organization/constants.ts +++ b/packages/server/src/modules/Organization/Organization/constants.ts @@ -39,5 +39,5 @@ export const ERRORS = { TENANT_DB_NOT_BUILT: 'tenant_db_not_built', TENANT_IS_BUILDING: 'TENANT_IS_BUILDING', BASE_CURRENCY_MUTATE_LOCKED: 'BASE_CURRENCY_MUTATE_LOCKED', - TENANT_UPGRADE_IS_RUNNING: 'TENANT_UPGRADE_IS_RUNNING' + TENANT_UPGRADE_IS_RUNNING: 'TENANT_UPGRADE_IS_RUNNING', }; diff --git a/packages/server/src/modules/Organization/commands/UpdateOrganization.service.ts b/packages/server/src/modules/Organization/commands/UpdateOrganization.service.ts index 7102bc9aa..0ae5c4443 100644 --- a/packages/server/src/modules/Organization/commands/UpdateOrganization.service.ts +++ b/packages/server/src/modules/Organization/commands/UpdateOrganization.service.ts @@ -14,7 +14,7 @@ export class UpdateOrganizationService { private readonly eventEmitter: EventEmitter2, private readonly commandOrganizationValidators: CommandOrganizationValidators, private readonly tenantRepository: TenantRepository, - ) { } + ) {} /** * Updates organization information. diff --git a/packages/server/src/modules/Organization/processors/OrganizationBuild.processor.ts b/packages/server/src/modules/Organization/processors/OrganizationBuild.processor.ts index 78d58a62c..dea82321e 100644 --- a/packages/server/src/modules/Organization/processors/OrganizationBuild.processor.ts +++ b/packages/server/src/modules/Organization/processors/OrganizationBuild.processor.ts @@ -24,16 +24,16 @@ export class OrganizationBuildProcessor extends WorkerHost { async process(job: Job) { console.log('Processing organization build job:', job.id); - this.clsService.set('organizationId', job.data.organizationId); - this.clsService.set('userId', job.data.userId); + this.clsService.set('organizationId', job.data.organizationId); + this.clsService.set('userId', job.data.userId); - try { - await this.organizationBuildService.build(job.data.buildDto); - } catch (e) { - // Unlock build status of the tenant. - await this.organizationBuildService.revertBuildRunJob(); - console.error('Error processing organization build job:', e); - throw e; // Re-throw to mark job as failed - } + try { + await this.organizationBuildService.build(job.data.buildDto); + } catch (e) { + // Unlock build status of the tenant. + await this.organizationBuildService.revertBuildRunJob(); + console.error('Error processing organization build job:', e); + throw e; // Re-throw to mark job as failed + } } } diff --git a/packages/server/src/modules/Organization/queries/GetCurrentOrganization.service.ts b/packages/server/src/modules/Organization/queries/GetCurrentOrganization.service.ts index 1cc3fb99f..005aeaffb 100644 --- a/packages/server/src/modules/Organization/queries/GetCurrentOrganization.service.ts +++ b/packages/server/src/modules/Organization/queries/GetCurrentOrganization.service.ts @@ -27,8 +27,11 @@ export class GetCurrentOrganizationService { throwIfTenantNotExists(tenant); - const logoUri = tenant.metadata?.logoKey ? - await this.getPresignedUrlService.getPresignedUrl(tenant.metadata.logoKey) : null; + const logoUri = tenant.metadata?.logoKey + ? await this.getPresignedUrlService.getPresignedUrl( + tenant.metadata.logoKey, + ) + : null; return await this.transformer.transform( tenant, diff --git a/packages/server/src/modules/Organization/queries/GetCurrentOrganization.transformer.ts b/packages/server/src/modules/Organization/queries/GetCurrentOrganization.transformer.ts index 67771d1cc..406d83a19 100644 --- a/packages/server/src/modules/Organization/queries/GetCurrentOrganization.transformer.ts +++ b/packages/server/src/modules/Organization/queries/GetCurrentOrganization.transformer.ts @@ -9,9 +9,13 @@ export class GetCurrentOrganizationTransformer extends Transformer { */ transform = (tenant: Record) => { const metadataTransformer = new GetCurrentOrganizationMetadataTransformer(); - const transformedMetadata = this.item(tenant.metadata, metadataTransformer, { - logoUri: this.options?.logoUri, - }); + const transformedMetadata = this.item( + tenant.metadata, + metadataTransformer, + { + logoUri: this.options?.logoUri, + }, + ); return { ...tenant, diff --git a/packages/server/src/modules/Organization/subscribers/SyncSystemUserToTenant.subscriber.ts b/packages/server/src/modules/Organization/subscribers/SyncSystemUserToTenant.subscriber.ts index 80d81a1b2..b1d198127 100644 --- a/packages/server/src/modules/Organization/subscribers/SyncSystemUserToTenant.subscriber.ts +++ b/packages/server/src/modules/Organization/subscribers/SyncSystemUserToTenant.subscriber.ts @@ -11,7 +11,9 @@ export class SyncSystemUserToTenantSubscriber { ) {} @OnEvent(events.organization.build) - async onOrgBuildSyncSystemUser({ systemUser }: IOrganizationBuildEventPayload) { + async onOrgBuildSyncSystemUser({ + systemUser, + }: IOrganizationBuildEventPayload) { await this.syncSystemUserToTenantService.syncSystemUserToTenant( systemUser.id, ); diff --git a/packages/server/src/modules/PaymentLinks/PaymentLinks.controller.ts b/packages/server/src/modules/PaymentLinks/PaymentLinks.controller.ts index 4acf9d220..97ee65401 100644 --- a/packages/server/src/modules/PaymentLinks/PaymentLinks.controller.ts +++ b/packages/server/src/modules/PaymentLinks/PaymentLinks.controller.ts @@ -3,9 +3,7 @@ import { Controller, Get, Param, Post, Res } from '@nestjs/common'; import { PaymentLinksApplication } from './PaymentLinksApplication'; import { ApiOperation, ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger'; import { ApiCommonHeaders } from '@/common/decorators/ApiCommonHeaders'; -import { - GetInvoicePaymentLinkResponseWrapperDto, -} from './dtos/GetInvoicePaymentLinkResponse.dto'; +import { GetInvoicePaymentLinkResponseWrapperDto } from './dtos/GetInvoicePaymentLinkResponse.dto'; import { CreateStripeCheckoutSessionResponseDto } from './dtos/CreateStripeCheckoutSessionResponse.dto'; @Controller('payment-links') diff --git a/packages/server/src/modules/PaymentLinks/dtos/GetInvoicePaymentLinkResponse.dto.ts b/packages/server/src/modules/PaymentLinks/dtos/GetInvoicePaymentLinkResponse.dto.ts index 37328a239..82aab5349 100644 --- a/packages/server/src/modules/PaymentLinks/dtos/GetInvoicePaymentLinkResponse.dto.ts +++ b/packages/server/src/modules/PaymentLinks/dtos/GetInvoicePaymentLinkResponse.dto.ts @@ -140,16 +140,25 @@ export class GetInvoicePaymentLinkResponseDto { @ApiProperty({ description: 'Terms and conditions' }) termsConditions: string; - @ApiProperty({ type: [PaymentLinkEntryDto], description: 'Invoice line entries' }) + @ApiProperty({ + type: [PaymentLinkEntryDto], + description: 'Invoice line entries', + }) entries: PaymentLinkEntryDto[]; @ApiProperty({ type: [PaymentLinkTaxEntryDto], description: 'Tax entries' }) taxes: PaymentLinkTaxEntryDto[]; - @ApiProperty({ type: PaymentLinkBrandingTemplateDto, description: 'Branding template' }) + @ApiProperty({ + type: PaymentLinkBrandingTemplateDto, + description: 'Branding template', + }) brandingTemplate: PaymentLinkBrandingTemplateDto; - @ApiProperty({ type: PaymentLinkOrganizationDto, description: 'Organization metadata' }) + @ApiProperty({ + type: PaymentLinkOrganizationDto, + description: 'Organization metadata', + }) organization: PaymentLinkOrganizationDto; @ApiProperty({ description: 'Whether Stripe is available as payment method' }) diff --git a/packages/server/src/modules/PaymentReceived/BulkDeletePaymentReceived.service.ts b/packages/server/src/modules/PaymentReceived/BulkDeletePaymentReceived.service.ts index c36f41a00..80a6aeabe 100644 --- a/packages/server/src/modules/PaymentReceived/BulkDeletePaymentReceived.service.ts +++ b/packages/server/src/modules/PaymentReceived/BulkDeletePaymentReceived.service.ts @@ -8,7 +8,7 @@ import { DeletePaymentReceivedService } from './commands/DeletePaymentReceived.s export class BulkDeletePaymentReceivedService { constructor( private readonly deletePaymentReceivedService: DeletePaymentReceivedService, - ) { } + ) {} async bulkDeletePaymentReceived( paymentReceiveIds: number | Array, @@ -37,4 +37,3 @@ export class BulkDeletePaymentReceivedService { } } } - diff --git a/packages/server/src/modules/PaymentReceived/PaymentReceived.application.ts b/packages/server/src/modules/PaymentReceived/PaymentReceived.application.ts index bcd56dc86..b922a2e2c 100644 --- a/packages/server/src/modules/PaymentReceived/PaymentReceived.application.ts +++ b/packages/server/src/modules/PaymentReceived/PaymentReceived.application.ts @@ -35,7 +35,7 @@ export class PaymentReceivesApplication { private paymentsReceivedPagesService: PaymentsReceivedPagesService, private bulkDeletePaymentReceivedService: BulkDeletePaymentReceivedService, private validateBulkDeletePaymentReceivedService: ValidateBulkDeletePaymentReceivedService, - ) { } + ) {} /** * Creates a new payment receive. @@ -94,8 +94,9 @@ export class PaymentReceivesApplication { * @param {number[]} paymentReceiveIds */ public validateBulkDeletePaymentReceives(paymentReceiveIds: number[]) { - return this.validateBulkDeletePaymentReceivedService - .validateBulkDeletePaymentReceived(paymentReceiveIds); + return this.validateBulkDeletePaymentReceivedService.validateBulkDeletePaymentReceived( + paymentReceiveIds, + ); } /** @@ -104,9 +105,7 @@ export class PaymentReceivesApplication { * @param {GetPaymentsReceivedQueryDto} filterDTO * @returns */ - public async getPaymentsReceived( - filterDTO: GetPaymentsReceivedQueryDto, - ) { + public async getPaymentsReceived(filterDTO: GetPaymentsReceivedQueryDto) { return this.getPaymentsReceivedService.getPaymentReceives(filterDTO); } @@ -171,7 +170,7 @@ export class PaymentReceivesApplication { /** * Retrieves html content of the given payment receive. - * @param {number} paymentReceivedId + * @param {number} paymentReceivedId * @returns {Promise} */ public getPaymentReceivedHtml(paymentReceivedId: number) { diff --git a/packages/server/src/modules/PaymentReceived/PaymentsReceived.controller.ts b/packages/server/src/modules/PaymentReceived/PaymentsReceived.controller.ts index d017d55f6..5f977b7dc 100644 --- a/packages/server/src/modules/PaymentReceived/PaymentsReceived.controller.ts +++ b/packages/server/src/modules/PaymentReceived/PaymentsReceived.controller.ts @@ -22,9 +22,7 @@ import { UseGuards, } from '@nestjs/common'; import { PaymentReceivesApplication } from './PaymentReceived.application'; -import { - PaymentReceiveMailOptsDTO, -} from './types/PaymentReceived.types'; +import { PaymentReceiveMailOptsDTO } from './types/PaymentReceived.types'; import { GetPaymentsReceivedQueryDto } from './dtos/GetPaymentsReceivedQuery.dto'; import { CreatePaymentReceivedDto, @@ -54,7 +52,7 @@ import { PaymentReceiveAction } from './types/PaymentReceived.types'; @ApiCommonHeaders() @UseGuards(AuthorizationGuard, PermissionGuard) export class PaymentReceivesController { - constructor(private paymentReceivesApplication: PaymentReceivesApplication) { } + constructor(private paymentReceivesApplication: PaymentReceivesApplication) {} @Post(':id/mail') @HttpCode(200) @@ -155,9 +153,7 @@ export class PaymentReceivesController { ], }, }) - public getPaymentsReceived( - @Query() filterDTO: GetPaymentsReceivedQueryDto, - ) { + public getPaymentsReceived(@Query() filterDTO: GetPaymentsReceivedQueryDto) { return this.paymentReceivesApplication.getPaymentsReceived(filterDTO); } @@ -190,9 +186,7 @@ export class PaymentReceivesController { status: 200, description: 'Payments received deleted successfully.', }) - public bulkDeletePaymentsReceived( - @Body() bulkDeleteDto: BulkDeleteDto, - ) { + public bulkDeletePaymentsReceived(@Body() bulkDeleteDto: BulkDeleteDto) { return this.paymentReceivesApplication.bulkDeletePaymentReceives( bulkDeleteDto.ids, { skipUndeletable: bulkDeleteDto.skipUndeletable ?? false }, @@ -246,9 +240,10 @@ export class PaymentReceivesController { @Res({ passthrough: true }) res: Response, ) { if (acceptHeader?.includes(AcceptType.ApplicationPdf)) { - const [pdfContent, filename] = await this.paymentReceivesApplication.getPaymentReceivePdf( - paymentReceiveId, - ); + const [pdfContent, filename] = + await this.paymentReceivesApplication.getPaymentReceivePdf( + paymentReceiveId, + ); res.set({ 'Content-Type': 'application/pdf', 'Content-Length': pdfContent.length, diff --git a/packages/server/src/modules/PaymentReceived/ValidateBulkDeletePaymentReceived.service.ts b/packages/server/src/modules/PaymentReceived/ValidateBulkDeletePaymentReceived.service.ts index 81bbfd729..29b60eae4 100644 --- a/packages/server/src/modules/PaymentReceived/ValidateBulkDeletePaymentReceived.service.ts +++ b/packages/server/src/modules/PaymentReceived/ValidateBulkDeletePaymentReceived.service.ts @@ -9,7 +9,7 @@ export class ValidateBulkDeletePaymentReceivedService { private readonly deletePaymentReceivedService: DeletePaymentReceivedService, @Inject(TENANCY_DB_CONNECTION) private readonly tenantKnex: () => Knex, - ) { } + ) {} public async validateBulkDeletePaymentReceived( paymentReceiveIds: number[], @@ -53,4 +53,3 @@ export class ValidateBulkDeletePaymentReceivedService { } } } - diff --git a/packages/server/src/modules/PaymentReceived/commands/DeletePaymentReceived.service.ts b/packages/server/src/modules/PaymentReceived/commands/DeletePaymentReceived.service.ts index b621ede45..611d1aec2 100644 --- a/packages/server/src/modules/PaymentReceived/commands/DeletePaymentReceived.service.ts +++ b/packages/server/src/modules/PaymentReceived/commands/DeletePaymentReceived.service.ts @@ -30,7 +30,7 @@ export class DeletePaymentReceivedService { private paymentReceiveEntryModel: TenantModelProxy< typeof PaymentReceivedEntry >, - ) { } + ) {} /** * Deletes the given payment receive with associated entries diff --git a/packages/server/src/modules/PaymentReceived/commands/PaymentReceivedValidators.service.ts b/packages/server/src/modules/PaymentReceived/commands/PaymentReceivedValidators.service.ts index 47c0646c5..cec55b267 100644 --- a/packages/server/src/modules/PaymentReceived/commands/PaymentReceivedValidators.service.ts +++ b/packages/server/src/modules/PaymentReceived/commands/PaymentReceivedValidators.service.ts @@ -32,7 +32,7 @@ export class PaymentReceivedValidators { @Inject(Account.name) private readonly accountModel: TenantModelProxy, - ) { } + ) {} /** * Validates the payment existance. diff --git a/packages/server/src/modules/PaymentReceived/commands/PaymentsReceivedExportable.ts b/packages/server/src/modules/PaymentReceived/commands/PaymentsReceivedExportable.ts index 1cc934610..727f96de7 100644 --- a/packages/server/src/modules/PaymentReceived/commands/PaymentsReceivedExportable.ts +++ b/packages/server/src/modules/PaymentReceived/commands/PaymentsReceivedExportable.ts @@ -28,7 +28,7 @@ export class PaymentsReceivedExportable extends Exportable { page: 1, pageSize: EXPORT_SIZE_LIMIT, filterQuery, - ...query + ...query, }; return this.paymentReceivedApp .getPaymentsReceived(parsedQuery) diff --git a/packages/server/src/modules/PaymentReceived/models/PaymentReceived.meta.ts b/packages/server/src/modules/PaymentReceived/models/PaymentReceived.meta.ts index bfa1d5c26..61405155f 100644 --- a/packages/server/src/modules/PaymentReceived/models/PaymentReceived.meta.ts +++ b/packages/server/src/modules/PaymentReceived/models/PaymentReceived.meta.ts @@ -1,4 +1,4 @@ -import { Features } from "@/common/types/Features"; +import { Features } from '@/common/types/Features'; export const PaymentReceivedMeta = { importable: true, @@ -9,7 +9,7 @@ export const PaymentReceivedMeta = { importAggregator: 'group', importAggregateOn: 'entries', importAggregateBy: 'paymentReceiveNo', - + fields: { customer: { name: 'payment_receive.field.customer', @@ -207,4 +207,4 @@ export const PaymentReceivedMeta = { required: true, }, }, -}; \ No newline at end of file +}; diff --git a/packages/server/src/modules/PaymentReceived/queries/GetPaymentReceivedMailState.transformer.ts b/packages/server/src/modules/PaymentReceived/queries/GetPaymentReceivedMailState.transformer.ts index 73c93c645..fa77efc50 100644 --- a/packages/server/src/modules/PaymentReceived/queries/GetPaymentReceivedMailState.transformer.ts +++ b/packages/server/src/modules/PaymentReceived/queries/GetPaymentReceivedMailState.transformer.ts @@ -182,4 +182,4 @@ export class GetPaymentReceivedEntryMailState extends PaymentReceivedEntryTransf public invoiceNumber = (entry) => { return entry.invoice.invoiceNo; }; -} \ No newline at end of file +} diff --git a/packages/server/src/modules/PaymentReceived/queries/GetPaymentReceivedMailTemplate.service.ts b/packages/server/src/modules/PaymentReceived/queries/GetPaymentReceivedMailTemplate.service.ts index 6c98dc3cd..f392c1bf9 100644 --- a/packages/server/src/modules/PaymentReceived/queries/GetPaymentReceivedMailTemplate.service.ts +++ b/packages/server/src/modules/PaymentReceived/queries/GetPaymentReceivedMailTemplate.service.ts @@ -42,7 +42,7 @@ export class GetPaymentReceivedMailTemplate { /** * Retrieves the mail template html content. - * @param {number} paymentReceivedId + * @param {number} paymentReceivedId * @param {Partial} overrideAttributes * @returns */ diff --git a/packages/server/src/modules/PaymentReceived/queries/GetPaymentReceivedMailTemplateAttrs.transformer.ts b/packages/server/src/modules/PaymentReceived/queries/GetPaymentReceivedMailTemplateAttrs.transformer.ts index 1e1acb544..6018362ec 100644 --- a/packages/server/src/modules/PaymentReceived/queries/GetPaymentReceivedMailTemplateAttrs.transformer.ts +++ b/packages/server/src/modules/PaymentReceived/queries/GetPaymentReceivedMailTemplateAttrs.transformer.ts @@ -1,4 +1,4 @@ -import { Transformer } from "@/modules/Transformer/Transformer"; +import { Transformer } from '@/modules/Transformer/Transformer'; export class GetPaymentReceivedMailTemplateAttrsTransformer extends Transformer { /** @@ -107,7 +107,7 @@ export class GetPaymentReceivedMailTemplateAttrsTransformer extends Transformer public items() { return this.item( this.options.paymentReceived.entries, - new GetPaymentReceivedMailTemplateItemAttrsTransformer() + new GetPaymentReceivedMailTemplateItemAttrsTransformer(), ); } } @@ -146,4 +146,4 @@ class GetPaymentReceivedMailTemplateItemAttrsTransformer extends Transformer { public total(entry) { return entry.paymentAmountFormatted; } -} \ No newline at end of file +} diff --git a/packages/server/src/modules/PaymentReceived/queries/PaymentReceivedEntryTransformer.ts b/packages/server/src/modules/PaymentReceived/queries/PaymentReceivedEntryTransformer.ts index e5fc694d2..1ba27a30b 100644 --- a/packages/server/src/modules/PaymentReceived/queries/PaymentReceivedEntryTransformer.ts +++ b/packages/server/src/modules/PaymentReceived/queries/PaymentReceivedEntryTransformer.ts @@ -1,6 +1,5 @@ -import { SaleInvoiceTransformer } from "@/modules/SaleInvoices/queries/SaleInvoice.transformer"; -import { Transformer } from "@/modules/Transformer/Transformer"; - +import { SaleInvoiceTransformer } from '@/modules/SaleInvoices/queries/SaleInvoice.transformer'; +import { Transformer } from '@/modules/Transformer/Transformer'; export class PaymentReceivedEntryTransfromer extends Transformer { /** diff --git a/packages/server/src/modules/PaymentReceived/queries/PaymentsReceivedPages.service.ts b/packages/server/src/modules/PaymentReceived/queries/PaymentsReceivedPages.service.ts index 942ad952b..06fc22cfb 100644 --- a/packages/server/src/modules/PaymentReceived/queries/PaymentsReceivedPages.service.ts +++ b/packages/server/src/modules/PaymentReceived/queries/PaymentsReceivedPages.service.ts @@ -18,7 +18,7 @@ export class PaymentsReceivedPagesService { @Inject(PaymentReceived.name) private readonly paymentReceived: TenantModelProxy, - ) { } + ) {} /** * Retrive page invoices entries from the given sale invoices models. diff --git a/packages/server/src/modules/PaymentReceived/subscribers/PaymentReceivedGLEntriesSubscriber.ts b/packages/server/src/modules/PaymentReceived/subscribers/PaymentReceivedGLEntriesSubscriber.ts index a5721c241..d2cce1c46 100644 --- a/packages/server/src/modules/PaymentReceived/subscribers/PaymentReceivedGLEntriesSubscriber.ts +++ b/packages/server/src/modules/PaymentReceived/subscribers/PaymentReceivedGLEntriesSubscriber.ts @@ -11,7 +11,7 @@ import { events } from '@/common/events/events'; @Injectable() export class PaymentReceivedGLEntriesSubscriber { /** - * @param {PaymentReceivedGLEntries} paymentReceivedGLEntries - + * @param {PaymentReceivedGLEntries} paymentReceivedGLEntries - */ constructor( private readonly paymentReceivedGLEntries: PaymentReceivedGLEntries, diff --git a/packages/server/src/modules/PaymentReceived/subscribers/PaymentReceivedSyncInvoices.ts b/packages/server/src/modules/PaymentReceived/subscribers/PaymentReceivedSyncInvoices.ts index 297fd80ef..563f1ada6 100644 --- a/packages/server/src/modules/PaymentReceived/subscribers/PaymentReceivedSyncInvoices.ts +++ b/packages/server/src/modules/PaymentReceived/subscribers/PaymentReceivedSyncInvoices.ts @@ -1,4 +1,3 @@ - import { IPaymentReceivedCreatedPayload, IPaymentReceivedDeletedPayload, @@ -12,7 +11,7 @@ import { events } from '@/common/events/events'; @Injectable() export class PaymentReceivedSyncInvoicesSubscriber { /** - * @param {PaymentReceivedInvoiceSync} paymentSyncInvoice - + * @param {PaymentReceivedInvoiceSync} paymentSyncInvoice - */ constructor( private readonly paymentSyncInvoice: PaymentReceivedInvoiceSync, @@ -30,7 +29,7 @@ export class PaymentReceivedSyncInvoicesSubscriber { await this.paymentSyncInvoice.saveChangeInvoicePaymentAmount( paymentReceive.entries, null, - trx + trx, ); } @@ -46,7 +45,7 @@ export class PaymentReceivedSyncInvoicesSubscriber { await this.paymentSyncInvoice.saveChangeInvoicePaymentAmount( paymentReceive.entries, oldPaymentReceive?.entries || null, - trx + trx, ); } @@ -65,7 +64,7 @@ export class PaymentReceivedSyncInvoicesSubscriber { paymentAmount: 0, })), oldPaymentReceive.entries, - trx + trx, ); - }; + } } diff --git a/packages/server/src/modules/PaymentReceived/types/PaymentReceived.types.ts b/packages/server/src/modules/PaymentReceived/types/PaymentReceived.types.ts index 8da0c3565..3f0f1e16c 100644 --- a/packages/server/src/modules/PaymentReceived/types/PaymentReceived.types.ts +++ b/packages/server/src/modules/PaymentReceived/types/PaymentReceived.types.ts @@ -9,7 +9,6 @@ import { import { TenantJobPayload } from '@/interfaces/Tenant'; import { EditPaymentReceivedDto } from '../dtos/PaymentReceived.dto'; - export interface IPaymentReceivedEntryDTO { id?: number; index?: number; @@ -18,7 +17,6 @@ export interface IPaymentReceivedEntryDTO { paymentAmount: number; } - export interface IPaymentReceivedCreateDTO { customerId: number; paymentDate: Date | string; diff --git a/packages/server/src/modules/PaymentReceived/utils.ts b/packages/server/src/modules/PaymentReceived/utils.ts index 7bb14dbd6..25a7ccfd1 100644 --- a/packages/server/src/modules/PaymentReceived/utils.ts +++ b/packages/server/src/modules/PaymentReceived/utils.ts @@ -1,12 +1,10 @@ // @ts-nocheck import { PaymentReceived } from './models/PaymentReceived'; -import { - PaymentReceivedPdfTemplateAttributes, -} from './types/PaymentReceived.types'; +import { PaymentReceivedPdfTemplateAttributes } from './types/PaymentReceived.types'; import { contactAddressTextFormat } from '@/utils/address-text-format'; export const transformPaymentReceivedToPdfTemplate = ( - payment: PaymentReceived + payment: PaymentReceived, ): Partial => { return { total: payment.formattedAmount, diff --git a/packages/server/src/modules/PaymentServices/models/TransactionPaymentServiceEntry.model.ts b/packages/server/src/modules/PaymentServices/models/TransactionPaymentServiceEntry.model.ts index e1120dd84..c2c15ef1d 100644 --- a/packages/server/src/modules/PaymentServices/models/TransactionPaymentServiceEntry.model.ts +++ b/packages/server/src/modules/PaymentServices/models/TransactionPaymentServiceEntry.model.ts @@ -8,7 +8,7 @@ export class TransactionPaymentServiceEntry extends BaseModel { readonly paymentIntegrationId!: number; readonly enable!: boolean; readonly options!: Record; - + readonly paymentIntegration: PaymentIntegration; /** diff --git a/packages/server/src/modules/PaymentServices/queries/GetPaymentMethodsState.ts b/packages/server/src/modules/PaymentServices/queries/GetPaymentMethodsState.ts index 9af65ee8d..98200fd5c 100644 --- a/packages/server/src/modules/PaymentServices/queries/GetPaymentMethodsState.ts +++ b/packages/server/src/modules/PaymentServices/queries/GetPaymentMethodsState.ts @@ -15,7 +15,7 @@ export class GetPaymentMethodsStateService { private readonly paymentIntegrationModel: TenantModelProxy< typeof PaymentIntegration >, - ) { } + ) {} /** * Retrieves the payment state provising state. diff --git a/packages/server/src/modules/PdfTemplate/PdfTemplate.application.ts b/packages/server/src/modules/PdfTemplate/PdfTemplate.application.ts index dda6c90d7..e4b9d4222 100644 --- a/packages/server/src/modules/PdfTemplate/PdfTemplate.application.ts +++ b/packages/server/src/modules/PdfTemplate/PdfTemplate.application.ts @@ -70,10 +70,7 @@ export class PdfTemplateApplication { * @param {number} templateId - The ID of the template to edit. * @param {IEditPdfTemplateDTO} editDTO - The data transfer object containing the updates. */ - public editPdfTemplate( - templateId: number, - editDTO: IEditPdfTemplateDTO, - ) { + public editPdfTemplate(templateId: number, editDTO: IEditPdfTemplateDTO) { return this.editPdfTemplateService.editPdfTemplate(templateId, editDTO); } diff --git a/packages/server/src/modules/PdfTemplate/PdfTemplates.module.ts b/packages/server/src/modules/PdfTemplate/PdfTemplates.module.ts index 81df06a8a..b4781c9bb 100644 --- a/packages/server/src/modules/PdfTemplate/PdfTemplates.module.ts +++ b/packages/server/src/modules/PdfTemplate/PdfTemplates.module.ts @@ -35,7 +35,7 @@ import { AttachmentsModule } from '../Attachments/Attachment.module'; TransformerInjectable, BrandingTemplateDTOTransformer, GetOrganizationBrandingAttributesService, - GetPdfTemplateBrandingState + GetPdfTemplateBrandingState, ], }) export class PdfTemplatesModule {} diff --git a/packages/server/src/modules/PdfTemplate/queries/GetPdfTemplate.transformer.ts b/packages/server/src/modules/PdfTemplate/queries/GetPdfTemplate.transformer.ts index 6d3ef895f..e5c018274 100644 --- a/packages/server/src/modules/PdfTemplate/queries/GetPdfTemplate.transformer.ts +++ b/packages/server/src/modules/PdfTemplate/queries/GetPdfTemplate.transformer.ts @@ -1,5 +1,5 @@ // import { getTransactionTypeLabel } from '@/utils/transactions-types'; -import { Transformer } from "../../Transformer/Transformer"; +import { Transformer } from '../../Transformer/Transformer'; export class GetPdfTemplateTransformer extends Transformer { /** @@ -7,7 +7,12 @@ export class GetPdfTemplateTransformer extends Transformer { * @returns {string[]} */ public includeAttributes = (): string[] => { - return ['createdAtFormatted', 'resourceFormatted', 'attributes', 'companyLogoUri']; + return [ + 'createdAtFormatted', + 'resourceFormatted', + 'attributes', + 'companyLogoUri', + ]; }; /** @@ -45,7 +50,7 @@ export class GetPdfTemplateTransformer extends Transformer { protected attributes = (template) => { return this.item( template.attributes, - new GetPdfTemplateAttributesTransformer() + new GetPdfTemplateAttributesTransformer(), ); }; } diff --git a/packages/server/src/modules/PdfTemplate/queries/GetPdfTemplateBrandingState.service.ts b/packages/server/src/modules/PdfTemplate/queries/GetPdfTemplateBrandingState.service.ts index 1ff7ef33e..fd922743b 100644 --- a/packages/server/src/modules/PdfTemplate/queries/GetPdfTemplateBrandingState.service.ts +++ b/packages/server/src/modules/PdfTemplate/queries/GetPdfTemplateBrandingState.service.ts @@ -8,8 +8,7 @@ export class GetPdfTemplateBrandingState { ) {} async execute() { - const brandingAttributes = - await this.getOrgBrandingAttributes.execute(); + const brandingAttributes = await this.getOrgBrandingAttributes.execute(); return brandingAttributes; } diff --git a/packages/server/src/modules/PdfTemplate/queries/GetPdfTemplates.transformer.ts b/packages/server/src/modules/PdfTemplate/queries/GetPdfTemplates.transformer.ts index d727dd661..6e0f8528c 100644 --- a/packages/server/src/modules/PdfTemplate/queries/GetPdfTemplates.transformer.ts +++ b/packages/server/src/modules/PdfTemplate/queries/GetPdfTemplates.transformer.ts @@ -1,5 +1,5 @@ // import { getTransactionTypeLabel } from '@/utils/transactions-types'; -import { Transformer } from "../../Transformer/Transformer"; +import { Transformer } from '../../Transformer/Transformer'; export class GetPdfTemplatesTransformer extends Transformer { /** diff --git a/packages/server/src/modules/Resource/Resource.module.ts b/packages/server/src/modules/Resource/Resource.module.ts index f919a8dc1..06b49a3e0 100644 --- a/packages/server/src/modules/Resource/Resource.module.ts +++ b/packages/server/src/modules/Resource/Resource.module.ts @@ -10,6 +10,6 @@ import { ResourceController } from './Resource.controller'; imports: [BranchesModule, WarehousesModule, AccountsModule], providers: [ResourceService], exports: [ResourceService], - controllers: [ResourceController] + controllers: [ResourceController], }) export class ResourceModule {} diff --git a/packages/server/src/modules/Resource/ResourceService.ts b/packages/server/src/modules/Resource/ResourceService.ts index c888e2076..eafb2329b 100644 --- a/packages/server/src/modules/Resource/ResourceService.ts +++ b/packages/server/src/modules/Resource/ResourceService.ts @@ -22,7 +22,7 @@ export class ResourceService { private readonly warehousesSettings: WarehousesSettings, private readonly moduleRef: ModuleRef, private readonly i18nService: I18nService, - ) { } + ) {} /** * Retrieve resource model object. diff --git a/packages/server/src/modules/Roles/AbilitySchema.ts b/packages/server/src/modules/Roles/AbilitySchema.ts index 36c35cf71..91f227d74 100644 --- a/packages/server/src/modules/Roles/AbilitySchema.ts +++ b/packages/server/src/modules/Roles/AbilitySchema.ts @@ -1,21 +1,28 @@ -import { ItemAction } from "@/interfaces/Item"; -import { ReportsAction } from "../FinancialStatements/types/Report.types"; -import { InventoryAdjustmentAction } from "../InventoryAdjutments/types/InventoryAdjustments.types"; -import { CashflowAction } from "../BankingTransactions/types/BankingTransactions.types"; -import { ManualJournalAction } from "../ManualJournals/types/ManualJournals.types"; -import { AccountAction } from "@/interfaces/Account"; -import { VendorCreditAction } from "../VendorCredit/types/VendorCredit.types"; -import { IPaymentMadeAction } from "../BillPayments/types/BillPayments.types"; -import { ExpenseAction } from "../Expenses/Expenses.types"; -import { CustomerAction, VendorAction } from "../Customers/types/Customers.types"; -import { SaleEstimateAction } from "../SaleEstimates/types/SaleEstimates.types"; -import { SaleInvoiceAction } from "../SaleInvoices/SaleInvoice.types"; -import { CreditNoteAction } from "../CreditNotes/types/CreditNotes.types"; -import { SaleReceiptAction } from "../SaleReceipts/types/SaleReceipts.types"; -import { BillAction } from "../Bills/Bills.types"; -import { AbilitySubject, ISubjectAbilitiesSchema, ISubjectAbilitySchema } from "./Roles.types"; -import { PaymentReceiveAction } from "../PaymentReceived/types/PaymentReceived.types"; -import { PreferencesAction } from "../Settings/Settings.types"; +import { ItemAction } from '@/interfaces/Item'; +import { ReportsAction } from '../FinancialStatements/types/Report.types'; +import { InventoryAdjustmentAction } from '../InventoryAdjutments/types/InventoryAdjustments.types'; +import { CashflowAction } from '../BankingTransactions/types/BankingTransactions.types'; +import { ManualJournalAction } from '../ManualJournals/types/ManualJournals.types'; +import { AccountAction } from '@/interfaces/Account'; +import { VendorCreditAction } from '../VendorCredit/types/VendorCredit.types'; +import { IPaymentMadeAction } from '../BillPayments/types/BillPayments.types'; +import { ExpenseAction } from '../Expenses/Expenses.types'; +import { + CustomerAction, + VendorAction, +} from '../Customers/types/Customers.types'; +import { SaleEstimateAction } from '../SaleEstimates/types/SaleEstimates.types'; +import { SaleInvoiceAction } from '../SaleInvoices/SaleInvoice.types'; +import { CreditNoteAction } from '../CreditNotes/types/CreditNotes.types'; +import { SaleReceiptAction } from '../SaleReceipts/types/SaleReceipts.types'; +import { BillAction } from '../Bills/Bills.types'; +import { + AbilitySubject, + ISubjectAbilitiesSchema, + ISubjectAbilitySchema, +} from './Roles.types'; +import { PaymentReceiveAction } from '../PaymentReceived/types/PaymentReceived.types'; +import { PreferencesAction } from '../Settings/Settings.types'; export const AbilitySchema: ISubjectAbilitiesSchema[] = [ { @@ -313,7 +320,7 @@ export const AbilitySchema: ISubjectAbilitiesSchema[] = [ * @returns {ISubjectAbilitiesSchema | null} */ export const getPermissionsSubject = ( - key: string + key: string, ): ISubjectAbilitiesSchema | null => { return AbilitySchema.find((subject) => subject.subject === key); }; @@ -326,7 +333,7 @@ export const getPermissionsSubject = ( */ export const getPermissionAbility = ( subjectKey: string, - abilityKey: string + abilityKey: string, ): ISubjectAbilitySchema | null => { const subject = getPermissionsSubject(subjectKey); diff --git a/packages/server/src/modules/Roles/Authorization.guard.ts b/packages/server/src/modules/Roles/Authorization.guard.ts index 5f863c509..3e16f9142 100644 --- a/packages/server/src/modules/Roles/Authorization.guard.ts +++ b/packages/server/src/modules/Roles/Authorization.guard.ts @@ -21,7 +21,7 @@ export class AuthorizationGuard implements CanActivate { @Inject(TenantUser.name) private readonly tenantUserModel: TenantModelProxy, - ) { } + ) {} /** * Checks if the user has the required abilities to access the route diff --git a/packages/server/src/modules/Roles/Permission.guard.ts b/packages/server/src/modules/Roles/Permission.guard.ts index 51aa72833..2328a0856 100644 --- a/packages/server/src/modules/Roles/Permission.guard.ts +++ b/packages/server/src/modules/Roles/Permission.guard.ts @@ -6,7 +6,10 @@ import { } from '@nestjs/common'; import { Reflector } from '@nestjs/core'; import { Request } from 'express'; -import { REQUIRED_PERMISSION_KEY, RequiredPermission } from './RequirePermission.decorator'; +import { + REQUIRED_PERMISSION_KEY, + RequiredPermission, +} from './RequirePermission.decorator'; import { AbilitySubject } from './Roles.types'; /** @@ -24,10 +27,11 @@ export class PermissionGuard implements CanActivate { * @throws ForbiddenException if the user doesn't have the required permission */ canActivate(context: ExecutionContext): boolean { - const requiredPermission = this.reflector.getAllAndOverride( - REQUIRED_PERMISSION_KEY, - [context.getHandler(), context.getClass()], - ); + const requiredPermission = + this.reflector.getAllAndOverride( + REQUIRED_PERMISSION_KEY, + [context.getHandler(), context.getClass()], + ); // If no permission is required, allow access if (!requiredPermission) { @@ -39,7 +43,9 @@ export class PermissionGuard implements CanActivate { // If no ability instance is attached to the request, deny access if (!ability) { - throw new ForbiddenException('Ability instance not found. Ensure AuthorizationGuard is applied.'); + throw new ForbiddenException( + 'Ability instance not found. Ensure AuthorizationGuard is applied.', + ); } const { ability: action, subject } = requiredPermission; diff --git a/packages/server/src/modules/Roles/Roles.controller.ts b/packages/server/src/modules/Roles/Roles.controller.ts index ccd1e72a1..88a1c2a8a 100644 --- a/packages/server/src/modules/Roles/Roles.controller.ts +++ b/packages/server/src/modules/Roles/Roles.controller.ts @@ -28,7 +28,7 @@ import { ApiCommonHeaders } from '@/common/decorators/ApiCommonHeaders'; @ApiExtraModels(RoleResponseDto) @ApiCommonHeaders() export class RolesController { - constructor(private readonly rolesApp: RolesApplication) { } + constructor(private readonly rolesApp: RolesApplication) {} @Post() @ApiOperation({ summary: 'Create a new role' }) diff --git a/packages/server/src/modules/Roles/Roles.types.ts b/packages/server/src/modules/Roles/Roles.types.ts index 258b76509..b126f8bed 100644 --- a/packages/server/src/modules/Roles/Roles.types.ts +++ b/packages/server/src/modules/Roles/Roles.types.ts @@ -13,11 +13,11 @@ export const actions = [ export const subjects = ['Article', 'all'] as const; export type Abilities = [ - typeof actions[number], + (typeof actions)[number], ( - | typeof subjects[number] - | ForcedSubject> - ) + | (typeof subjects)[number] + | ForcedSubject> + ), ]; export type AppAbility = Ability; @@ -25,7 +25,6 @@ export type AppAbility = Ability; export const createAbility = (rules: RawRuleOf[]) => new Ability(rules); - export interface ISubjectAbilitySchema { key: string; label: string; @@ -60,7 +59,7 @@ export enum AbilitySubject { CreditNote = 'CreditNode', VendorCredit = 'VendorCredit', Project = 'Project', - TaxRate = 'TaxRate' + TaxRate = 'TaxRate', } export interface IRoleCreatedPayload { diff --git a/packages/server/src/modules/Roles/TenantAbilities.ts b/packages/server/src/modules/Roles/TenantAbilities.ts index bf27d4da7..4d79a8355 100644 --- a/packages/server/src/modules/Roles/TenantAbilities.ts +++ b/packages/server/src/modules/Roles/TenantAbilities.ts @@ -52,4 +52,4 @@ function getRulesFromRolePermissions(permissions: RolePermission[]) { subject: permission.subject, }; }); -} \ No newline at end of file +} diff --git a/packages/server/src/modules/Roles/commands/EditRole.service.ts b/packages/server/src/modules/Roles/commands/EditRole.service.ts index a7ab3b566..59ea5b4e0 100644 --- a/packages/server/src/modules/Roles/commands/EditRole.service.ts +++ b/packages/server/src/modules/Roles/commands/EditRole.service.ts @@ -17,7 +17,7 @@ export class EditRoleService { @Inject(Role.name) private readonly roleModel: TenantModelProxy, - ) { } + ) {} /** * Edits details of the given role on the storage. diff --git a/packages/server/src/modules/Roles/constants.ts b/packages/server/src/modules/Roles/constants.ts index 39d1d768f..67523c6bb 100644 --- a/packages/server/src/modules/Roles/constants.ts +++ b/packages/server/src/modules/Roles/constants.ts @@ -2,5 +2,6 @@ export const ERRORS = { ROLE_NOT_FOUND: 'ROLE_NOT_FOUND', ROLE_PREFINED: 'ROLE_PREFINED', INVALIDATE_PERMISSIONS: 'INVALIDATE_PERMISSIONS', - CANNT_DELETE_ROLE_ASSOCIATED_TO_USERS: 'CANNT_DELETE_ROLE_ASSOCIATED_TO_USERS' + CANNT_DELETE_ROLE_ASSOCIATED_TO_USERS: + 'CANNT_DELETE_ROLE_ASSOCIATED_TO_USERS', }; diff --git a/packages/server/src/modules/Roles/dtos/Role.dto.ts b/packages/server/src/modules/Roles/dtos/Role.dto.ts index 3ef300553..4afdb4d00 100644 --- a/packages/server/src/modules/Roles/dtos/Role.dto.ts +++ b/packages/server/src/modules/Roles/dtos/Role.dto.ts @@ -39,7 +39,7 @@ export class CommandRolePermissionDto { value: boolean; } -export class CreateRolePermissionDto extends CommandRolePermissionDto { } +export class CreateRolePermissionDto extends CommandRolePermissionDto {} export class EditRolePermissionDto extends CommandRolePermissionDto { @IsNumber() @IsOptional() diff --git a/packages/server/src/modules/Roles/models/RolePermission.model.ts b/packages/server/src/modules/Roles/models/RolePermission.model.ts index 1bd6dc313..1aec105de 100644 --- a/packages/server/src/modules/Roles/models/RolePermission.model.ts +++ b/packages/server/src/modules/Roles/models/RolePermission.model.ts @@ -28,7 +28,7 @@ export class RolePermission extends TenantBaseModel { return { /** - * + * */ role: { relation: Model.BelongsToOneRelation, diff --git a/packages/server/src/modules/SaleEstimates/BulkDeleteSaleEstimates.service.ts b/packages/server/src/modules/SaleEstimates/BulkDeleteSaleEstimates.service.ts index e5dc864e5..b612a6419 100644 --- a/packages/server/src/modules/SaleEstimates/BulkDeleteSaleEstimates.service.ts +++ b/packages/server/src/modules/SaleEstimates/BulkDeleteSaleEstimates.service.ts @@ -6,7 +6,7 @@ import { DeleteSaleEstimate } from './commands/DeleteSaleEstimate.service'; @Injectable() export class BulkDeleteSaleEstimatesService { - constructor(private readonly deleteSaleEstimateService: DeleteSaleEstimate) { } + constructor(private readonly deleteSaleEstimateService: DeleteSaleEstimate) {} async bulkDeleteSaleEstimates( saleEstimateIds: number | Array, @@ -33,4 +33,3 @@ export class BulkDeleteSaleEstimatesService { } } } - diff --git a/packages/server/src/modules/SaleEstimates/SaleEstimates.application.ts b/packages/server/src/modules/SaleEstimates/SaleEstimates.application.ts index f81042a8d..8888dc845 100644 --- a/packages/server/src/modules/SaleEstimates/SaleEstimates.application.ts +++ b/packages/server/src/modules/SaleEstimates/SaleEstimates.application.ts @@ -39,7 +39,7 @@ export class SaleEstimatesApplication { private readonly getSaleEstimateMailStateService: GetSaleEstimateMailStateService, private readonly bulkDeleteSaleEstimatesService: BulkDeleteSaleEstimatesService, private readonly validateBulkDeleteSaleEstimatesService: ValidateBulkDeleteSaleEstimatesService, - ) { } + ) {} /** * Create a sale estimate. diff --git a/packages/server/src/modules/SaleEstimates/SaleEstimates.controller.ts b/packages/server/src/modules/SaleEstimates/SaleEstimates.controller.ts index fda590534..ad5a2d1ff 100644 --- a/packages/server/src/modules/SaleEstimates/SaleEstimates.controller.ts +++ b/packages/server/src/modules/SaleEstimates/SaleEstimates.controller.ts @@ -97,7 +97,7 @@ export class SaleEstimatesController { */ constructor( private readonly saleEstimatesApplication: SaleEstimatesApplication, - ) { } + ) {} @Post() @RequirePermission(SaleEstimateAction.Create, AbilitySubject.SaleEstimate) @@ -250,7 +250,10 @@ export class SaleEstimatesController { } @Post(':id/notify-sms') - @RequirePermission(SaleEstimateAction.NotifyBySms, AbilitySubject.SaleEstimate) + @RequirePermission( + SaleEstimateAction.NotifyBySms, + AbilitySubject.SaleEstimate, + ) @ApiOperation({ summary: 'Notify the given sale estimate by SMS.' }) @ApiParam({ name: 'id', diff --git a/packages/server/src/modules/SaleEstimates/SaleEstimatesImportable.ts b/packages/server/src/modules/SaleEstimates/SaleEstimatesImportable.ts index f60c8e2a2..2b216f534 100644 --- a/packages/server/src/modules/SaleEstimates/SaleEstimatesImportable.ts +++ b/packages/server/src/modules/SaleEstimates/SaleEstimatesImportable.ts @@ -9,10 +9,8 @@ import { SaleEstimate } from './models/SaleEstimate'; @Injectable() @ImportableService({ name: SaleEstimate.name }) -export class SaleEstimatesImportable extends Importable{ - constructor( - private readonly createEstimateService: CreateSaleEstimate - ) { +export class SaleEstimatesImportable extends Importable { + constructor(private readonly createEstimateService: CreateSaleEstimate) { super(); } @@ -23,12 +21,9 @@ export class SaleEstimatesImportable extends Importable{ */ public importable( createEstimateDTO: CreateSaleEstimateDto, - trx?: Knex.Transaction + trx?: Knex.Transaction, ) { - return this.createEstimateService.createEstimate( - createEstimateDTO, - trx - ); + return this.createEstimateService.createEstimate(createEstimateDTO, trx); } /** diff --git a/packages/server/src/modules/SaleEstimates/ValidateBulkDeleteSaleEstimates.service.ts b/packages/server/src/modules/SaleEstimates/ValidateBulkDeleteSaleEstimates.service.ts index 3ab7609d0..3b0893fef 100644 --- a/packages/server/src/modules/SaleEstimates/ValidateBulkDeleteSaleEstimates.service.ts +++ b/packages/server/src/modules/SaleEstimates/ValidateBulkDeleteSaleEstimates.service.ts @@ -9,7 +9,7 @@ export class ValidateBulkDeleteSaleEstimatesService { private readonly deleteSaleEstimateService: DeleteSaleEstimate, @Inject(TENANCY_DB_CONNECTION) private readonly tenantKnex: () => Knex, - ) { } + ) {} public async validateBulkDeleteSaleEstimates( saleEstimateIds: number[], diff --git a/packages/server/src/modules/SaleEstimates/commands/DeleteSaleEstimate.service.ts b/packages/server/src/modules/SaleEstimates/commands/DeleteSaleEstimate.service.ts index 5a1e5b5ff..1e7559ba2 100644 --- a/packages/server/src/modules/SaleEstimates/commands/DeleteSaleEstimate.service.ts +++ b/packages/server/src/modules/SaleEstimates/commands/DeleteSaleEstimate.service.ts @@ -24,7 +24,7 @@ export class DeleteSaleEstimate { private readonly eventPublisher: EventEmitter2, private readonly uow: UnitOfWork, - ) { } + ) {} /** * Deletes the given estimate id with associated entries. diff --git a/packages/server/src/modules/SaleEstimates/commands/SendSaleEstimateMail.ts b/packages/server/src/modules/SaleEstimates/commands/SendSaleEstimateMail.ts index 3141cbec4..3c040e9c7 100644 --- a/packages/server/src/modules/SaleEstimates/commands/SendSaleEstimateMail.ts +++ b/packages/server/src/modules/SaleEstimates/commands/SendSaleEstimateMail.ts @@ -50,7 +50,7 @@ export class SendSaleEstimateMail { @InjectQueue(SendSaleEstimateMailQueue) private readonly sendEstimateMailQueue: Queue, - ) { } + ) {} /** * Triggers the reminder mail of the given sale estimate. diff --git a/packages/server/src/modules/SaleEstimates/dtos/SaleEstimate.dto.ts b/packages/server/src/modules/SaleEstimates/dtos/SaleEstimate.dto.ts index 544ca2260..821456d5f 100644 --- a/packages/server/src/modules/SaleEstimates/dtos/SaleEstimate.dto.ts +++ b/packages/server/src/modules/SaleEstimates/dtos/SaleEstimate.dto.ts @@ -21,7 +21,7 @@ enum DiscountType { Amount = 'amount', } -class SaleEstimateEntryDto extends ItemEntryDto { } +class SaleEstimateEntryDto extends ItemEntryDto {} class AttachmentDto { @IsString() @@ -178,5 +178,5 @@ export class CommandSaleEstimateDto { adjustment?: number; } -export class CreateSaleEstimateDto extends CommandSaleEstimateDto { } -export class EditSaleEstimateDto extends CommandSaleEstimateDto { } +export class CreateSaleEstimateDto extends CommandSaleEstimateDto {} +export class EditSaleEstimateDto extends CommandSaleEstimateDto {} diff --git a/packages/server/src/modules/SaleEstimates/models/SaleEstimate.meta.ts b/packages/server/src/modules/SaleEstimates/models/SaleEstimate.meta.ts index 567a0be27..8100890b0 100644 --- a/packages/server/src/modules/SaleEstimates/models/SaleEstimate.meta.ts +++ b/packages/server/src/modules/SaleEstimates/models/SaleEstimate.meta.ts @@ -1,4 +1,4 @@ -import { Features } from "@/common/types/Features"; +import { Features } from '@/common/types/Features'; export const SaleEstimateMeta = { defaultFilterField: 'estimate_date', @@ -291,4 +291,4 @@ function StatusFieldSortQuery(query, role) { function StatusFieldFilterQuery(query, role) { query.modify('filterByStatus', role.value); -} \ No newline at end of file +} diff --git a/packages/server/src/modules/SaleEstimates/processes/SendSaleEstimateMail.process.ts b/packages/server/src/modules/SaleEstimates/processes/SendSaleEstimateMail.process.ts index b9fbfc4f1..0794775e9 100644 --- a/packages/server/src/modules/SaleEstimates/processes/SendSaleEstimateMail.process.ts +++ b/packages/server/src/modules/SaleEstimates/processes/SendSaleEstimateMail.process.ts @@ -28,7 +28,10 @@ export class SendSaleEstimateMailProcess extends WorkerHost { this.clsService.set('userId', userId); try { - await this.sendEstimateMailService.sendMail(saleEstimateId, messageOptions); + await this.sendEstimateMailService.sendMail( + saleEstimateId, + messageOptions, + ); } catch (error) { console.error('Failed to process estimate mail job:', error); throw error; diff --git a/packages/server/src/modules/SaleEstimates/queries/GetSaleEstimateMailState.service.ts b/packages/server/src/modules/SaleEstimates/queries/GetSaleEstimateMailState.service.ts index f6f5f40a7..cb1d1ab1a 100644 --- a/packages/server/src/modules/SaleEstimates/queries/GetSaleEstimateMailState.service.ts +++ b/packages/server/src/modules/SaleEstimates/queries/GetSaleEstimateMailState.service.ts @@ -12,7 +12,7 @@ export class GetSaleEstimateMailStateService { private readonly transformer: TransformerInjectable, @Inject(SaleEstimate.name) - private readonly saleEstimateModel: TenantModelProxy + private readonly saleEstimateModel: TenantModelProxy, ) {} /** @@ -21,26 +21,23 @@ export class GetSaleEstimateMailStateService { * @param {number} saleEstimateId * @returns {Promise} */ - async getEstimateMailState( - saleEstimateId: number - ) { - const saleEstimate = await this.saleEstimateModel().query() + async getEstimateMailState(saleEstimateId: number) { + const saleEstimate = await this.saleEstimateModel() + .query() .findById(saleEstimateId) .withGraphFetched('customer') .withGraphFetched('entries.item') .withGraphFetched('pdfTemplate') .throwIfNotFound(); - const mailOptions = await this.estimateMail.getMailOptions( - saleEstimateId - ); + const mailOptions = await this.estimateMail.getMailOptions(saleEstimateId); const transformed = await this.transformer.transform( saleEstimate, new GetSaleEstimateMailStateTransformer(), { mailOptions, - } + }, ); return transformed; } -} \ No newline at end of file +} diff --git a/packages/server/src/modules/SaleEstimates/queries/GetSaleEstimatePdf.ts b/packages/server/src/modules/SaleEstimates/queries/GetSaleEstimatePdf.ts index cb6bfb6b7..da11ff196 100644 --- a/packages/server/src/modules/SaleEstimates/queries/GetSaleEstimatePdf.ts +++ b/packages/server/src/modules/SaleEstimates/queries/GetSaleEstimatePdf.ts @@ -26,7 +26,7 @@ export class GetSaleEstimatePdf { @Inject(SaleEstimate.name) private readonly saleEstimateModel: TenantModelProxy, - ) { } + ) {} /** * Retrieve sale estimate html content. @@ -50,8 +50,7 @@ export class GetSaleEstimatePdf { // Retrieves the sale estimate html. const htmlContent = await this.saleEstimateHtml(saleEstimateId); - const buffer = - await this.chromiumlyTenancy.convertHtmlContent(htmlContent); + const buffer = await this.chromiumlyTenancy.convertHtmlContent(htmlContent); const eventPayload = { saleEstimateId }; diff --git a/packages/server/src/modules/SaleEstimates/queries/SaleEstimate.transformer.ts b/packages/server/src/modules/SaleEstimates/queries/SaleEstimate.transformer.ts index 379a6d6d4..071d4a10c 100644 --- a/packages/server/src/modules/SaleEstimates/queries/SaleEstimate.transformer.ts +++ b/packages/server/src/modules/SaleEstimates/queries/SaleEstimate.transformer.ts @@ -104,8 +104,6 @@ export class SaleEstimateTransfromer extends Transformer { return this.formatNumber(estimate.amount, { money: false }); }; - - /** * Retrieves formatted discount amount. * @param {SaleEstimate} estimate @@ -124,9 +122,7 @@ export class SaleEstimateTransfromer extends Transformer { * @returns {string} */ protected discountPercentageFormatted = (estimate: SaleEstimate): string => { - return estimate.discountPercentage - ? `${estimate.discountPercentage}%` - : ''; + return estimate.discountPercentage ? `${estimate.discountPercentage}%` : ''; }; /** @@ -162,7 +158,6 @@ export class SaleEstimateTransfromer extends Transformer { }); }; - /** * Retrieves the entries of the sale estimate. * @param {ISaleEstimate} estimate diff --git a/packages/server/src/modules/SaleEstimates/subscribers/SaleEstimateAutoIncrementSubscriber.ts b/packages/server/src/modules/SaleEstimates/subscribers/SaleEstimateAutoIncrementSubscriber.ts index 6602579ca..aba932b0a 100644 --- a/packages/server/src/modules/SaleEstimates/subscribers/SaleEstimateAutoIncrementSubscriber.ts +++ b/packages/server/src/modules/SaleEstimates/subscribers/SaleEstimateAutoIncrementSubscriber.ts @@ -6,14 +6,14 @@ import { ISaleEstimateCreatedPayload } from '../types/SaleEstimates.types'; @Injectable() export class SaleEstimateAutoIncrementSubscriber { - constructor(private readonly estimateIncrement: SaleEstimateIncrement) { } + constructor(private readonly estimateIncrement: SaleEstimateIncrement) {} /** * Handles increment next number of estimate once be created. * @param {ISaleEstimateCreatedPayload} payload - */ @OnEvent(events.saleEstimate.onCreated) - private async handleEstimateNextNumberIncrement({ }: ISaleEstimateCreatedPayload) { + private async handleEstimateNextNumberIncrement({}: ISaleEstimateCreatedPayload) { await this.estimateIncrement.incrementNextEstimateNumber(); } } diff --git a/packages/server/src/modules/SaleEstimates/utils.ts b/packages/server/src/modules/SaleEstimates/utils.ts index efd301af3..51e54a093 100644 --- a/packages/server/src/modules/SaleEstimates/utils.ts +++ b/packages/server/src/modules/SaleEstimates/utils.ts @@ -2,7 +2,7 @@ import { contactAddressTextFormat } from '@/utils/address-text-format'; import { EstimatePdfBrandingAttributes } from './constants'; export const transformEstimateToPdfTemplate = ( - estimate + estimate, ): Partial => { return { expirationDate: estimate.formattedExpirationDate, diff --git a/packages/server/src/modules/SaleInvoices/BulkDeleteSaleInvoices.service.ts b/packages/server/src/modules/SaleInvoices/BulkDeleteSaleInvoices.service.ts index 142634787..75f7b6fda 100644 --- a/packages/server/src/modules/SaleInvoices/BulkDeleteSaleInvoices.service.ts +++ b/packages/server/src/modules/SaleInvoices/BulkDeleteSaleInvoices.service.ts @@ -6,7 +6,7 @@ import { DeleteSaleInvoice } from './commands/DeleteSaleInvoice.service'; @Injectable() export class BulkDeleteSaleInvoicesService { - constructor(private readonly deleteSaleInvoiceService: DeleteSaleInvoice) { } + constructor(private readonly deleteSaleInvoiceService: DeleteSaleInvoice) {} async bulkDeleteSaleInvoices( saleInvoiceIds: number | Array, diff --git a/packages/server/src/modules/SaleInvoices/InvoiceInventoryTransactions.ts b/packages/server/src/modules/SaleInvoices/InvoiceInventoryTransactions.ts index ebbac3223..5f3e862f7 100644 --- a/packages/server/src/modules/SaleInvoices/InvoiceInventoryTransactions.ts +++ b/packages/server/src/modules/SaleInvoices/InvoiceInventoryTransactions.ts @@ -25,7 +25,7 @@ export class InvoiceInventoryTransactions { saleInvoice: ModelObject, override?: boolean, trx?: Knex.Transaction, -): Promise { + ): Promise { // Loads the inventory items entries of the given sale invoice. const inventoryEntries = await this.itemsEntriesService.filterInventoryEntries( diff --git a/packages/server/src/modules/SaleInvoices/InvoicePaymentsGLRewrite.ts b/packages/server/src/modules/SaleInvoices/InvoicePaymentsGLRewrite.ts index b266e1582..1aecc0998 100644 --- a/packages/server/src/modules/SaleInvoices/InvoicePaymentsGLRewrite.ts +++ b/packages/server/src/modules/SaleInvoices/InvoicePaymentsGLRewrite.ts @@ -11,7 +11,9 @@ export class InvoicePaymentsGLEntriesRewrite { private readonly paymentGLEntries: PaymentReceivedGLEntries, @Inject(PaymentReceivedEntry.name) - private readonly paymentReceivedEntryModel: TenantModelProxy + private readonly paymentReceivedEntryModel: TenantModelProxy< + typeof PaymentReceivedEntry + >, ) {} /** @@ -19,14 +21,8 @@ export class InvoicePaymentsGLEntriesRewrite { * @param {{ tenantId: number, paymentId: number, trx: Knex?.Transaction }} * @returns {Promise} */ - public rewritePaymentsGLEntriesTask = async ({ - paymentId, - trx, - }) => { - await this.paymentGLEntries.rewritePaymentGLEntries( - paymentId, - trx - ); + public rewritePaymentsGLEntriesTask = async ({ paymentId, trx }) => { + await this.paymentGLEntries.rewritePaymentGLEntries(paymentId, trx); }; /** @@ -36,7 +32,7 @@ export class InvoicePaymentsGLEntriesRewrite { */ public rewritePaymentsGLEntriesQueue = async ( paymentsIds: number[], - trx?: Knex.Transaction + trx?: Knex.Transaction, ) => { // Initiate a new queue for accounts balance mutation. const rewritePaymentGL = async.queue(this.rewritePaymentsGLEntriesTask, 10); @@ -57,7 +53,7 @@ export class InvoicePaymentsGLEntriesRewrite { */ public invoicePaymentsGLEntriesRewrite = async ( invoiceId: number, - trx?: Knex.Transaction + trx?: Knex.Transaction, ) => { const invoicePaymentEntries = await this.paymentReceivedEntryModel() .query() diff --git a/packages/server/src/modules/SaleInvoices/SaleInvoiceCostGLEntries.ts b/packages/server/src/modules/SaleInvoices/SaleInvoiceCostGLEntries.ts index d2e0ca93f..9d129a3ff 100644 --- a/packages/server/src/modules/SaleInvoices/SaleInvoiceCostGLEntries.ts +++ b/packages/server/src/modules/SaleInvoices/SaleInvoiceCostGLEntries.ts @@ -19,7 +19,7 @@ export class SaleInvoiceCostGLEntries { private readonly inventoryCostLotTracker: TenantModelProxy< typeof InventoryCostLotTracker >, - ) { } + ) {} /** * Writes journal entries from sales invoices. diff --git a/packages/server/src/modules/SaleInvoices/SaleInvoices.application.ts b/packages/server/src/modules/SaleInvoices/SaleInvoices.application.ts index 7c2a2d193..31527d774 100644 --- a/packages/server/src/modules/SaleInvoices/SaleInvoices.application.ts +++ b/packages/server/src/modules/SaleInvoices/SaleInvoices.application.ts @@ -45,7 +45,7 @@ export class SaleInvoiceApplication { private generateShareLinkService: GenerateShareLink, private bulkDeleteSaleInvoicesService: BulkDeleteSaleInvoicesService, private validateBulkDeleteSaleInvoicesService: ValidateBulkDeleteSaleInvoicesService, - ) { } + ) {} /** * Creates a new sale invoice with associated GL entries. diff --git a/packages/server/src/modules/SaleInvoices/SaleInvoices.controller.ts b/packages/server/src/modules/SaleInvoices/SaleInvoices.controller.ts index 73760252f..2a8627dc4 100644 --- a/packages/server/src/modules/SaleInvoices/SaleInvoices.controller.ts +++ b/packages/server/src/modules/SaleInvoices/SaleInvoices.controller.ts @@ -60,7 +60,7 @@ import { SaleInvoiceAction } from './SaleInvoice.types'; @ApiExtraModels(ValidateBulkDeleteResponseDto) @UseGuards(AuthorizationGuard, PermissionGuard) export class SaleInvoicesController { - constructor(private saleInvoiceApplication: SaleInvoiceApplication) { } + constructor(private saleInvoiceApplication: SaleInvoiceApplication) {} @Post('validate-bulk-delete') @RequirePermission(SaleInvoiceAction.Delete, AbilitySubject.SaleInvoice) diff --git a/packages/server/src/modules/SaleInvoices/ValidateBulkDeleteSaleInvoices.service.ts b/packages/server/src/modules/SaleInvoices/ValidateBulkDeleteSaleInvoices.service.ts index 167369f83..0fce703e8 100644 --- a/packages/server/src/modules/SaleInvoices/ValidateBulkDeleteSaleInvoices.service.ts +++ b/packages/server/src/modules/SaleInvoices/ValidateBulkDeleteSaleInvoices.service.ts @@ -9,9 +9,11 @@ export class ValidateBulkDeleteSaleInvoicesService { private readonly deleteSaleInvoiceService: DeleteSaleInvoice, @Inject(TENANCY_DB_CONNECTION) private readonly tenantKnex: () => Knex, - ) { } + ) {} - public async validateBulkDeleteSaleInvoices(saleInvoiceIds: number[]): Promise<{ + public async validateBulkDeleteSaleInvoices( + saleInvoiceIds: number[], + ): Promise<{ deletableCount: number; nonDeletableCount: number; deletableIds: number[]; @@ -51,4 +53,3 @@ export class ValidateBulkDeleteSaleInvoicesService { } } } - diff --git a/packages/server/src/modules/SaleInvoices/commands/DeleteSaleInvoice.service.ts b/packages/server/src/modules/SaleInvoices/commands/DeleteSaleInvoice.service.ts index d586f6f9e..88dbbeb32 100644 --- a/packages/server/src/modules/SaleInvoices/commands/DeleteSaleInvoice.service.ts +++ b/packages/server/src/modules/SaleInvoices/commands/DeleteSaleInvoice.service.ts @@ -47,7 +47,7 @@ export class DeleteSaleInvoice { @Inject(ItemEntry.name) private itemEntryModel: TenantModelProxy, - ) { } + ) {} /** * Validate the sale invoice has no payment entries. diff --git a/packages/server/src/modules/SaleInvoices/commands/GenerateInvoicePaymentLink.service.ts b/packages/server/src/modules/SaleInvoices/commands/GenerateInvoicePaymentLink.service.ts index 7b6662842..11a50ac64 100644 --- a/packages/server/src/modules/SaleInvoices/commands/GenerateInvoicePaymentLink.service.ts +++ b/packages/server/src/modules/SaleInvoices/commands/GenerateInvoicePaymentLink.service.ts @@ -26,7 +26,7 @@ export class GenerateShareLink { @Inject(PaymentLink.name) private paymentLinkModel: typeof PaymentLink, - ) { } + ) {} /** * Generates private or public payment link for the given sale invoice. @@ -79,7 +79,7 @@ export class GenerateShareLink { new GeneratePaymentLinkTransformer(), { baseUrl: this.configService.get('app.baseUrl'), - } + }, ); }); } diff --git a/packages/server/src/modules/SaleInvoices/commands/SaleInvoicesExportable.ts b/packages/server/src/modules/SaleInvoices/commands/SaleInvoicesExportable.ts index 4d8df9c25..c0c55260e 100644 --- a/packages/server/src/modules/SaleInvoices/commands/SaleInvoicesExportable.ts +++ b/packages/server/src/modules/SaleInvoices/commands/SaleInvoicesExportable.ts @@ -8,7 +8,7 @@ import { SaleInvoice } from '../models/SaleInvoice'; @Injectable() @ExportableService({ name: SaleInvoice.name }) -export class SaleInvoicesExportable extends Exportable{ +export class SaleInvoicesExportable extends Exportable { constructor( private readonly saleInvoicesApplication: SaleInvoiceApplication, ) { diff --git a/packages/server/src/modules/SaleInvoices/commands/SendSaleInvoiceMail.ts b/packages/server/src/modules/SaleInvoices/commands/SendSaleInvoiceMail.ts index 1323a9bcf..dd51491eb 100644 --- a/packages/server/src/modules/SaleInvoices/commands/SendSaleInvoiceMail.ts +++ b/packages/server/src/modules/SaleInvoices/commands/SendSaleInvoiceMail.ts @@ -33,7 +33,7 @@ export class SendSaleInvoiceMail { private readonly tenancyContect: TenancyContext, @InjectQueue(SendSaleInvoiceQueue) private readonly sendInvoiceQueue: Queue, - ) { } + ) {} /** * Sends the invoice mail of the given sale invoice. diff --git a/packages/server/src/modules/SaleInvoices/constants.ts b/packages/server/src/modules/SaleInvoices/constants.ts index 48b9da1b0..33907a32a 100644 --- a/packages/server/src/modules/SaleInvoices/constants.ts +++ b/packages/server/src/modules/SaleInvoices/constants.ts @@ -2,7 +2,7 @@ export const SendSaleInvoiceQueue = 'SendSaleInvoiceQueue'; export const SendSaleInvoiceMailJob = 'SendSaleInvoiceMailJob'; export const DEFAULT_INVOICE_MAIL_SUBJECT = -'Invoice {Invoice Number} from {Company Name} for {Customer Name}'; + 'Invoice {Invoice Number} from {Company Name} for {Customer Name}'; export const DEFAULT_INVOICE_MAIL_CONTENT = `Hi {Customer Name}, Here's invoice # {Invoice Number} for {Invoice Amount} @@ -19,7 +19,7 @@ Thanks, export const DEFAULT_INVOICE_REMINDER_MAIL_SUBJECT = 'Invoice {InvoiceNumber} reminder from {CompanyName}'; - export const DEFAULT_INVOICE_REMINDER_MAIL_CONTENT = ` +export const DEFAULT_INVOICE_REMINDER_MAIL_CONTENT = `

Dear {CustomerName}

You might have missed the payment date and the invoice is now overdue by {OverdueDays} days.

Invoice #{InvoiceNumber}
@@ -32,7 +32,7 @@ Amount : {InvoiceAmount}

`; -export const PUBLIC_PAYMENT_LINK = "{BASE_URL}/payment/{PAYMENT_LINK_ID}"; +export const PUBLIC_PAYMENT_LINK = '{BASE_URL}/payment/{PAYMENT_LINK_ID}'; export const ERRORS = { INVOICE_NUMBER_NOT_UNIQUE: 'INVOICE_NUMBER_NOT_UNIQUE', diff --git a/packages/server/src/modules/SaleInvoices/ledger/InvoiceGL.ts b/packages/server/src/modules/SaleInvoices/ledger/InvoiceGL.ts index 597c58067..81feb67d5 100644 --- a/packages/server/src/modules/SaleInvoices/ledger/InvoiceGL.ts +++ b/packages/server/src/modules/SaleInvoices/ledger/InvoiceGL.ts @@ -158,7 +158,7 @@ export class InvoiceGL { accountNormal: AccountNormal.CREDIT, index: 1, } as ILedgerEntry; - }; + } /** * Retrieves the invoice adjustment GL entry. @@ -176,15 +176,15 @@ export class InvoiceGL { accountNormal: AccountNormal.CREDIT, index: 1, }; - }; + } /** * Retrieves the invoice GL entries. * @returns {ILedgerEntry[]} */ public getInvoiceGLEntries = (): ILedgerEntry[] => { - const creditEntries = this.saleInvoice.entries.map( - (entry, index) => this.getInvoiceItemEntry(entry, index), + const creditEntries = this.saleInvoice.entries.map((entry, index) => + this.getInvoiceItemEntry(entry, index), ); const taxEntries = this.saleInvoice.entries .filter((entry) => entry.taxAmount > 0) diff --git a/packages/server/src/modules/SaleInvoices/models/SaleInvoice.meta.ts b/packages/server/src/modules/SaleInvoices/models/SaleInvoice.meta.ts index 48e6828ef..8222ea347 100644 --- a/packages/server/src/modules/SaleInvoices/models/SaleInvoice.meta.ts +++ b/packages/server/src/modules/SaleInvoices/models/SaleInvoice.meta.ts @@ -1,4 +1,4 @@ -import { Features } from "@/common/types/Features"; +import { Features } from '@/common/types/Features'; export const SaleInvoiceMeta = { defaultFilterField: 'customer', @@ -313,4 +313,4 @@ function StatusFieldFilterQuery(query, role) { */ function StatusFieldSortQuery(query, role) { query.modify('sortByStatus', role.order); -} \ No newline at end of file +} diff --git a/packages/server/src/modules/SaleInvoices/processors/SendSaleInvoiceMail.processor.ts b/packages/server/src/modules/SaleInvoices/processors/SendSaleInvoiceMail.processor.ts index ffe7d358b..490b3b22b 100644 --- a/packages/server/src/modules/SaleInvoices/processors/SendSaleInvoiceMail.processor.ts +++ b/packages/server/src/modules/SaleInvoices/processors/SendSaleInvoiceMail.processor.ts @@ -20,8 +20,7 @@ export class SendSaleInvoiceMailProcessor extends WorkerHost { @UseCls() async process(job: Job) { - const { messageOptions, saleInvoiceId, organizationId, userId } = - job.data; + const { messageOptions, saleInvoiceId, organizationId, userId } = job.data; this.clsService.set('organizationId', organizationId); this.clsService.set('userId', userId); diff --git a/packages/server/src/modules/SaleInvoices/queries/GetInvoicePaymentLink.transformer.ts b/packages/server/src/modules/SaleInvoices/queries/GetInvoicePaymentLink.transformer.ts index 25bbe7332..8539764ab 100644 --- a/packages/server/src/modules/SaleInvoices/queries/GetInvoicePaymentLink.transformer.ts +++ b/packages/server/src/modules/SaleInvoices/queries/GetInvoicePaymentLink.transformer.ts @@ -60,7 +60,7 @@ export class GetInvoicePaymentLinkMetaTransformer extends SaleInvoiceTransformer public organization(invoice) { return this.item( this.context.organization, - new GetPaymentLinkOrganizationMetaTransformer() + new GetPaymentLinkOrganizationMetaTransformer(), ); } @@ -72,7 +72,7 @@ export class GetInvoicePaymentLinkMetaTransformer extends SaleInvoiceTransformer public brandingTemplate(invoice) { return this.item( invoice.pdfTemplate, - new GetInvoicePaymentLinkBrandingTemplate() + new GetInvoicePaymentLinkBrandingTemplate(), ); } @@ -87,7 +87,7 @@ export class GetInvoicePaymentLinkMetaTransformer extends SaleInvoiceTransformer new GetInvoicePaymentLinkEntryMetaTransformer(), { currencyCode: invoice.currencyCode, - } + }, ); }; @@ -103,7 +103,7 @@ export class GetInvoicePaymentLinkMetaTransformer extends SaleInvoiceTransformer subtotal: invoice.subtotal, isInclusiveTax: invoice.isInclusiveTax, currencyCode: invoice.currencyCode, - } + }, ); }; @@ -113,7 +113,7 @@ export class GetInvoicePaymentLinkMetaTransformer extends SaleInvoiceTransformer protected hasStripePaymentMethod(invoice) { return invoice.paymentMethods.some( - (paymentMethod) => paymentMethod.paymentIntegration.service === 'Stripe' + (paymentMethod) => paymentMethod.paymentIntegration.service === 'Stripe', ); } @@ -133,7 +133,7 @@ export class GetInvoicePaymentLinkMetaTransformer extends SaleInvoiceTransformer protected formattedCustomerAddress(invoice) { return contactAddressTextFormat( invoice.customer, - this.customerAddressFormat + this.customerAddressFormat, ); } } diff --git a/packages/server/src/modules/SaleInvoices/queries/GetSaleInvoice.service.ts b/packages/server/src/modules/SaleInvoices/queries/GetSaleInvoice.service.ts index 4bfcfaa94..ee94c8ff4 100644 --- a/packages/server/src/modules/SaleInvoices/queries/GetSaleInvoice.service.ts +++ b/packages/server/src/modules/SaleInvoices/queries/GetSaleInvoice.service.ts @@ -18,7 +18,7 @@ export class GetSaleInvoice { @Inject(SaleInvoice.name) private saleInvoiceModel: TenantModelProxy, - ) { } + ) {} /** * Retrieve sale invoice with associated entries. diff --git a/packages/server/src/modules/SaleInvoices/queries/GetSaleInvoices.ts b/packages/server/src/modules/SaleInvoices/queries/GetSaleInvoices.ts index e0cb1536f..dcb98aa5f 100644 --- a/packages/server/src/modules/SaleInvoices/queries/GetSaleInvoices.ts +++ b/packages/server/src/modules/SaleInvoices/queries/GetSaleInvoices.ts @@ -24,9 +24,7 @@ export class GetSaleInvoicesService { * @param {GetSaleInvoicesQueryDto} filterDTO - * @returns {Promise<{ data: SaleInvoice[]; pagination: IPaginationMeta; filterMeta: IFilterMeta; }>} */ - public async getSaleInvoices( - filterDTO: GetSaleInvoicesQueryDto, - ): Promise<{ + public async getSaleInvoices(filterDTO: GetSaleInvoicesQueryDto): Promise<{ salesInvoices: SaleInvoice[]; pagination: IPaginationMeta; filterMeta: IFilterMeta; diff --git a/packages/server/src/modules/SaleInvoices/queries/InvoicePaymentTransaction.transformer.ts b/packages/server/src/modules/SaleInvoices/queries/InvoicePaymentTransaction.transformer.ts index ea3223fda..d1e22363f 100644 --- a/packages/server/src/modules/SaleInvoices/queries/InvoicePaymentTransaction.transformer.ts +++ b/packages/server/src/modules/SaleInvoices/queries/InvoicePaymentTransaction.transformer.ts @@ -1,4 +1,4 @@ -import { Transformer } from "../../Transformer/Transformer"; +import { Transformer } from '../../Transformer/Transformer'; export class InvoicePaymentTransactionTransformer extends Transformer { /** @@ -22,7 +22,7 @@ export class InvoicePaymentTransactionTransformer extends Transformer { /** * Formatted payment date. - * @param entry + * @param entry * @returns {string} */ protected formattedPaymentDate = (entry): string => { diff --git a/packages/server/src/modules/SaleInvoices/queries/SaleInvoice.transformer.ts b/packages/server/src/modules/SaleInvoices/queries/SaleInvoice.transformer.ts index 2ab529f42..3d7059508 100644 --- a/packages/server/src/modules/SaleInvoices/queries/SaleInvoice.transformer.ts +++ b/packages/server/src/modules/SaleInvoices/queries/SaleInvoice.transformer.ts @@ -70,7 +70,7 @@ export class SaleInvoiceTransformer extends Transformer { protected dueAmountFormatted = (invoice: SaleInvoice): string => { return this.formatNumber(invoice.dueAmount, { currencyCode: invoice.currencyCode, - money: true + money: true, }); }; @@ -156,7 +156,9 @@ export class SaleInvoiceTransformer extends Transformer { * @param invoice * @returns {string} */ - protected taxAmountWithheldLocalFormatted = (invoice: SaleInvoice): string => { + protected taxAmountWithheldLocalFormatted = ( + invoice: SaleInvoice, + ): string => { return this.formatNumber(invoice.taxAmountWithheldLocal, { currencyCode: this.context.organization.baseCurrency, }); @@ -170,7 +172,7 @@ export class SaleInvoiceTransformer extends Transformer { protected totalFormatted = (invoice: SaleInvoice): string => { return this.formatNumber(invoice.total, { currencyCode: invoice.currencyCode, - money: true + money: true, }); }; @@ -209,14 +211,14 @@ export class SaleInvoiceTransformer extends Transformer { /** * Retrieves formatted adjustment amount. - * @param invoice + * @param invoice * @returns {string} */ protected adjustmentFormatted = (invoice: SaleInvoice): string => { return this.formatNumber(invoice.adjustment, { currencyCode: invoice.currencyCode, - }) - } + }); + }; /** * Retrieve the taxes lines of sale invoice. diff --git a/packages/server/src/modules/SaleInvoices/queries/SaleInvoiceTaxEntry.transformer.ts b/packages/server/src/modules/SaleInvoices/queries/SaleInvoiceTaxEntry.transformer.ts index 6b3b01e3a..5854323ec 100644 --- a/packages/server/src/modules/SaleInvoices/queries/SaleInvoiceTaxEntry.transformer.ts +++ b/packages/server/src/modules/SaleInvoices/queries/SaleInvoiceTaxEntry.transformer.ts @@ -1,6 +1,8 @@ - import { Transformer } from '@/modules/Transformer/Transformer'; -import { getExlusiveTaxAmount, getInclusiveTaxAmount } from '../../TaxRates/utils'; +import { + getExlusiveTaxAmount, + getInclusiveTaxAmount, +} from '../../TaxRates/utils'; export class SaleInvoiceTaxEntryTransformer extends Transformer { /** diff --git a/packages/server/src/modules/SaleInvoices/subscribers/InvoiceCostGLEntriesSubscriber.ts b/packages/server/src/modules/SaleInvoices/subscribers/InvoiceCostGLEntriesSubscriber.ts index 318aee942..eaabb6ed3 100644 --- a/packages/server/src/modules/SaleInvoices/subscribers/InvoiceCostGLEntriesSubscriber.ts +++ b/packages/server/src/modules/SaleInvoices/subscribers/InvoiceCostGLEntriesSubscriber.ts @@ -6,7 +6,7 @@ import { SaleInvoiceCostGLEntries } from '../SaleInvoiceCostGLEntries'; @Injectable() export class InvoiceCostGLEntriesSubscriber { - constructor(private readonly invoiceCostEntries: SaleInvoiceCostGLEntries) { } + constructor(private readonly invoiceCostEntries: SaleInvoiceCostGLEntries) {} /** * Writes the invoices cost GL entries once the inventory cost lots be written. diff --git a/packages/server/src/modules/SaleInvoices/subscribers/InvoiceGLEntriesSubscriber.ts b/packages/server/src/modules/SaleInvoices/subscribers/InvoiceGLEntriesSubscriber.ts index 0c27afa51..1917d1477 100644 --- a/packages/server/src/modules/SaleInvoices/subscribers/InvoiceGLEntriesSubscriber.ts +++ b/packages/server/src/modules/SaleInvoices/subscribers/InvoiceGLEntriesSubscriber.ts @@ -10,7 +10,7 @@ import { events } from '@/common/events/events'; @Injectable() export class InvoiceGLEntriesSubscriber { - constructor(public readonly saleInvoiceGLEntries: SaleInvoiceGLEntries) { } + constructor(public readonly saleInvoiceGLEntries: SaleInvoiceGLEntries) {} /** * Records journal entries of the non-inventory invoice. diff --git a/packages/server/src/modules/SaleInvoices/subscribers/SaleInvoiceAutoIncrementSubscriber.ts b/packages/server/src/modules/SaleInvoices/subscribers/SaleInvoiceAutoIncrementSubscriber.ts index f82d870b6..7653e338d 100644 --- a/packages/server/src/modules/SaleInvoices/subscribers/SaleInvoiceAutoIncrementSubscriber.ts +++ b/packages/server/src/modules/SaleInvoices/subscribers/SaleInvoiceAutoIncrementSubscriber.ts @@ -6,14 +6,14 @@ import { ISaleInvoiceCreatedPayload } from '../SaleInvoice.types'; @Injectable() export class SaleInvoiceAutoIncrementSubscriber { - constructor(private readonly invoiceIncrement: SaleInvoiceIncrement) { } + constructor(private readonly invoiceIncrement: SaleInvoiceIncrement) {} /** * Handles increment next number of invoice once be created. * @param {ISaleInvoiceCreatedPayload} payload - */ @OnEvent(events.saleInvoice.onCreated) - private async handleInvoiceNextNumberIncrement({ }: ISaleInvoiceCreatedPayload) { + private async handleInvoiceNextNumberIncrement({}: ISaleInvoiceCreatedPayload) { await this.invoiceIncrement.incrementNextInvoiceNumber(); } } diff --git a/packages/server/src/modules/SaleInvoices/utils.ts b/packages/server/src/modules/SaleInvoices/utils.ts index 089e8a4ad..24f0dcc7b 100644 --- a/packages/server/src/modules/SaleInvoices/utils.ts +++ b/packages/server/src/modules/SaleInvoices/utils.ts @@ -5,11 +5,11 @@ import { contactAddressTextFormat } from '@/utils/address-text-format'; export const mergePdfTemplateWithDefaultAttributes = ( brandingTemplate?: Record, - defaultAttributes: Record = {} + defaultAttributes: Record = {}, ) => { const brandingAttributes = pickBy( brandingTemplate, - (val, key) => val !== null && Object.keys(defaultAttributes).includes(key) + (val, key) => val !== null && Object.keys(defaultAttributes).includes(key), ); return { ...defaultAttributes, @@ -18,7 +18,7 @@ export const mergePdfTemplateWithDefaultAttributes = ( }; export const transformInvoiceToPdfTemplate = ( - invoice: ISaleInvoice + invoice: ISaleInvoice, ): Partial => { return { dueDate: invoice.dueDateFormatted, diff --git a/packages/server/src/modules/SaleReceipts/BulkDeleteSaleReceipts.service.ts b/packages/server/src/modules/SaleReceipts/BulkDeleteSaleReceipts.service.ts index 04c605608..99e1bc68b 100644 --- a/packages/server/src/modules/SaleReceipts/BulkDeleteSaleReceipts.service.ts +++ b/packages/server/src/modules/SaleReceipts/BulkDeleteSaleReceipts.service.ts @@ -6,9 +6,7 @@ import { DeleteSaleReceipt } from './commands/DeleteSaleReceipt.service'; @Injectable() export class BulkDeleteSaleReceiptsService { - constructor( - private readonly deleteSaleReceiptService: DeleteSaleReceipt, - ) { } + constructor(private readonly deleteSaleReceiptService: DeleteSaleReceipt) {} async bulkDeleteSaleReceipts( saleReceiptIds: number | number[], @@ -35,5 +33,3 @@ export class BulkDeleteSaleReceiptsService { } } } - - diff --git a/packages/server/src/modules/SaleReceipts/SaleReceiptApplication.service.ts b/packages/server/src/modules/SaleReceipts/SaleReceiptApplication.service.ts index 14e5d6dde..501c03c59 100644 --- a/packages/server/src/modules/SaleReceipts/SaleReceiptApplication.service.ts +++ b/packages/server/src/modules/SaleReceipts/SaleReceiptApplication.service.ts @@ -40,7 +40,7 @@ export class SaleReceiptApplication { private getSaleReceiptMailStateService: GetSaleReceiptMailStateService, private bulkDeleteSaleReceiptsService: BulkDeleteSaleReceiptsService, private validateBulkDeleteSaleReceiptsService: ValidateBulkDeleteSaleReceiptsService, - ) { } + ) {} /** * Creates a new sale receipt with associated entries. @@ -182,9 +182,7 @@ export class SaleReceiptApplication { * Retrieves the mail state of the given sale receipt. * @param {number} saleReceiptId */ - public getSaleReceiptMail( - saleReceiptId: number, - ): Promise { + public getSaleReceiptMail(saleReceiptId: number): Promise { return this.getSaleReceiptMailStateService.getMailState(saleReceiptId); } } diff --git a/packages/server/src/modules/SaleReceipts/SaleReceipts.controller.ts b/packages/server/src/modules/SaleReceipts/SaleReceipts.controller.ts index 822a53825..bee81e8e2 100644 --- a/packages/server/src/modules/SaleReceipts/SaleReceipts.controller.ts +++ b/packages/server/src/modules/SaleReceipts/SaleReceipts.controller.ts @@ -26,9 +26,7 @@ import { EditSaleReceiptDto, } from './dtos/SaleReceipt.dto'; import { GetSaleReceiptsQueryDto } from './dtos/GetSaleReceiptsQuery.dto'; -import { - SaleReceiptMailOptsDTO, -} from './types/SaleReceipts.types'; +import { SaleReceiptMailOptsDTO } from './types/SaleReceipts.types'; import { AcceptType } from '@/constants/accept-type'; import { Response } from 'express'; import { SaleReceiptResponseDto } from './dtos/SaleReceiptResponse.dto'; @@ -48,7 +46,7 @@ import { @ApiCommonHeaders() @ApiExtraModels(ValidateBulkDeleteResponseDto) export class SaleReceiptsController { - constructor(private saleReceiptApplication: SaleReceiptApplication) { } + constructor(private saleReceiptApplication: SaleReceiptApplication) {} @Post('validate-bulk-delete') @ApiOperation({ diff --git a/packages/server/src/modules/SaleReceipts/ValidateBulkDeleteSaleReceipts.service.ts b/packages/server/src/modules/SaleReceipts/ValidateBulkDeleteSaleReceipts.service.ts index c824eed91..f1dc51abb 100644 --- a/packages/server/src/modules/SaleReceipts/ValidateBulkDeleteSaleReceipts.service.ts +++ b/packages/server/src/modules/SaleReceipts/ValidateBulkDeleteSaleReceipts.service.ts @@ -53,5 +53,3 @@ export class ValidateBulkDeleteSaleReceiptsService { } } } - - diff --git a/packages/server/src/modules/SaleReceipts/commands/CreateSaleReceipt.service.ts b/packages/server/src/modules/SaleReceipts/commands/CreateSaleReceipt.service.ts index c685a0295..d141715c7 100644 --- a/packages/server/src/modules/SaleReceipts/commands/CreateSaleReceipt.service.ts +++ b/packages/server/src/modules/SaleReceipts/commands/CreateSaleReceipt.service.ts @@ -38,7 +38,7 @@ export class CreateSaleReceipt { @Inject(Customer.name) private readonly customerModel: TenantModelProxy, - ) { } + ) {} /** * Creates a new sale receipt with associated entries. diff --git a/packages/server/src/modules/SaleReceipts/commands/SaleReceiptsImportable.ts b/packages/server/src/modules/SaleReceipts/commands/SaleReceiptsImportable.ts index 0b3674d8a..f29b8b9b0 100644 --- a/packages/server/src/modules/SaleReceipts/commands/SaleReceiptsImportable.ts +++ b/packages/server/src/modules/SaleReceipts/commands/SaleReceiptsImportable.ts @@ -21,10 +21,7 @@ export class SaleReceiptsImportable extends Importable { createAccountDTO: CreateSaleReceiptDto, trx?: Knex.Transaction, ) { - return this.createReceiptService.createSaleReceipt( - createAccountDTO, - trx, - ); + return this.createReceiptService.createSaleReceipt(createAccountDTO, trx); } /** diff --git a/packages/server/src/modules/SaleReceipts/inventory/SaleReceiptWriteInventoryTransactions.ts b/packages/server/src/modules/SaleReceipts/inventory/SaleReceiptWriteInventoryTransactions.ts index 8c1b10c09..580c86b87 100644 --- a/packages/server/src/modules/SaleReceipts/inventory/SaleReceiptWriteInventoryTransactions.ts +++ b/packages/server/src/modules/SaleReceipts/inventory/SaleReceiptWriteInventoryTransactions.ts @@ -11,7 +11,7 @@ import { SaleReceiptInventoryTransactions } from './SaleReceiptInventoryTransact @Injectable() export class SaleReceiptInventoryTransactionsSubscriber { constructor( - private readonly saleReceiptInventory: SaleReceiptInventoryTransactions + private readonly saleReceiptInventory: SaleReceiptInventoryTransactions, ) {} /** @@ -29,9 +29,9 @@ export class SaleReceiptInventoryTransactionsSubscriber { await this.saleReceiptInventory.recordInventoryTransactions( saleReceipt, false, - trx + trx, ); - }; + } /** * Rewriting the inventory transactions once the sale invoice be edited. @@ -48,9 +48,9 @@ export class SaleReceiptInventoryTransactionsSubscriber { await this.saleReceiptInventory.recordInventoryTransactions( saleReceipt, true, - trx + trx, ); - }; + } /** * Handles deleting the inventory transactions once the receipt deleted. @@ -63,7 +63,7 @@ export class SaleReceiptInventoryTransactionsSubscriber { }: ISaleReceiptEventDeletedPayload) { await this.saleReceiptInventory.revertInventoryTransactions( saleReceiptId, - trx + trx, ); - }; + } } diff --git a/packages/server/src/modules/SaleReceipts/processes/SendSaleReceiptMail.process.ts b/packages/server/src/modules/SaleReceipts/processes/SendSaleReceiptMail.process.ts index 185a631ee..acff1bffa 100644 --- a/packages/server/src/modules/SaleReceipts/processes/SendSaleReceiptMail.process.ts +++ b/packages/server/src/modules/SaleReceipts/processes/SendSaleReceiptMail.process.ts @@ -19,8 +19,7 @@ export class SendSaleReceiptMailProcess extends WorkerHost { @UseCls() async process(job: Job) { - const { messageOpts, saleReceiptId, organizationId, userId } = - job.data; + const { messageOpts, saleReceiptId, organizationId, userId } = job.data; this.clsService.set('organizationId', organizationId); this.clsService.set('userId', userId); diff --git a/packages/server/src/modules/SaleReceipts/queries/GetSaleReceiptMailState.service.ts b/packages/server/src/modules/SaleReceipts/queries/GetSaleReceiptMailState.service.ts index 9fc6fef22..accb552c8 100644 --- a/packages/server/src/modules/SaleReceipts/queries/GetSaleReceiptMailState.service.ts +++ b/packages/server/src/modules/SaleReceipts/queries/GetSaleReceiptMailState.service.ts @@ -12,7 +12,7 @@ export class GetSaleReceiptMailStateService { private readonly receiptMail: SaleReceiptMailNotification, @Inject(SaleReceipt.name) - private readonly saleReceiptModel: TenantModelProxy + private readonly saleReceiptModel: TenantModelProxy, ) {} /** @@ -20,7 +20,8 @@ export class GetSaleReceiptMailStateService { * @param {number} saleReceiptId */ public async getMailState(saleReceiptId: number) { - const saleReceipt = await this.saleReceiptModel().query() + const saleReceipt = await this.saleReceiptModel() + .query() .findById(saleReceiptId) .withGraphFetched('entries.item') .withGraphFetched('customer') diff --git a/packages/server/src/modules/SaleReceipts/queries/GetSaleReceiptMailState.transformer.ts b/packages/server/src/modules/SaleReceipts/queries/GetSaleReceiptMailState.transformer.ts index ecbe42f00..d07e9aedb 100644 --- a/packages/server/src/modules/SaleReceipts/queries/GetSaleReceiptMailState.transformer.ts +++ b/packages/server/src/modules/SaleReceipts/queries/GetSaleReceiptMailState.transformer.ts @@ -135,15 +135,15 @@ export class GetSaleReceiptMailStateTransformer extends Transformer { }; /** - * Retrieves the discount label of the estimate. - * @param estimate - * @returns {string} - */ - protected discountLabel(receipt) { - return receipt.discountType === DiscountType.Percentage - ? `Discount [${receipt.discountPercentageFormatted}]` - : 'Discount'; - } + * Retrieves the discount label of the estimate. + * @param estimate + * @returns {string} + */ + protected discountLabel(receipt) { + return receipt.discountType === DiscountType.Percentage + ? `Discount [${receipt.discountPercentageFormatted}]` + : 'Discount'; + } /** * diff --git a/packages/server/src/modules/SaleReceipts/queries/GetSaleReceiptMailTemplate.transformer.ts b/packages/server/src/modules/SaleReceipts/queries/GetSaleReceiptMailTemplate.transformer.ts index 4ab22e3da..8fd536545 100644 --- a/packages/server/src/modules/SaleReceipts/queries/GetSaleReceiptMailTemplate.transformer.ts +++ b/packages/server/src/modules/SaleReceipts/queries/GetSaleReceiptMailTemplate.transformer.ts @@ -31,7 +31,7 @@ export class GetSaleReceiptMailTemplateAttributesTransformer extends Transformer 'adjustment', 'adjustmentLabel', - + 'items', ]; }; diff --git a/packages/server/src/modules/SaleReceipts/queries/SaleReceiptTransformer.ts b/packages/server/src/modules/SaleReceipts/queries/SaleReceiptTransformer.ts index 25b2ab529..8c6c23bda 100644 --- a/packages/server/src/modules/SaleReceipts/queries/SaleReceiptTransformer.ts +++ b/packages/server/src/modules/SaleReceipts/queries/SaleReceiptTransformer.ts @@ -23,7 +23,7 @@ export class SaleReceiptTransformer extends Transformer { 'discountAmountFormatted', 'discountPercentageFormatted', 'adjustmentFormatted', - + 'entries', 'attachments', ]; diff --git a/packages/server/src/modules/SaleReceipts/subscribers/SaleReceiptAutoIncrementSubscriber.ts b/packages/server/src/modules/SaleReceipts/subscribers/SaleReceiptAutoIncrementSubscriber.ts index 59f8259b3..6287245f5 100644 --- a/packages/server/src/modules/SaleReceipts/subscribers/SaleReceiptAutoIncrementSubscriber.ts +++ b/packages/server/src/modules/SaleReceipts/subscribers/SaleReceiptAutoIncrementSubscriber.ts @@ -6,14 +6,14 @@ import { ISaleReceiptCreatedPayload } from '../types/SaleReceipts.types'; @Injectable() export class SaleReceiptAutoIncrementSubscriber { - constructor(private readonly receiptIncrement: SaleReceiptIncrement) { } + constructor(private readonly receiptIncrement: SaleReceiptIncrement) {} /** * Handles increment next number of receipt once be created. * @param {ISaleReceiptCreatedPayload} payload - */ @OnEvent(events.saleReceipt.onCreated) - private async handleReceiptNextNumberIncrement({ }: ISaleReceiptCreatedPayload) { + private async handleReceiptNextNumberIncrement({}: ISaleReceiptCreatedPayload) { await this.receiptIncrement.incrementNextReceiptNumber(); } } diff --git a/packages/server/src/modules/SaleReceipts/types/SaleReceipts.types.ts b/packages/server/src/modules/SaleReceipts/types/SaleReceipts.types.ts index 5deff7c90..74c272c79 100644 --- a/packages/server/src/modules/SaleReceipts/types/SaleReceipts.types.ts +++ b/packages/server/src/modules/SaleReceipts/types/SaleReceipts.types.ts @@ -3,7 +3,10 @@ import { SaleReceipt } from '../models/SaleReceipt'; import { CommonMailOptionsDTO } from '@/modules/MailNotification/MailNotification.types'; import { CommonMailOptions } from '@/modules/MailNotification/MailNotification.types'; import { TenantJobPayload } from '@/interfaces/Tenant'; -import { CreateSaleReceiptDto, EditSaleReceiptDto } from '../dtos/SaleReceipt.dto'; +import { + CreateSaleReceiptDto, + EditSaleReceiptDto, +} from '../dtos/SaleReceipt.dto'; export interface ISalesReceiptsFilter { filterQuery?: (query: any) => void; diff --git a/packages/server/src/modules/SaleReceipts/utils.ts b/packages/server/src/modules/SaleReceipts/utils.ts index e70ac5e72..a122cdefe 100644 --- a/packages/server/src/modules/SaleReceipts/utils.ts +++ b/packages/server/src/modules/SaleReceipts/utils.ts @@ -6,7 +6,7 @@ import { import { contactAddressTextFormat } from '@/utils/address-text-format'; export const transformReceiptToBrandingTemplateAttributes = ( - saleReceipt: ISaleReceipt + saleReceipt: ISaleReceipt, ): Partial => { return { total: saleReceipt.totalFormatted, diff --git a/packages/server/src/modules/Search/SearchableMdel.ts b/packages/server/src/modules/Search/SearchableMdel.ts index 238316bce..125b4d4ad 100644 --- a/packages/server/src/modules/Search/SearchableMdel.ts +++ b/packages/server/src/modules/Search/SearchableMdel.ts @@ -1,8 +1,8 @@ import * as O from 'objection'; -import { IModelMeta, } from '@/interfaces/Model'; +import { IModelMeta } from '@/interfaces/Model'; export const SearchableModel: O.Plugin = (Model) => - // @ts-ignore + // @ts-ignore class extends Model { additionalProperty: string; @@ -19,4 +19,4 @@ export const SearchableModel: O.Plugin = (Model) => // static get searchRoles(): ISearchRole[] { // return []; // } - }; \ No newline at end of file + }; diff --git a/packages/server/src/modules/Settings/Settings.types.ts b/packages/server/src/modules/Settings/Settings.types.ts index 47d66a870..7fe90fd82 100644 --- a/packages/server/src/modules/Settings/Settings.types.ts +++ b/packages/server/src/modules/Settings/Settings.types.ts @@ -1,4 +1,3 @@ - export interface IOptionDTO { key: string; value: string; @@ -9,9 +8,8 @@ export interface ISettingsDTO { options: IOptionDTO[]; } - export const SETTINGS_PROVIDER = 'SETTINGS'; export enum PreferencesAction { - Mutate = 'Mutate' -} \ No newline at end of file + Mutate = 'Mutate', +} diff --git a/packages/server/src/modules/Settings/SettingsStore.ts b/packages/server/src/modules/Settings/SettingsStore.ts index 56c0adff5..80911348b 100644 --- a/packages/server/src/modules/Settings/SettingsStore.ts +++ b/packages/server/src/modules/Settings/SettingsStore.ts @@ -13,5 +13,4 @@ export class SettingsStore extends MetableDBStore { this.setExtraColumns(['group']); this.setRepository(repository); } - } diff --git a/packages/server/src/modules/Socket/Socket.gateway.ts b/packages/server/src/modules/Socket/Socket.gateway.ts index be20afea7..c73c16d58 100644 --- a/packages/server/src/modules/Socket/Socket.gateway.ts +++ b/packages/server/src/modules/Socket/Socket.gateway.ts @@ -17,7 +17,8 @@ import { Logger } from '@nestjs/common'; }, }) export class SocketGateway - implements OnGatewayInit, OnGatewayConnection, OnGatewayDisconnect { + implements OnGatewayInit, OnGatewayConnection, OnGatewayDisconnect +{ @WebSocketServer() server: Server; @@ -47,5 +48,3 @@ export class SocketGateway this.logger.log('Emitted SUBSCRIPTION_CHANGED event'); } } - - diff --git a/packages/server/src/modules/Socket/Socket.module.ts b/packages/server/src/modules/Socket/Socket.module.ts index 8d7219be1..338c0bb0a 100644 --- a/packages/server/src/modules/Socket/Socket.module.ts +++ b/packages/server/src/modules/Socket/Socket.module.ts @@ -5,6 +5,4 @@ import { SocketGateway } from './Socket.gateway'; providers: [SocketGateway], exports: [SocketGateway], }) -export class SocketModule { } - - +export class SocketModule {} diff --git a/packages/server/src/modules/StripePayment/CreatePaymentReceivedStripePayment.ts b/packages/server/src/modules/StripePayment/CreatePaymentReceivedStripePayment.ts index ccab8c45a..7113d319b 100644 --- a/packages/server/src/modules/StripePayment/CreatePaymentReceivedStripePayment.ts +++ b/packages/server/src/modules/StripePayment/CreatePaymentReceivedStripePayment.ts @@ -12,7 +12,7 @@ export class CreatePaymentReceiveStripePayment { private readonly createPaymentReceivedService: CreatePaymentReceivedService, private readonly uow: UnitOfWork, private readonly accountRepository: AccountRepository, - ) { } + ) {} /** * Creates a payment received transaction associated to the given invoice. @@ -27,8 +27,10 @@ export class CreatePaymentReceiveStripePayment { await this.accountRepository.findOrCreateStripeClearing({}, trx); // Retrieves the given invoice to create payment transaction associated to it. - const invoice = - await this.getSaleInvoiceService.getSaleInvoice(saleInvoiceId, trx); + const invoice = await this.getSaleInvoiceService.getSaleInvoice( + saleInvoiceId, + trx, + ); const paymentReceivedDTO = { customerId: invoice.customerId, diff --git a/packages/server/src/modules/StripePayment/StripePayment.controller.ts b/packages/server/src/modules/StripePayment/StripePayment.controller.ts index fea3c65ed..104d2bb0c 100644 --- a/packages/server/src/modules/StripePayment/StripePayment.controller.ts +++ b/packages/server/src/modules/StripePayment/StripePayment.controller.ts @@ -109,11 +109,10 @@ export class StripeIntegrationController { description: 'Successfully created account link', type: CreateStripeAccountLinkResponseDto, }) - public async createAccountLink( - @Body() body: CreateStripeAccountLinkBodyDto, - ) { - const clientSecret = - await this.stripePaymentApp.createAccountLink(body.stripeAccountId); + public async createAccountLink(@Body() body: CreateStripeAccountLinkBodyDto) { + const clientSecret = await this.stripePaymentApp.createAccountLink( + body.stripeAccountId, + ); return { clientSecret }; } diff --git a/packages/server/src/modules/StripePayment/StripePayment.module.ts b/packages/server/src/modules/StripePayment/StripePayment.module.ts index 503949970..c82e970da 100644 --- a/packages/server/src/modules/StripePayment/StripePayment.module.ts +++ b/packages/server/src/modules/StripePayment/StripePayment.module.ts @@ -36,4 +36,4 @@ import { TenancyContext } from '../Tenancy/TenancyContext.service'; exports: [StripePaymentService, GetStripeAuthorizationLinkService], controllers: [StripeIntegrationController, StripePaymentWebhooksController], }) -export class StripePaymentModule { } +export class StripePaymentModule {} diff --git a/packages/server/src/modules/StripePayment/StripePaymentWebhooks.controller.ts b/packages/server/src/modules/StripePayment/StripePaymentWebhooks.controller.ts index a8bbde9a5..d16545cc2 100644 --- a/packages/server/src/modules/StripePayment/StripePaymentWebhooks.controller.ts +++ b/packages/server/src/modules/StripePayment/StripePaymentWebhooks.controller.ts @@ -28,7 +28,7 @@ export class StripePaymentWebhooksController { private readonly stripePaymentService: StripePaymentService, private readonly eventEmitter: EventEmitter2, private readonly configService: ConfigService, - ) { } + ) {} /** * Handles incoming Stripe webhook events. diff --git a/packages/server/src/modules/StripePayment/dtos/CreateStripeAccountSessionResponse.dto.ts b/packages/server/src/modules/StripePayment/dtos/CreateStripeAccountSessionResponse.dto.ts index 97a567b44..eb6e5b66d 100644 --- a/packages/server/src/modules/StripePayment/dtos/CreateStripeAccountSessionResponse.dto.ts +++ b/packages/server/src/modules/StripePayment/dtos/CreateStripeAccountSessionResponse.dto.ts @@ -2,7 +2,8 @@ import { ApiProperty } from '@nestjs/swagger'; export class CreateStripeAccountSessionResponseDto { @ApiProperty({ - description: 'Stripe Account Session client secret for the Connect embedded component', + description: + 'Stripe Account Session client secret for the Connect embedded component', example: 'acs_xxx_secret_xxx', }) client_secret: string; diff --git a/packages/server/src/modules/StripePayment/dtos/GetStripeConnectLinkResponse.dto.ts b/packages/server/src/modules/StripePayment/dtos/GetStripeConnectLinkResponse.dto.ts index 2b19a5596..989482648 100644 --- a/packages/server/src/modules/StripePayment/dtos/GetStripeConnectLinkResponse.dto.ts +++ b/packages/server/src/modules/StripePayment/dtos/GetStripeConnectLinkResponse.dto.ts @@ -3,7 +3,8 @@ import { ApiProperty } from '@nestjs/swagger'; export class GetStripeConnectLinkResponseDto { @ApiProperty({ description: 'Stripe OAuth2 Connect authorization URL', - example: 'https://connect.stripe.com/oauth/authorize?response_type=code&client_id=...', + example: + 'https://connect.stripe.com/oauth/authorize?response_type=code&client_id=...', }) url: string; } diff --git a/packages/server/src/modules/StripePayment/subscribers/StripeWebhooksSubscriber.ts b/packages/server/src/modules/StripePayment/subscribers/StripeWebhooksSubscriber.ts index 012c7359b..0dbdfd1e8 100644 --- a/packages/server/src/modules/StripePayment/subscribers/StripeWebhooksSubscriber.ts +++ b/packages/server/src/modules/StripePayment/subscribers/StripeWebhooksSubscriber.ts @@ -28,7 +28,7 @@ export class StripeWebhooksSubscriber { @Inject(TenantModel.name) private readonly tenantModel: typeof TenantModel, - ) { } + ) {} /** * Handles the checkout session completed webhook event. diff --git a/packages/server/src/modules/Subscription/Subscription.module.ts b/packages/server/src/modules/Subscription/Subscription.module.ts index a00e11daf..bc3a6aef4 100644 --- a/packages/server/src/modules/Subscription/Subscription.module.ts +++ b/packages/server/src/modules/Subscription/Subscription.module.ts @@ -50,4 +50,4 @@ const models = [InjectSystemModel(Plan), InjectSystemModel(PlanSubscription)]; controllers: [SubscriptionsController, SubscriptionsLemonWebhook], exports: [...models], }) -export class SubscriptionModule { } +export class SubscriptionModule {} diff --git a/packages/server/src/modules/Subscription/SubscriptionPeriod.ts b/packages/server/src/modules/Subscription/SubscriptionPeriod.ts index 4570c46af..d166499bd 100644 --- a/packages/server/src/modules/Subscription/SubscriptionPeriod.ts +++ b/packages/server/src/modules/Subscription/SubscriptionPeriod.ts @@ -16,7 +16,7 @@ export class SubscriptionPeriod { constructor( interval: unitOfTime.DurationConstructor = 'month', count: number, - start?: Date + start?: Date, ) { this.interval = interval; this.count = count; @@ -47,4 +47,4 @@ export class SubscriptionPeriod { getIntervalCount() { return this.count; } -} \ No newline at end of file +} diff --git a/packages/server/src/modules/Subscription/commands/CancelLemonSubscription.service.ts b/packages/server/src/modules/Subscription/commands/CancelLemonSubscription.service.ts index 80bc2d752..6b1585286 100644 --- a/packages/server/src/modules/Subscription/commands/CancelLemonSubscription.service.ts +++ b/packages/server/src/modules/Subscription/commands/CancelLemonSubscription.service.ts @@ -23,9 +23,7 @@ export class CancelLemonSubscription { * @param {number} subscriptionId - Subscription id. * @returns {Promise} */ - public async cancelSubscription( - subscriptionSlug: string = 'main', - ) { + public async cancelSubscription(subscriptionSlug: string = 'main') { configureLemonSqueezy(); const tenant = await this.tenancyContext.getTenant(); diff --git a/packages/server/src/modules/Subscription/commands/ChangeLemonSubscription.service.ts b/packages/server/src/modules/Subscription/commands/ChangeLemonSubscription.service.ts index f1a8bc34d..7773f8e71 100644 --- a/packages/server/src/modules/Subscription/commands/ChangeLemonSubscription.service.ts +++ b/packages/server/src/modules/Subscription/commands/ChangeLemonSubscription.service.ts @@ -1,4 +1,3 @@ - import { updateSubscription } from '@lemonsqueezy/lemonsqueezy.js'; import { configureLemonSqueezy } from '../utils'; import { IOrganizationSubscriptionChanged } from '../types'; diff --git a/packages/server/src/modules/Subscription/commands/MarkSubscriptionCanceled.service.ts b/packages/server/src/modules/Subscription/commands/MarkSubscriptionCanceled.service.ts index f680c9fb7..21e11d2a6 100644 --- a/packages/server/src/modules/Subscription/commands/MarkSubscriptionCanceled.service.ts +++ b/packages/server/src/modules/Subscription/commands/MarkSubscriptionCanceled.service.ts @@ -43,4 +43,4 @@ export class MarkSubscriptionCanceled { }, ); } -} \ No newline at end of file +} diff --git a/packages/server/src/modules/Subscription/commands/NewSubscription.service.ts b/packages/server/src/modules/Subscription/commands/NewSubscription.service.ts index d8dbaaf82..f5f84f279 100644 --- a/packages/server/src/modules/Subscription/commands/NewSubscription.service.ts +++ b/packages/server/src/modules/Subscription/commands/NewSubscription.service.ts @@ -15,7 +15,7 @@ export class NewSubscriptionService { @Inject(Plan.name) private readonly planModel: typeof Plan, - ) { } + ) {} /** * Give the tenant a new subscription. diff --git a/packages/server/src/modules/Subscription/queries/GetLemonSqueezyCheckout.service.ts b/packages/server/src/modules/Subscription/queries/GetLemonSqueezyCheckout.service.ts index fa73d9ed2..167852a85 100644 --- a/packages/server/src/modules/Subscription/queries/GetLemonSqueezyCheckout.service.ts +++ b/packages/server/src/modules/Subscription/queries/GetLemonSqueezyCheckout.service.ts @@ -7,9 +7,10 @@ import { TenancyContext } from '@/modules/Tenancy/TenancyContext.service'; @Injectable() export class GetLemonSqueezyCheckoutService { - constructor(private readonly configService: ConfigService, + constructor( + private readonly configService: ConfigService, - private readonly tenancyContext: TenancyContext + private readonly tenancyContext: TenancyContext, ) {} /** diff --git a/packages/server/src/modules/Subscription/queries/GetSubscriptionsTransformer.ts b/packages/server/src/modules/Subscription/queries/GetSubscriptionsTransformer.ts index 7281cbb95..89957d2d7 100644 --- a/packages/server/src/modules/Subscription/queries/GetSubscriptionsTransformer.ts +++ b/packages/server/src/modules/Subscription/queries/GetSubscriptionsTransformer.ts @@ -1,4 +1,4 @@ -import { Transformer } from "@/modules/Transformer/Transformer"; +import { Transformer } from '@/modules/Transformer/Transformer'; export class GetSubscriptionsTransformer extends Transformer { /** @@ -47,9 +47,7 @@ export class GetSubscriptionsTransformer extends Transformer { * @returns {string} */ public endsAtFormatted = (subscription) => { - return subscription.cancelsAt - ? this.formatDate(subscription.endsAt) - : null; + return subscription.cancelsAt ? this.formatDate(subscription.endsAt) : null; }; /** @@ -119,7 +117,7 @@ export class GetSubscriptionsTransformer extends Transformer { /** * Retrieves the subscription plan price. - * @param subscription + * @param subscription * @returns {number} */ public planPrice(subscription) { @@ -128,7 +126,7 @@ export class GetSubscriptionsTransformer extends Transformer { /** * Retrieves the subscription plan price currency. - * @param subscription + * @param subscription * @returns {string} */ public planPriceCurrency(subscription) { @@ -137,19 +135,19 @@ export class GetSubscriptionsTransformer extends Transformer { /** * Retrieves the subscription plan formatted price. - * @param subscription + * @param subscription * @returns {string} */ public planPriceFormatted(subscription) { return this.formatMoney(subscription.plan?.price, { currencyCode: subscription.plan?.currency, - precision: 0 + precision: 0, }); } /** * Retrieves the subscription plan period. - * @param subscription + * @param subscription * @returns {string} */ public planPeriod(subscription) { diff --git a/packages/server/src/modules/Subscription/subscribers/SubscribeFreeOnSignupCommunity.ts b/packages/server/src/modules/Subscription/subscribers/SubscribeFreeOnSignupCommunity.ts index 202e1207d..d8c993ca6 100644 --- a/packages/server/src/modules/Subscription/subscribers/SubscribeFreeOnSignupCommunity.ts +++ b/packages/server/src/modules/Subscription/subscribers/SubscribeFreeOnSignupCommunity.ts @@ -9,7 +9,7 @@ export class SubscribeFreeOnSignupCommunity { constructor( private readonly subscriptionApp: SubscriptionApplication, private readonly configService: ConfigService, - ) { } + ) {} /** * Creates a new free subscription once the user signup if the app is self-hosted. diff --git a/packages/server/src/modules/Subscription/subscribers/TriggerInvalidateCacheOnSubscriptionChange.ts b/packages/server/src/modules/Subscription/subscribers/TriggerInvalidateCacheOnSubscriptionChange.ts index 592e80c0e..4cef6eea7 100644 --- a/packages/server/src/modules/Subscription/subscribers/TriggerInvalidateCacheOnSubscriptionChange.ts +++ b/packages/server/src/modules/Subscription/subscribers/TriggerInvalidateCacheOnSubscriptionChange.ts @@ -5,7 +5,7 @@ import { SocketGateway } from '../../Socket/Socket.gateway'; @Injectable() export class TriggerInvalidateCacheOnSubscriptionChange { - constructor(private readonly socketGateway: SocketGateway) { } + constructor(private readonly socketGateway: SocketGateway) {} @OnEvent(events.subscription.onSubscriptionCancelled) @OnEvent(events.subscription.onSubscriptionResumed) diff --git a/packages/server/src/modules/Subscription/utils.ts b/packages/server/src/modules/Subscription/utils.ts index 56dc7e4b4..9a462b62e 100644 --- a/packages/server/src/modules/Subscription/utils.ts +++ b/packages/server/src/modules/Subscription/utils.ts @@ -16,8 +16,8 @@ export function configureLemonSqueezy() { if (missingVars.length > 0) { throw new Error( `Missing required LEMONSQUEEZY env variables: ${missingVars.join( - ', ' - )}. Please, set them in your .env file.` + ', ', + )}. Please, set them in your .env file.`, ); } lemonSqueezySetup({ diff --git a/packages/server/src/modules/Subscription/webhooks/LemonSqueezyWebhooks.ts b/packages/server/src/modules/Subscription/webhooks/LemonSqueezyWebhooks.ts index 19a72cd7f..44798c0c5 100644 --- a/packages/server/src/modules/Subscription/webhooks/LemonSqueezyWebhooks.ts +++ b/packages/server/src/modules/Subscription/webhooks/LemonSqueezyWebhooks.ts @@ -110,18 +110,14 @@ export class LemonSqueezyWebhooks { ); // Cancel the given subscription of the organization. } else if (webhookEvent === 'subscription_cancelled') { - await this.subscriptionApp.cancelSubscription( - subscriptionSlug, - ); + await this.subscriptionApp.cancelSubscription(subscriptionSlug); } else if (webhookEvent === 'subscription_plan_changed') { await this.subscriptionApp.markSubscriptionPlanChanged( plan.slug, subscriptionSlug, ); } else if (webhookEvent === 'subscription_resumed') { - await this.subscriptionApp.resumeSubscription( - subscriptionSlug, - ); + await this.subscriptionApp.resumeSubscription(subscriptionSlug); } } else if (webhookEvent.startsWith('order_')) { // Save orders; eventBody is a "Order" diff --git a/packages/server/src/modules/System/SystemDB/SystemDB.constants.ts b/packages/server/src/modules/System/SystemDB/SystemDB.constants.ts index 7365644a6..b6c6ed4c6 100644 --- a/packages/server/src/modules/System/SystemDB/SystemDB.constants.ts +++ b/packages/server/src/modules/System/SystemDB/SystemDB.constants.ts @@ -1,2 +1,2 @@ -export const SystemKnexConnection ='SystemKnexConnection'; -export const SystemKnexConnectionConfigure = 'SystemKnexConnectionConfigure'; \ No newline at end of file +export const SystemKnexConnection = 'SystemKnexConnection'; +export const SystemKnexConnectionConfigure = 'SystemKnexConnectionConfigure'; diff --git a/packages/server/src/modules/System/SystemModels/SystemModels.constants.ts b/packages/server/src/modules/System/SystemModels/SystemModels.constants.ts index d270c008a..4b85c668f 100644 --- a/packages/server/src/modules/System/SystemModels/SystemModels.constants.ts +++ b/packages/server/src/modules/System/SystemModels/SystemModels.constants.ts @@ -1 +1 @@ -export const SystemModelsConnection = 'SystemModelsConnection'; \ No newline at end of file +export const SystemModelsConnection = 'SystemModelsConnection'; diff --git a/packages/server/src/modules/TaxRates/TaxRate.controller.ts b/packages/server/src/modules/TaxRates/TaxRate.controller.ts index 0edaff458..8edcc9302 100644 --- a/packages/server/src/modules/TaxRates/TaxRate.controller.ts +++ b/packages/server/src/modules/TaxRates/TaxRate.controller.ts @@ -31,7 +31,7 @@ import { TaxRateAction } from './TaxRates.types'; @ApiCommonHeaders() @UseGuards(AuthorizationGuard, PermissionGuard) export class TaxRatesController { - constructor(private readonly taxRatesApplication: TaxRatesApplication) { } + constructor(private readonly taxRatesApplication: TaxRatesApplication) {} @Post() @RequirePermission(TaxRateAction.CREATE, AbilitySubject.TaxRate) diff --git a/packages/server/src/modules/TaxRates/TaxRate.module.ts b/packages/server/src/modules/TaxRates/TaxRate.module.ts index e14da028f..8f3b9b2a4 100644 --- a/packages/server/src/modules/TaxRates/TaxRate.module.ts +++ b/packages/server/src/modules/TaxRates/TaxRate.module.ts @@ -50,7 +50,7 @@ const models = [RegisterTenancyModel(TaxRateTransaction)]; WriteTaxTransactionsItemEntries, SyncItemTaxRateOnEditTaxRate, TaxRatesExportable, - TaxRatesImportable + TaxRatesImportable, ], exports: [ItemEntriesTaxTransactions, ...models], }) diff --git a/packages/server/src/modules/TaxRates/constants.ts b/packages/server/src/modules/TaxRates/constants.ts index e1553f4ee..4d812aaa7 100644 --- a/packages/server/src/modules/TaxRates/constants.ts +++ b/packages/server/src/modules/TaxRates/constants.ts @@ -4,5 +4,5 @@ export const ERRORS = { ITEM_ENTRY_TAX_RATE_CODE_NOT_FOUND: 'ITEM_ENTRY_TAX_RATE_CODE_NOT_FOUND', ITEM_ENTRY_TAX_RATE_ID_NOT_FOUND: 'ITEM_ENTRY_TAX_RATE_ID_NOT_FOUND', TAX_RATE_ALREADY_ACTIVE: 'TAX_RATE_ALREADY_ACTIVE', - TAX_RATE_ALREADY_INACTIVE: 'TAX_RATE_ALREADY_INACTIVE' + TAX_RATE_ALREADY_INACTIVE: 'TAX_RATE_ALREADY_INACTIVE', }; diff --git a/packages/server/src/modules/TaxRates/models/TaxRateTransaction.model.ts b/packages/server/src/modules/TaxRates/models/TaxRateTransaction.model.ts index 5c8e88718..7f972d3c1 100644 --- a/packages/server/src/modules/TaxRates/models/TaxRateTransaction.model.ts +++ b/packages/server/src/modules/TaxRates/models/TaxRateTransaction.model.ts @@ -10,7 +10,7 @@ export class TaxRateTransaction extends BaseModel { public referenceId: string; public rate: number; public taxAccountId?: number; - + /** * Table name */ diff --git a/packages/server/src/modules/TemplateInjectable/TemplateInjectable.module.ts b/packages/server/src/modules/TemplateInjectable/TemplateInjectable.module.ts index 1e37c3c6f..2e7dee12f 100644 --- a/packages/server/src/modules/TemplateInjectable/TemplateInjectable.module.ts +++ b/packages/server/src/modules/TemplateInjectable/TemplateInjectable.module.ts @@ -4,6 +4,6 @@ import { TenancyContext } from '../Tenancy/TenancyContext.service'; @Module({ providers: [TemplateInjectable, TenancyContext], - exports: [TemplateInjectable] + exports: [TemplateInjectable], }) export class TemplateInjectableModule {} diff --git a/packages/server/src/modules/Tenancy/EnsureTenantIsInitialized.guard.ts b/packages/server/src/modules/Tenancy/EnsureTenantIsInitialized.guard.ts index 67282b5ee..a613388a2 100644 --- a/packages/server/src/modules/Tenancy/EnsureTenantIsInitialized.guard.ts +++ b/packages/server/src/modules/Tenancy/EnsureTenantIsInitialized.guard.ts @@ -19,7 +19,7 @@ export class EnsureTenantIsInitializedGuard implements CanActivate { constructor( private readonly tenancyContext: TenancyContext, private reflector: Reflector, - ) { } + ) {} /** * Validate the tenant of the current request is initialized.. diff --git a/packages/server/src/modules/Tenancy/EnsureTenantIsSeeded.guards.ts b/packages/server/src/modules/Tenancy/EnsureTenantIsSeeded.guards.ts index cab864c8f..17a8810b5 100644 --- a/packages/server/src/modules/Tenancy/EnsureTenantIsSeeded.guards.ts +++ b/packages/server/src/modules/Tenancy/EnsureTenantIsSeeded.guards.ts @@ -20,7 +20,7 @@ export class EnsureTenantIsSeededGuard implements CanActivate { constructor( private readonly tenancyContext: TenancyContext, private reflector: Reflector, - ) { } + ) {} /** * Validate the tenant of the current request is seeded. diff --git a/packages/server/src/modules/Tenancy/TenancyCache/TenancyCache.module.ts b/packages/server/src/modules/Tenancy/TenancyCache/TenancyCache.module.ts index d5df8d863..418d877a5 100644 --- a/packages/server/src/modules/Tenancy/TenancyCache/TenancyCache.module.ts +++ b/packages/server/src/modules/Tenancy/TenancyCache/TenancyCache.module.ts @@ -15,4 +15,3 @@ export class TenancyCacheModule { }; } } - diff --git a/packages/server/src/modules/Tenancy/TenancyContext.service.ts b/packages/server/src/modules/Tenancy/TenancyContext.service.ts index 2e47ffa71..29ba85978 100644 --- a/packages/server/src/modules/Tenancy/TenancyContext.service.ts +++ b/packages/server/src/modules/Tenancy/TenancyContext.service.ts @@ -14,7 +14,7 @@ export class TenancyContext { @Inject(TenantModel.name) private readonly systemTenantModel: typeof TenantModel, - ) { } + ) {} /** * Get the current tenant. diff --git a/packages/server/src/modules/Tenancy/TenancyModels/Tenancy.module.ts b/packages/server/src/modules/Tenancy/TenancyModels/Tenancy.module.ts index 0bc1d639c..e16537b95 100644 --- a/packages/server/src/modules/Tenancy/TenancyModels/Tenancy.module.ts +++ b/packages/server/src/modules/Tenancy/TenancyModels/Tenancy.module.ts @@ -107,4 +107,4 @@ const modelProviders = models.map((model) => RegisterTenancyModel(model)); imports: [...modelProviders], exports: [...modelProviders], }) -export class TenancyModelsModule { } +export class TenancyModelsModule {} diff --git a/packages/server/src/modules/Tenancy/TenancyModels/decorators/InjectModelMeta.decorator.ts b/packages/server/src/modules/Tenancy/TenancyModels/decorators/InjectModelMeta.decorator.ts index 9c0793be2..729edc2f0 100644 --- a/packages/server/src/modules/Tenancy/TenancyModels/decorators/InjectModelMeta.decorator.ts +++ b/packages/server/src/modules/Tenancy/TenancyModels/decorators/InjectModelMeta.decorator.ts @@ -1,18 +1,17 @@ - /** * Decorator function that adds metadata to the model class. * @param value - The metadata value to be added to the model. * @returns A class decorator function. */ export function InjectModelMeta(value: any) { - return function(target: any) { + return function (target: any) { // Define a static getter for 'meta' on the target class Object.defineProperty(target, 'meta', { - get: function() { + get: function () { return value; }, enumerable: true, - configurable: true + configurable: true, }); }; -} \ No newline at end of file +} diff --git a/packages/server/src/modules/Tenancy/Tenant.controller.ts b/packages/server/src/modules/Tenancy/Tenant.controller.ts index 9d97585b9..a51245c33 100644 --- a/packages/server/src/modules/Tenancy/Tenant.controller.ts +++ b/packages/server/src/modules/Tenancy/Tenant.controller.ts @@ -1,4 +1,4 @@ -import { Controller } from "@nestjs/common"; +import { Controller } from '@nestjs/common'; @Controller('/') export class TenantController {} diff --git a/packages/server/src/modules/TenantDBManager/TenantDBManager.ts b/packages/server/src/modules/TenantDBManager/TenantDBManager.ts index 1ba2c8628..b3ced7038 100644 --- a/packages/server/src/modules/TenantDBManager/TenantDBManager.ts +++ b/packages/server/src/modules/TenantDBManager/TenantDBManager.ts @@ -23,7 +23,7 @@ export class TenantDBManager { @Inject(SystemKnexConnection) private readonly systemKnex: Knex, - ) { } + ) {} /** * Retrieves the tenant database name. @@ -45,8 +45,8 @@ export class TenantDBManager { const results = await this.systemKnex.raw( 'SELECT * FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = "' + - databaseName + - '"', + databaseName + + '"', ); return results[0].length > 0; } diff --git a/packages/server/src/modules/TenantDBManager/TenantsManager.ts b/packages/server/src/modules/TenantDBManager/TenantsManager.ts index db4c77cd3..6a968cc75 100644 --- a/packages/server/src/modules/TenantDBManager/TenantsManager.ts +++ b/packages/server/src/modules/TenantDBManager/TenantsManager.ts @@ -71,7 +71,7 @@ export class TenantsManagerService { */ public async migrateTenant(): Promise { const tenant = await this.tenancyContext.getTenant(); - + // Throw error if the tenant already initialized. throwErrorIfTenantAlreadyInitialized(tenant); diff --git a/packages/server/src/modules/TransactionItemEntry/ItemEntry.transformer.ts b/packages/server/src/modules/TransactionItemEntry/ItemEntry.transformer.ts index 52c186f7c..48542cf95 100644 --- a/packages/server/src/modules/TransactionItemEntry/ItemEntry.transformer.ts +++ b/packages/server/src/modules/TransactionItemEntry/ItemEntry.transformer.ts @@ -1,11 +1,14 @@ import { Transformer } from '../Transformer/Transformer'; import { ItemEntry } from './models/ItemEntry'; -interface ItemEntryTransformerContext{ +interface ItemEntryTransformerContext { currencyCode: string; } -export class ItemEntryTransformer extends Transformer<{}, ItemEntryTransformerContext> { +export class ItemEntryTransformer extends Transformer< + {}, + ItemEntryTransformerContext +> { /** * Include these attributes to item entry object. * @returns {Array} diff --git a/packages/server/src/modules/TransactionItemEntry/ItemEntry.types.ts b/packages/server/src/modules/TransactionItemEntry/ItemEntry.types.ts index 6607bc303..11f94fbe7 100644 --- a/packages/server/src/modules/TransactionItemEntry/ItemEntry.types.ts +++ b/packages/server/src/modules/TransactionItemEntry/ItemEntry.types.ts @@ -8,7 +8,7 @@ export interface IItemEntryDTO { warehouseId?: number; sellAccountId?: number; - costAccountId?: number; + costAccountId?: number; projectRefId?: number; projectRefType?: ProjectLinkRefType; diff --git a/packages/server/src/modules/TransactionsLocking/commands/CommandTransactionsLockingService.ts b/packages/server/src/modules/TransactionsLocking/commands/CommandTransactionsLockingService.ts index e70abb3b4..d5d43ef67 100644 --- a/packages/server/src/modules/TransactionsLocking/commands/CommandTransactionsLockingService.ts +++ b/packages/server/src/modules/TransactionsLocking/commands/CommandTransactionsLockingService.ts @@ -26,7 +26,7 @@ export class TransactionsLockingService { constructor( private readonly transactionsLockingRepo: TransactionsLockingRepository, private readonly eventPublisher: EventEmitter2, - ) { } + ) {} /** * Enable/disable all transacations locking. diff --git a/packages/server/src/modules/TransactionsLocking/guards/PurchasesTransactionLockingGuard.ts b/packages/server/src/modules/TransactionsLocking/guards/PurchasesTransactionLockingGuard.ts index db2c75106..c593ae706 100644 --- a/packages/server/src/modules/TransactionsLocking/guards/PurchasesTransactionLockingGuard.ts +++ b/packages/server/src/modules/TransactionsLocking/guards/PurchasesTransactionLockingGuard.ts @@ -13,12 +13,10 @@ export class PurchasesTransactionLockingGuard { * Validates the transaction locking of purchases services commands. * @param {Date} transactionDate - The transaction date. */ - public transactionLockingGuard = async ( - transactionDate: MomentInput - ) => { + public transactionLockingGuard = async (transactionDate: MomentInput) => { await this.transactionLockingGuardService.transactionsLockingGuard( transactionDate, - TransactionsLockingGroup.Purchases + TransactionsLockingGroup.Purchases, ); }; } diff --git a/packages/server/src/modules/TransactionsLocking/guards/SalesTransactionLockingGuard.ts b/packages/server/src/modules/TransactionsLocking/guards/SalesTransactionLockingGuard.ts index fc8d8bd4a..917f6666f 100644 --- a/packages/server/src/modules/TransactionsLocking/guards/SalesTransactionLockingGuard.ts +++ b/packages/server/src/modules/TransactionsLocking/guards/SalesTransactionLockingGuard.ts @@ -13,12 +13,10 @@ export class SalesTransactionLockingGuard { * Validates the transaction locking of sales services commands. * @param {Date} transactionDate - The transaction date. */ - public transactionLockingGuard = async ( - transactionDate: MomentInput - ) => { + public transactionLockingGuard = async (transactionDate: MomentInput) => { await this.transactionLockingGuardService.transactionsLockingGuard( transactionDate, - TransactionsLockingGroup.Sales + TransactionsLockingGroup.Sales, ); }; } diff --git a/packages/server/src/modules/TransactionsLocking/guards/TransactionsLockingGuard.ts b/packages/server/src/modules/TransactionsLocking/guards/TransactionsLockingGuard.ts index d0e4665fd..335892963 100644 --- a/packages/server/src/modules/TransactionsLocking/guards/TransactionsLockingGuard.ts +++ b/packages/server/src/modules/TransactionsLocking/guards/TransactionsLockingGuard.ts @@ -10,7 +10,7 @@ import { ServiceError } from '@/modules/Items/ServiceError'; export class TransactionsLockingGuard { constructor( private readonly transactionsLockingRepo: TransactionsLockingRepository, - ) { } + ) {} /** * Detarmines whether the transaction date between the locking date period. @@ -31,7 +31,7 @@ export class TransactionsLockingGuard { const inUnlockDate = unlockFromDate && unlockToDate ? moment(transactionDate).isSameOrAfter(unlockFromDate) && - moment(transactionDate).isSameOrBefore(unlockFromDate) + moment(transactionDate).isSameOrBefore(unlockFromDate) : false; // Retruns true in case the transaction date between locking date @@ -71,10 +71,14 @@ export class TransactionsLockingGuard { const { lockToDate } = await this.transactionsLockingRepo.getTransactionsLocking(lockingGroup); - throw new ServiceError(ERRORS.TRANSACTIONS_DATE_LOCKED, 'Transactions locked', { - lockedToDate: lockToDate, - formattedLockedToDate: moment(lockToDate).format('YYYY/MM/DD'), - }); + throw new ServiceError( + ERRORS.TRANSACTIONS_DATE_LOCKED, + 'Transactions locked', + { + lockedToDate: lockToDate, + formattedLockedToDate: moment(lockToDate).format('YYYY/MM/DD'), + }, + ); }; /** diff --git a/packages/server/src/modules/TransactionsLocking/subscribers/FinancialsTransactionLockingGuardSubscriber.ts b/packages/server/src/modules/TransactionsLocking/subscribers/FinancialsTransactionLockingGuardSubscriber.ts index 0869f7f5e..398e243a8 100644 --- a/packages/server/src/modules/TransactionsLocking/subscribers/FinancialsTransactionLockingGuardSubscriber.ts +++ b/packages/server/src/modules/TransactionsLocking/subscribers/FinancialsTransactionLockingGuardSubscriber.ts @@ -22,7 +22,7 @@ import { events } from '@/common/events/events'; export class FinancialTransactionLockingGuardSubscriber { constructor( public readonly financialTransactionsLocking: FinancialTransactionLocking, - ) { } + ) {} /** * --------------------------------------------- diff --git a/packages/server/src/modules/TransactionsLocking/subscribers/PurchasesTransactionLockingGuardSubscriber.ts b/packages/server/src/modules/TransactionsLocking/subscribers/PurchasesTransactionLockingGuardSubscriber.ts index ec8340d88..c0e7cb104 100644 --- a/packages/server/src/modules/TransactionsLocking/subscribers/PurchasesTransactionLockingGuardSubscriber.ts +++ b/packages/server/src/modules/TransactionsLocking/subscribers/PurchasesTransactionLockingGuardSubscriber.ts @@ -26,7 +26,7 @@ import { OnEvent } from '@nestjs/event-emitter'; export class PurchasesTransactionLockingGuardSubscriber { constructor( public readonly purchasesTransactionsLocking: PurchasesTransactionLockingGuard, - ) { } + ) {} /** * --------------------------------------------- diff --git a/packages/server/src/modules/TransactionsLocking/subscribers/SalesTransactionLockingGuardSubscriber.ts b/packages/server/src/modules/TransactionsLocking/subscribers/SalesTransactionLockingGuardSubscriber.ts index 4cbc8af22..aca58d3df 100644 --- a/packages/server/src/modules/TransactionsLocking/subscribers/SalesTransactionLockingGuardSubscriber.ts +++ b/packages/server/src/modules/TransactionsLocking/subscribers/SalesTransactionLockingGuardSubscriber.ts @@ -37,7 +37,7 @@ import { ISaleReceiptEventClosingPayload } from '@/modules/SaleReceipts/types/Sa export class SalesTransactionLockingGuardSubscriber { constructor( public readonly salesLockingGuard: SalesTransactionLockingGuard, - ) { } + ) {} /** * --------------------------------------------- diff --git a/packages/server/src/modules/UsersModule/Users.module.ts b/packages/server/src/modules/UsersModule/Users.module.ts index 3e16edd91..b267c5ccd 100644 --- a/packages/server/src/modules/UsersModule/Users.module.ts +++ b/packages/server/src/modules/UsersModule/Users.module.ts @@ -59,8 +59,12 @@ const models = [InjectSystemModel(UserInvite)]; InviteSendMainNotificationSubscribe, SendInviteUserMailProcessor, SendInviteUsersMailMessage, - UsersApplication + UsersApplication, + ], + controllers: [ + UsersController, + UsersInviteController, + UsersInvitePublicController, ], - controllers: [UsersController, UsersInviteController, UsersInvitePublicController], }) export class UsersModule {} diff --git a/packages/server/src/modules/UsersModule/commands/AcceptInviteUser.service.ts b/packages/server/src/modules/UsersModule/commands/AcceptInviteUser.service.ts index d228a88c7..2c7bc45b6 100644 --- a/packages/server/src/modules/UsersModule/commands/AcceptInviteUser.service.ts +++ b/packages/server/src/modules/UsersModule/commands/AcceptInviteUser.service.ts @@ -17,8 +17,8 @@ import { ModelObject } from 'objection'; import { InviteUserDto } from '../dtos/InviteUser.dto'; interface InviteAcceptResponseDto { - inviteToken: { email: string, token: string, createdAt: Date }; - orgName: string + inviteToken: { email: string; token: string; createdAt: Date }; + orgName: string; } @Injectable() @@ -92,9 +92,7 @@ export class AcceptInviteUserService { * @param {string} token - the given token string. * @throws {ServiceError} */ - public async checkInvite( - token: string, - ): Promise { + public async checkInvite(token: string): Promise { const inviteToken = await this.getInviteTokenOrThrowError(token); // Find the tenant that associated to the given token. diff --git a/packages/server/src/modules/UsersModule/commands/EditUser.service.ts b/packages/server/src/modules/UsersModule/commands/EditUser.service.ts index e1024a072..28013b72c 100644 --- a/packages/server/src/modules/UsersModule/commands/EditUser.service.ts +++ b/packages/server/src/modules/UsersModule/commands/EditUser.service.ts @@ -18,7 +18,7 @@ export class EditUserService { private readonly tenantUserModel: TenantModelProxy, private readonly eventEmitter: EventEmitter2, private readonly tenancyContext: TenancyContext, - ) { } + ) {} /** * Creates a new user. diff --git a/packages/server/src/modules/UsersModule/commands/InviteUser.service.ts b/packages/server/src/modules/UsersModule/commands/InviteUser.service.ts index 951b685c1..7f694b578 100644 --- a/packages/server/src/modules/UsersModule/commands/InviteUser.service.ts +++ b/packages/server/src/modules/UsersModule/commands/InviteUser.service.ts @@ -78,7 +78,9 @@ export class InviteTenantUserService { * @param {string} email - * @return {Promise<{ invite: IUserInvite }>} */ - public async resendInvite(userId: number): Promise<{ user: ModelObject }> { + public async resendInvite( + userId: number, + ): Promise<{ user: ModelObject }> { // Retrieve the user by id or throw not found service error. const user = await this.getUserByIdOrThrowError(userId); diff --git a/packages/server/src/modules/UsersModule/queries/GetUsers.service.ts b/packages/server/src/modules/UsersModule/queries/GetUsers.service.ts index 74c9484fb..2bb125bfd 100644 --- a/packages/server/src/modules/UsersModule/queries/GetUsers.service.ts +++ b/packages/server/src/modules/UsersModule/queries/GetUsers.service.ts @@ -18,9 +18,6 @@ export class GetUsersService { public async getUsers() { const users = await this.tenantUserModel().query().withGraphFetched('role'); - return this.transformerInjectable.transform( - users, - new UserTransformer(), - ); + return this.transformerInjectable.transform(users, new UserTransformer()); } } diff --git a/packages/server/src/modules/UsersModule/subscribers/PurgeUserAbilityCache.subscriber.ts b/packages/server/src/modules/UsersModule/subscribers/PurgeUserAbilityCache.subscriber.ts index 372694845..7d7ea1cb2 100644 --- a/packages/server/src/modules/UsersModule/subscribers/PurgeUserAbilityCache.subscriber.ts +++ b/packages/server/src/modules/UsersModule/subscribers/PurgeUserAbilityCache.subscriber.ts @@ -26,4 +26,4 @@ export class PurgeUserAbilityCacheSubscriber { | ITenantUserEditedPayload) { ABILITIES_CACHE.del(tenantUser.systemUserId); } -} \ No newline at end of file +} diff --git a/packages/server/src/modules/UsersModule/subscribers/SyncSystemSendInvite.subscriber.ts b/packages/server/src/modules/UsersModule/subscribers/SyncSystemSendInvite.subscriber.ts index ed74118b0..161899cd0 100644 --- a/packages/server/src/modules/UsersModule/subscribers/SyncSystemSendInvite.subscriber.ts +++ b/packages/server/src/modules/UsersModule/subscribers/SyncSystemSendInvite.subscriber.ts @@ -1,4 +1,3 @@ - import { EventEmitter2, OnEvent } from '@nestjs/event-emitter'; import { Inject, Injectable } from '@nestjs/common'; import { @@ -25,7 +24,7 @@ export class SyncSystemSendInviteSubscriber { @Inject(UserInvite.name) private readonly inviteModel: typeof UserInvite, private readonly eventEmitter: EventEmitter2, - private readonly tenancyContext: TenancyContext + private readonly tenancyContext: TenancyContext, ) {} /** @@ -33,7 +32,11 @@ export class SyncSystemSendInviteSubscriber { * @param {IUserInvitedEventPayload} payload - */ @OnEvent(events.inviteUser.sendInvite) - async syncSendInviteSystem({ inviteToken, user, invitingUser }: IUserInvitedEventPayload) { + async syncSendInviteSystem({ + inviteToken, + user, + invitingUser, + }: IUserInvitedEventPayload) { const authorizedUser = await this.tenancyContext.getSystemUser(); const tenantId = authorizedUser.tenantId; @@ -95,7 +98,10 @@ export class SyncSystemSendInviteSubscriber { * Clear invite tokens of the given user id. * @param {number} userId - User id. */ - private clearInviteTokensByUserId = async (tenantId: number, userId: number) => { + private clearInviteTokensByUserId = async ( + tenantId: number, + userId: number, + ) => { await this.inviteModel .query() .where({ diff --git a/packages/server/src/modules/UsersModule/subscribers/SyncTenantUserSaved.subscriber.ts b/packages/server/src/modules/UsersModule/subscribers/SyncTenantUserSaved.subscriber.ts index e3a624403..c598c98d4 100644 --- a/packages/server/src/modules/UsersModule/subscribers/SyncTenantUserSaved.subscriber.ts +++ b/packages/server/src/modules/UsersModule/subscribers/SyncTenantUserSaved.subscriber.ts @@ -4,7 +4,7 @@ import { ITenantUserActivatedPayload, ITenantUserEditedPayload, ITenantUserInactivatedPayload, -} from '../Users.types' +} from '../Users.types'; import { OnEvent } from '@nestjs/event-emitter'; import { SystemUser } from '@/modules/System/models/SystemUser'; import { events } from '@/common/events/events'; diff --git a/packages/server/src/modules/VendorCredit/BulkDeleteVendorCredits.service.ts b/packages/server/src/modules/VendorCredit/BulkDeleteVendorCredits.service.ts index a77e6b818..5bb0bfd88 100644 --- a/packages/server/src/modules/VendorCredit/BulkDeleteVendorCredits.service.ts +++ b/packages/server/src/modules/VendorCredit/BulkDeleteVendorCredits.service.ts @@ -8,7 +8,7 @@ import { DeleteVendorCreditService } from './commands/DeleteVendorCredit.service export class BulkDeleteVendorCreditsService { constructor( private readonly deleteVendorCreditService: DeleteVendorCreditService, - ) { } + ) {} async bulkDeleteVendorCredits( vendorCreditIds: number | Array, @@ -37,4 +37,3 @@ export class BulkDeleteVendorCreditsService { } } } - diff --git a/packages/server/src/modules/VendorCredit/ValidateBulkDeleteVendorCredits.service.ts b/packages/server/src/modules/VendorCredit/ValidateBulkDeleteVendorCredits.service.ts index c5a4d1929..0fa0ca9c8 100644 --- a/packages/server/src/modules/VendorCredit/ValidateBulkDeleteVendorCredits.service.ts +++ b/packages/server/src/modules/VendorCredit/ValidateBulkDeleteVendorCredits.service.ts @@ -9,7 +9,7 @@ export class ValidateBulkDeleteVendorCreditsService { private readonly deleteVendorCreditService: DeleteVendorCreditService, @Inject(TENANCY_DB_CONNECTION) private readonly tenantKnex: () => Knex, - ) { } + ) {} public async validateBulkDeleteVendorCredits( vendorCreditIds: number[], @@ -53,4 +53,3 @@ export class ValidateBulkDeleteVendorCreditsService { } } } - diff --git a/packages/server/src/modules/VendorCredit/VendorCredits.controller.ts b/packages/server/src/modules/VendorCredit/VendorCredits.controller.ts index c4d08d31a..f6cc28812 100644 --- a/packages/server/src/modules/VendorCredit/VendorCredits.controller.ts +++ b/packages/server/src/modules/VendorCredit/VendorCredits.controller.ts @@ -41,7 +41,7 @@ import { VendorCreditAction } from './types/VendorCredit.types'; export class VendorCreditsController { constructor( private readonly vendorCreditsApplication: VendorCreditsApplicationService, - ) { } + ) {} @Post('validate-bulk-delete') @RequirePermission(VendorCreditAction.Delete, AbilitySubject.VendorCredit) diff --git a/packages/server/src/modules/VendorCredit/VendorCredits.module.ts b/packages/server/src/modules/VendorCredit/VendorCredits.module.ts index ff9e9365a..c4f1599c7 100644 --- a/packages/server/src/modules/VendorCredit/VendorCredits.module.ts +++ b/packages/server/src/modules/VendorCredit/VendorCredits.module.ts @@ -83,4 +83,4 @@ import { ValidateBulkDeleteVendorCreditsService } from './ValidateBulkDeleteVend ], controllers: [VendorCreditsController], }) -export class VendorCreditsModule { } +export class VendorCreditsModule {} diff --git a/packages/server/src/modules/VendorCredit/VendorCreditsApplication.service.ts b/packages/server/src/modules/VendorCredit/VendorCreditsApplication.service.ts index aacf02b6a..e33e8f4bf 100644 --- a/packages/server/src/modules/VendorCredit/VendorCreditsApplication.service.ts +++ b/packages/server/src/modules/VendorCredit/VendorCreditsApplication.service.ts @@ -3,9 +3,7 @@ import { CreateVendorCreditService } from './commands/CreateVendorCredit.service import { DeleteVendorCreditService } from './commands/DeleteVendorCredit.service'; import { EditVendorCreditService } from './commands/EditVendorCredit.service'; import { GetVendorCreditService } from './queries/GetVendorCredit.service'; -import { - IVendorCreditEditDTO, -} from './types/VendorCredit.types'; +import { IVendorCreditEditDTO } from './types/VendorCredit.types'; import { IVendorCreditCreateDTO } from './types/VendorCredit.types'; import { GetVendorCreditsQueryDto } from './dtos/GetVendorCreditsQuery.dto'; import { Injectable } from '@nestjs/common'; @@ -36,7 +34,7 @@ export class VendorCreditsApplicationService { private readonly getVendorCreditsService: GetVendorCreditsService, private readonly bulkDeleteVendorCreditsService: BulkDeleteVendorCreditsService, private readonly validateBulkDeleteVendorCreditsService: ValidateBulkDeleteVendorCreditsService, - ) { } + ) {} /** * Creates a new vendor credit. diff --git a/packages/server/src/modules/VendorCredit/commands/VendorCreditAutoIncrement.service.ts b/packages/server/src/modules/VendorCredit/commands/VendorCreditAutoIncrement.service.ts index f7be79a70..17b929225 100644 --- a/packages/server/src/modules/VendorCredit/commands/VendorCreditAutoIncrement.service.ts +++ b/packages/server/src/modules/VendorCredit/commands/VendorCreditAutoIncrement.service.ts @@ -1,7 +1,6 @@ import { AutoIncrementOrdersService } from '@/modules/AutoIncrementOrders/AutoIncrementOrders.service'; import { Injectable } from '@nestjs/common'; - @Injectable() export class VendorCreditAutoIncrementService { /** diff --git a/packages/server/src/modules/VendorCredit/commands/VendorCreditDTOTransform.service.ts b/packages/server/src/modules/VendorCredit/commands/VendorCreditDTOTransform.service.ts index 8c2c05016..84f76e28d 100644 --- a/packages/server/src/modules/VendorCredit/commands/VendorCreditDTOTransform.service.ts +++ b/packages/server/src/modules/VendorCredit/commands/VendorCreditDTOTransform.service.ts @@ -31,7 +31,7 @@ export class VendorCreditDTOTransformService { private branchDTOTransform: BranchTransactionDTOTransformer, private warehouseDTOTransform: WarehouseTransactionDTOTransform, private vendorCreditAutoIncrement: VendorCreditAutoIncrementService, - ) { } + ) {} /** * Transforms the credit/edit vendor credit DTO to model. @@ -71,10 +71,9 @@ export class VendorCreditDTOTransformService { autoNextNumber; const initialDTO = { - ...formatDateFields( - omit(vendorCreditDTO, ['open', 'attachments']), - ['vendorCreditDate'], - ), + ...formatDateFields(omit(vendorCreditDTO, ['open', 'attachments']), [ + 'vendorCreditDate', + ]), amount, currencyCode: vendorCurrencyCode, exchangeRate: vendorCreditDTO.exchangeRate || 1, @@ -82,8 +81,8 @@ export class VendorCreditDTOTransformService { entries, ...(vendorCreditDTO.open && !oldVendorCredit?.openedAt && { - openedAt: moment().toMySqlDateTime(), - }), + openedAt: moment().toMySqlDateTime(), + }), }; return composeAsync( this.branchDTOTransform.transformDTO, diff --git a/packages/server/src/modules/VendorCredit/commands/VendorCreditInventoryTransactions.ts b/packages/server/src/modules/VendorCredit/commands/VendorCreditInventoryTransactions.ts index d35cec5b3..1e4a3ba75 100644 --- a/packages/server/src/modules/VendorCredit/commands/VendorCreditInventoryTransactions.ts +++ b/packages/server/src/modules/VendorCredit/commands/VendorCreditInventoryTransactions.ts @@ -9,7 +9,7 @@ import { ItemsEntriesService } from '@/modules/Items/ItemsEntries.service'; export class VendorCreditInventoryTransactions { constructor( private readonly inventoryService: InventoryTransactionsService, - private readonly itemsEntriesService: ItemsEntriesService + private readonly itemsEntriesService: ItemsEntriesService, ) {} /** @@ -19,12 +19,12 @@ export class VendorCreditInventoryTransactions { */ public createInventoryTransactions = async ( vendorCredit: VendorCredit, - trx: Knex.Transaction + trx: Knex.Transaction, ): Promise => { // Loads the inventory items entries of the given sale invoice. const inventoryEntries = await this.itemsEntriesService.filterInventoryEntries( - vendorCredit.entries + vendorCredit.entries, ); const transaction = { @@ -42,7 +42,7 @@ export class VendorCreditInventoryTransactions { await this.inventoryService.recordInventoryTransactionsFromItemsEntries( transaction, false, - trx + trx, ); }; @@ -55,14 +55,14 @@ export class VendorCreditInventoryTransactions { public async editInventoryTransactions( vendorCreditId: number, vendorCredit: VendorCredit, - trx?: Knex.Transaction + trx?: Knex.Transaction, ): Promise { // Deletes inventory transactions. await this.deleteInventoryTransactions(vendorCreditId, trx); // Re-write inventory transactions. await this.createInventoryTransactions(vendorCredit, trx); - }; + } /** * Deletes credit note associated inventory transactions. @@ -71,13 +71,13 @@ export class VendorCreditInventoryTransactions { */ public async deleteInventoryTransactions( vendorCreditId: number, - trx?: Knex.Transaction + trx?: Knex.Transaction, ): Promise { // Deletes the inventory transactions by the given reference id and type. await this.inventoryService.deleteInventoryTransactions( vendorCreditId, 'VendorCredit', - trx + trx, ); - }; + } } diff --git a/packages/server/src/modules/VendorCredit/commands/VendorCreditsImportable.ts b/packages/server/src/modules/VendorCredit/commands/VendorCreditsImportable.ts index e5006bf27..492627f5c 100644 --- a/packages/server/src/modules/VendorCredit/commands/VendorCreditsImportable.ts +++ b/packages/server/src/modules/VendorCredit/commands/VendorCreditsImportable.ts @@ -11,9 +11,9 @@ import { VendorCredit } from '../models/VendorCredit'; @ImportableService({ name: VendorCredit.name }) export class VendorCreditsImportable extends Importable { constructor( - private readonly createVendorCreditService: CreateVendorCreditService, + private readonly createVendorCreditService: CreateVendorCreditService, ) { - super() + super(); } /** @@ -24,11 +24,11 @@ export class VendorCreditsImportable extends Importable { */ public importable( createPaymentDTO: CreateVendorCreditDto, - trx?: Knex.Transaction + trx?: Knex.Transaction, ) { return this.createVendorCreditService.newVendorCredit( createPaymentDTO, - trx + trx, ); } diff --git a/packages/server/src/modules/VendorCredit/models/VendorCredit.meta.ts b/packages/server/src/modules/VendorCredit/models/VendorCredit.meta.ts index 6410e6f78..24eaf434e 100644 --- a/packages/server/src/modules/VendorCredit/models/VendorCredit.meta.ts +++ b/packages/server/src/modules/VendorCredit/models/VendorCredit.meta.ts @@ -245,7 +245,7 @@ export const VendorCreditMeta = { relationModel: 'Branch', relationImportMatch: ['name', 'code'], features: [Features.BRANCHES], - required: true + required: true, }, warehouseId: { name: 'invoice.field.warehouse', @@ -253,7 +253,7 @@ export const VendorCreditMeta = { relationModel: 'Warehouse', relationImportMatch: ['name', 'code'], features: [Features.WAREHOUSES], - required: true + required: true, }, }, -}; \ No newline at end of file +}; diff --git a/packages/server/src/modules/VendorCredit/queries/VendorCreditTransformer.ts b/packages/server/src/modules/VendorCredit/queries/VendorCreditTransformer.ts index 39809923d..b687e595a 100644 --- a/packages/server/src/modules/VendorCredit/queries/VendorCreditTransformer.ts +++ b/packages/server/src/modules/VendorCredit/queries/VendorCreditTransformer.ts @@ -1,7 +1,7 @@ -import { AttachmentTransformer } from "@/modules/Attachments/Attachment.transformer"; -import { ItemEntryTransformer } from "@/modules/TransactionItemEntry/ItemEntry.transformer"; -import { Transformer } from "@/modules/Transformer/Transformer"; -import { VendorCredit } from "../models/VendorCredit"; +import { AttachmentTransformer } from '@/modules/Attachments/Attachment.transformer'; +import { ItemEntryTransformer } from '@/modules/TransactionItemEntry/ItemEntry.transformer'; +import { Transformer } from '@/modules/Transformer/Transformer'; +import { VendorCredit } from '../models/VendorCredit'; export class VendorCreditTransformer extends Transformer { /** @@ -35,7 +35,9 @@ export class VendorCreditTransformer extends Transformer { * @param {VendorCredit} credit * @returns {String} */ - protected formattedVendorCreditDate = (vendorCredit: VendorCredit): string => { + protected formattedVendorCreditDate = ( + vendorCredit: VendorCredit, + ): string => { return this.formatDate(vendorCredit.vendorCreditDate); }; diff --git a/packages/server/src/modules/VendorCredit/subscribers/VendorCreditAutoSerialSubscriber.ts b/packages/server/src/modules/VendorCredit/subscribers/VendorCreditAutoSerialSubscriber.ts index 48d8d6b34..7d4a58d77 100644 --- a/packages/server/src/modules/VendorCredit/subscribers/VendorCreditAutoSerialSubscriber.ts +++ b/packages/server/src/modules/VendorCredit/subscribers/VendorCreditAutoSerialSubscriber.ts @@ -8,14 +8,14 @@ import { IVendorCreditCreatedPayload } from '../types/VendorCredit.types'; export class VendorCreditAutoSerialSubscriber { constructor( private readonly vendorCreditIncrementService: VendorCreditAutoIncrementService, - ) { } + ) {} /** * Auto serial increment once vendor credit created. * @param {IVendorCreditCreatedPayload} payload - */ @OnEvent(events.vendorCredit.onCreated) - async autoSerialIncrementOnceCreated({ }: IVendorCreditCreatedPayload) { + async autoSerialIncrementOnceCreated({}: IVendorCreditCreatedPayload) { await this.vendorCreditIncrementService.incrementSerialNumber(); } } diff --git a/packages/server/src/modules/VendorCreditsApplyBills/VendorCreditApplyBills.controller.ts b/packages/server/src/modules/VendorCreditsApplyBills/VendorCreditApplyBills.controller.ts index f1858d4a2..b7c225d69 100644 --- a/packages/server/src/modules/VendorCreditsApplyBills/VendorCreditApplyBills.controller.ts +++ b/packages/server/src/modules/VendorCreditsApplyBills/VendorCreditApplyBills.controller.ts @@ -28,7 +28,9 @@ export class VendorCreditApplyBillsController { @Get(':vendorCreditId/bills-to-apply') @RequirePermission(VendorCreditAction.View, AbilitySubject.VendorCredit) - @ApiOperation({ summary: 'Get bills that can be applied with this vendor credit.' }) + @ApiOperation({ + summary: 'Get bills that can be applied with this vendor credit.', + }) async getVendorCreditToApplyBills( @Param('vendorCreditId') vendorCreditId: number, ) { diff --git a/packages/server/src/modules/VendorCreditsApplyBills/VendorCreditApplyBills.module.ts b/packages/server/src/modules/VendorCreditsApplyBills/VendorCreditApplyBills.module.ts index fcc27805b..e263e7f48 100644 --- a/packages/server/src/modules/VendorCreditsApplyBills/VendorCreditApplyBills.module.ts +++ b/packages/server/src/modules/VendorCreditsApplyBills/VendorCreditApplyBills.module.ts @@ -22,7 +22,7 @@ import { VendorCreditsModule } from '../VendorCredit/VendorCredits.module'; ItemsModule, BranchesModule, WarehousesModule, - VendorCreditsModule + VendorCreditsModule, ], providers: [ ApplyVendorCreditSyncBillsService, @@ -35,4 +35,4 @@ import { VendorCreditsModule } from '../VendorCredit/VendorCredits.module'; ], controllers: [VendorCreditApplyBillsController], }) -export class VendorCreditApplyBillsModule { } +export class VendorCreditApplyBillsModule {} diff --git a/packages/server/src/modules/VendorCreditsApplyBills/queries/VendorCreditAppliedBillTransformer.ts b/packages/server/src/modules/VendorCreditsApplyBills/queries/VendorCreditAppliedBillTransformer.ts index a03fd9249..53fdeaf36 100644 --- a/packages/server/src/modules/VendorCreditsApplyBills/queries/VendorCreditAppliedBillTransformer.ts +++ b/packages/server/src/modules/VendorCreditsApplyBills/queries/VendorCreditAppliedBillTransformer.ts @@ -1,5 +1,5 @@ -import { Transformer } from "@/modules/Transformer/Transformer"; -import { VendorCreditAppliedBill } from "@/modules/VendorCreditsApplyBills/models/VendorCreditAppliedBill"; +import { Transformer } from '@/modules/Transformer/Transformer'; +import { VendorCreditAppliedBill } from '@/modules/VendorCreditsApplyBills/models/VendorCreditAppliedBill'; export class VendorCreditAppliedBillTransformer extends Transformer { /** @@ -27,9 +27,9 @@ export class VendorCreditAppliedBillTransformer extends Transformer { }; /** - * - * @param item - * @returns + * + * @param item + * @returns */ protected formattedAmount = (item: VendorCreditAppliedBill) => { return this.formatNumber(item.amount, { diff --git a/packages/server/src/modules/VendorCreditsRefund/VendorCreditsRefund.application.ts b/packages/server/src/modules/VendorCreditsRefund/VendorCreditsRefund.application.ts index 38834239d..5b959c42c 100644 --- a/packages/server/src/modules/VendorCreditsRefund/VendorCreditsRefund.application.ts +++ b/packages/server/src/modules/VendorCreditsRefund/VendorCreditsRefund.application.ts @@ -20,7 +20,7 @@ export class VendorCreditsRefundApplication { private readonly deleteRefundVendorCreditService: DeleteRefundVendorCreditService, private readonly getRefundVendorCreditsService: GetRefundVendorCreditsService, private readonly getRefundVendorCreditService: GetRefundVendorCreditService, - ) { } + ) {} /** * Retrieve the vendor credit refunds graph. diff --git a/packages/server/src/modules/VendorCreditsRefund/VendorCreditsRefund.controller.ts b/packages/server/src/modules/VendorCreditsRefund/VendorCreditsRefund.controller.ts index f7d0081c9..e0b326f3b 100644 --- a/packages/server/src/modules/VendorCreditsRefund/VendorCreditsRefund.controller.ts +++ b/packages/server/src/modules/VendorCreditsRefund/VendorCreditsRefund.controller.ts @@ -25,7 +25,7 @@ import { VendorCreditAction } from '../VendorCredit/types/VendorCredit.types'; export class VendorCreditsRefundController { constructor( private readonly vendorCreditsRefundApplication: VendorCreditsRefundApplication, - ) { } + ) {} /** * Retrieve a single refund vendor credit transaction by id. @@ -34,7 +34,9 @@ export class VendorCreditsRefundController { */ @Get('refunds/:refundCreditId') @RequirePermission(VendorCreditAction.View, AbilitySubject.VendorCredit) - @ApiOperation({ summary: 'Retrieve a refund vendor credit transaction by id.' }) + @ApiOperation({ + summary: 'Retrieve a refund vendor credit transaction by id.', + }) public getRefundVendorCreditTransaction( @Param('refundCreditId') refundCreditId: string, ) { diff --git a/packages/server/src/modules/VendorCreditsRefund/VendorCreditsRefund.module.ts b/packages/server/src/modules/VendorCreditsRefund/VendorCreditsRefund.module.ts index 49aa421cc..c6ec879ff 100644 --- a/packages/server/src/modules/VendorCreditsRefund/VendorCreditsRefund.module.ts +++ b/packages/server/src/modules/VendorCreditsRefund/VendorCreditsRefund.module.ts @@ -25,4 +25,4 @@ import { AccountsModule } from '../Accounts/Accounts.module'; ], controllers: [VendorCreditsRefundController], }) -export class VendorCreditsRefundModule { } +export class VendorCreditsRefundModule {} diff --git a/packages/server/src/modules/VendorCreditsRefund/commands/RefundVendorCreditGLEntries.ts b/packages/server/src/modules/VendorCreditsRefund/commands/RefundVendorCreditGLEntries.ts index 8c961233b..00c22a92f 100644 --- a/packages/server/src/modules/VendorCreditsRefund/commands/RefundVendorCreditGLEntries.ts +++ b/packages/server/src/modules/VendorCreditsRefund/commands/RefundVendorCreditGLEntries.ts @@ -22,7 +22,7 @@ export class RefundVendorCreditGLEntries { private readonly refundVendorCreditModel: TenantModelProxy< typeof RefundVendorCredit >, - ) { } + ) {} /** * Retrieves the refund vendor credit common GL entry. @@ -65,9 +65,8 @@ export class RefundVendorCreditGLEntries { refundVendorCredit: RefundVendorCredit, APAccountId: number, ): ILedgerEntry => { - const commonEntry = this.getRefundVendorCreditCommonGLEntry( - refundVendorCredit, - ); + const commonEntry = + this.getRefundVendorCreditCommonGLEntry(refundVendorCredit); return { ...commonEntry, @@ -87,9 +86,8 @@ export class RefundVendorCreditGLEntries { private getRefundVendorCreditGLDepositEntry = ( refundVendorCredit: RefundVendorCredit, ): ILedgerEntry => { - const commonEntry = this.getRefundVendorCreditCommonGLEntry( - refundVendorCredit, - ); + const commonEntry = + this.getRefundVendorCreditCommonGLEntry(refundVendorCredit); return { ...commonEntry, @@ -114,9 +112,8 @@ export class RefundVendorCreditGLEntries { refundVendorCredit, APAccountId, ); - const depositEntry = this.getRefundVendorCreditGLDepositEntry( - refundVendorCredit, - ); + const depositEntry = + this.getRefundVendorCreditGLDepositEntry(refundVendorCredit); return [payableEntry, depositEntry]; } diff --git a/packages/server/src/modules/VendorCreditsRefund/commands/RefundVendorCreditTransformer.ts b/packages/server/src/modules/VendorCreditsRefund/commands/RefundVendorCreditTransformer.ts index 1c211eba6..561fddec2 100644 --- a/packages/server/src/modules/VendorCreditsRefund/commands/RefundVendorCreditTransformer.ts +++ b/packages/server/src/modules/VendorCreditsRefund/commands/RefundVendorCreditTransformer.ts @@ -1,4 +1,4 @@ -import { Transformer } from "@/modules/Transformer/Transformer"; +import { Transformer } from '@/modules/Transformer/Transformer'; export class RefundVendorCreditTransformer extends Transformer { /** diff --git a/packages/server/src/modules/VendorCreditsRefund/constants.ts b/packages/server/src/modules/VendorCreditsRefund/constants.ts index 21f355ed3..a613b8240 100644 --- a/packages/server/src/modules/VendorCreditsRefund/constants.ts +++ b/packages/server/src/modules/VendorCreditsRefund/constants.ts @@ -1,5 +1,6 @@ export const ERRORS = { REFUND_VENDOR_CREDIT_NOT_FOUND: 'REFUND_VENDOR_CREDIT_NOT_FOUND', DEPOSIT_ACCOUNT_INVALID_TYPE: 'DEPOSIT_ACCOUNT_INVALID_TYPE', - VENDOR_CREDIT_HAS_NO_CREDITS_REMAINING: 'VENDOR_CREDIT_HAS_NO_CREDITS_REMAINING' -} \ No newline at end of file + VENDOR_CREDIT_HAS_NO_CREDITS_REMAINING: + 'VENDOR_CREDIT_HAS_NO_CREDITS_REMAINING', +}; diff --git a/packages/server/src/modules/VendorCreditsRefund/subscribers/RefundVendorCreditGLEntriesSubscriber.ts b/packages/server/src/modules/VendorCreditsRefund/subscribers/RefundVendorCreditGLEntriesSubscriber.ts index 620ac092b..a23a99cf3 100644 --- a/packages/server/src/modules/VendorCreditsRefund/subscribers/RefundVendorCreditGLEntriesSubscriber.ts +++ b/packages/server/src/modules/VendorCreditsRefund/subscribers/RefundVendorCreditGLEntriesSubscriber.ts @@ -11,7 +11,7 @@ import { OnEvent } from '@nestjs/event-emitter'; export class RefundVendorCreditGLEntriesSubscriber { constructor( private readonly refundVendorCreditGLEntries: RefundVendorCreditGLEntries, - ) { } + ) {} /** * Writes refund vendor credit GL entries once the transaction created. @@ -45,4 +45,3 @@ export class RefundVendorCreditGLEntriesSubscriber { ); } } - diff --git a/packages/server/src/modules/Vendors/BulkDeleteVendors.service.ts b/packages/server/src/modules/Vendors/BulkDeleteVendors.service.ts index d25d04176..76b699082 100644 --- a/packages/server/src/modules/Vendors/BulkDeleteVendors.service.ts +++ b/packages/server/src/modules/Vendors/BulkDeleteVendors.service.ts @@ -31,4 +31,3 @@ export class BulkDeleteVendorsService { } } } - diff --git a/packages/server/src/modules/Vendors/ValidateBulkDeleteVendors.service.ts b/packages/server/src/modules/Vendors/ValidateBulkDeleteVendors.service.ts index 8f51d36de..74c805f7b 100644 --- a/packages/server/src/modules/Vendors/ValidateBulkDeleteVendors.service.ts +++ b/packages/server/src/modules/Vendors/ValidateBulkDeleteVendors.service.ts @@ -58,4 +58,3 @@ export class ValidateBulkDeleteVendorsService { } } } - diff --git a/packages/server/src/modules/Vendors/VendorGLEntries.ts b/packages/server/src/modules/Vendors/VendorGLEntries.ts index 1c380bf6b..29a5b4508 100644 --- a/packages/server/src/modules/Vendors/VendorGLEntries.ts +++ b/packages/server/src/modules/Vendors/VendorGLEntries.ts @@ -36,7 +36,7 @@ export class VendorGLEntries { */ private getOpeningBalanceGLDebitEntry = ( costAccountId: number, - vendor: Vendor + vendor: Vendor, ): ILedgerEntry => { const commonEntry = this.getOpeningBalanceGLCommonEntry(vendor); @@ -58,7 +58,7 @@ export class VendorGLEntries { */ private getOpeningBalanceGLCreditEntry = ( APAccountId: number, - vendor: Vendor + vendor: Vendor, ): ILedgerEntry => { const commonEntry = this.getOpeningBalanceGLCommonEntry(vendor); @@ -81,15 +81,15 @@ export class VendorGLEntries { public getOpeningBalanceGLEntries = ( APAccountId: number, costAccountId: number, - vendor: Vendor + vendor: Vendor, ): ILedgerEntry[] => { const debitEntry = this.getOpeningBalanceGLDebitEntry( costAccountId, - vendor + vendor, ); const creditEntry = this.getOpeningBalanceGLCreditEntry( APAccountId, - vendor + vendor, ); return [debitEntry, creditEntry]; }; @@ -104,12 +104,12 @@ export class VendorGLEntries { public getOpeningBalanceLedger = ( APAccountId: number, costAccountId: number, - vendor: Vendor + vendor: Vendor, ) => { const entries = this.getOpeningBalanceGLEntries( APAccountId, costAccountId, - vendor + vendor, ); return new Ledger(entries); }; diff --git a/packages/server/src/modules/Vendors/VendorGLEntriesStorage.ts b/packages/server/src/modules/Vendors/VendorGLEntriesStorage.ts index fdb230ae4..cbd074678 100644 --- a/packages/server/src/modules/Vendors/VendorGLEntriesStorage.ts +++ b/packages/server/src/modules/Vendors/VendorGLEntriesStorage.ts @@ -15,7 +15,7 @@ export class VendorGLEntriesStorage { @Inject(Vendor.name) private readonly vendorModel: TenantModelProxy, - ) { } + ) {} /** * Vendor opening balance journals. @@ -26,22 +26,17 @@ export class VendorGLEntriesStorage { vendorId: number, trx?: Knex.Transaction, ) => { - const vendor = await this.vendorModel() - .query(trx) - .findById(vendorId); + const vendor = await this.vendorModel().query(trx).findById(vendorId); // Finds the expense account. - const expenseAccount = await this.accountRepository.findOrCreateOtherExpensesAccount( + const expenseAccount = + await this.accountRepository.findOrCreateOtherExpensesAccount({}, trx); + // Find or create the A/P account. + const APAccount = await this.accountRepository.findOrCreateAccountsPayable( + vendor.currencyCode, {}, trx, ); - // Find or create the A/P account. - const APAccount = - await this.accountRepository.findOrCreateAccountsPayable( - vendor.currencyCode, - {}, - trx, - ); // Retrieves the vendor opening balance ledger. const ledger = this.vendorGLEntries.getOpeningBalanceLedger( APAccount.id, diff --git a/packages/server/src/modules/Vendors/Vendors.controller.ts b/packages/server/src/modules/Vendors/Vendors.controller.ts index f3c29030c..f3618f626 100644 --- a/packages/server/src/modules/Vendors/Vendors.controller.ts +++ b/packages/server/src/modules/Vendors/Vendors.controller.ts @@ -103,9 +103,7 @@ export class VendorsController { validateBulkDeleteVendors( @Body() bulkDeleteDto: BulkDeleteVendorsDto, ): Promise { - return this.vendorsApplication.validateBulkDeleteVendors( - bulkDeleteDto.ids, - ); + return this.vendorsApplication.validateBulkDeleteVendors(bulkDeleteDto.ids); } @Post('bulk-delete') diff --git a/packages/server/src/modules/Vendors/Vendors.module.ts b/packages/server/src/modules/Vendors/Vendors.module.ts index 0bdba020e..e1d3ceec7 100644 --- a/packages/server/src/modules/Vendors/Vendors.module.ts +++ b/packages/server/src/modules/Vendors/Vendors.module.ts @@ -25,7 +25,12 @@ import { VendorGLEntriesStorage } from './VendorGLEntriesStorage'; import { VendorsWriteGLOpeningSubscriber } from './subscribers/VendorGLEntriesSubscriber'; @Module({ - imports: [TenancyDatabaseModule, DynamicListModule, LedgerModule, AccountsModule], + imports: [ + TenancyDatabaseModule, + DynamicListModule, + LedgerModule, + AccountsModule, + ], controllers: [VendorsController], providers: [ ActivateVendorService, @@ -49,4 +54,4 @@ import { VendorsWriteGLOpeningSubscriber } from './subscribers/VendorGLEntriesSu VendorsWriteGLOpeningSubscriber, ], }) -export class VendorsModule { } +export class VendorsModule {} diff --git a/packages/server/src/modules/Vendors/VendorsExportable.ts b/packages/server/src/modules/Vendors/VendorsExportable.ts index 9f9913954..133a16637 100644 --- a/packages/server/src/modules/Vendors/VendorsExportable.ts +++ b/packages/server/src/modules/Vendors/VendorsExportable.ts @@ -9,9 +9,7 @@ import { Vendor } from './models/Vendor'; @Injectable() @ExportableService({ name: Vendor.name }) export class VendorsExportable extends Exportable { - constructor( - private readonly vendorsApplication: VendorsApplication, - ) { + constructor(private readonly vendorsApplication: VendorsApplication) { super(); } diff --git a/packages/server/src/modules/Vendors/VendorsImportable.ts b/packages/server/src/modules/Vendors/VendorsImportable.ts index e8d31ba06..b52fb82fe 100644 --- a/packages/server/src/modules/Vendors/VendorsImportable.ts +++ b/packages/server/src/modules/Vendors/VendorsImportable.ts @@ -7,9 +7,7 @@ import { CreateVendorDto } from './dtos/CreateVendor.dto'; @Injectable() export class VendorsImportable extends Importable { - constructor( - private readonly createVendorService: CreateVendorService, - ) { + constructor(private readonly createVendorService: CreateVendorService) { super(); } @@ -20,7 +18,7 @@ export class VendorsImportable extends Importable { */ public async importable( createDTO: CreateVendorDto, - trx?: Knex.Transaction + trx?: Knex.Transaction, ): Promise { await this.createVendorService.createVendor(createDTO, trx); } diff --git a/packages/server/src/modules/Vendors/_SampleData.ts b/packages/server/src/modules/Vendors/_SampleData.ts index 5e6e4edda..80f76c695 100644 --- a/packages/server/src/modules/Vendors/_SampleData.ts +++ b/packages/server/src/modules/Vendors/_SampleData.ts @@ -1,122 +1,122 @@ export const VendorsSampleData = [ { - "First Name": "Nicolette", - "Last Name": "Schamberger", - "Company Name": "Homenick - Hane", - "Display Name": "Rowland Rowe", - "Email": "cicero86@yahoo.com", - "Personal Phone Number": "811-603-2235", - "Work Phone Number": "906-993-5190", - "Website": "http://google.com", - "Opening Balance": 54302.23, - "Opening Balance At": "2022-02-02", - "Opening Balance Ex. Rate": 2, - "Currency": "LYD", - "Active": "T", - "Note": "Doloribus autem optio temporibus dolores mollitia sit.", - "Billing Address 1": "862 Jessika Well", - "Billing Address 2": "1091 Dorthy Mount", - "Billing Address City": "Deckowfort", - "Billing Address Country": "Ghana", - "Billing Address Phone": "825-011-5207", - "Billing Address Postcode": "38228", - "Billing Address State": "Oregon", - "Shipping Address 1": "37626 Thiel Villages", - "Shipping Address 2": "132 Batz Avenue", - "Shipping Address City": "Pagacburgh", - "Shipping Address Country": "Albania", - "Shipping Address Phone": "171-546-3701", - "Shipping Address Postcode": "13709", - "Shipping Address State": "Georgia" + 'First Name': 'Nicolette', + 'Last Name': 'Schamberger', + 'Company Name': 'Homenick - Hane', + 'Display Name': 'Rowland Rowe', + Email: 'cicero86@yahoo.com', + 'Personal Phone Number': '811-603-2235', + 'Work Phone Number': '906-993-5190', + Website: 'http://google.com', + 'Opening Balance': 54302.23, + 'Opening Balance At': '2022-02-02', + 'Opening Balance Ex. Rate': 2, + Currency: 'LYD', + Active: 'T', + Note: 'Doloribus autem optio temporibus dolores mollitia sit.', + 'Billing Address 1': '862 Jessika Well', + 'Billing Address 2': '1091 Dorthy Mount', + 'Billing Address City': 'Deckowfort', + 'Billing Address Country': 'Ghana', + 'Billing Address Phone': '825-011-5207', + 'Billing Address Postcode': '38228', + 'Billing Address State': 'Oregon', + 'Shipping Address 1': '37626 Thiel Villages', + 'Shipping Address 2': '132 Batz Avenue', + 'Shipping Address City': 'Pagacburgh', + 'Shipping Address Country': 'Albania', + 'Shipping Address Phone': '171-546-3701', + 'Shipping Address Postcode': '13709', + 'Shipping Address State': 'Georgia', }, { - "First Name": "Hermann", - "Last Name": "Crooks", - "Company Name": "Veum - Schaefer", - "Display Name": "Harley Veum", - "Email": "immanuel56@hotmail.com", - "Personal Phone Number": "449-780-9999", - "Work Phone Number": "970-473-5785", - "Website": "http://google.com", - "Opening Balance": 54302.23, - "Opening Balance At": "2022-02-02", - "Opening Balance Ex. Rate": 2, - "Currency": "LYD", - "Active": "T", - "Note": "Doloribus dolore dolor dicta vitae in fugit nisi quibusdam.", - "Billing Address 1": "532 Simonis Spring", - "Billing Address 2": "3122 Nicolas Inlet", - "Billing Address City": "East Matteofort", - "Billing Address Country": "Holy See (Vatican City State)", - "Billing Address Phone": "366-084-8629", - "Billing Address Postcode": "41607", - "Billing Address State": "Montana", - "Shipping Address 1": "2889 Tremblay Plaza", - "Shipping Address 2": "71355 Kutch Isle", - "Shipping Address City": "D'Amorehaven", - "Shipping Address Country": "Monaco", - "Shipping Address Phone": "614-189-3328", - "Shipping Address Postcode": "09634-0435", - "Shipping Address State": "Nevada" + 'First Name': 'Hermann', + 'Last Name': 'Crooks', + 'Company Name': 'Veum - Schaefer', + 'Display Name': 'Harley Veum', + Email: 'immanuel56@hotmail.com', + 'Personal Phone Number': '449-780-9999', + 'Work Phone Number': '970-473-5785', + Website: 'http://google.com', + 'Opening Balance': 54302.23, + 'Opening Balance At': '2022-02-02', + 'Opening Balance Ex. Rate': 2, + Currency: 'LYD', + Active: 'T', + Note: 'Doloribus dolore dolor dicta vitae in fugit nisi quibusdam.', + 'Billing Address 1': '532 Simonis Spring', + 'Billing Address 2': '3122 Nicolas Inlet', + 'Billing Address City': 'East Matteofort', + 'Billing Address Country': 'Holy See (Vatican City State)', + 'Billing Address Phone': '366-084-8629', + 'Billing Address Postcode': '41607', + 'Billing Address State': 'Montana', + 'Shipping Address 1': '2889 Tremblay Plaza', + 'Shipping Address 2': '71355 Kutch Isle', + 'Shipping Address City': "D'Amorehaven", + 'Shipping Address Country': 'Monaco', + 'Shipping Address Phone': '614-189-3328', + 'Shipping Address Postcode': '09634-0435', + 'Shipping Address State': 'Nevada', }, { - "First Name": "Nellie", - "Last Name": "Gulgowski", - "Company Name": "Boyle, Heller and Jones", - "Display Name": "Randall Kohler", - "Email": "anibal_frami@yahoo.com", - "Personal Phone Number": "498-578-0740", - "Work Phone Number": "394-550-6827", - "Website": "http://google.com", - "Opening Balance": 54302.23, - "Opening Balance At": "2022-02-02", - "Opening Balance Ex. Rate": 2, - "Currency": "LYD", - "Active": "T", - "Note": "Vero quibusdam rem fugit aperiam est modi.", - "Billing Address 1": "214 Sauer Villages", - "Billing Address 2": "30687 Kacey Square", - "Billing Address City": "Jayceborough", - "Billing Address Country": "Benin", - "Billing Address Phone": "332-820-1127", - "Billing Address Postcode": "16425-3887", - "Billing Address State": "Mississippi", - "Shipping Address 1": "562 Diamond Loaf", - "Shipping Address 2": "9595 Satterfield Trafficway", - "Shipping Address City": "Alexandrinefort", - "Shipping Address Country": "Puerto Rico", - "Shipping Address Phone": "776-500-8456", - "Shipping Address Postcode": "30258", - "Shipping Address State": "South Dakota" + 'First Name': 'Nellie', + 'Last Name': 'Gulgowski', + 'Company Name': 'Boyle, Heller and Jones', + 'Display Name': 'Randall Kohler', + Email: 'anibal_frami@yahoo.com', + 'Personal Phone Number': '498-578-0740', + 'Work Phone Number': '394-550-6827', + Website: 'http://google.com', + 'Opening Balance': 54302.23, + 'Opening Balance At': '2022-02-02', + 'Opening Balance Ex. Rate': 2, + Currency: 'LYD', + Active: 'T', + Note: 'Vero quibusdam rem fugit aperiam est modi.', + 'Billing Address 1': '214 Sauer Villages', + 'Billing Address 2': '30687 Kacey Square', + 'Billing Address City': 'Jayceborough', + 'Billing Address Country': 'Benin', + 'Billing Address Phone': '332-820-1127', + 'Billing Address Postcode': '16425-3887', + 'Billing Address State': 'Mississippi', + 'Shipping Address 1': '562 Diamond Loaf', + 'Shipping Address 2': '9595 Satterfield Trafficway', + 'Shipping Address City': 'Alexandrinefort', + 'Shipping Address Country': 'Puerto Rico', + 'Shipping Address Phone': '776-500-8456', + 'Shipping Address Postcode': '30258', + 'Shipping Address State': 'South Dakota', }, { - "First Name": "Stone", - "Last Name": "Jerde", - "Company Name": "Cassin, Casper and Maggio", - "Display Name": "Clint McLaughlin", - "Email": "nathanael22@yahoo.com", - "Personal Phone Number": "562-790-6059", - "Work Phone Number": "686-838-0027", - "Website": "http://google.com", - "Opening Balance": 54302.23, - "Opening Balance At": "2022-02-02", - "Opening Balance Ex. Rate": 2, - "Currency": "LYD", - "Active": "T", - "Note": "Quis cumque molestias rerum.", - "Billing Address 1": "22590 Cathy Harbor", - "Billing Address 2": "24493 Brycen Brooks", - "Billing Address City": "Elnorashire", - "Billing Address Country": "Andorra", - "Billing Address Phone": "701-852-8005", - "Billing Address Postcode": "5680", - "Billing Address State": "Nevada", - "Shipping Address 1": "5355 Erdman Bridge", - "Shipping Address 2": "421 Jeanette Camp", - "Shipping Address City": "East Philip", - "Shipping Address Country": "Venezuela", - "Shipping Address Phone": "426-119-0858", - "Shipping Address Postcode": "34929-0501", - "Shipping Address State": "Tennessee" - } -] + 'First Name': 'Stone', + 'Last Name': 'Jerde', + 'Company Name': 'Cassin, Casper and Maggio', + 'Display Name': 'Clint McLaughlin', + Email: 'nathanael22@yahoo.com', + 'Personal Phone Number': '562-790-6059', + 'Work Phone Number': '686-838-0027', + Website: 'http://google.com', + 'Opening Balance': 54302.23, + 'Opening Balance At': '2022-02-02', + 'Opening Balance Ex. Rate': 2, + Currency: 'LYD', + Active: 'T', + Note: 'Quis cumque molestias rerum.', + 'Billing Address 1': '22590 Cathy Harbor', + 'Billing Address 2': '24493 Brycen Brooks', + 'Billing Address City': 'Elnorashire', + 'Billing Address Country': 'Andorra', + 'Billing Address Phone': '701-852-8005', + 'Billing Address Postcode': '5680', + 'Billing Address State': 'Nevada', + 'Shipping Address 1': '5355 Erdman Bridge', + 'Shipping Address 2': '421 Jeanette Camp', + 'Shipping Address City': 'East Philip', + 'Shipping Address Country': 'Venezuela', + 'Shipping Address Phone': '426-119-0858', + 'Shipping Address Postcode': '34929-0501', + 'Shipping Address State': 'Tennessee', + }, +]; diff --git a/packages/server/src/modules/Vendors/commands/CreateVendor.service.ts b/packages/server/src/modules/Vendors/commands/CreateVendor.service.ts index fcc7f69b8..6bc816b2f 100644 --- a/packages/server/src/modules/Vendors/commands/CreateVendor.service.ts +++ b/packages/server/src/modules/Vendors/commands/CreateVendor.service.ts @@ -35,7 +35,10 @@ export class CreateVendorService { * @param {IVendorNewDTO} vendorDTO * @return {Promise} */ - public async createVendor(vendorDTO: CreateVendorDto, trx?: Knex.Transaction) { + public async createVendor( + vendorDTO: CreateVendorDto, + trx?: Knex.Transaction, + ) { // Transforms create DTO to customer object. const vendorObject = await this.transformDTO.transformCreateDTO(vendorDTO); diff --git a/packages/server/src/modules/Vendors/dtos/BulkDeleteVendors.dto.ts b/packages/server/src/modules/Vendors/dtos/BulkDeleteVendors.dto.ts index f038ca1c6..93a575b0e 100644 --- a/packages/server/src/modules/Vendors/dtos/BulkDeleteVendors.dto.ts +++ b/packages/server/src/modules/Vendors/dtos/BulkDeleteVendors.dto.ts @@ -22,7 +22,9 @@ export class BulkDeleteVendorsDto { @IsOptional() @IsBoolean() - @Transform(({ value, obj }) => parseBoolean(value ?? obj?.skip_undeletable, false)) + @Transform(({ value, obj }) => + parseBoolean(value ?? obj?.skip_undeletable, false), + ) @ApiPropertyOptional({ description: 'When true, undeletable vendors will be skipped and only deletable ones removed.', @@ -59,4 +61,3 @@ export class ValidateBulkDeleteVendorsResponseDto { }) nonDeletableIds: number[]; } - diff --git a/packages/server/src/modules/Vendors/dtos/CreateVendor.dto.ts b/packages/server/src/modules/Vendors/dtos/CreateVendor.dto.ts index fd97a23fb..029e3c65d 100644 --- a/packages/server/src/modules/Vendors/dtos/CreateVendor.dto.ts +++ b/packages/server/src/modules/Vendors/dtos/CreateVendor.dto.ts @@ -34,10 +34,13 @@ export class CreateVendorDto extends ContactAddressDto { @ApiProperty({ required: false, - description: 'Date of the opening balance (required when openingBalance is provided)', + description: + 'Date of the opening balance (required when openingBalance is provided)', }) @ValidateIf((o) => o.openingBalance != null) - @IsNotEmpty({ message: 'openingBalanceAt is required when openingBalance is provided' }) + @IsNotEmpty({ + message: 'openingBalanceAt is required when openingBalance is provided', + }) @IsISO8601() openingBalanceAt?: Date; diff --git a/packages/server/src/modules/Vendors/models/Vendor.meta.ts b/packages/server/src/modules/Vendors/models/Vendor.meta.ts index 90411934f..634c47a25 100644 --- a/packages/server/src/modules/Vendors/models/Vendor.meta.ts +++ b/packages/server/src/modules/Vendors/models/Vendor.meta.ts @@ -131,26 +131,26 @@ export const VendorMeta = { openingBalance: { name: 'vendor.field.opening_balance', type: 'number', - printable: false + printable: false, }, openingBalanceAt: { name: 'vendor.field.opening_balance_at', type: 'date', - printable: false + printable: false, }, currencyCode: { name: 'vendor.field.currency', type: 'text', - printable: false + printable: false, }, status: { name: 'vendor.field.status', - printable: false + printable: false, }, note: { name: 'vendor.field.note', type: 'text', - printable: false + printable: false, }, // Billing Address billingAddress1: { @@ -158,49 +158,49 @@ export const VendorMeta = { column: 'billing_address1', type: 'text', exportable: true, - printable: false + printable: false, }, billingAddress2: { name: 'Billing Address 2', column: 'billing_address2', type: 'text', exportable: true, - printable: false + printable: false, }, billingAddressCity: { name: 'Billing Address City', column: 'billing_address_city', type: 'text', exportable: true, - printable: false + printable: false, }, billingAddressCountry: { name: 'Billing Address Country', column: 'billing_address_country', type: 'text', exportable: true, - printable: false + printable: false, }, billingAddressPostcode: { name: 'Billing Address Postcode', column: 'billing_address_postcode', type: 'text', exportable: true, - printable: false + printable: false, }, billingAddressState: { name: 'Billing Address State', column: 'billing_address_state', type: 'text', exportable: true, - printable: false + printable: false, }, billingAddressPhone: { name: 'Billing Address Phone', column: 'billing_address_phone', type: 'text', exportable: true, - printable: false + printable: false, }, // Shipping Address shippingAddress1: { @@ -208,55 +208,55 @@ export const VendorMeta = { column: 'shipping_address1', type: 'text', exportable: true, - printable: false + printable: false, }, shippingAddress2: { name: 'Shipping Address 2', column: 'shipping_address2', type: 'text', exportable: true, - printable: false + printable: false, }, shippingAddressCity: { name: 'Shipping Address City', column: 'shipping_address_city', type: 'text', exportable: true, - printable: false + printable: false, }, shippingAddressCountry: { name: 'Shipping Address Country', column: 'shipping_address_country', type: 'text', exportable: true, - printable: false + printable: false, }, shippingAddressPostcode: { name: 'Shipping Address Postcode', column: 'shipping_address_postcode', type: 'text', exportable: true, - printable: false + printable: false, }, shippingAddressState: { name: 'Shipping Address State', column: 'shipping_address_state', type: 'text', exportable: true, - printable: false + printable: false, }, shippingAddressPhone: { name: 'Shipping Address Phone', column: 'shipping_address_phone', type: 'text', exportable: true, - printable: false + printable: false, }, createdAt: { name: 'vendor.field.created_at', type: 'date', exportable: true, - printable: false + printable: false, }, }, fields2: { @@ -404,4 +404,4 @@ export const VendorMeta = { fieldType: 'text', }, }, -}; \ No newline at end of file +}; diff --git a/packages/server/src/modules/Vendors/queries/VendorTransformer.ts b/packages/server/src/modules/Vendors/queries/VendorTransformer.ts index 68f16a4ce..876330baf 100644 --- a/packages/server/src/modules/Vendors/queries/VendorTransformer.ts +++ b/packages/server/src/modules/Vendors/queries/VendorTransformer.ts @@ -1,4 +1,4 @@ -import { ContactTransfromer } from "../../Contacts/Contact.transformer"; +import { ContactTransfromer } from '../../Contacts/Contact.transformer'; export class VendorTransfromer extends ContactTransfromer { /** @@ -9,7 +9,7 @@ export class VendorTransfromer extends ContactTransfromer { return [ 'formattedBalance', 'formattedOpeningBalance', - 'formattedOpeningBalanceAt' + 'formattedOpeningBalanceAt', ]; }; } diff --git a/packages/server/src/modules/Vendors/subscribers/VendorGLEntriesSubscriber.ts b/packages/server/src/modules/Vendors/subscribers/VendorGLEntriesSubscriber.ts index 31a5f4e89..0cdfdba96 100644 --- a/packages/server/src/modules/Vendors/subscribers/VendorGLEntriesSubscriber.ts +++ b/packages/server/src/modules/Vendors/subscribers/VendorGLEntriesSubscriber.ts @@ -41,10 +41,7 @@ export class VendorsWriteGLOpeningSubscriber { vendorId, trx, }: IVendorEventDeletedPayload) { - await this.vendorGLEntriesStorage.revertVendorOpeningBalance( - vendorId, - trx, - ); + await this.vendorGLEntriesStorage.revertVendorOpeningBalance(vendorId, trx); } /** diff --git a/packages/server/src/modules/Views/Views.types.ts b/packages/server/src/modules/Views/Views.types.ts index 857f45808..cf78fde33 100644 --- a/packages/server/src/modules/Views/Views.types.ts +++ b/packages/server/src/modules/Views/Views.types.ts @@ -1,61 +1,60 @@ - export interface IView { - id: number, - name: string, + id: number; + name: string; slug: string; - predefined: boolean, - resourceModel: string, - favourite: boolean, - rolesLogicExpression: string, + predefined: boolean; + resourceModel: string; + favourite: boolean; + rolesLogicExpression: string; - roles: IViewRole[], - columns: IViewHasColumn[], -}; + roles: IViewRole[]; + columns: IViewHasColumn[]; +} export interface IViewRole { - id: number, - fieldKey: string, - index: number, - comparator: string, - value: string, - viewId: number, -}; + id: number; + fieldKey: string; + index: number; + comparator: string; + value: string; + viewId: number; +} export interface IViewHasColumn { - id :number, - viewId: number, - fieldId: number, - index: number, + id: number; + viewId: number; + fieldId: number; + index: number; } export interface IViewRoleDTO { - index: number, - fieldKey: string, - comparator: string, - value: string, - viewId: number, + index: number; + fieldKey: string; + comparator: string; + value: string; + viewId: number; } export interface IViewColumnDTO { - id: number, - index: number, - viewId: number, - fieldKey: string, -}; + id: number; + index: number; + viewId: number; + fieldKey: string; +} export interface IViewDTO { - name: string, - logicExpression: string, - resourceModel: string, + name: string; + logicExpression: string; + resourceModel: string; - roles: IViewRoleDTO[], - columns: IViewColumnDTO[], -}; + roles: IViewRoleDTO[]; + columns: IViewColumnDTO[]; +} export interface IViewEditDTO { - name: string, - logicExpression: string, + name: string; + logicExpression: string; - roles: IViewRoleDTO[], - columns: IViewColumnDTO[], -}; + roles: IViewRoleDTO[]; + columns: IViewColumnDTO[]; +} diff --git a/packages/server/src/modules/Warehouses/Activate/CreditNoteWarehousesActivate.ts b/packages/server/src/modules/Warehouses/Activate/CreditNoteWarehousesActivate.ts index a5089098e..db0a319c5 100644 --- a/packages/server/src/modules/Warehouses/Activate/CreditNoteWarehousesActivate.ts +++ b/packages/server/src/modules/Warehouses/Activate/CreditNoteWarehousesActivate.ts @@ -20,7 +20,7 @@ export class CreditNotesActivateWarehouses { * @returns {Promise} */ public updateCreditsWithWarehouse = async ( - primaryWarehouse: Warehouse + primaryWarehouse: Warehouse, ): Promise => { // Updates the sale estimates with primary warehouse. await this.creditNoteModel().query().update({ diff --git a/packages/server/src/modules/Warehouses/Activate/InventoryTransactionsWarehousesActivate.ts b/packages/server/src/modules/Warehouses/Activate/InventoryTransactionsWarehousesActivate.ts index b26360ba7..8dcbceeaa 100644 --- a/packages/server/src/modules/Warehouses/Activate/InventoryTransactionsWarehousesActivate.ts +++ b/packages/server/src/modules/Warehouses/Activate/InventoryTransactionsWarehousesActivate.ts @@ -1,14 +1,18 @@ -import { InventoryTransaction } from "@/modules/InventoryCost/models/InventoryTransaction"; -import { TenantModelProxy } from "@/modules/System/models/TenantBaseModel"; -import { Injectable } from "@nestjs/common"; -import { Warehouse } from "../models/Warehouse.model"; -import { InventoryCostLotTracker } from "@/modules/InventoryCost/models/InventoryCostLotTracker"; +import { InventoryTransaction } from '@/modules/InventoryCost/models/InventoryTransaction'; +import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel'; +import { Injectable } from '@nestjs/common'; +import { Warehouse } from '../models/Warehouse.model'; +import { InventoryCostLotTracker } from '@/modules/InventoryCost/models/InventoryCostLotTracker'; @Injectable() export class InventoryActivateWarehouses { constructor( - private readonly inventoryTransactionModel: TenantModelProxy, - private readonly inventoryCostLotTrackerModel: TenantModelProxy, + private readonly inventoryTransactionModel: TenantModelProxy< + typeof InventoryTransaction + >, + private readonly inventoryCostLotTrackerModel: TenantModelProxy< + typeof InventoryCostLotTracker + >, ) {} /** @@ -18,7 +22,7 @@ export class InventoryActivateWarehouses { * @returns {Promise} */ public updateInventoryTransactionsWithWarehouse = async ( - primaryWarehouse: Warehouse + primaryWarehouse: Warehouse, ): Promise => { // Updates the inventory transactions with primary warehouse. await this.inventoryTransactionModel().query().update({ diff --git a/packages/server/src/modules/Warehouses/Warehouse.types.ts b/packages/server/src/modules/Warehouses/Warehouse.types.ts index 436239b35..04972645c 100644 --- a/packages/server/src/modules/Warehouses/Warehouse.types.ts +++ b/packages/server/src/modules/Warehouses/Warehouse.types.ts @@ -140,8 +140,7 @@ export interface IItemWarehouseQuantityChange { amount: number; } -export interface IWarehousesActivatePayload { -} +export interface IWarehousesActivatePayload {} export interface IWarehousesActivatedPayload { primaryWarehouse: Warehouse; } diff --git a/packages/server/src/modules/Warehouses/WarehouseItems.controller.ts b/packages/server/src/modules/Warehouses/WarehouseItems.controller.ts index b5e1cacf9..01316d778 100644 --- a/packages/server/src/modules/Warehouses/WarehouseItems.controller.ts +++ b/packages/server/src/modules/Warehouses/WarehouseItems.controller.ts @@ -1,18 +1,13 @@ import { Controller, Get, Param } from '@nestjs/common'; import { WarehousesApplication } from './WarehousesApplication.service'; -import { - ApiOperation, - ApiParam, - ApiResponse, - ApiTags, -} from '@nestjs/swagger'; +import { ApiOperation, ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger'; import { ApiCommonHeaders } from '@/common/decorators/ApiCommonHeaders'; @Controller('items') @ApiTags('Warehouses') @ApiCommonHeaders() export class WarehouseItemsController { - constructor(private warehousesApplication: WarehousesApplication) { } + constructor(private warehousesApplication: WarehousesApplication) {} @Get(':id/warehouses') @ApiOperation({ @@ -34,4 +29,3 @@ export class WarehouseItemsController { return this.warehousesApplication.getItemWarehouses(Number(itemId)); } } - diff --git a/packages/server/src/modules/Warehouses/Warehouses.module.ts b/packages/server/src/modules/Warehouses/Warehouses.module.ts index c3a6e2a0b..f650d76cf 100644 --- a/packages/server/src/modules/Warehouses/Warehouses.module.ts +++ b/packages/server/src/modules/Warehouses/Warehouses.module.ts @@ -89,8 +89,13 @@ const models = [RegisterTenancyModel(Warehouse)]; WarehousesDTOValidators, DeleteItemWarehousesQuantity, InventoryTransactionsWarehouses, - ValidateWarehouseExistance + ValidateWarehouseExistance, + ], + exports: [ + WarehousesSettings, + WarehouseTransactionDTOTransform, + WarehousesApplication, + ...models, ], - exports: [WarehousesSettings, WarehouseTransactionDTOTransform, WarehousesApplication, ...models], }) export class WarehousesModule {} diff --git a/packages/server/src/modules/Warehouses/WarehousesApplication.service.ts b/packages/server/src/modules/Warehouses/WarehousesApplication.service.ts index 25b439173..3572492a0 100644 --- a/packages/server/src/modules/Warehouses/WarehousesApplication.service.ts +++ b/packages/server/src/modules/Warehouses/WarehousesApplication.service.ts @@ -1,6 +1,4 @@ -import { - IWarehouse, -} from './Warehouse.types'; +import { IWarehouse } from './Warehouse.types'; import { ActivateWarehousesService } from './commands/ActivateWarehouses.service'; import { CreateWarehouse } from './commands/CreateWarehouse.service'; import { DeleteWarehouseService } from './commands/DeleteWarehouse.service'; diff --git a/packages/server/src/modules/Warehouses/contants.ts b/packages/server/src/modules/Warehouses/contants.ts index e41d9b3ff..cd6f0947c 100644 --- a/packages/server/src/modules/Warehouses/contants.ts +++ b/packages/server/src/modules/Warehouses/contants.ts @@ -3,5 +3,6 @@ export const ERRORS = { MUTLI_WAREHOUSES_ALREADY_ACTIVATED: 'MUTLI_WAREHOUSES_ALREADY_ACTIVATED', COULD_NOT_DELETE_ONLY_WAERHOUSE: 'COULD_NOT_DELETE_ONLY_WAERHOUSE', WAREHOUSE_CODE_NOT_UNIQUE: 'WAREHOUSE_CODE_NOT_UNIQUE', - WAREHOUSE_HAS_ASSOCIATED_TRANSACTIONS: 'WAREHOUSE_HAS_ASSOCIATED_TRANSACTIONS' -}; \ No newline at end of file + WAREHOUSE_HAS_ASSOCIATED_TRANSACTIONS: + 'WAREHOUSE_HAS_ASSOCIATED_TRANSACTIONS', +}; diff --git a/packages/server/src/modules/Warehouses/dtos/Warehouse.dto.ts b/packages/server/src/modules/Warehouses/dtos/Warehouse.dto.ts index 3b69744cd..df7ca6f3d 100644 --- a/packages/server/src/modules/Warehouses/dtos/Warehouse.dto.ts +++ b/packages/server/src/modules/Warehouses/dtos/Warehouse.dto.ts @@ -1,9 +1,8 @@ -import { IsOptional } from "@/common/decorators/Validators"; -import { ApiProperty } from "@nestjs/swagger"; -import { IsBoolean, IsEmail, IsUrl } from "class-validator"; -import { IsNotEmpty } from "class-validator"; -import { IsString } from "class-validator"; - +import { IsOptional } from '@/common/decorators/Validators'; +import { ApiProperty } from '@nestjs/swagger'; +import { IsBoolean, IsEmail, IsUrl } from 'class-validator'; +import { IsNotEmpty } from 'class-validator'; +import { IsString } from 'class-validator'; export class CommandWarehouseDto { @IsString() @@ -20,7 +19,7 @@ export class CommandWarehouseDto { @IsOptional() @ApiProperty({ description: 'The code of the warehouse' }) code?: string; - + @IsString() @IsOptional() @ApiProperty({ description: 'The address of the warehouse' }) @@ -35,7 +34,7 @@ export class CommandWarehouseDto { @IsOptional() @ApiProperty({ description: 'The country of the warehouse' }) country?: string; - + @IsString() @IsOptional() @ApiProperty({ description: 'The phone number of the warehouse' }) @@ -53,4 +52,4 @@ export class CommandWarehouseDto { } export class CreateWarehouseDto extends CommandWarehouseDto {} -export class EditWarehouseDto extends CommandWarehouseDto {} \ No newline at end of file +export class EditWarehouseDto extends CommandWarehouseDto {} diff --git a/packages/server/src/modules/Warehouses/models/ItemWarehouseQuantity.ts b/packages/server/src/modules/Warehouses/models/ItemWarehouseQuantity.ts index 8640e1bd3..b46bc085a 100644 --- a/packages/server/src/modules/Warehouses/models/ItemWarehouseQuantity.ts +++ b/packages/server/src/modules/Warehouses/models/ItemWarehouseQuantity.ts @@ -1,7 +1,7 @@ import { BaseModel } from '@/models/Model'; import { Model } from 'objection'; -export class ItemWarehouseQuantity extends BaseModel{ +export class ItemWarehouseQuantity extends BaseModel { /** * Table name. */ diff --git a/packages/server/src/modules/Warehouses/subscribers/Activate/BillWarehousesActivateSubscriber.ts b/packages/server/src/modules/Warehouses/subscribers/Activate/BillWarehousesActivateSubscriber.ts index 00dfacd0e..f5b71433f 100644 --- a/packages/server/src/modules/Warehouses/subscribers/Activate/BillWarehousesActivateSubscriber.ts +++ b/packages/server/src/modules/Warehouses/subscribers/Activate/BillWarehousesActivateSubscriber.ts @@ -16,11 +16,11 @@ export class BillsActivateWarehousesSubscriber { * @param {IWarehousesActivatedPayload} */ @OnEvent(events.warehouse.onActivated) - async updateBillsWithWarehouseOnActivated ({ + async updateBillsWithWarehouseOnActivated({ primaryWarehouse, }: IWarehousesActivatedPayload) { await this.billsActivateWarehouses.updateBillsWithWarehouse( - primaryWarehouse + primaryWarehouse, ); - }; + } } diff --git a/packages/server/src/modules/Warehouses/subscribers/Activate/ReceiptWarehousesActivateSubscriber.ts b/packages/server/src/modules/Warehouses/subscribers/Activate/ReceiptWarehousesActivateSubscriber.ts index 0eb1dbc51..11f985126 100644 --- a/packages/server/src/modules/Warehouses/subscribers/Activate/ReceiptWarehousesActivateSubscriber.ts +++ b/packages/server/src/modules/Warehouses/subscribers/Activate/ReceiptWarehousesActivateSubscriber.ts @@ -4,11 +4,10 @@ import { ReceiptActivateWarehouses } from '../../Activate/ReceiptWarehousesActiv import { events } from '@/common/events/events'; import { IWarehousesActivatedPayload } from '../../Warehouse.types'; - @Injectable() export class ReceiptsActivateWarehousesSubscriber { constructor( - private readonly receiptsActivateWarehouses: ReceiptActivateWarehouses, + private readonly receiptsActivateWarehouses: ReceiptActivateWarehouses, ) {} /** @@ -21,7 +20,7 @@ export class ReceiptsActivateWarehousesSubscriber { primaryWarehouse, }: IWarehousesActivatedPayload) { await this.receiptsActivateWarehouses.updateReceiptsWithWarehouse( - primaryWarehouse + primaryWarehouse, ); - }; + } } diff --git a/packages/server/src/modules/WarehousesTransfers/WarehouseTransfers.module.ts b/packages/server/src/modules/WarehousesTransfers/WarehouseTransfers.module.ts index 268457150..dfa889a09 100644 --- a/packages/server/src/modules/WarehousesTransfers/WarehouseTransfers.module.ts +++ b/packages/server/src/modules/WarehousesTransfers/WarehouseTransfers.module.ts @@ -52,4 +52,4 @@ const models = [ exports: [...models], controllers: [WarehouseTransfersController], }) -export class WarehousesTransfersModule { } +export class WarehousesTransfersModule {} diff --git a/packages/server/src/modules/WarehousesTransfers/models/WarehouseTransfer.meta.ts b/packages/server/src/modules/WarehousesTransfers/models/WarehouseTransfer.meta.ts index 1183dd660..8a8709c7a 100644 --- a/packages/server/src/modules/WarehousesTransfers/models/WarehouseTransfer.meta.ts +++ b/packages/server/src/modules/WarehousesTransfers/models/WarehouseTransfer.meta.ts @@ -1,4 +1,3 @@ - function StatusFieldFilterQuery(query, role) { query.modify('filterByStatus', role.value); } @@ -67,4 +66,4 @@ export const WarehouseTransferMeta = { fieldType: 'date', }, }, -}; \ No newline at end of file +}; diff --git a/packages/server/src/modules/WarehousesTransfers/models/WarehouseTransfer.ts b/packages/server/src/modules/WarehousesTransfers/models/WarehouseTransfer.ts index 071821a69..63f4f11fa 100644 --- a/packages/server/src/modules/WarehousesTransfers/models/WarehouseTransfer.ts +++ b/packages/server/src/modules/WarehousesTransfers/models/WarehouseTransfer.ts @@ -106,7 +106,7 @@ export class WarehouseTransfer extends TenantBaseModel { }, /** - * + * */ fromWarehouse: { relation: Model.BelongsToOneRelation, diff --git a/packages/server/src/modules/WarehousesTransfers/queries/WarehouseTransferItemTransformer.ts b/packages/server/src/modules/WarehousesTransfers/queries/WarehouseTransferItemTransformer.ts index d1c4a6055..87a908adc 100644 --- a/packages/server/src/modules/WarehousesTransfers/queries/WarehouseTransferItemTransformer.ts +++ b/packages/server/src/modules/WarehousesTransfers/queries/WarehouseTransferItemTransformer.ts @@ -1,4 +1,4 @@ -import { Transformer } from "../../Transformer/Transformer"; +import { Transformer } from '../../Transformer/Transformer'; export class WarehouseTransferItemTransformer extends Transformer { /** diff --git a/packages/server/src/utils/accum-sum.ts b/packages/server/src/utils/accum-sum.ts index c5eb0f62d..d2ddae832 100644 --- a/packages/server/src/utils/accum-sum.ts +++ b/packages/server/src/utils/accum-sum.ts @@ -1,5 +1,7 @@ - -export const accumSum = (data: any[], callback: (data: any) => number): number => { +export const accumSum = ( + data: any[], + callback: (data: any) => number, +): number => { return data.reduce((acc, _data) => { const amount = callback(_data); return acc + amount; diff --git a/packages/server/src/utils/address-text-format.ts b/packages/server/src/utils/address-text-format.ts index 3813f7e04..7a1f3023f 100644 --- a/packages/server/src/utils/address-text-format.ts +++ b/packages/server/src/utils/address-text-format.ts @@ -1,4 +1,4 @@ -import { Contact } from "@/modules/Contacts/models/Contact"; +import { Contact } from '@/modules/Contacts/models/Contact'; interface OrganizationAddressFormatArgs { organizationName?: string; @@ -34,7 +34,7 @@ const formatText = (message: string, replacements: Record) => { (msg, [key, value]) => { return msg.split(`{${key}}`).join(value || ''); }, - message + message, ); // Removes any empty lines. formattedMessage = formattedMessage.replace(/^\s*[\r\n]/gm, ''); @@ -47,7 +47,7 @@ const formatText = (message: string, replacements: Record) => { export const organizationAddressTextFormat = ( message: string, - args: OrganizationAddressFormatArgs + args: OrganizationAddressFormatArgs, ) => { const replacements: Record = { ORGANIZATION_NAME: args.organizationName || '', @@ -84,7 +84,7 @@ export const defaultContactAddressFormat = `{CONTACT_NAME} export const contactAddressTextFormat = ( contact: Contact, - message: string = defaultContactAddressFormat + message: string = defaultContactAddressFormat, ) => { const args = { displayName: contact.displayName, diff --git a/packages/server/src/utils/assoc-depth-level-to-object-tree.ts b/packages/server/src/utils/assoc-depth-level-to-object-tree.ts index 88a6919ca..1141f9162 100644 --- a/packages/server/src/utils/assoc-depth-level-to-object-tree.ts +++ b/packages/server/src/utils/assoc-depth-level-to-object-tree.ts @@ -1,8 +1,7 @@ - export const assocDepthLevelToObjectTree = ( objects, level = 1, - propertyName = 'level' + propertyName = 'level', ) => { for (let i = 0; i < objects.length; i++) { const object = objects[i]; @@ -13,4 +12,4 @@ export const assocDepthLevelToObjectTree = ( } } return objects; -}; \ No newline at end of file +}; diff --git a/packages/server/src/utils/deepdash.ts b/packages/server/src/utils/deepdash.ts index 7c44d298a..5b33da61b 100644 --- a/packages/server/src/utils/deepdash.ts +++ b/packages/server/src/utils/deepdash.ts @@ -39,7 +39,7 @@ const mapValuesDeepReverse = (nodes, callback, config?) => { const children = _.get( clonedNodes, `${pathString}.${config.childrenPath}`, - [] + [], ); const mappedNode = callback(node, children); @@ -75,8 +75,8 @@ const filterNodesDeep = (predicate, nodes) => { childrenPath: 'children', pathFormat: 'array', callbackAfterIterate: true, - } - ) + }, + ), ); }; @@ -97,7 +97,7 @@ const flatNestedTree = (obj, mapper, options) => { childrenPath: 'children', pathFormat: 'array', ...options, - } + }, ); }; diff --git a/packages/server/src/utils/format-message.ts b/packages/server/src/utils/format-message.ts index 61e79a8e0..3b82fde91 100644 --- a/packages/server/src/utils/format-message.ts +++ b/packages/server/src/utils/format-message.ts @@ -9,8 +9,8 @@ export const formatMessage = (message: string, args: Record) => { formattedMessage = formattedMessage.replace( new RegExp(variable, 'g'), - value + value, ); }); return formattedMessage; -}; \ No newline at end of file +}; diff --git a/packages/server/src/utils/increment.ts b/packages/server/src/utils/increment.ts index 0ef538abf..51ffd441b 100644 --- a/packages/server/src/utils/increment.ts +++ b/packages/server/src/utils/increment.ts @@ -1,4 +1,3 @@ - export const increment = (n: number = 0) => { let counter = n; diff --git a/packages/server/src/utils/multi-number-parse.ts b/packages/server/src/utils/multi-number-parse.ts index 72c3a291f..de5b5f7f7 100644 --- a/packages/server/src/utils/multi-number-parse.ts +++ b/packages/server/src/utils/multi-number-parse.ts @@ -8,7 +8,10 @@ const validGrouping = (integerPart, sep) => return acc && group.length; }, true); -export const multiNumberParse = (number: number | string, standardDecSep = '.') => { +export const multiNumberParse = ( + number: number | string, + standardDecSep = '.', +) => { // if it's a number already, this is going to be easy... if (typeof number === 'number') { return number; @@ -48,7 +51,7 @@ export const multiNumberParse = (number: number | string, standardDecSep = '.') }, }; }, - {} + {}, ); // check correctness of separators @@ -128,4 +131,4 @@ export const multiNumberParse = (number: number | string, standardDecSep = '.') // well, it looks like it's a simple float return parseFloat(stripped.replace(sep.sep, '.')) * (negative ? -1 : 1); -}; \ No newline at end of file +}; diff --git a/packages/server/src/utils/parse-json.ts b/packages/server/src/utils/parse-json.ts index 393558ba8..f8a12e2e7 100644 --- a/packages/server/src/utils/parse-json.ts +++ b/packages/server/src/utils/parse-json.ts @@ -4,4 +4,4 @@ export const parseJsonSafe = (value: string) => { } catch { return null; } -}; \ No newline at end of file +}; diff --git a/packages/server/src/utils/running-balance.ts b/packages/server/src/utils/running-balance.ts index 690c23c76..fef006ae7 100644 --- a/packages/server/src/utils/running-balance.ts +++ b/packages/server/src/utils/running-balance.ts @@ -1,5 +1,3 @@ - - export const runningBalance = (amount: number) => { let runningBalance = amount; @@ -12,4 +10,4 @@ export const runningBalance = (amount: number) => { }, amount: () => runningBalance, }; -}; \ No newline at end of file +}; diff --git a/packages/server/src/utils/sanitize-model-name.ts b/packages/server/src/utils/sanitize-model-name.ts index 2dd7a0715..d3aeda871 100644 --- a/packages/server/src/utils/sanitize-model-name.ts +++ b/packages/server/src/utils/sanitize-model-name.ts @@ -2,4 +2,4 @@ import { camelCase, upperFirst } from 'lodash'; export const sanitizeModelName = (modelName: string) => { return upperFirst(camelCase(modelName)); -} \ No newline at end of file +}; diff --git a/packages/server/src/utils/transaction-increment.ts b/packages/server/src/utils/transaction-increment.ts index 488bdd4ed..42ce1a6f1 100644 --- a/packages/server/src/utils/transaction-increment.ts +++ b/packages/server/src/utils/transaction-increment.ts @@ -1 +1,2 @@ -export const transactionIncrement = (s) => s.replace(/([0-8]|\d?9+)?$/, (e) => ++e); \ No newline at end of file +export const transactionIncrement = (s) => + s.replace(/([0-8]|\d?9+)?$/, (e) => ++e); diff --git a/packages/server/src/utils/transform-to-key.ts b/packages/server/src/utils/transform-to-key.ts index dc9783c58..0c1f1c4e9 100644 --- a/packages/server/src/utils/transform-to-key.ts +++ b/packages/server/src/utils/transform-to-key.ts @@ -1,4 +1,3 @@ - export const transformToMap = (objects, key) => { const map = new Map(); diff --git a/packages/server/test/accounts.e2e-spec.ts b/packages/server/test/accounts.e2e-spec.ts index d6152f20a..c97b993a8 100644 --- a/packages/server/test/accounts.e2e-spec.ts +++ b/packages/server/test/accounts.e2e-spec.ts @@ -1,10 +1,6 @@ import * as request from 'supertest'; import { faker } from '@faker-js/faker'; -import { - app, - AuthorizationHeader, - orgainzationId, -} from './init-app-test'; +import { app, AuthorizationHeader, orgainzationId } from './init-app-test'; const makeAccountRequest = () => ({ name: `${faker.finance.accountName()} ${Date.now()}-${faker.string.alphanumeric({ length: 4 })}`, diff --git a/packages/server/test/customers.e2e-spec.ts b/packages/server/test/customers.e2e-spec.ts index cfc416a2a..0413f33be 100644 --- a/packages/server/test/customers.e2e-spec.ts +++ b/packages/server/test/customers.e2e-spec.ts @@ -35,7 +35,7 @@ describe('Customers (e2e)', () => { return request(app.getHttpServer()) .get(`/customers/${customerId}`) .set('organization-id', orgainzationId) - .set('Authorization', AuthorizationHeader) + .set('Authorization', AuthorizationHeader) .expect(200); }); diff --git a/packages/server/test/organization.e2e-spec.ts b/packages/server/test/organization.e2e-spec.ts index 02f1abf97..b8dcdcd48 100644 --- a/packages/server/test/organization.e2e-spec.ts +++ b/packages/server/test/organization.e2e-spec.ts @@ -25,7 +25,7 @@ describe('Organization (e2e)', () => { }); }); - it('/organization (POST)', async () => { + it('/organization (POST)', async () => { return request(app.getHttpServer()) .post('/organization/build') .set('Accept', 'application/json') @@ -45,13 +45,13 @@ describe('Organization (e2e)', () => { it('/organization (GET)', () => { return request(app.getHttpServer()) - .get('/organization/current') - .set('Accept', 'application/json') - .set('Content-Type', 'application/json') - .set('Authorization', `Bearer ${signinResponse.body.access_token}`) - .set('organization-id', signupResponse.body.organization_id) - .send() - .expect(200); + .get('/organization/current') + .set('Accept', 'application/json') + .set('Content-Type', 'application/json') + .set('Authorization', `Bearer ${signinResponse.body.access_token}`) + .set('organization-id', signupResponse.body.organization_id) + .send() + .expect(200); }); it('/organization (PUT)', () => { diff --git a/packages/server/test/roles.e2e-spec.ts b/packages/server/test/roles.e2e-spec.ts index e60553d20..0ece0cf6f 100644 --- a/packages/server/test/roles.e2e-spec.ts +++ b/packages/server/test/roles.e2e-spec.ts @@ -21,7 +21,7 @@ const createRoleRequest = () => ({ describe('Roles (e2e)', () => { it('/roles (POST)', () => { - console.log(createRoleRequest()) + console.log(createRoleRequest()); return request(app.getHttpServer()) .post('/roles') .set('organization-id', orgainzationId)