feat: add wartosc_zlecenia field to projects table and update related functionalities

This commit is contained in:
2025-11-14 09:04:46 +01:00
parent 056198ff16
commit 3f87ea16f2
6 changed files with 78 additions and 3 deletions

View File

@@ -30,6 +30,7 @@ export default function initializeDatabase() {
wp TEXT,
contact TEXT,
notes TEXT,
wartosc_zlecenia REAL,
project_type TEXT CHECK(project_type IN ('design', 'construction', 'design+construction')) DEFAULT 'design',
project_status TEXT CHECK(project_status IN ('registered', 'in_progress_design', 'in_progress_construction', 'fulfilled', 'cancelled')) DEFAULT 'registered',
FOREIGN KEY (contract_id) REFERENCES contracts(contract_id)

View File

@@ -76,8 +76,8 @@ export function createProject(data, userId = null) {
const stmt = db.prepare(`
INSERT INTO projects (
contract_id, project_name, project_number, address, plot, district, unit, city, investment_number, finish_date,
wp, contact, notes, project_type, project_status, coordinates, created_by, assigned_to, created_at, updated_at
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, datetime('now', 'localtime'), datetime('now', 'localtime'))
wp, contact, notes, wartosc_zlecenia, project_type, project_status, coordinates, created_by, assigned_to, created_at, updated_at
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, datetime('now', 'localtime'), datetime('now', 'localtime'))
`);
const result = stmt.run(
@@ -94,6 +94,7 @@ export function createProject(data, userId = null) {
data.wp,
data.contact,
data.notes,
data.wartosc_zlecenia || null,
data.project_type || "design",
data.project_status || "registered",
data.coordinates || null,
@@ -108,7 +109,7 @@ export function updateProject(id, data, userId = null) {
const stmt = db.prepare(`
UPDATE projects SET
contract_id = ?, project_name = ?, project_number = ?, address = ?, plot = ?, district = ?, unit = ?, city = ?,
investment_number = ?, finish_date = ?, wp = ?, contact = ?, notes = ?, project_type = ?, project_status = ?,
investment_number = ?, finish_date = ?, wp = ?, contact = ?, notes = ?, wartosc_zlecenia = ?, project_type = ?, project_status = ?,
coordinates = ?, assigned_to = ?, updated_at = CURRENT_TIMESTAMP
WHERE project_id = ?
`);
@@ -126,6 +127,7 @@ export function updateProject(id, data, userId = null) {
data.wp,
data.contact,
data.notes,
data.wartosc_zlecenia || null,
data.project_type || "design",
data.project_status || "registered",
data.coordinates || null,