Added company and vat numbers to show in panel #105

This commit is contained in:
Pinga 2024-07-24 10:40:32 +03:00
parent 1294c9faec
commit 3e22833450
9 changed files with 71 additions and 16 deletions

View file

@ -50,7 +50,10 @@ class FinancialsController extends Controller
$billing = $db->selectRow('SELECT * FROM registrar_contact WHERE id = ?', $billing = $db->selectRow('SELECT * FROM registrar_contact WHERE id = ?',
[ $invoice_details['billing_contact_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'] ] [ $invoice_details['registrar_id'] ]
); );
$company_name = $db->selectValue("SELECT value FROM settings WHERE name = 'company_name'"); $company_name = $db->selectValue("SELECT value FROM settings WHERE name = 'company_name'");
@ -86,6 +89,7 @@ class FinancialsController extends Controller
return view($response,'admin/financials/viewInvoice.twig', [ return view($response,'admin/financials/viewInvoice.twig', [
'invoice_details' => $invoice_details, 'invoice_details' => $invoice_details,
'billing' => $billing, 'billing' => $billing,
'billing_company' => $billing_company,
'billing_vat' => $billing_vat, 'billing_vat' => $billing_vat,
'statement' => $statement, 'statement' => $statement,
'company_name' => $company_name, 'company_name' => $company_name,

View file

@ -75,6 +75,8 @@ class RegistrarsController extends Controller
'creditLimit' => v::numericVal(), 'creditLimit' => v::numericVal(),
'creditThreshold' => v::numericVal(), 'creditThreshold' => v::numericVal(),
'thresholdType' => v::in(['fixed', 'percent']), 'thresholdType' => v::in(['fixed', 'percent']),
'companyNumber' => v::positive()->length(1, 30),
'vatNumber' => v::optional(v::length(1, 30)),
'ipAddress' => v::optional($ipAddressValidator), 'ipAddress' => v::optional($ipAddressValidator),
'user_name' => v::stringType()->notEmpty()->length(1, 255), 'user_name' => v::stringType()->notEmpty()->length(1, 255),
'user_email' => v::email(), 'user_email' => v::email(),
@ -122,6 +124,9 @@ class RegistrarsController extends Controller
if (empty($data['ianaId']) || !is_numeric($data['ianaId'])) { if (empty($data['ianaId']) || !is_numeric($data['ianaId'])) {
$data['ianaId'] = null; $data['ianaId'] = null;
} }
if (empty($data['vatNumber'])) {
$data['vatNumber'] = null;
}
$db->insert( $db->insert(
'registrar', 'registrar',
@ -141,6 +146,8 @@ class RegistrarsController extends Controller
'creditLimit' => $data['creditLimit'], 'creditLimit' => $data['creditLimit'],
'creditThreshold' => $data['creditThreshold'], 'creditThreshold' => $data['creditThreshold'],
'thresholdType' => $data['thresholdType'], 'thresholdType' => $data['thresholdType'],
'companyNumber' => $data['companyNumber'],
'vatNumber' => $data['vatNumber'],
'currency' => $currency, 'currency' => $currency,
'crdate' => $crdate, 'crdate' => $crdate,
'lastupdate' => $crdate 'lastupdate' => $crdate

View file

@ -44,7 +44,7 @@
<p class="h3">{{ __('Client') }} / {{ __('Registrar') }}</p> <p class="h3">{{ __('Client') }} / {{ __('Registrar') }}</p>
<address> <address>
{{ billing.org }}<br> {{ billing.org }}<br>
{{ billing_vat }} {% if validVAT %}<svg xmlns="http://www.w3.org/2000/svg" class="icon text-success" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M5 12l5 5l10 -10" /></svg>{% endif %}<br> {{ billing_company }} / {{ billing_vat|default('N/A') }} {% if validVAT %}<svg xmlns="http://www.w3.org/2000/svg" class="icon text-success" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M5 12l5 5l10 -10" /></svg>{% endif %}<br>
{{ billing.street1 }}<br> {{ billing.street1 }}<br>
{{ billing.city }}, {{ billing.sp }}<br> {{ billing.city }}, {{ billing.sp }}<br>
{{ billing.pc }}, {{ billing_country }}<br> {{ billing.pc }}, {{ billing_country }}<br>

View file

@ -89,21 +89,21 @@
<h5 class="card-title">{{ __('Financial Information') }}</h5> <h5 class="card-title">{{ __('Financial Information') }}</h5>
<div class="row"> <div class="row">
<!-- First Column --> <!-- First Column -->
<div class="col-md-6"> <div class="col-md-4">
<div class="mb-3"> <div class="mb-3">
<label for="accountBalance" class="form-label required">{{ __('Account Balance') }}</label> <label for="accountBalance" class="form-label required">{{ __('Account Balance') }}</label>
<input type="number" step="0.01" class="form-control" id="accountBalance" name="accountBalance" required> <input type="number" step="0.01" class="form-control" id="accountBalance" name="accountBalance" value="0" required>
<small class="text-muted">{{ __('Current balance in the registrar\'s account.') }}</small> <small class="text-muted">{{ __('Current balance in the registrar\'s account.') }}</small>
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="creditLimit" class="form-label required">{{ __('Credit Limit') }}</label> <label for="creditLimit" class="form-label required">{{ __('Credit Limit') }}</label>
<input type="number" step="0.01" class="form-control" id="creditLimit" name="creditLimit" required> <input type="number" step="0.01" class="form-control" id="creditLimit" name="creditLimit" value="0" required>
<small class="text-muted">{{ __('Maximum credit limit for the registrar.') }}</small> <small class="text-muted">{{ __('Maximum credit limit for the registrar.') }}</small>
</div> </div>
</div> </div>
<!-- Second Column --> <!-- Second Column -->
<div class="col-md-6"> <div class="col-md-4">
<div class="mb-3"> <div class="mb-3">
<label for="creditThreshold" class="form-label required">{{ __('Credit Threshold') }}</label> <label for="creditThreshold" class="form-label required">{{ __('Credit Threshold') }}</label>
<input type="number" step="0.01" class="form-control" id="creditThreshold" name="creditThreshold" required> <input type="number" step="0.01" class="form-control" id="creditThreshold" name="creditThreshold" required>
@ -118,6 +118,20 @@
<small class="text-muted">{{ __('Type of threshold: fixed value or percentage.') }}</small> <small class="text-muted">{{ __('Type of threshold: fixed value or percentage.') }}</small>
</div> </div>
</div> </div>
<!-- Third Column -->
<div class="col-md-4">
<div class="mb-3">
<label for="companyNumber" class="form-label required">{{ __('Company Number') }}</label>
<input type="text" class="form-control" id="companyNumber" name="companyNumber" required>
<small class="text-muted">{{ __('Official registration number provided by the relevant authority.') }}</small>
</div>
<div class="mb-3">
<label for="vatNumber" class="form-label">{{ __('VAT Number') }}</label>
<input type="text" class="form-control" id="vatNumber" name="vatNumber">
<small class="text-muted">{{ __('VAT number for tax purposes, if registered for VAT.') }}</small>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>

View file

@ -89,7 +89,7 @@
<h5 class="card-title">{{ __('Financial Information') }}</h5> <h5 class="card-title">{{ __('Financial Information') }}</h5>
<div class="row"> <div class="row">
<!-- First Column --> <!-- First Column -->
<div class="col-md-6"> <div class="col-md-4">
<div class="mb-3"> <div class="mb-3">
<label for="accountBalance" class="form-label">{{ __('Account Balance') }}</label> <label for="accountBalance" class="form-label">{{ __('Account Balance') }}</label>
<div class="form-control-plaintext">{{ currency }} {{ registrar.accountBalance }}</div> <div class="form-control-plaintext">{{ currency }} {{ registrar.accountBalance }}</div>
@ -103,7 +103,7 @@
</div> </div>
<!-- Second Column --> <!-- Second Column -->
<div class="col-md-6"> <div class="col-md-4">
<div class="mb-3"> <div class="mb-3">
<label for="creditThreshold" class="form-label required">{{ __('Credit Threshold') }}</label> <label for="creditThreshold" class="form-label required">{{ __('Credit Threshold') }}</label>
<input type="number" step="0.01" class="form-control" id="creditThreshold" name="creditThreshold" required value="{{ registrar.creditThreshold }}"> <input type="number" step="0.01" class="form-control" id="creditThreshold" name="creditThreshold" required value="{{ registrar.creditThreshold }}">
@ -115,6 +115,20 @@
<small class="text-muted">{{ __('Type of threshold: fixed value or percentage.') }}</small> <small class="text-muted">{{ __('Type of threshold: fixed value or percentage.') }}</small>
</div> </div>
</div> </div>
<!-- Third Column -->
<div class="col-md-4">
<div class="mb-3">
<label for="companyNumber" class="form-label">{{ __('Company Number') }}</label>
<div class="form-control-plaintext">{{ registrar.companyNumber }}</div>
<small class="text-muted">{{ __('Official registration number provided by the relevant authority.') }}</small>
</div>
<div class="mb-3">
<label for="vatNumber" class="form-label">{{ __('VAT Number') }}</label>
<div class="form-control-plaintext">{{ registrar.vatNumber|default('N/A') }}</div>
<small class="text-muted">{{ __('VAT number for tax purposes, if registered for VAT.') }}</small>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>

View file

@ -89,7 +89,7 @@
<h5 class="card-title">{{ __('Financial Information') }}</h5> <h5 class="card-title">{{ __('Financial Information') }}</h5>
<div class="row"> <div class="row">
<!-- First Column --> <!-- First Column -->
<div class="col-md-6"> <div class="col-md-4">
<div class="mb-3"> <div class="mb-3">
<label for="accountBalance" class="form-label">{{ __('Account Balance') }}</label> <label for="accountBalance" class="form-label">{{ __('Account Balance') }}</label>
<div class="form-control-plaintext">{{ currency }} {{ registrar.accountBalance }}</div> <div class="form-control-plaintext">{{ currency }} {{ registrar.accountBalance }}</div>
@ -103,7 +103,7 @@
</div> </div>
<!-- Second Column --> <!-- Second Column -->
<div class="col-md-6"> <div class="col-md-4">
<div class="mb-3"> <div class="mb-3">
<label for="creditThreshold" class="form-label">{{ __('Credit Threshold') }}</label> <label for="creditThreshold" class="form-label">{{ __('Credit Threshold') }}</label>
<div class="form-control-plaintext">{{ currency }} {{ registrar.creditThreshold }}</div> <div class="form-control-plaintext">{{ currency }} {{ registrar.creditThreshold }}</div>
@ -115,6 +115,20 @@
<small class="text-muted">{{ __('Type of threshold: fixed value or percentage.') }}</small> <small class="text-muted">{{ __('Type of threshold: fixed value or percentage.') }}</small>
</div> </div>
</div> </div>
<!-- Third Column -->
<div class="col-md-4">
<div class="mb-3">
<label for="companyNumber" class="form-label">{{ __('Company Number') }}</label>
<div class="form-control-plaintext">{{ registrar.companyNumber }}</div>
<small class="text-muted">{{ __('Official registration number provided by the relevant authority.') }}</small>
</div>
<div class="mb-3">
<label for="vatNumber" class="form-label">{{ __('VAT Number') }}</label>
<div class="form-control-plaintext">{{ registrar.vatNumber|default('N/A') }}</div>
<small class="text-muted">{{ __('VAT number for tax purposes, if registered for VAT.') }}</small>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>

View file

@ -27,7 +27,7 @@
{% include 'partials/flash.twig' %} {% include 'partials/flash.twig' %}
<div class="card mb-3"> <div class="card mb-3">
<div class="card-header"> <div class="card-header">
<h3 class="card-title">{{ __('Registrar') }} {{ registrar.name }}&nbsp;<span class="status status-green" title="Prefix">{{ registrar.prefix }}</span>&nbsp;<span class="status status-info" title="IANA ID">{{ registrar.iana_id|default('N/A') }}</span></h3> <h3 class="card-title">{{ __('Registrar') }} {{ registrar.name }}&nbsp;<span class="status status-green" title="Prefix">{{ registrar.prefix }}</span>&nbsp;<span class="status status-info" title="IANA ID">{{ registrar.iana_id|default('N/A') }}</span>&nbsp;<span class="status status-indigo" title="{{ __('Company Number') }}">{{ registrar.companyNumber|default('N/A') }}</span>&nbsp;<span class="status status-cyan" title="{{ __('VAT Number') }}">{{ registrar.vatNumber|default('N/A') }}</span></h3>
{% if roles != 0 %} {% if roles != 0 %}
<div class="card-actions"> <div class="card-actions">
<a href="{{route('editRegistrar')}}" type="button" class="btn btn-primary"> <a href="{{route('editRegistrar')}}" type="button" class="btn btn-primary">

View file

@ -113,7 +113,8 @@ CREATE TABLE IF NOT EXISTS `registry`.`registrar` (
`creditThreshold` decimal(12,2) NOT NULL default '0.00', `creditThreshold` decimal(12,2) NOT NULL default '0.00',
`thresholdType` enum('fixed','percent') NOT NULL default 'fixed', `thresholdType` enum('fixed','percent') NOT NULL default 'fixed',
`currency` varchar(5) NOT NULL default 'USD', `currency` varchar(5) NOT NULL default 'USD',
`vat_number` varchar(30) DEFAULT NULL, `companyNumber` varchar(30) DEFAULT NULL,
`vatNumber` varchar(30) DEFAULT NULL,
`crdate` datetime(3) NOT NULL, `crdate` datetime(3) NOT NULL,
`lastupdate` TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP, `lastupdate` TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),

View file

@ -108,7 +108,8 @@ CREATE TABLE registrar (
"creditthreshold" decimal(12,2) NOT NULL default '0.00', "creditthreshold" decimal(12,2) NOT NULL default '0.00',
"thresholdtype" varchar CHECK ("thresholdtype" IN ( 'fixed','percent' )) NOT NULL default 'fixed', "thresholdtype" varchar CHECK ("thresholdtype" IN ( 'fixed','percent' )) NOT NULL default 'fixed',
"currency" varchar(5) NOT NULL default 'USD', "currency" varchar(5) NOT NULL default 'USD',
"vat_number" VARCHAR(30) DEFAULT NULL, "companyNumber" VARCHAR(30) DEFAULT NULL,
"vatNumber" VARCHAR(30) DEFAULT NULL,
"crdate" timestamp(3) without time zone NOT NULL, "crdate" timestamp(3) without time zone NOT NULL,
"lastupdate" timestamp(3), "lastupdate" timestamp(3),
unique ("clid"), unique ("clid"),