Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
64 lines
2.1 KiB
JavaScript
64 lines
2.1 KiB
JavaScript
/**
|
|
* Create contract_line_presets table
|
|
*
|
|
* This table stores reusable contract line presets/templates that can be
|
|
* copied into contracts or contract templates. These are not actual contract
|
|
* lines associated with clients, but templates for quick setup.
|
|
*
|
|
* @param { import('knex').Knex } knex
|
|
* @returns { Promise<void> }
|
|
*/
|
|
exports.up = async function up(knex) {
|
|
await knex.schema.createTable('contract_line_presets', (table) => {
|
|
table.uuid('tenant').notNullable();
|
|
table
|
|
.uuid('preset_id')
|
|
.notNullable()
|
|
.defaultTo(knex.raw('gen_random_uuid()'));
|
|
table.string('preset_name', 255).notNullable();
|
|
table.string('billing_frequency', 50).notNullable().defaultTo('monthly');
|
|
table.string('service_category', 100);
|
|
table.string('contract_line_type', 50).notNullable(); // 'Fixed', 'Hourly', or 'Usage'
|
|
|
|
// Hourly-specific fields
|
|
table.decimal('hourly_rate', 10, 2);
|
|
table.integer('minimum_billable_time');
|
|
table.integer('round_up_to_nearest');
|
|
table.boolean('enable_overtime').defaultTo(false);
|
|
table.decimal('overtime_rate', 10, 2);
|
|
table.integer('overtime_threshold');
|
|
table.boolean('enable_after_hours_rate').defaultTo(false);
|
|
table.decimal('after_hours_multiplier', 10, 2);
|
|
|
|
table
|
|
.timestamp('created_at', { useTz: true })
|
|
.notNullable()
|
|
.defaultTo(knex.fn.now());
|
|
table
|
|
.timestamp('updated_at', { useTz: true })
|
|
.notNullable()
|
|
.defaultTo(knex.fn.now());
|
|
|
|
// Primary key includes tenant for CitusDB compatibility
|
|
table.primary(['tenant', 'preset_id']);
|
|
|
|
// Indexes
|
|
table.index(['tenant', 'contract_line_type'], 'idx_contract_line_presets_type');
|
|
});
|
|
|
|
// Foreign key to tenants table
|
|
await knex.raw(`
|
|
ALTER TABLE contract_line_presets
|
|
ADD CONSTRAINT contract_line_presets_tenant_fk
|
|
FOREIGN KEY (tenant) REFERENCES tenants(tenant) ON DELETE CASCADE
|
|
`);
|
|
};
|
|
|
|
/**
|
|
* @param { import('knex').Knex } knex
|
|
* @returns { Promise<void> }
|
|
*/
|
|
exports.down = async function down(knex) {
|
|
await knex.schema.dropTableIfExists('contract_line_presets');
|
|
};
|