diff --git a/cp/app/Controllers/FinancialsController.php b/cp/app/Controllers/FinancialsController.php index 5d5aa98..f7d95e8 100644 --- a/cp/app/Controllers/FinancialsController.php +++ b/cp/app/Controllers/FinancialsController.php @@ -50,7 +50,10 @@ class FinancialsController extends Controller $billing = $db->selectRow('SELECT * FROM registrar_contact WHERE id = ?', [ $invoice_details['billing_contact_id'] ] ); - $billing_vat = $db->selectValue('SELECT vat_number FROM registrar WHERE id = ?', + $billing_company = $db->selectValue('SELECT companyNumber FROM registrar WHERE id = ?', + [ $invoice_details['registrar_id'] ] + ); + $billing_vat = $db->selectValue('SELECT vatNumber FROM registrar WHERE id = ?', [ $invoice_details['registrar_id'] ] ); $company_name = $db->selectValue("SELECT value FROM settings WHERE name = 'company_name'"); @@ -60,14 +63,14 @@ class FinancialsController extends Controller $vat_number = $db->selectValue("SELECT value FROM settings WHERE name = 'vat_number'"); $phone = $db->selectValue("SELECT value FROM settings WHERE name = 'phone'"); $email = $db->selectValue("SELECT value FROM settings WHERE name = 'email'"); - + $issueDate = new \DateTime($invoice_details['issue_date']); $firstDayPrevMonth = (clone $issueDate)->modify('first day of last month')->format('Y-m-d'); $lastDayPrevMonth = (clone $issueDate)->modify('last day of last month')->format('Y-m-d'); $statement = $db->select('SELECT * FROM statement WHERE date BETWEEN ? AND ? AND registrar_id = ?', [ $firstDayPrevMonth, $lastDayPrevMonth, $invoice_details['registrar_id'] ] ); - + $vatCalculator = new VatCalculator(); $vatCalculator->setBusinessCountryCode(strtoupper($cc)); $grossPrice = $vatCalculator->calculate($invoice_details['total_amount'], strtoupper($billing['cc'])); @@ -86,6 +89,7 @@ class FinancialsController extends Controller return view($response,'admin/financials/viewInvoice.twig', [ 'invoice_details' => $invoice_details, 'billing' => $billing, + 'billing_company' => $billing_company, 'billing_vat' => $billing_vat, 'statement' => $statement, 'company_name' => $company_name, diff --git a/cp/app/Controllers/RegistrarsController.php b/cp/app/Controllers/RegistrarsController.php index bada3d9..d0c61f3 100644 --- a/cp/app/Controllers/RegistrarsController.php +++ b/cp/app/Controllers/RegistrarsController.php @@ -58,7 +58,7 @@ class RegistrarsController extends Controller v::key('fax', v::optional(v::phone()), false), v::key('email', v::email(), true) ]; - + $validators = [ 'name' => v::stringType()->notEmpty()->length(1, 255), 'ianaId' => v::optional(v::positive()->length(1, 5)), @@ -75,6 +75,8 @@ class RegistrarsController extends Controller 'creditLimit' => v::numericVal(), 'creditThreshold' => v::numericVal(), 'thresholdType' => v::in(['fixed', 'percent']), + 'companyNumber' => v::positive()->length(1, 30), + 'vatNumber' => v::optional(v::length(1, 30)), 'ipAddress' => v::optional($ipAddressValidator), 'user_name' => v::stringType()->notEmpty()->length(1, 255), 'user_email' => v::email(), @@ -122,6 +124,9 @@ class RegistrarsController extends Controller if (empty($data['ianaId']) || !is_numeric($data['ianaId'])) { $data['ianaId'] = null; } + if (empty($data['vatNumber'])) { + $data['vatNumber'] = null; + } $db->insert( 'registrar', @@ -141,6 +146,8 @@ class RegistrarsController extends Controller 'creditLimit' => $data['creditLimit'], 'creditThreshold' => $data['creditThreshold'], 'thresholdType' => $data['thresholdType'], + 'companyNumber' => $data['companyNumber'], + 'vatNumber' => $data['vatNumber'], 'currency' => $currency, 'crdate' => $crdate, 'lastupdate' => $crdate diff --git a/cp/resources/views/admin/financials/viewInvoice.twig b/cp/resources/views/admin/financials/viewInvoice.twig index 82df695..a3a877e 100644 --- a/cp/resources/views/admin/financials/viewInvoice.twig +++ b/cp/resources/views/admin/financials/viewInvoice.twig @@ -44,7 +44,7 @@

{{ __('Client') }} / {{ __('Registrar') }}

{{ billing.org }}
- {{ billing_vat }} {% if validVAT %}{% endif %}
+ {{ billing_company }} / {{ billing_vat|default('N/A') }} {% if validVAT %}{% endif %}
{{ billing.street1 }}
{{ billing.city }}, {{ billing.sp }}
{{ billing.pc }}, {{ billing_country }}
diff --git a/cp/resources/views/admin/registrars/create.twig b/cp/resources/views/admin/registrars/create.twig index bd5d08f..a16a0d2 100644 --- a/cp/resources/views/admin/registrars/create.twig +++ b/cp/resources/views/admin/registrars/create.twig @@ -89,21 +89,21 @@
{{ __('Financial Information') }}
-
+
- + {{ __('Current balance in the registrar\'s account.') }}
- + {{ __('Maximum credit limit for the registrar.') }}
-
+
@@ -118,6 +118,20 @@ {{ __('Type of threshold: fixed value or percentage.') }}
+ + +
+
+ + + {{ __('Official registration number provided by the relevant authority.') }} +
+
+ + + {{ __('VAT number for tax purposes, if registered for VAT.') }} +
+
diff --git a/cp/resources/views/admin/registrars/updateRegistrar.twig b/cp/resources/views/admin/registrars/updateRegistrar.twig index ae8eca8..72d8ffe 100644 --- a/cp/resources/views/admin/registrars/updateRegistrar.twig +++ b/cp/resources/views/admin/registrars/updateRegistrar.twig @@ -89,7 +89,7 @@
{{ __('Financial Information') }}
-
+
{{ currency }} {{ registrar.accountBalance }}
@@ -103,7 +103,7 @@
-
+
@@ -115,6 +115,20 @@ {{ __('Type of threshold: fixed value or percentage.') }}
+ + +
+
+ +
{{ registrar.companyNumber }}
+ {{ __('Official registration number provided by the relevant authority.') }} +
+
+ +
{{ registrar.vatNumber|default('N/A') }}
+ {{ __('VAT number for tax purposes, if registered for VAT.') }} +
+
diff --git a/cp/resources/views/admin/registrars/updateRegistrarUser.twig b/cp/resources/views/admin/registrars/updateRegistrarUser.twig index 4703500..30a3758 100644 --- a/cp/resources/views/admin/registrars/updateRegistrarUser.twig +++ b/cp/resources/views/admin/registrars/updateRegistrarUser.twig @@ -89,7 +89,7 @@
{{ __('Financial Information') }}
-
+
{{ currency }} {{ registrar.accountBalance }}
@@ -103,7 +103,7 @@
-
+
{{ currency }} {{ registrar.creditThreshold }}
@@ -115,6 +115,20 @@ {{ __('Type of threshold: fixed value or percentage.') }}
+ + +
+
+ +
{{ registrar.companyNumber }}
+ {{ __('Official registration number provided by the relevant authority.') }} +
+
+ +
{{ registrar.vatNumber|default('N/A') }}
+ {{ __('VAT number for tax purposes, if registered for VAT.') }} +
+
diff --git a/cp/resources/views/admin/registrars/viewRegistrar.twig b/cp/resources/views/admin/registrars/viewRegistrar.twig index 1e1605b..a032b87 100644 --- a/cp/resources/views/admin/registrars/viewRegistrar.twig +++ b/cp/resources/views/admin/registrars/viewRegistrar.twig @@ -27,7 +27,7 @@ {% include 'partials/flash.twig' %}
-

{{ __('Registrar') }} {{ registrar.name }} {{ registrar.prefix }} {{ registrar.iana_id|default('N/A') }}

+

{{ __('Registrar') }} {{ registrar.name }} {{ registrar.prefix }} {{ registrar.iana_id|default('N/A') }} {{ registrar.companyNumber|default('N/A') }} {{ registrar.vatNumber|default('N/A') }}

{% if roles != 0 %}