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';
|
||||
|
||||
class ReceiptBillingManager {
|
||||
@@ -11,23 +12,10 @@ class ReceiptBillingManager {
|
||||
$this->company_id = $company_id;
|
||||
}
|
||||
|
||||
private function generateBillingNumber(): string
|
||||
private function generateBillingNumber(array $data = []): string
|
||||
{
|
||||
$prefix = 'RB-' . date('Ymd') . '-';
|
||||
$sth = $this->pdo->prepare(
|
||||
"SELECT billing_number FROM td_receipt_billing
|
||||
WHERE company_id = :company_id
|
||||
AND billing_number LIKE :prefix
|
||||
ORDER BY billing_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_billing', 'td_receipt_billing', 'billing_number');
|
||||
}
|
||||
|
||||
private function unavailableDocumentAmount(int $invoice_id): float
|
||||
@@ -338,7 +326,7 @@ class ReceiptBillingManager {
|
||||
)->execute([
|
||||
':company_id' => $this->company_id,
|
||||
':uuid' => bin2hex(random_bytes(16)),
|
||||
':billing_number' => $this->generateBillingNumber(),
|
||||
':billing_number' => $this->generateBillingNumber($data),
|
||||
':contact_id' => $contact_id,
|
||||
':billing_date' => $billing_date,
|
||||
':amount' => $net_amount,
|
||||
|
||||
Reference in New Issue
Block a user