forked from unimatrix/web
28 lines
4.6 KiB
JavaScript
28 lines
4.6 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…');status.className='fine document-status';status.setAttribute('role','status');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 date=value=>new Date(value).toLocaleDateString('en-GB',{timeZone:'Europe/Brussels'});
|
||
const description=documentBox.querySelector('div');if(description){description.replaceChildren(el('span','IMPERIAL POSTBANK · PUBLIC HANDBOOK'),el('h2','Rates & Charges'),el('p','Banking tariffs, tax rules and the realm economy in one reference guide.'));description.firstChild.className='eyebrow';}
|
||
const actions=documentBox.querySelector('.document-actions'),edition=actions?.querySelector('.fine');
|
||
status.textContent='Bank tariffs dated '+date(data.publishedAt)+'.';
|
||
try{const manifest=await (await fetch('/downloads/rates-guide-manifest.json',{cache:'no-store',credentials:'omit'})).json();if(edition)edition.textContent='Version '+manifest.edition.replace(/^alpha-/,'Alpha ').replace(/-\d{8}$/,'')+' · Published '+date(manifest.publishedAt);if(manifest.sourcePublicationVersion!==data.version)status.textContent+=' The handbook uses an earlier bank snapshot; current figures above take precedence.';}catch{status.textContent+=' Handbook publication details could not be verified.';}
|
||
if(data.pdfReady){const link=el('a','Bank tariff snapshot · PDF');link.href=origin+data.pdfUrl;link.className='snapshot-download';actions?.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