Master data review: spec updates and C1/C2/M3-M6 fixes

This commit is contained in:
Thanakorn S
2026-05-26 17:33:58 +07:00
parent 6ca4c91865
commit 1c5236d8e0
5 changed files with 230 additions and 35 deletions
@@ -71,10 +71,17 @@ class DepartmentManager
public function delete(int $id): void
{
$sth = $this->pdo->prepare(
"SELECT COUNT(*) FROM td_gl_item WHERE department_id = :id LIMIT 1"
);
$sth->execute([':id' => $id]);
if ((int)$sth->fetchColumn() > 0) {
throw new Exception('Cannot deactivate — this department has GL journal entries.');
}
$this->pdo->prepare(
"UPDATE md_department SET status = 0
WHERE company_id = :cid AND id = :id"
);
$sth->execute([':cid' => $this->companyId, ':id' => $id]);
)->execute([':cid' => $this->companyId, ':id' => $id]);
}
public function getStats(): array