forked from unimatrix/web
24 lines
4 KiB
JavaScript
24 lines
4 KiB
JavaScript
/* Anonymous public register: never sends account cookies or personal data. */
|
||
(()=>{
|
||
const origin='https://cp.dunerealms.com',money=n=>(Number(n)/100).toFixed(2)+' DM',percent=n=>(Number(n)/100).toFixed(2)+'%';
|
||
const el=(tag,text)=>{const node=document.createElement(tag);if(text!==undefined)node.textContent=text;return node;};
|
||
async function load(){
|
||
const documentBox=document.querySelector('.document'),status=el('p','Loading the current public tariff publication…');documentBox?.append(status);
|
||
try{
|
||
const response=await fetch(origin+'/api/bank/public/rates',{credentials:'omit',cache:'no-store'});if(!response.ok)throw Error('Current publication unavailable.');const data=await response.json();
|
||
document.querySelector('.stamp').textContent='PUBLIC TARIFF REGISTER · '+new Date(data.publishedAt).toLocaleDateString('en-GB',{timeZone:'Europe/Brussels'});
|
||
for(const row of document.querySelectorAll('#packages tbody tr')){const rate=data.packages.find(p=>p.name===row.children[0].textContent);if(rate){row.children[2].textContent=money(rate.monthlyMinor);if(row.children[4].textContent!=='—')row.children[4].textContent=money(rate.extraMinor);}}
|
||
for(const row of document.querySelectorAll('#credit tbody tr')){const rate=data.credit.find(p=>p.name===row.children[0].textContent);if(rate)row.children[1].textContent=percent(rate.annualBps);}
|
||
const notice=document.querySelector('.notice p');if(notice)notice.textContent='All amounts are fictional Dunemarks (DM). '+data.serviceNotices.join(' ');
|
||
const taxCard=document.querySelector('#services .service-grid article:last-child');if(taxCard){taxCard.replaceChildren(el('h3','Configured game taxes'),el('p','VAT on applicable sales: '+percent(data.taxes.vatBps)),el('p','VAT on bank fees: '+percent(data.taxes.bankFeeVatBps)),el('p','Monthly account tax: '+money(data.taxes.monthlyAccountTaxMinor)),el('small','Collection applies to supported game flows; monthly package billing and Balance Guard availability are disclosed above.'));}
|
||
const section=el('section');section.id='payroll-tax';section.append(el('span','04 / PEOPLE & ORGANISATION'),el('h2','Payroll contributions & income tax'),el('p','Employee social contribution: '+percent(data.payrollTax.employeeSocialBps)+' · Employer social contribution: '+percent(data.payrollTax.employerSocialBps)),el('p','Annual basic allowance: '+money(data.payrollTax.annualAllowanceMinor)));
|
||
const wrap=el('div');wrap.className='table-wrap';const table=el('table'),head=el('thead'),header=el('tr'),body=el('tbody');for(const text of ['Annual taxable income','Tax rate'])header.append(el('th',text));head.append(header);let lower=0;
|
||
for(const band of data.payrollTax.bands){const row=el('tr');row.append(el('td',band.upToMinor===null?'Above '+money(lower):money(lower)+'–'+money(band.upToMinor)),el('td',percent(band.bps)));body.append(row);lower=band.upToMinor;}
|
||
table.append(head,body);wrap.append(table);section.append(wrap,el('p','Fictional game payroll using selected Belgian-inspired parameters. The basic allowance is a tax credit; individual salaries remain private.'));documentBox.before(section);
|
||
const description=documentBox.querySelector('div');if(description){description.replaceChildren(el('h2','Download the public tariff guide'),el('p','Publication '+data.version+' · '+new Date(data.publishedAt).toLocaleString('en-GB',{timeZone:'Europe/Brussels'})),el('p','The PDF and live register use the same immutable publication. Accepted loan rates and recorded package prices retain their agreed terms.'));}
|
||
status.textContent=data.pdfReady?'Current publication verified.':'The current publication PDF is being prepared. Reload shortly.';
|
||
if(data.pdfReady){const link=el('a','Download Rates & Charges PDF');link.href=origin+data.pdfUrl;link.className='pdf-download';documentBox.append(link);}
|
||
}catch{status.textContent='Live publication unavailable. Catalogue reference prices are shown; retry before relying on a changed tariff.';}
|
||
}
|
||
if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',load,{once:true});else void load();
|
||
})();
|

Staff