Fixed invoices page to display right currency

This commit is contained in:
Pinga 2025-02-11 16:18:38 +02:00
parent e22ed9782e
commit dd5aef123d
2 changed files with 11 additions and 9 deletions

View file

@ -53,6 +53,9 @@ class FinancialsController extends Controller
$billing_company = $db->selectValue('SELECT companyNumber FROM registrar WHERE id = ?', $billing_company = $db->selectValue('SELECT companyNumber FROM registrar WHERE id = ?',
[ $invoice_details['registrar_id'] ] [ $invoice_details['registrar_id'] ]
); );
$currency = $db->selectValue('SELECT currency FROM registrar WHERE id = ?',
[ $invoice_details['registrar_id'] ]
);
$billing_vat = $db->selectValue('SELECT vatNumber FROM registrar WHERE id = ?', $billing_vat = $db->selectValue('SELECT vatNumber FROM registrar WHERE id = ?',
[ $invoice_details['registrar_id'] ] [ $invoice_details['registrar_id'] ]
); );
@ -87,7 +90,6 @@ class FinancialsController extends Controller
$billing_country = $billing_country['name']; $billing_country = $billing_country['name'];
$locale = $_SESSION['_lang'] ?? 'en_US'; // Fallback to 'en_US' if no locale is set $locale = $_SESSION['_lang'] ?? 'en_US'; // Fallback to 'en_US' if no locale is set
$currency = $_SESSION['_currency'] ?? 'USD'; // Fallback to 'USD' if no currency is set
// Initialize the number formatter for the locale // Initialize the number formatter for the locale
$numberFormatter = new \NumberFormatter($locale, \NumberFormatter::DECIMAL); $numberFormatter = new \NumberFormatter($locale, \NumberFormatter::DECIMAL);

View file

@ -18,8 +18,6 @@
`; `;
} }
currency = "{{ currency }} ";
table = new Tabulator("#invoicesTable", { table = new Tabulator("#invoicesTable", {
ajaxURL:"/api/records/invoices?join=registrar", // Set the URL for your JSON data ajaxURL:"/api/records/invoices?join=registrar", // Set the URL for your JSON data
ajaxConfig:"GET", ajaxConfig:"GET",
@ -41,11 +39,13 @@
{title:"{{ __('Number') }}", field:"invoice_number", width:200, resizable:false, headerSort:true, formatter: invoiceLinkFormatter, responsive:0}, {title:"{{ __('Number') }}", field:"invoice_number", width:200, resizable:false, headerSort:true, formatter: invoiceLinkFormatter, responsive:0},
{title:"{{ __('Registrar') }}", field:"registrar_id.name", width:300, resizable:false, headerSort:true, responsive:0}, {title:"{{ __('Registrar') }}", field:"registrar_id.name", width:300, resizable:false, headerSort:true, responsive:0},
{title:"{{ __('Date') }}", field:"issue_date", width:300, resizable:false, headerSort:true, responsive:0}, {title:"{{ __('Date') }}", field:"issue_date", width:300, resizable:false, headerSort:true, responsive:0},
{title:"{{ __('Amount') }}", field:"total_amount", width:200, resizable:false, headerSort:true, responsive:0, formatter:"money", formatterParams:{ {title:"{{ __('Amount') }}", field:"total_amount", width:200, resizable:false, headerSort:true, responsive:0, formatter:"money", formatterParams:function(cell){
decimal:".", return {
thousand:" ", decimal: ".",
symbol:currency, thousand: " ",
negativeSign:true, symbol: (cell.getRow().getData().registrar_id.currency || "$") + " ", // Ensures space after currency symbol
negativeSign: true
};
}}, }},
{title: "{{ __('Actions') }}", formatter: actionsFormatter, headerSort: false, download:false, hozAlign: "center", responsive:0, cellClick:function(e, cell){ e.stopPropagation(); }}, {title: "{{ __('Actions') }}", formatter: actionsFormatter, headerSort: false, download:false, hozAlign: "center", responsive:0, cellClick:function(e, cell){ e.stopPropagation(); }},
] ]