feat: add billing and organization workflows
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
ALTER TABLE `clients` ADD `industry` text;--> statement-breakpoint
|
||||
ALTER TABLE `clients` DROP COLUMN `type`;--> statement-breakpoint
|
||||
ALTER TABLE `clients` DROP COLUMN `status`;--> statement-breakpoint
|
||||
ALTER TABLE `addresses` ADD `type` text DEFAULT 'primary' NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE `addresses` ADD `line_3` text;--> statement-breakpoint
|
||||
ALTER TABLE `addresses` DROP COLUMN `label`;--> statement-breakpoint
|
||||
ALTER TABLE `addresses` DROP COLUMN `is_primary`;--> statement-breakpoint
|
||||
ALTER TABLE `contacts` ADD `receives_invoices` integer DEFAULT false NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE `contacts` ADD `receives_contracts` integer DEFAULT false NOT NULL;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE `contacts` DROP COLUMN `notes`;
|
||||
@@ -0,0 +1,28 @@
|
||||
PRAGMA foreign_keys=OFF;--> statement-breakpoint
|
||||
CREATE TABLE `__new_contracts` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`organization_id` text NOT NULL,
|
||||
`client_id` text NOT NULL,
|
||||
`room_id` text,
|
||||
`service_id` text,
|
||||
`start_date` text NOT NULL,
|
||||
`end_date` text NOT NULL,
|
||||
`status` text DEFAULT 'draft' NOT NULL,
|
||||
`notes` text,
|
||||
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
|
||||
`updated_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
|
||||
`archived_at` integer,
|
||||
FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE no action ON DELETE restrict,
|
||||
FOREIGN KEY (`client_id`) REFERENCES `clients`(`id`) ON UPDATE no action ON DELETE restrict,
|
||||
FOREIGN KEY (`room_id`) REFERENCES `rooms`(`id`) ON UPDATE no action ON DELETE restrict,
|
||||
FOREIGN KEY (`service_id`) REFERENCES `services`(`id`) ON UPDATE no action ON DELETE restrict
|
||||
);
|
||||
--> statement-breakpoint
|
||||
INSERT INTO `__new_contracts`("id", "organization_id", "client_id", "room_id", "service_id", "start_date", "end_date", "status", "notes", "created_at", "updated_at", "archived_at") SELECT "id", "organization_id", "client_id", NULL, NULL, "start_date", COALESCE(NULLIF("end_date", ''), "start_date"), CASE WHEN "status" = 'cancelled' THEN 'void' ELSE "status" END, "notes", "created_at", "updated_at", "archived_at" FROM `contracts`;--> statement-breakpoint
|
||||
DROP TABLE `contracts`;--> statement-breakpoint
|
||||
ALTER TABLE `__new_contracts` RENAME TO `contracts`;--> statement-breakpoint
|
||||
PRAGMA foreign_keys=ON;--> statement-breakpoint
|
||||
CREATE INDEX `contracts_organization_id_idx` ON `contracts` (`organization_id`);--> statement-breakpoint
|
||||
CREATE INDEX `contracts_client_id_idx` ON `contracts` (`client_id`);--> statement-breakpoint
|
||||
CREATE INDEX `contracts_room_id_idx` ON `contracts` (`room_id`);--> statement-breakpoint
|
||||
CREATE INDEX `contracts_service_id_idx` ON `contracts` (`service_id`);
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE `contracts` ADD `license_fee_gbp` real DEFAULT 0 NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE `contracts` ADD `deposit_gbp` real DEFAULT 0 NOT NULL;
|
||||
@@ -0,0 +1,26 @@
|
||||
ALTER TABLE `contracts` ADD `billed_to` text;--> statement-breakpoint
|
||||
CREATE TABLE `invoice_lines` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`organization_id` text NOT NULL,
|
||||
`invoice_id` text NOT NULL,
|
||||
`client_id` text NOT NULL,
|
||||
`source_type` text NOT NULL,
|
||||
`source_id` text NOT NULL,
|
||||
`period_start` text NOT NULL,
|
||||
`period_end` text NOT NULL,
|
||||
`description` text NOT NULL,
|
||||
`quantity` real DEFAULT 1 NOT NULL,
|
||||
`unit_price_gbp` real DEFAULT 0 NOT NULL,
|
||||
`total_gbp` real DEFAULT 0 NOT NULL,
|
||||
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
|
||||
`updated_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
|
||||
`archived_at` integer,
|
||||
FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE no action ON DELETE restrict,
|
||||
FOREIGN KEY (`invoice_id`) REFERENCES `invoices`(`id`) ON UPDATE no action ON DELETE cascade,
|
||||
FOREIGN KEY (`client_id`) REFERENCES `clients`(`id`) ON UPDATE no action ON DELETE restrict
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE INDEX `invoice_lines_organization_id_idx` ON `invoice_lines` (`organization_id`);--> statement-breakpoint
|
||||
CREATE INDEX `invoice_lines_invoice_id_idx` ON `invoice_lines` (`invoice_id`);--> statement-breakpoint
|
||||
CREATE INDEX `invoice_lines_client_id_idx` ON `invoice_lines` (`client_id`);--> statement-breakpoint
|
||||
CREATE INDEX `invoice_lines_source_idx` ON `invoice_lines` (`source_type`,`source_id`);
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -50,6 +50,41 @@
|
||||
"when": 1780750080744,
|
||||
"tag": "0006_cloudy_catseye",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 7,
|
||||
"version": "6",
|
||||
"when": 1781787818482,
|
||||
"tag": "0007_numerous_invaders",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 8,
|
||||
"version": "6",
|
||||
"when": 1781795846034,
|
||||
"tag": "0008_violet_metal_master",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 9,
|
||||
"version": "6",
|
||||
"when": 1781814809169,
|
||||
"tag": "0009_safe_speed_demon",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 10,
|
||||
"version": "6",
|
||||
"when": 1781816209764,
|
||||
"tag": "0010_dazzling_hairball",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 11,
|
||||
"version": "6",
|
||||
"when": 1782291600000,
|
||||
"tag": "0011_billing_flow",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user