softDelete features
This commit is contained in:
@@ -8,7 +8,9 @@
|
||||
* Lifecycle:
|
||||
* post() — first-time GL creation; throws if a record already exists.
|
||||
* replace() — snapshot current lines into td_gl.history, then delete + re-insert.
|
||||
* delete() — create a reversal journal entry (audit trail), then hard-delete the original.
|
||||
* delete() — create a reversal journal entry (debit/credit swapped), then mark the original
|
||||
* source_type = 'voided' so it stays in the table for audit trail but is invisible
|
||||
* to getBySource() lookups.
|
||||
*/
|
||||
class GlManager
|
||||
{
|
||||
@@ -265,12 +267,10 @@ class GlManager
|
||||
$this->insertLines((int)$this->pdo->lastInsertId(), $reversal_lines);
|
||||
}
|
||||
|
||||
// Mark original as voided — keeps audit trail; getBySource() won't match 'voided' source_type
|
||||
$this->pdo->prepare(
|
||||
"DELETE FROM td_gl_item WHERE company_id = :cid AND gl_id = :gl_id"
|
||||
)->execute([':cid' => $this->companyId, ':gl_id' => $gl_id]);
|
||||
|
||||
$this->pdo->prepare(
|
||||
"DELETE FROM td_gl WHERE id = :id AND company_id = :cid"
|
||||
"UPDATE td_gl SET source_type = 'voided', updated_at = NOW()
|
||||
WHERE id = :id AND company_id = :cid"
|
||||
)->execute([':id' => $gl_id, ':cid' => $this->companyId]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user