document number sequence
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/DocumentNumberManager.php';
|
||||
require_once __DIR__ . '/../classes_ac/PostingWindowGuard.php';
|
||||
require_once __DIR__ . '/../classes_ac/GlManager.php';
|
||||
|
||||
@@ -12,23 +13,10 @@ class ReceiptManager {
|
||||
$this->company_id = $company_id;
|
||||
}
|
||||
|
||||
private function generateReceiptNumber(): string
|
||||
private function generateReceiptNumber(array $data = []): string
|
||||
{
|
||||
$prefix = 'RC-' . date('Ymd') . '-';
|
||||
$sth = $this->pdo->prepare(
|
||||
"SELECT receipt_number FROM td_receipt
|
||||
WHERE company_id = :company_id
|
||||
AND receipt_number LIKE :prefix
|
||||
ORDER BY receipt_number DESC
|
||||
LIMIT 1"
|
||||
);
|
||||
$sth->execute([
|
||||
':company_id' => $this->company_id,
|
||||
':prefix' => $prefix . '%',
|
||||
]);
|
||||
$last = $sth->fetchColumn();
|
||||
$seq = $last ? ((int)substr($last, -4) + 1) : 1;
|
||||
return $prefix . str_pad($seq, 4, '0', STR_PAD_LEFT);
|
||||
return (new DocumentNumberManager($this->pdo, $this->company_id))
|
||||
->resolveNumber($data, 'receipt', 'td_receipt', 'receipt_number');
|
||||
}
|
||||
|
||||
private function assertPostingWindow(?string $date, string $context): void
|
||||
@@ -448,7 +436,7 @@ class ReceiptManager {
|
||||
)->execute([
|
||||
':company_id' => $this->company_id,
|
||||
':uuid' => bin2hex(random_bytes(16)),
|
||||
':receipt_number' => $this->generateReceiptNumber(),
|
||||
':receipt_number' => $this->generateReceiptNumber($data),
|
||||
':contact_id' => $contact_id,
|
||||
':department_id' => (int)($data['department_id'] ?? 0),
|
||||
':receipt_billing_id' => $billing_id,
|
||||
|
||||
Reference in New Issue
Block a user