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 PaymentManager {
|
||||
$this->company_id = $company_id;
|
||||
}
|
||||
|
||||
private function generatePaymentNumber(): string
|
||||
private function generatePaymentNumber(array $data = []): string
|
||||
{
|
||||
$prefix = 'PY-' . date('Ymd') . '-';
|
||||
$sth = $this->pdo->prepare(
|
||||
"SELECT payment_number FROM td_payment
|
||||
WHERE company_id = :company_id
|
||||
AND payment_number LIKE :prefix
|
||||
ORDER BY payment_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, 'payment', 'td_payment', 'payment_number');
|
||||
}
|
||||
|
||||
private function assertPostingWindow(?string $date, string $context): void
|
||||
@@ -450,7 +438,7 @@ class PaymentManager {
|
||||
)->execute([
|
||||
':company_id' => $this->company_id,
|
||||
':uuid' => bin2hex(random_bytes(16)),
|
||||
':payment_number' => $this->generatePaymentNumber(),
|
||||
':payment_number' => $this->generatePaymentNumber($data),
|
||||
':contact_id' => $contact_id,
|
||||
':department_id' => (int)($data['department_id'] ?? 0),
|
||||
':payment_billing_id' => $billing_id,
|
||||
|
||||
Reference in New Issue
Block a user