diff --git a/website/control-panel/public/cp-v2/cp-v2-postbank-credit.mjs b/website/control-panel/public/cp-v2/cp-v2-postbank-credit.mjs index f9920ae3..504e5eae 100644 --- a/website/control-panel/public/cp-v2/cp-v2-postbank-credit.mjs +++ b/website/control-panel/public/cp-v2/cp-v2-postbank-credit.mjs @@ -16,8 +16,8 @@ export function mountPostbankCredit(host,id,{fetcher=fetch}={}){ let selected=accounts[0];const tabs=el('div',undefined,'pb-credit-account-tabs'),stage=el('section',undefined,'pb-credit-stage');tabs.setAttribute('role','tablist');tabs.setAttribute('aria-label','Borrowing account');stage.id='pb-credit-account-panel';stage.setAttribute('role','tabpanel');const buttons=[]; for(const account of accounts){const button=el('button',undefined,'pb-credit-account-tab');button.type='button';button.setAttribute('role','tab');button.id='pb-credit-account-tab-'+buttons.length;button.setAttribute('aria-controls',stage.id);button.append(el('strong',account.holder||account.name),el('small',account.name+' · '+account.number.replace(/(.{4})/g,'$1 ').trim()));button.onclick=()=>{if(busy)return;selected=account;renderProducts();};buttons.push({button,account});tabs.append(button);} frame.content.append(tabs,stage); - function renderProducts(){for(const {button,account} of buttons){const chosen=account.id===selected.id;button.setAttribute('aria-selected',String(chosen));button.tabIndex=chosen?0:-1;if(chosen)stage.setAttribute('aria-labelledby',button.id);}stage.replaceChildren();const products=el('div',undefined,'pb-credit-products');stage.append(products);for(const [group,label]of [['grants','Launch Grants'],['personal','Personal Loans'],['professional','Business & Civic Loans'],['refinancing','Refinancing']]){const choices=view.products.filter(p=>p.group===group&&p.kinds.includes(selected.kind));if(!choices.length)continue;const section=el('section',undefined,'pb-credit-category'),cards=el('div',undefined,'pb-package-choices');section.append(el('h2',label),cards); - for(const product of choices){const theme=creditTheme(product),card=el('section',undefined,'pb-choice-card pb-credit-product pb-plan-'+theme),brand=packageBrand({key:'pb_'+theme,name:product.name}),price=el('div',undefined,'pb-credit-price');price.append(el('strong',product.amount?product.amount+' DM':product.min+'–'+product.max+' DM'),el('small',(product.annualBps/100).toFixed(2)+'% annual interest'));const list=el('ul');for(const text of group==='grants'?['No collateral required','Choose your monthly repayment','Up to 12 monthly instalments']:['Fixed repayment schedule','25% blocked DM collateral','Client funds only'])list.append(el('li',text));const choose=el('button',product.revolving?'Coming soon':'Simulate repayments','pb-credit-simulate');choose.type='button';choose.disabled=!!product.revolving;choose.onclick=()=>{if(busy)return;stage.replaceChildren();simulator(product,selected,stage,renderProducts);};card.append(brand,price,list,choose);cards.append(card);}products.append(section);} + function renderProducts(){for(const {button,account} of buttons){const chosen=account.id===selected.id;button.setAttribute('aria-selected',String(chosen));button.tabIndex=chosen?0:-1;if(chosen)stage.setAttribute('aria-labelledby',button.id);}stage.replaceChildren();const products=el('div',undefined,'pb-credit-products');stage.append(products);for(const [group,label]of [['grants','Launch Grants'],['personal','Personal Loans'],['professional','Business & Civic Loans'],['refinancing','Refinancing']]){const choices=(selected.products||view.products).filter(p=>p.group===group&&p.kinds.includes(selected.kind));if(!choices.length)continue;const section=el('section',undefined,'pb-credit-category'),cards=el('div',undefined,'pb-package-choices');section.append(el('h2',label),cards); + for(const product of choices){const theme=product.packageBenefit?'pro':creditTheme(product),card=el('section',undefined,'pb-choice-card pb-credit-product pb-plan-'+theme),brand=packageBrand({key:'pb_'+theme,name:product.name}),price=el('div',undefined,'pb-credit-price');price.append(el('strong',product.amount?product.amount+' DM':product.min+'–'+product.max+' DM'),el('small',(product.annualBps/100).toFixed(2)+'% annual interest'));const list=el('ul');for(const text of group==='grants'?['No collateral required','Choose your monthly repayment','Up to 12 monthly instalments']:['Fixed repayment schedule','25% blocked DM collateral','Client funds only'])list.append(el('li',text));if(product.packageBenefit)list.append(el('li',product.packageBenefit));const choose=el('button',product.revolving?'Coming soon':'Simulate repayments','pb-credit-simulate');choose.type='button';choose.disabled=!!product.revolving;choose.onclick=()=>{if(busy)return;stage.replaceChildren();simulator(product,selected,stage,renderProducts);};card.append(brand,price,list,choose);cards.append(card);}products.append(section);} } tabs.onkeydown=e=>{const index=buttons.findIndex(b=>b.button===e.target);if(index<0||!['ArrowLeft','ArrowRight','Home','End'].includes(e.key)||busy)return;e.preventDefault();const next=e.key==='Home'?0:e.key==='End'?buttons.length-1:(index+(e.key==='ArrowRight'?1:-1)+buttons.length)%buttons.length;buttons[next].button.onclick();buttons[next].button.focus();};renderProducts(); } diff --git a/website/control-panel/public/cp-v2/cp-v2-postbank-foundation.mjs b/website/control-panel/public/cp-v2/cp-v2-postbank-foundation.mjs index 5ed6cc09..c017aa2c 100644 --- a/website/control-panel/public/cp-v2/cp-v2-postbank-foundation.mjs +++ b/website/control-panel/public/cp-v2/cp-v2-postbank-foundation.mjs @@ -10,12 +10,12 @@ const number=value=>typeof value==='string'&&/^DR\d{14}$/.test(value)?value.matc const accountNames={'102':'Current','103':'Savings','104':'Savings+','105':'Corporate current','106':'Blocked collateral','107':'Civic current','108':'Current','979':'Official current'}; function box(title){const section=el('section',undefined,'pb-box');if(title)section.append(el('h4',title));return section;} function datum(parent,label,value){const row=el('div',undefined,'pb-datum');row.append(el('span',label),el('strong',String(value)));parent.append(row);} -const packageClass=key=>'pb-plan-'+({pb_start:'start',pb_flow:'flow',pb_connect:'connect',pb_scale:'scale',pb_civic:'civic',pb_public:'public'}[key]||'start'); +const packageClass=key=>'pb-plan-'+({pb_start:'start',pb_flow:'flow',pb_pro:'pro',pb_connect:'connect',pb_scale:'scale',pb_civic:'civic',pb_public:'public'}[key]||'start'); // Original vector package marks: a shared Postbank arch with a distinct product motif. // These are package identities, not payment-card artwork. export function packageBrand(choice,entity=null){ const brand=el('div',undefined,'pb-package-brand'),svg=document.createElementNS('http://www.w3.org/2000/svg','svg');svg.setAttribute('viewBox','0 0 64 64');svg.setAttribute('role','img');svg.setAttribute('aria-label',choice.name+' package logo');svg.classList.add('pb-package-logo'); - const paths={pb_start:'M23 41V27a9 9 0 0 1 18 0v14M18 45h28M32 16v-5',pb_flow:'M17 27c8-12 22 12 30 0M17 37c8-12 22 12 30 0M21 47c6-8 16 8 22 0',pb_connect:'M28 25l-5 5a7 7 0 0 0 10 10l5-5M36 39l5-5a7 7 0 0 0-10-10l-5 5M26 38l12-12',pb_scale:'M17 45h30M21 40V29h8v11M35 40V19h8v21M18 21l10-7 6 3 12-8',pb_civic:'M17 27l15-11 15 11M21 30v13M32 30v13M43 30v13M17 47h30',pb_public:'M32 15l15 6v11c0 9-8 15-15 18-7-3-15-9-15-18V21zM25 32l5 5 10-11'}; + const paths={pb_pro:'M17 44h30M19 39l-3-17 10 8 6-16 6 16 10-8-3 17z',pb_start:'M23 41V27a9 9 0 0 1 18 0v14M18 45h28M32 16v-5',pb_flow:'M17 27c8-12 22 12 30 0M17 37c8-12 22 12 30 0M21 47c6-8 16 8 22 0',pb_connect:'M28 25l-5 5a7 7 0 0 0 10 10l5-5M36 39l5-5a7 7 0 0 0-10-10l-5 5M26 38l12-12',pb_scale:'M17 45h30M21 40V29h8v11M35 40V19h8v21M18 21l10-7 6 3 12-8',pb_civic:'M17 27l15-11 15 11M21 30v13M32 30v13M43 30v13M17 47h30',pb_public:'M32 15l15 6v11c0 9-8 15-15 18-7-3-15-9-15-18V21zM25 32l5 5 10-11'}; const arch=document.createElementNS(svg.namespaceURI,'path');arch.setAttribute('d','M6 32a26 26 0 0 1 52 0M6 39v7M58 39v7');arch.setAttribute('class','pb-logo-arch'); const motif=document.createElementNS(svg.namespaceURI,'path');motif.setAttribute('d',paths[choice.key]||paths.pb_start);svg.append(arch,motif); const text=el('div');text.append(el('small','IMPERIAL POSTBANK'),el('h5',entity&&entity.kind!=='person'?choice.name+' — '+entity.name:choice.name));brand.append(svg,text);return brand; @@ -36,7 +36,8 @@ export function mountPostbankFoundation(host,page,{fetcher=fetch,onAccountSelect const price=el('div',undefined,'pb-choice-price');price.append(el('strong',choice.monthly==='0.00'?'Free':choice.monthly),el('span',choice.monthly==='0.00'?'No monthly package fee':'DM / month')); const list=el('ul',undefined,'pb-choice-features'); const features=['One current account',choice.savings?'Savings account included':choice.key==='pb_start'?'A simple everyday account':'Dedicated entity banking']; - features.push(choice.instant?choice.instant+' instant payments per month':'Standard payments only'); + features.push(choice.unlimitedInstant?'Unlimited instant payments · No per-transfer fee':choice.instant?choice.instant+' instant payments per month':'Standard payments only'); + if(choice.key==='pb_pro')features.push('No transfer amount cap · Subject to available funds','3× personal borrowing ceilings · Credit review applies','180 DM / year · Base package'); if(choice.extra)features.push('Up to '+choice.extra+' additional current '+(choice.extra===1?'account':'accounts')+' · '+choice.extraFee+' DM each / month'); else features.push('No additional current accounts'); for(const feature of features)list.append(el('li',feature)); diff --git a/website/control-panel/public/cp-v2/cp-v2-postbank-payments.mjs b/website/control-panel/public/cp-v2/cp-v2-postbank-payments.mjs index a697faa2..21558226 100644 --- a/website/control-panel/public/cp-v2/cp-v2-postbank-payments.mjs +++ b/website/control-panel/public/cp-v2/cp-v2-postbank-payments.mjs @@ -22,7 +22,7 @@ export function mountPostbankPayments(host,page,{fetcher=fetch,accountId=null}={ const balance=el('p',undefined,'pb-transfer-available'),searchArea=el('section',undefined,'pb-recipient-search'),query=el('input');query.type='search';query.minLength=3;query.maxLength=80;query.placeholder='Name or full DR account number'; const search=el('button','Find beneficiary');search.type='button';const found=el('select');found.setAttribute('aria-label','Verified beneficiary account');const searchStatus=el('p',undefined,'pb-muted'); searchArea.append(field('Find another beneficiary',query),search,field('Verified beneficiary',found),searchStatus);let external=null,searchVersion=0; - const amount=el('input');amount.type='text';amount.inputMode='decimal';amount.required=true;amount.pattern='(?:0|[1-9][0-9]{0,6})(?:\\.[0-9]{1,2})?';amount.placeholder='0.00'; + const amount=el('input');amount.type='text';amount.inputMode='decimal';amount.required=true;amount.pattern='(?:0|[1-9][0-9]{0,16})(?:\\.[0-9]{1,2})?';amount.placeholder='0.00'; const reference=el('textarea');reference.required=true;reference.maxLength=140;reference.rows=2;reference.placeholder='Payment reference'; const standard=el('input'),instant=el('input');standard.type=instant.type='radio';standard.name=instant.name='payment-processing';standard.checked=true;const modes=el('fieldset',undefined,'pb-transfer-modes');modes.append(el('legend','Processing'));const standardLabel=el('label',undefined,'pb-processing-choice'),instantLabel=el('label',undefined,'pb-processing-choice');standardLabel.append(standard,el('strong','Standard'),el('small','Every four hours'));instantLabel.append(instant,el('strong','Instant'),el('small','Within your package allowance'));modes.append(standardLabel,instantLabel);const processing=el('p',undefined,'pb-muted'); const confirm=el('input');confirm.type='checkbox';const confirmLabel=el('label',undefined,'pb-consent');confirmLabel.append(confirm,el('span','I confirm the beneficiary and payment details.')); @@ -31,7 +31,7 @@ export function mountPostbankPayments(host,page,{fetcher=fetch,accountId=null}={ const body=el('div',undefined,'pb-remittance-body'),recap=el('aside',undefined,'pb-transfer-recap'),recapAmount=el('strong','0.00 DM','pb-recap-amount'),recapFrom=el('p'),recapTo=el('p'),recapMode=el('p');fromBox.append(balance);body.append(grid,searchArea,moneyRow,modes,processing,secretField,secretHelp,confirmLabel,el('p',options.fees.message,'pb-muted'),submit);recap.append(el('small','YOUR TRANSFER'),recapAmount,el('h5','From'),recapFrom,el('h5','To'),recapTo,el('h5','Processing'),recapMode,el('p','Your bank confirms the instruction before any balance is posted.','pb-muted'));form.append(body,recap);frame.content.append(form);const history=el('a','Open Transactions');history.href='#bank/bank-statements';frame.content.append(history);let pending=null,finished=false; const currentSource=()=>sources.find(a=>a.id===from.value),currentTarget=()=>to.value==='external'?external:targets.find(a=>a.number===to.value); const isOwn=()=>{const a=currentSource(),b=currentTarget();return !!a?.isPersonalOwner&&a.entityId===b?.entityId;}; - function update(){const source=currentSource();balance.textContent='Available: '+source.available+' DM';for(const o of to.options)o.disabled=o.value===source.number;if(to.value===source.number)to.value=[...to.options].find(o=>!o.disabled)?.value||'external';searchArea.hidden=to.value!=='external';query.required=!searchArea.hidden;found.required=!searchArea.hidden;instant.disabled=source.instantQuota===0;if(instant.disabled){instant.checked=false;standard.checked=true;}processing.textContent=instant.checked?'Instant payments included in this package: '+source.instantQuota+' per calendar month.':options.standard.processing+(options.standard.nextAt>Date.now()?' Next batch: '+new Date(options.standard.nextAt).toLocaleString('en-GB',{timeZone:'Europe/Brussels'})+' (Belgian time).':'');recapAmount.textContent=(amount.value||'0.00')+' DM';recapFrom.textContent=currentSource().holder;recapTo.textContent=currentTarget()?.holder||'Select a beneficiary';recapMode.textContent=instant.checked?'Instant':'Standard · Every four hours';const protectedAmount=instant.checked&&options.security?.enabled!==false&&Number(amount.value)>Number(options.security?.threshold||'5000.00');secretField.hidden=!protectedAmount;secretHelp.hidden=!protectedAmount;paymentSecret.required=protectedAmount&&!!options.security?.configured;if(!protectedAmount)paymentSecret.value='';securityLink.textContent=options.security?.configured?'Manage payment security':'Set your payment secret before sending this amount, or choose Standard';submit.disabled=protectedAmount&&!options.security?.configured;confirmLabel.hidden=isOwn();confirm.required=!isOwn();} + function update(){const source=currentSource();balance.textContent='Available: '+source.available+' DM';for(const o of to.options)o.disabled=o.value===source.number;if(to.value===source.number)to.value=[...to.options].find(o=>!o.disabled)?.value||'external';searchArea.hidden=to.value!=='external';query.required=!searchArea.hidden;found.required=!searchArea.hidden;instant.disabled=!source.unlimitedInstant&&source.instantQuota===0;if(instant.disabled){instant.checked=false;standard.checked=true;}processing.textContent=instant.checked?(source.unlimitedInstant?'Unlimited instant payments · No per-transfer fee.':'Instant payments included in this package: '+source.instantQuota+' per calendar month.'):options.standard.processing+(options.standard.nextAt>Date.now()?' Next batch: '+new Date(options.standard.nextAt).toLocaleString('en-GB',{timeZone:'Europe/Brussels'})+' (Belgian time).':'');recapAmount.textContent=(amount.value||'0.00')+' DM';recapFrom.textContent=currentSource().holder;recapTo.textContent=currentTarget()?.holder||'Select a beneficiary';recapMode.textContent=instant.checked?'Instant':'Standard · Every four hours';const protectedAmount=instant.checked&&options.security?.enabled!==false&&Number(amount.value)>Number(options.security?.threshold||'5000.00');secretField.hidden=!protectedAmount;secretHelp.hidden=!protectedAmount;paymentSecret.required=protectedAmount&&!!options.security?.configured;if(!protectedAmount)paymentSecret.value='';securityLink.textContent=options.security?.configured?'Manage payment security':'Set your payment secret before sending this amount, or choose Standard';submit.disabled=protectedAmount&&!options.security?.configured;confirmLabel.hidden=isOwn();confirm.required=!isOwn();} from.onchange=()=>{confirm.checked=false;update();};to.onchange=()=>{confirm.checked=false;update();};instant.onchange=standard.onchange=update;amount.oninput=update;query.oninput=()=>{external=null;found.replaceChildren();searchVersion++;confirm.checked=false;};found.onchange=()=>{external=found._results?.find(a=>a.number===found.value)||null;confirm.checked=false;update();}; search.onclick=async()=>{const version=++searchVersion;external=null;found.replaceChildren();search.disabled=true;searchStatus.textContent='Searching…';try{const data=await api.request('/api/bank/recipients?q='+encodeURIComponent(query.value));if(!active||version!==searchVersion)return;found._results=data.recipients;selectOption(found,'Choose a beneficiary','');for(const r of data.recipients)selectOption(found,r.holder+' · '+formatNumber(r.number),r.number);searchStatus.textContent=data.recipients.length?'Select and confirm the matching account.':'No active matching account was found.';}catch(error){if(active&&version===searchVersion)searchStatus.textContent=error.message;}finally{if(active)search.disabled=false;}}; form.onsubmit=async event=>{ diff --git a/website/control-panel/public/cp-v2/v2.css b/website/control-panel/public/cp-v2/v2.css index 64a5664f..fcb8cb18 100644 --- a/website/control-panel/public/cp-v2/v2.css +++ b/website/control-panel/public/cp-v2/v2.css @@ -238,3 +238,6 @@ .pb-credit-detail-row[hidden]{display:none!important}.pb-credit-detail-row>td{padding:24px!important;background:#102f25!important}.pb-credit-contract-panel{width:100%;min-width:0;max-width:100%;box-sizing:border-box}.pb-credit-contract-panel .pb-transfer-form,.pb-credit-contract-panel .pb-credit-instruction{width:100%;min-width:0;max-width:100%;box-sizing:border-box}.pb-credit-contract-panel input,.pb-credit-contract-panel textarea{max-width:100%;box-sizing:border-box}.pb-credit-contract-panel .pb-ledger-scroll{max-width:100%;overflow-x:auto}.pb-credit-contract-panel p,.pb-credit-contract-panel label{white-space:normal;overflow-wrap:anywhere} .pb-payroll-form>.pb-ledger-scroll,.pb-payroll-form>p,.pb-payroll-form>button{grid-column:1/-1}.pb-payroll-form .pb-ledger input{width:115px;max-width:100%;padding:10px;border:1px solid #82926d;border-radius:6px;background:#102e24;color:#eee6d2;box-sizing:border-box}.pb-payroll-form input[type=checkbox]{width:24px;height:24px;align-self:start;accent-color:#b89a50}.pb-payroll-form .pb-ledger th{white-space:normal}.pb-payroll-form .pb-ledger-scroll{min-width:0;max-width:100%} .portals{grid-template-columns:repeat(auto-fit,minmax(145px,1fr))}.portal[data-id=clan]{background:linear-gradient(145deg,#263c54,#142a27);border-color:#b7a16c;color:#e6d6a3}.portal[data-id=quests]{background:linear-gradient(145deg,#3d382a,#142b23)}.portal[data-id=kits]{background:linear-gradient(145deg,#263f43,#10291f)}.portal[data-id=events]{background:linear-gradient(145deg,#433348,#152b23)}body[data-workspace=clan] .layout{background:linear-gradient(120deg,#161f22f5,#24251eea),url('https://www.dunerealms.com/assets/sietch.webp') center/cover fixed}body[data-workspace=clan] .hero{border-color:#b99a58;background:linear-gradient(90deg,#252b28ed,#122a29d9),url('https://www.dunerealms.com/assets/clan-atelier-v1.webp') center/cover}body[data-workspace=clan] .hero h1{font-family:Georgia,serif;color:#f0d59c}body[data-workspace=clan] .card{background:linear-gradient(140deg,#29362be8,#102b25f5);border-color:#8f8254}body[data-workspace=clan] .side-hero{background:linear-gradient(100deg,#2d261cbd,#172b2cde),url('https://www.dunerealms.com/assets/clan-atelier-v1.webp') center/cover;color:#f2d9a1}body[data-workspace=clan] .category-block{background:#152b25;border-color:#9b8651}body[data-workspace=clan] .category-heading{background:linear-gradient(90deg,#413923,#1c342b)}body[data-workspace=clan] .navitem[aria-current=page]{border-color:#f1d18d;box-shadow:inset 3px 0 #c2a56a;background:#354432}.cp-play-placeholder{padding:28px;border:1px solid #9b8651;border-radius:12px;background:linear-gradient(130deg,#293d32,#132b23)}.cp-play-placeholder strong{display:inline-block;border:1px solid #a88d54;padding:8px 15px;border-radius:20px;color:#d9bf81}@media(max-width:420px){.portals{grid-template-columns:repeat(2,minmax(0,1fr))}} + +/* Pro: platinum, midnight blue and restrained gold. */ +.pb-plan-pro{--pb-accent:#e5e9f3;--pb-glow:#b8cbea;--pb-tint:#243e51;background:linear-gradient(135deg,#18372f,#132736 70%);border-color:#b7c5d5}.pb-plan-pro .pb-package-logo{filter:drop-shadow(0 2px 9px #b8cbea35)}.pb-plan-pro .pb-choice-price strong{color:#f6df9c} diff --git a/website/docs/postbank-pro.md b/website/docs/postbank-pro.md new file mode 100644 index 00000000..1aa68d33 --- /dev/null +++ b/website/docs/postbank-pro.md @@ -0,0 +1,7 @@ +# Personal packages + +Start / Flow / Pro: 0 / 5 / 15 DM per month. Pro includes a current account, savings account, unlimited instant payments with no per-transfer fee, and up to three extra current accounts priced at 2 DM each per month when that service is available. Base annual price: 180 DM; with three extras: 252 DM. Flow base annual price: 60 DM. Monthly charging remains subject to the existing billing activation; no new charge is triggered by publishing this package. + +Transfers have no commercial amount cap for any package. Available funds, mandates, user payment-secret rules, and signed 64-bit ledger capacity remain enforced. Unlimited instant use is represented explicitly, never with a large finite quota. Existing accepted packages are not upgraded automatically. + +Pro scales personal borrowing ceilings by 3: Personal Loan 75,000 DM; One-Month Advance 7,500 DM; Personal Refinancing 300,000 DM. Launch grants are unchanged, revolving credit remains unavailable, rates/terms/collateral and review rules remain unchanged. Eligibility is checked from the actual borrowing account package during simulation and again within application submission. diff --git a/website/node/postbank-catalogue.mjs b/website/node/postbank-catalogue.mjs index d0a0cc00..f498e94e 100644 --- a/website/node/postbank-catalogue.mjs +++ b/website/node/postbank-catalogue.mjs @@ -3,6 +3,7 @@ export const BANK_VERSION='postbank-foundation-2026-11-13'; export const PACKAGES=Object.freeze([ {key:'pb_start',name:'Start',kinds:['person'],monthly:0,code:'108',extra:0,extraFee:0,instant:0}, {key:'pb_flow',name:'Flow',kinds:['person'],monthly:500,code:'102',extra:1,extraFee:300,instant:5,savings:true}, + {key:'pb_pro',name:'Pro',kinds:['person'],monthly:1500,code:'102',extra:3,extraFee:200,instant:null,unlimitedInstant:true,savings:true}, {key:'pb_connect',name:'Connect',kinds:['clan','company'],monthly:1000,code:'105',extra:2,extraFee:300,instant:15}, {key:'pb_scale',name:'Scale',kinds:['clan','company'],monthly:2500,code:'105',extra:9,extraFee:200,instant:40}, {key:'pb_civic',name:'Civic',kinds:['house','office'],monthly:0,code:'107',extra:0,extraFee:0,instant:10}, @@ -25,3 +26,5 @@ export function minorAmount(value){if(typeof value!=='string'||! /^(?:0|[1-9]\d{ export const money=n=>{const a=BigInt(n),v=a<0n?-a:a;return(a<0n?'-':'')+(v/100n)+'.'+String(v%100n).padStart(2,'0');}; export const availablePackages=kind=>PACKAGES.filter(p=>p.kinds.includes(kind)); export const canInvest=()=>false; +// No commercial transfer ceiling; retain the signed 64-bit ledger boundary. +export function transferAmount(value){if(typeof value!=='string'||!/^(?:0|[1-9]\d{0,16})(?:\.\d{1,2})?$/.test(value))throw Error('Use a positive amount with at most two decimals.');const [whole,fraction='']=value.split('.'),amount=BigInt(whole)*100n+BigInt(fraction.padEnd(2,'0'));if(amount<=0n||amount>9223372036854775807n)throw Error('The amount cannot be represented safely by the bank ledger.');return amount;} diff --git a/website/node/postbank-credit-model.mjs b/website/node/postbank-credit-model.mjs index 53584c96..7f84d45c 100644 --- a/website/node/postbank-credit-model.mjs +++ b/website/node/postbank-credit-model.mjs @@ -15,8 +15,9 @@ export const CREDIT_PRODUCTS=Object.freeze([ {key:'civic_refinance',name:'Civic Refinancing',group:'refinancing',kinds:['house','office'],min:'0.01',max:'500000.00',annualBps:550,terms:[3,6,12]} ].map(Object.freeze)); export function creditProduct(key){const p=CREDIT_PRODUCTS.find(p=>p.key===key);if(!p)throw new BankError('Choose a credit product.');return p;} -export function creditQuote({productKey,amount,months,monthly},{annualBps=null}={}){ - const product=creditProduct(productKey),rateBps=annualBps??product.annualBps;if(!Number.isInteger(rateBps)||rateBps<0||rateBps>10000)throw new BankError('Invalid credit rate.');let principal;try{principal=minorAmount(product.amount||amount);}catch(e){throw new BankError(e.message);} +export function creditProductsForPackage(packageKey){return CREDIT_PRODUCTS.map(p=>packageKey==='pb_pro'&&p.kinds.includes('person')&&!p.automatic&&!p.revolving?{...p,max:money(minorAmount(p.max)*3n),packageBenefit:'Pro · 3× borrowing limit'}:p);} +export function creditQuote({productKey,amount,months,monthly},{annualBps=null,packageKey=null}={}){ + const product=creditProductsForPackage(packageKey).find(p=>p.key===productKey)||creditProduct(productKey),rateBps=annualBps??product.annualBps;if(!Number.isInteger(rateBps)||rateBps<0||rateBps>10000)throw new BankError('Invalid credit rate.');let principal;try{principal=minorAmount(product.amount||amount);}catch(e){throw new BankError(e.message);} if(principalminorAmount(product.max))throw new BankError('Choose an amount within this product’s limits.'); let n=Number(months),payment; if(product.group==='grants'){let requested;try{requested=minorAmount(monthly);}catch{throw new BankError('Choose your monthly repayment.');}n=Number((principal+requested-1n)/requested);if(n<1||n>product.maxMonths)throw new BankError('Choose a monthly repayment that clears the grant within 12 months.');payment=requested;} diff --git a/website/node/postbank-credit.mjs b/website/node/postbank-credit.mjs index e85967d3..e12eaa75 100644 --- a/website/node/postbank-credit.mjs +++ b/website/node/postbank-credit.mjs @@ -3,14 +3,14 @@ import {BankError} from './postbank-service.mjs'; import {currentPayoff} from './postbank-credit-ledger.mjs'; import {refinanceConcession} from './postbank-credit-concessions.mjs'; import {money,minorAmount} from './postbank-catalogue.mjs'; -import {CREDIT_PRODUCTS,CREDIT_VERSION,creditProduct,creditQuote,creditScore} from './postbank-credit-model.mjs'; +import {CREDIT_PRODUCTS,CREDIT_VERSION,creditProduct,creditProductsForPackage,creditQuote,creditScore} from './postbank-credit-model.mjs'; const uuid=s=>typeof s==='string'&&/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(s); -const accountSQL='SELECT a.*,e.id entity_id,e.kind,e.external_key,e.display_name entity_name,e.active entity_active,e.created_at entity_created,p.state package_state FROM pb_accounts a JOIN pb_clients c ON c.client_number=a.client_number JOIN pb_entities e ON e.id=c.entity_id JOIN pb_packages p ON p.id=a.package_id'; +const accountSQL='SELECT a.*,e.id entity_id,e.kind,e.external_key,e.display_name entity_name,e.active entity_active,e.created_at entity_created,p.state package_state,p.package_key FROM pb_accounts a JOIN pb_clients c ON c.client_number=a.client_number JOIN pb_entities e ON e.id=c.entity_id JOIN pb_packages p ON p.id=a.package_id'; const eligible=a=>a&&Number(a.entity_active)===1&&a.state==='active'&&a.package_state==='active'&&!a.system_key&&['102','105','107','108'].includes(a.type_code)&&['person','clan','company','house','office'].includes(a.kind); export class PostbankCredit{ constructor(db,authority,{clock=Date.now,central=null}={}){this.db=db;this.authority=authority;this.clock=clock;this.central=central;} async account(user,id,store=this.db){if(typeof id!=='string'||!/^\d{1,12}$/.test(id))throw new BankError('Choose a borrowing account.');const a=await store.first(accountSQL+' WHERE a.id=?',[id]),context=await this.authority(user,{bank:store});if(!eligible(a)||!context.entities.some(e=>e.id===a.entity_id&&e.canActivate))throw new BankError('You cannot apply for credit for this account.',403);return a;} - async overview(user){const c=await this.authority(user),ids=c.entities.filter(e=>e.canActivate).map(e=>e.id);if(!ids.length)return {accounts:[],loans:[],products:CREDIT_PRODUCTS,termsVersion:CREDIT_VERSION};const rows=await this.db.query(accountSQL+' WHERE e.id IN ('+ids.map(()=>'?').join(',')+') ORDER BY a.id',ids),clients=[...new Set(rows.map(a=>a.client_number))];const loans=clients.length?await this.db.query('SELECT * FROM pb_credit_loans WHERE client_number IN ('+clients.map(()=>'?').join(',')+') ORDER BY created_at DESC LIMIT 100',clients):[];return {accounts:rows.filter(eligible).map(a=>({id:String(a.id),name:a.display_name,holder:a.entity_name,number:a.account_number,kind:a.kind,canApply:c.entities.some(e=>e.id===a.entity_id&&e.canActivate)})),loans:loans.map(l=>({id:l.id,accountId:String(l.account_id),productKey:l.product_key,state:l.state,principal:money(l.principal_minor),outstanding:money(l.outstanding_minor),monthly:money(l.monthly_minor),annualRate:(l.annual_bps/100).toFixed(2),months:Number(l.months),createdAt:Number(l.created_at),version:Number(l.version),collateral:money(l.collateral_minor),nextDueAt:l.next_due_at?Number(l.next_due_at):null,motivation:l.motivation,decision:l.decision_reason||null})),products:CREDIT_PRODUCTS,termsVersion:CREDIT_VERSION};} + async overview(user){const c=await this.authority(user),ids=c.entities.filter(e=>e.canActivate).map(e=>e.id);if(!ids.length)return {accounts:[],loans:[],products:CREDIT_PRODUCTS,termsVersion:CREDIT_VERSION};const rows=await this.db.query(accountSQL+' WHERE e.id IN ('+ids.map(()=>'?').join(',')+') ORDER BY a.id',ids),clients=[...new Set(rows.map(a=>a.client_number))];const loans=clients.length?await this.db.query('SELECT * FROM pb_credit_loans WHERE client_number IN ('+clients.map(()=>'?').join(',')+') ORDER BY created_at DESC LIMIT 100',clients):[];return {accounts:rows.filter(eligible).map(a=>({id:String(a.id),name:a.display_name,holder:a.entity_name,number:a.account_number,kind:a.kind,packageKey:a.package_key,products:creditProductsForPackage(a.package_key),canApply:c.entities.some(e=>e.id===a.entity_id&&e.canActivate)})),loans:loans.map(l=>({id:l.id,accountId:String(l.account_id),productKey:l.product_key,state:l.state,principal:money(l.principal_minor),outstanding:money(l.outstanding_minor),monthly:money(l.monthly_minor),annualRate:(l.annual_bps/100).toFixed(2),months:Number(l.months),createdAt:Number(l.created_at),version:Number(l.version),collateral:money(l.collateral_minor),nextDueAt:l.next_due_at?Number(l.next_due_at):null,motivation:l.motivation,decision:l.decision_reason||null})),products:CREDIT_PRODUCTS,termsVersion:CREDIT_VERSION};} async staff(user){const rights=await this.authority(user);if(!rights.readAdmin)throw new BankError('Bank administration view permission is required.',403);const rows=await this.db.query('SELECT l.*,e.display_name entity_name FROM pb_credit_loans l JOIN pb_entities e ON e.id=l.entity_id ORDER BY l.created_at DESC LIMIT 100');return {canManage:!!rights.manageAdmin,applications:rows.map(l=>({id:l.id,entity:l.entity_name,productKey:l.product_key,state:l.state,principal:money(l.principal_minor),monthly:money(l.monthly_minor),annualRate:(l.annual_bps/100).toFixed(2),months:Number(l.months),collateral:money(l.collateral_minor),createdAt:Number(l.created_at),version:Number(l.version),outstanding:money(l.outstanding_minor),createdBy:l.created_by,canReview:l.created_by!==user.id&&!rights.entities.some(e=>e.id===l.entity_id&&e.canActivate),motivation:l.motivation,score:JSON.parse(l.score_json),quote:JSON.parse(l.quote_json)})),processing:'not_active'};} async details(user,loanId,staff=false){ if(!uuid(loanId))throw new BankError('Choose a valid credit contract.');const loan=await this.db.first('SELECT * FROM pb_credit_loans WHERE id=?',[loanId]);if(!loan)throw new BankError('Credit contract not found.',404);if(staff){if(!(await this.authority(user)).readAdmin)throw new BankError('Credit-management access denied.',403);}else if(!(await this.authority(user)).entities.some(e=>e.id===loan.entity_id&&e.canActivate))throw new BankError('Credit-contract access denied.',403); @@ -36,7 +36,7 @@ export class PostbankCredit{ for(const l of loans){const payoff=await currentPayoff(store,l,this.clock());refinanced.push({id:l.id,payoffMinor:String(payoff.total),collateralMinor:String(l.collateral_minor),createdAt:Number(l.created_at)});} const principal=refinanced.reduce((n,l)=>n+BigInt(l.payoffMinor),0n);request.amount=money(principal);concession=await refinanceConcession(this.central,store,a,user,principal,this.clock(),loans); } - const quote=creditQuote(request,{annualBps:concession?.annualBps});if(concession)quote.concession=concession;const collateral=product.group==='grants'?0n:(minorAmount(quote.amount)+3n)/4n; + const quote=creditQuote(request,{annualBps:concession?.annualBps,packageKey:a.package_key});if(concession)quote.concession=concession;const collateral=product.group==='grants'?0n:(minorAmount(quote.amount)+3n)/4n; return {quote,refinanced,collateral:money(collateral),score:await this.score(a,store,minorAmount(quote.monthly),refinanced.map(l=>l.id)),disbursement:'not_active',notice:product.group==='refinancing'?'Refinancing replaces all interest-bearing contracts for this same client. Grants remain separate; there is no additional cash payout.':'Simulation only. No application, collateral movement or payment has been made.'}; } async apply(user,input,{revalidate=async()=>user}={}){ diff --git a/website/node/postbank-financial-policy.mjs b/website/node/postbank-financial-policy.mjs index 0947f07b..cf984422 100644 --- a/website/node/postbank-financial-policy.mjs +++ b/website/node/postbank-financial-policy.mjs @@ -18,11 +18,14 @@ export function validateFinancialPolicy(key,value){ } export async function readFinancialPolicy(db,key){ const fallback=defaultFinancialPolicy(key),row=await db.first('SELECT policy_json,version,updated_at FROM pb_financial_policies WHERE policy_key=?',[key]); - return {key,value:row?validateFinancialPolicy(key,JSON.parse(row.policy_json)):fallback,version:Number(row?.version||0),updatedAt:Number(row?.updated_at||0)}; + const saved=row?JSON.parse(row.policy_json):null; + // Extend an existing six-package policy without overwriting its agreed prices. + if(key==='bank_rates'&&saved?.packages&&!Object.hasOwn(saved.packages,'pb_pro')&&Object.keys(saved.packages).length===PACKAGES.length-1&&PACKAGES.filter(p=>p.key!=='pb_pro').every(p=>Object.hasOwn(saved.packages,p.key)))saved.packages.pb_pro=structuredClone(fallback.packages.pb_pro); + return {key,value:row?validateFinancialPolicy(key,saved):fallback,version:Number(row?.version||0),updatedAt:Number(row?.updated_at||0)}; } export async function makePublicRatesSnapshot(tx,{id=randomUUID(),now=Date.now()}={}){ const bank=await readFinancialPolicy(tx,'bank_rates'),tax=await readFinancialPolicy(tx,'taxes'),payroll=await readFinancialPolicy(tx,'payroll_tax'); - return {version:id,publishedAt:now,policyVersions:{bank:bank.version,taxes:tax.version,payrollTax:payroll.version},packages:PACKAGES.map(p=>({key:p.key,name:p.name,...bank.value.packages[p.key]})),credit:CREDIT_PRODUCTS.map(p=>({key:p.key,name:p.name,annualBps:bank.value.creditAnnualBps[p.key],availability:p.automatic?'Automatic launch grant':p.revolving?'Planned credit line':'Subject to credit review'})),taxes:tax.value,payrollTax:payroll.value,serviceNotices:[bank.value.billingEnabled?'Monthly package charges are processed automatically.':'Monthly package billing is not enabled.', 'Standard transfers settle every four hours in Europe/Brussels. Instant transfers post immediately.', 'Balance Guard is a configured option; protection and billing remain inactive until that service is enabled.', 'Service compensation posts immediately. Statements are free for every package.']}; + return {version:id,publishedAt:now,policyVersions:{bank:bank.version,taxes:tax.version,payrollTax:payroll.version},packages:PACKAGES.map(p=>({key:p.key,name:p.name,instant:p.instant,unlimitedInstant:p.unlimitedInstant===true,transferAmountCap:null,...bank.value.packages[p.key]})),credit:CREDIT_PRODUCTS.map(p=>({key:p.key,name:p.name,annualBps:bank.value.creditAnnualBps[p.key],availability:p.automatic?'Automatic launch grant':p.revolving?'Planned credit line':'Subject to credit review'})),taxes:tax.value,payrollTax:payroll.value,serviceNotices:[bank.value.billingEnabled?'Monthly package charges are processed automatically.':'Monthly package billing is not enabled.', 'Standard transfers settle every four hours in Europe/Brussels. Instant transfers post immediately.', 'Pro includes unlimited instant payments at no per-transfer fee. Transfers have no package amount cap; available funds and payment security apply.', 'Pro personal borrowing ceilings: Personal Loan 75,000 DM; One-Month Advance 7,500 DM; Personal Refinancing 300,000 DM. Credit review and 25% collateral still apply. Launch grants are unchanged.', 'Balance Guard is a configured option; protection and billing remain inactive until that service is enabled.', 'Service compensation posts immediately. Statements are free for every package.']}; } export async function queueRatesPublication(tx,actorId,now=Date.now()){ const previous=await tx.first('SELECT created_at FROM pb_rate_publications ORDER BY created_at DESC LIMIT 1 FOR UPDATE');now=Math.max(now,Number(previous?.created_at||0)+1); diff --git a/website/node/postbank-payments.mjs b/website/node/postbank-payments.mjs index 2f1a22fe..2efbb98c 100644 --- a/website/node/postbank-payments.mjs +++ b/website/node/postbank-payments.mjs @@ -10,7 +10,7 @@ import {reconcilePostbankClans} from './postbank-registry.mjs'; import {PostbankStatementArchive,statementSettings} from './postbank-statement-archive.mjs'; import {createHash,randomUUID} from 'node:crypto'; import {BankError} from './postbank-service.mjs'; -import {PACKAGES,minorAmount,money,validBankNumber} from './postbank-catalogue.mjs'; +import {PACKAGES,transferAmount,money,validBankNumber} from './postbank-catalogue.mjs'; import {createPostbankAuthority} from './postbank-authority.mjs'; const uuid=s=>typeof s==='string'&&/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(s); const accountSQL='SELECT a.*,c.entity_id,e.kind,e.external_key,e.active AS entity_active,e.display_name AS holder,p.package_key,p.state AS package_state FROM pb_accounts a JOIN pb_clients c ON c.client_number=a.client_number JOIN pb_entities e ON e.id=c.entity_id JOIN pb_packages p ON p.id=a.package_id'; @@ -22,7 +22,7 @@ export class PostbankPayments{ async accounts(user){ const context=await this.authority(user),entities=context.entities.filter(e=>e.canView);if(!entities.length)return []; const rows=await this.db.query(accountSQL+' WHERE c.entity_id IN ('+entities.map(()=>'?').join(',')+') ORDER BY a.id',entities.map(e=>e.id)); - return rows.filter(a=>canViewAccount(context,a.entity_id,a.id)).map(a=>({id:String(a.id),number:a.account_number,name:a.display_name,holder:a.holder,entityId:a.entity_id,kind:a.kind,isPersonalOwner:a.kind==='person'&&a.external_key===user.id,state:a.state,type:a.type_code,canReceive:payable(a),available:money(BigInt(a.balance_minor)-BigInt(a.reserved_minor)),canDebit:payable(a)&&canDebitAccount(context,a.entity_id,a.id),instantQuota:PACKAGES.find(p=>p.key===a.package_key)?.instant||0})); + return rows.filter(a=>canViewAccount(context,a.entity_id,a.id)).map(a=>({id:String(a.id),number:a.account_number,name:a.display_name,holder:a.holder,entityId:a.entity_id,kind:a.kind,isPersonalOwner:a.kind==='person'&&a.external_key===user.id,state:a.state,type:a.type_code,canReceive:payable(a),available:money(BigInt(a.balance_minor)-BigInt(a.reserved_minor)),canDebit:payable(a)&&canDebitAccount(context,a.entity_id,a.id),unlimitedInstant:PACKAGES.find(p=>p.key===a.package_key)?.unlimitedInstant===true,instantQuota:PACKAGES.find(p=>p.key===a.package_key)?.instant||0})); } async recipients(user,query){ if(typeof query!=='string'||query.trim().length<3||query.trim().length>80)throw new BankError('Enter at least three characters of a name, or a full account number.'); @@ -40,7 +40,7 @@ export class PostbankPayments{ async transfer(user,input,{revalidate=async()=>user}={}){ const allowed=['requestId','sourceAccount','targetNumber','amount','reference','mode','confirmed','paymentSecret']; if(!input||Object.keys(input).some(k=>!allowed.includes(k))||input.paymentSecret!==undefined&&(typeof input.paymentSecret!=='string'||input.paymentSecret.length>256)||!uuid(input.requestId)||typeof input.sourceAccount!=='string'||!/^\d{1,12}$/.test(input.sourceAccount)||!['standard','instant'].includes(input.mode)||typeof input.reference!=='string'||!input.reference.trim()||input.reference.trim().length>140||/[\u0000-\u001f]/.test(input.reference)||typeof input.confirmed!=='boolean')throw new BankError('Complete the transfer amount, reference and beneficiary details.'); - let amount;try{amount=minorAmount(input.amount);}catch(e){throw new BankError(e.message);} + let amount;try{amount=transferAmount(input.amount);}catch(e){throw new BankError(e.message);} const targetNumber=typeof input.targetNumber==='string'?input.targetNumber.replace(/\s/g,'').toUpperCase():'';if(!validBankNumber(targetNumber))throw new BankError('Select or verify a valid beneficiary account.'); const context=await this.authority(user),source=await this.db.first(accountSQL+' WHERE a.id=?',[input.sourceAccount]),target=await this.db.first(accountSQL+' WHERE a.account_number=?',[targetNumber]); if(!source||!canDebitAccount(context,source.entity_id,source.id))throw new BankError('You cannot debit this account.',403); @@ -63,11 +63,11 @@ export class PostbankPayments{ const now=this.clock(); if(input.mode==='instant'){ if(this.security)await this.security.assertCurrent(tx,fresh,amount,securityProof); - const quota=PACKAGES.find(p=>p.key===debit.package_key)?.instant||0;if(!quota)throw new BankError('This package does not include instant payments. Choose standard processing.'); + const plan=PACKAGES.find(p=>p.key===debit.package_key),unlimited=plan?.unlimitedInstant===true,quota=plan?.instant||0;if(!unlimited&&!quota)throw new BankError('This package does not include instant payments. Choose standard processing.'); const parts=new Intl.DateTimeFormat('en-CA',{timeZone:'Europe/Brussels',year:'numeric',month:'2-digit'}).formatToParts(new Date(now));const month=parts.find(p=>p.type==='year').value+'-'+parts.find(p=>p.type==='month').value; await tx.query('INSERT INTO pb_instant_usage(package_id,month,used) VALUES(?,?,0) ON DUPLICATE KEY UPDATE package_id=VALUES(package_id)',[debit.package_id,month]); const usage=await tx.first('SELECT used FROM pb_instant_usage WHERE package_id=? AND month=? FOR UPDATE',[debit.package_id,month]); - if(Number(usage.used)>=quota)throw new BankError('Your package instant allowance is used up for this month. Choose standard processing.',409); + if(!unlimited&&Number(usage.used)>=quota)throw new BankError('Your package instant allowance is used up for this month. Choose standard processing.',409); await tx.query('UPDATE pb_instant_usage SET used=used+1 WHERE package_id=? AND month=?',[debit.package_id,month]); } await tx.query('INSERT INTO pb_orders(id,actor_id,source_id,target_id,fingerprint,amount_minor,memo,mode,state,created_at) VALUES(?,?,?,?,?,?,?,?,?,?)',[input.requestId,user.id,debit.id,credit.id,fingerprint,amount.toString(),reference,input.mode,'queued',now]); diff --git a/website/scripts/bank-rates-page.mjs b/website/scripts/bank-rates-page.mjs index a2c9215a..e97ac877 100644 --- a/website/scripts/bank-rates-page.mjs +++ b/website/scripts/bank-rates-page.mjs @@ -4,7 +4,7 @@ import {CREDIT_PRODUCTS,CREDIT_VERSION} from '../node/postbank-credit-model.mjs' import {createHash} from 'node:crypto'; export function bankRatesPage(){ const version=createHash('sha256').update(JSON.stringify([PACKAGES,CREDIT_PRODUCTS])).digest('hex').slice(0,10); -const packages=PACKAGES.map(p=>`${p.name}${p.kinds.join(' / ')}${(p.monthly/100).toFixed(2)} DM${p.extra}${p.extra?(p.extraFee/100).toFixed(2)+' DM':'—'}${p.instant}`).join(''); +const packages=PACKAGES.map(p=>`${p.name}${p.kinds.join(' / ')}${(p.monthly/100).toFixed(2)} DM${p.extra}${p.extra?(p.extraFee/100).toFixed(2)+' DM':'—'}${p.unlimitedInstant?'Unlimited':p.instant}`).join(''); const credit=CREDIT_PRODUCTS.filter(p=>!p.revolving).map(p=>`${p.name}${(p.annualBps/100).toFixed(2)}%${p.min}–${p.max} DM${p.terms?p.terms.join(', '):'Up to '+p.maxMonths} months`).join(''); -return `Rates & Charges | Imperial Postbank${SHARED_HEADER}
Imperial Postbank

YOUR MONEY. CLEAR TERMS.

Rates & Charges

A clear guide to your banking costs.

PUBLIC TARIFF GUIDE · ${version}
01 / EVERYDAY BANKING

Accounts & packages

One current account is included in each package.

${packages}
PackageClientMonthly priceExtra current accounts¹Each / month¹Instant quota / month

¹ Published additional-account limits and prices, subject to feature availability. Flow includes a savings account. Start has no instant payments. Instant quotas are server usage limits.

02 / BORROWING

Credit rates

Annual rates for new applications. Your accepted contract and repayment schedule govern your loan.

${credit}
ProductAnnual ratePrincipal rangeAvailable terms

Launch grants are repayable at 0% interest. Ordinary loans require review and 25% blocked DM collateral. Eligibility, available funding and refinancing conditions apply. Existing fixed-rate contracts retain their agreed rate. Revolving credit is not available.

03 / TRANSPARENCY

Services & taxes

Monthly statements

Free

Automatically archived PDF statements after month-end.

Balance Guard

1.00 DM / month

Published optional price per eligible account. Preference saving is available; protection and charging are not active yet.

Tax policy

Not yet published

VAT and account-tax rates await central configuration. No unconfirmed rate is presented as active.

Your tariff guide

Generated from the bank catalogues on each build. Version ${version}. Package terms: ${BANK_VERSION}. Credit terms: ${CREDIT_VERSION}.

Catalogue references identify source terms, not a new effective date. Administrative rate editing and automatic downloadable PDF publication are planned. You can print or save this guide as PDF now.

No private account or transaction data is published here.

`; +return `Rates & Charges | Imperial Postbank${SHARED_HEADER}
Imperial Postbank

YOUR MONEY. CLEAR TERMS.

Rates & Charges

A clear guide to your banking costs.

PUBLIC TARIFF GUIDE · ${version}
01 / EVERYDAY BANKING

Accounts & packages

One current account is included in each package.

${packages}
PackageClientMonthly priceExtra current accounts¹Each / month¹Instant quota / month

¹ Published additional-account limits and prices, subject to feature availability. Flow and Pro include a savings account. Pro includes unlimited instant payments with no per-transfer fee. Transfers have no package amount cap; available funds and payment security apply. Start has no instant payments. Instant quotas are server usage limits.

02 / BORROWING

Credit rates

Annual rates for new applications. Your accepted contract and repayment schedule govern your loan.

${credit}
ProductAnnual ratePrincipal rangeAvailable terms

Launch grants are repayable at 0% interest. Ordinary loans require review and 25% blocked DM collateral. Eligibility, available funding and refinancing conditions apply. Existing fixed-rate contracts retain their agreed rate. Revolving credit is not available.

03 / TRANSPARENCY

Services & taxes

Monthly statements

Free

Automatically archived PDF statements after month-end.

Balance Guard

1.00 DM / month

Published optional price per eligible account. Preference saving is available; protection and charging are not active yet.

Tax policy

Not yet published

VAT and account-tax rates await central configuration. No unconfirmed rate is presented as active.

Your tariff guide

Generated from the bank catalogues on each build. Version ${version}. Package terms: ${BANK_VERSION}. Credit terms: ${CREDIT_VERSION}.

Catalogue references identify source terms, not a new effective date. Administrative rate editing and automatic downloadable PDF publication are planned. You can print or save this guide as PDF now.

No private account or transaction data is published here.

`; } diff --git a/website/scripts/publish-postbank-pro.mjs b/website/scripts/publish-postbank-pro.mjs new file mode 100644 index 00000000..1706572f --- /dev/null +++ b/website/scripts/publish-postbank-pro.mjs @@ -0,0 +1,22 @@ +import {openDatabase} from '../node/mysql.mjs'; +import {openPostbankDatabase} from '../node/postbank-db.mjs'; +import {canRunScheduler} from '../node/scheduler-authority.mjs'; +import {queueRatesPublication} from '../node/postbank-financial-policy.mjs'; +import {PostbankRatePublications} from '../node/postbank-rate-publications.mjs'; +const central=await openDatabase(process.env),bank=await openPostbankDatabase(process.env); +try{ + const actorId=process.argv.find(a=>a.startsWith('--actor='))?.slice(8);if(!bank||!await canRunScheduler(central,{id:actorId}))throw Error('Current deployment or Big Four control required.'); + if(!process.argv.includes('--apply'))console.log(JSON.stringify({plan:true,package:'Pro',monthlyMinor:1500,payrollRun:false})); + else{ + const id=await bank.transaction(async tx=>{ + await tx.query("INSERT INTO pb_financial_policies(policy_key,policy_json,version,updated_by,updated_at) VALUES('publication_guard','{}',0,?,?) ON DUPLICATE KEY UPDATE policy_key=VALUES(policy_key)",[actorId,Date.now()]); + await tx.first("SELECT policy_key FROM pb_financial_policies WHERE policy_key='publication_guard' FOR UPDATE"); + const latest=await tx.first('SELECT id,data_json FROM pb_rate_publications ORDER BY created_at DESC,id DESC LIMIT 1 FOR UPDATE'); + if(latest&&JSON.parse(latest.data_json).packages.some(p=>p.key==='pb_pro'&&p.unlimitedInstant===true))return latest.id; + return queueRatesPublication(tx,actorId); + }); + const publisher=new PostbankRatePublications(bank,{python:process.env.POSTBANK_PYTHON,logo:process.env.POSTBANK_STATEMENT_LOGO}); + for(let i=0;i<20;i++){if((await bank.first('SELECT state FROM pb_rate_publications WHERE id=?',[id]))?.state==='ready')break;const result=await publisher.process();if(result.failed||!result.generated)throw Error('Tariff generation not confirmed; inspect the publication worker before retrying.');} + const ready=(await bank.first('SELECT state FROM pb_rate_publications WHERE id=?',[id]))?.state==='ready';if(!ready)throw Error('Pro tariff PDF not ready.');console.log(JSON.stringify({published:true,publication:id,payrollRun:false})); + } +}finally{await bank?.close();await central.close();} diff --git a/website/tests/postbank-credit.test.mjs b/website/tests/postbank-credit.test.mjs index 34dd6f66..dae90b9b 100644 --- a/website/tests/postbank-credit.test.mjs +++ b/website/tests/postbank-credit.test.mjs @@ -11,3 +11,19 @@ test('credit API provides simulations with fresh authority while financial intak test('enabled credit API accepts a real request once while rejecting origins and unauthorized decisions',async()=>{const f=await fixture();try{const api=createPostbankApi(null,f.db,{POSTBANK_CREDIT_ENABLED:'true'}, {authenticate:async()=>f.user,authority:f.authority,resolveUser:async()=>f.user}),body=application(f),request=(path,input,origin='https://cp.dunerealms.com')=>new Request('https://cp.dunerealms.com'+path,{method:'POST',headers:{Origin:origin,'Content-Type':'application/json'},body:JSON.stringify(input)});assert.equal((await api(request('/api/bank/credit/apply',body,'https://evil.invalid'))).status,403);assert.equal((await api(request('/api/bank/credit/apply',body))).status,200);const replay=await api(request('/api/bank/credit/apply',body));assert.equal((await replay.json()).replayed,true);assert.equal((await f.db.first('SELECT COUNT(*) n FROM pb_credit_loans')).n,1);assert.equal((await api(request('/api/bank/admin/credit/decision',{requestId:randomUUID(),loanId:body.requestId,action:'approve',confirmed:true,reason:'Not an authorised manager'}))).status,403);assert.equal((await api(new Request('https://cp.dunerealms.com/api/bank/credit/details?loanId='+body.requestId))).status,200);assert.equal((await f.db.first('SELECT COUNT(*) n FROM pb_orders')).n,0);}finally{f.db.close();}}); test('launch grants require no motivation while ordinary credit still requires one',async()=>{const f=await fixture();try{const grant=application(f);delete grant.motivation;await assert.rejects(f.credit.apply(f.user,{...grant,accepted:false}),e=>e.status===400);assert.equal((await f.credit.apply(f.user,grant)).state,'approved_pending');assert.equal((await f.db.first('SELECT motivation FROM pb_credit_loans')).motivation,'');assert.equal((await f.db.first('SELECT COUNT(*) n FROM pb_credit_grants')).n,1);}finally{f.db.close();}const ordinary=await fixture();try{const body={...application(ordinary),productKey:'personal_loan',amount:'1000.00',months:3};delete body.motivation;await assert.rejects(ordinary.credit.apply(ordinary.user,body),e=>e.status===400&&/motivation/.test(e.message));assert.equal((await ordinary.db.first('SELECT COUNT(*) n FROM pb_credit_loans')).n,0);}finally{ordinary.db.close();}}); + +test('Pro borrowing limits follow the actual account package and are rechecked after downgrade',async()=>{ + const f=await fixture();try{ + const request={accountId:String(f.account.id),productKey:'personal_loan',amount:'75000.00',months:12}; + await assert.rejects(f.credit.simulate(f.user,request),/limits/); + await assert.rejects(f.credit.simulate(f.user,{...request,packageKey:'pb_pro'}),/valid simulation/); + await f.db.query("UPDATE pb_packages SET package_key='pb_pro',monthly_minor=1500"); + const quote=await f.credit.simulate(f.user,request);assert.equal(quote.quote.amount,'75000.00');assert.equal(quote.collateral,'18750.00'); + const overview=await f.credit.overview(f.user),products=overview.accounts.find(a=>a.id===String(f.account.id)).products; + assert.equal(products.find(p=>p.key==='personal_loan').max,'75000.00');assert.equal(products.find(p=>p.key==='personal_overdraft').max,'7500.00');assert.equal(products.find(p=>p.key==='personal_refinance').max,'300000.00');assert.equal(products.find(p=>p.key==='grant_advance').max,'10000.00');assert.equal(products.find(p=>p.key==='personal_card').revolving,true); + await assert.rejects(f.credit.simulate(f.user,{...request,amount:'75000.01'}),/limits/); + await f.db.query("UPDATE pb_packages SET package_key='pb_flow',monthly_minor=500"); + await assert.rejects(f.credit.apply(f.user,{...application(f),...request}),/limits/); + assert.equal((await f.db.first('SELECT COUNT(*) n FROM pb_credit_loans')).n,0); + }finally{f.db.close();} +}); diff --git a/website/tests/postbank-foundation.test.mjs b/website/tests/postbank-foundation.test.mjs index f3a5c65f..c4e71762 100644 --- a/website/tests/postbank-foundation.test.mjs +++ b/website/tests/postbank-foundation.test.mjs @@ -11,7 +11,7 @@ class BankFixture{ close(){this.sqlite.close();} } const input=(key='pb_flow')=>({entityId:entity.id,packageKey:key,termsVersion:BANK_VERSION,accepted:true,requestId:'32345678-1234-4234-8234-123456789abc'}); -test('a bank visit imports no personal account, number or package before acceptance',async()=>{const db=new BankFixture();try{const service=new PostbankService(db,authority),v=await service.overview(user);assert.equal(v.entities[0].state,'not_activated');assert.equal(v.entities[0].clientNumber,null);assert.equal((await db.first('SELECT COUNT(*) n FROM pb_clients')).n,0);assert.equal((await db.first('SELECT COUNT(*) n FROM pb_accounts')).n,0);assert.equal(v.server.state,'not_linked');assert.equal(v.catalogue.length,6);}finally{db.close();}}); +test('a bank visit imports no personal account, number or package before acceptance',async()=>{const db=new BankFixture();try{const service=new PostbankService(db,authority),v=await service.overview(user);assert.equal(v.entities[0].state,'not_activated');assert.equal(v.entities[0].clientNumber,null);assert.equal((await db.first('SELECT COUNT(*) n FROM pb_clients')).n,0);assert.equal((await db.first('SELECT COUNT(*) n FROM pb_accounts')).n,0);assert.equal(v.server.state,'not_linked');assert.equal(v.catalogue.length,7);}finally{db.close();}}); test('accepted activation creates zero-funded client, package and correct numbers exactly once',async()=>{const db=new BankFixture();try{const service=new PostbankService(db,authority);const first=await service.activate(user,input());assert.match(first.clientNumber,/^\d{12}$/);const again=await service.activate(user,input());assert.equal(again.replayed,true);assert.equal(again.clientNumber,first.clientNumber);assert.equal((await db.first('SELECT COUNT(*) n FROM pb_clients')).n,1);const accounts=await db.query('SELECT * FROM pb_accounts ORDER BY id');assert.deepEqual(accounts.map(a=>a.type_code),['102','103']);assert.ok(accounts.every(a=>a.balance_minor===0&&validBankNumber(a.account_number)));await assert.rejects(service.activate(user,input('pb_start')),e=>e.status===409);}finally{db.close();}}); test('repeated concurrent acceptance cannot create two packages or two clients',async()=>{const db=new BankFixture();try{const service=new PostbankService(db,authority);await Promise.all(Array.from({length:5},()=>service.activate(user,input())));assert.equal((await db.first('SELECT COUNT(*) n FROM pb_packages')).n,1);assert.equal((await db.first('SELECT COUNT(*) n FROM pb_clients')).n,1);}finally{db.close();}}); test('account insertion failure and revoked authority roll back all activation records',async()=>{const db=new BankFixture();try{const service=new PostbankService(db,authority);db.sqlite.exec("CREATE TRIGGER fail_account BEFORE INSERT ON pb_accounts BEGIN SELECT RAISE(ABORT,'injected failure'); END;");await assert.rejects(service.activate(user,input()));for(const table of ['pb_clients','pb_packages','pb_accounts','pb_activations'])assert.equal((await db.first('SELECT COUNT(*) n FROM '+table)).n,0);db.sqlite.exec('DROP TRIGGER fail_account');await assert.rejects(service.activate(user,input(),{revalidate:async()=>null}),e=>e.status===409);assert.equal((await db.first('SELECT COUNT(*) n FROM pb_clients')).n,0);}finally{db.close();}}); diff --git a/website/tests/postbank-payments.test.mjs b/website/tests/postbank-payments.test.mjs index 4b53547a..da048df1 100644 --- a/website/tests/postbank-payments.test.mjs +++ b/website/tests/postbank-payments.test.mjs @@ -39,3 +39,32 @@ test('Instant payment security rejects before any funds or quota move, then post assert(!JSON.stringify(await f.db.query('SELECT * FROM pb_orders')).includes(secret)); }finally{f.db.close();} }); + + +test('Pro permits repeated instant payments beyond Flow quota and amounts above one million without duplicate posting',async()=>{ + const f=await setup();try{ + await f.db.query("UPDATE pb_packages SET package_key='pb_pro',monthly_minor=1500"); + await f.db.query('UPDATE pb_accounts SET balance_minor=300000000 WHERE id=?',[f.current(0).id]); + for(let i=0;i<8;i++)await f.service.transfer(f.users[0],f.input({mode:'instant',amount:'1.00'})); + const instruction=f.input({mode:'instant',amount:'1000000.01'}); + assert.equal((await f.service.transfer(f.users[0],instruction)).state,'posted'); + assert.equal((await f.service.transfer(f.users[0],instruction)).replayed,true); + assert.equal((await f.db.first('SELECT used FROM pb_instant_usage')).used,9); + assert.equal((await f.db.first('SELECT COUNT(*) n FROM pb_orders')).n,9); + assert.equal((await f.db.first('SELECT SUM(amount_minor) total FROM pb_entries')).total,0); + const accounts=await f.service.accounts(f.users[0]);assert.equal(accounts.find(a=>a.id===String(f.current(0).id)).unlimitedInstant,true); + await assert.rejects(f.service.transfer(f.users[0],f.input({mode:'instant',amount:'2000000.00'})),/Insufficient available funds/); + }finally{f.db.close();} +}); + +test('transfer amounts retain exact cents and reject ledger overflow and malformed values',async()=>{ + const {transferAmount}=await import('../node/postbank-catalogue.mjs'); + assert.equal(transferAmount('92233720368547758.07'),9223372036854775807n); + assert.equal(transferAmount('1000000.01'),100000001n); + for(const value of ['92233720368547758.08','0','-1','1.001','1e7',1000001,'01.00'])assert.throws(()=>transferAmount(value)); +}); + +test('old tariff policies gain Pro without resetting existing customised prices',async()=>{ + const {defaultBankRates,readFinancialPolicy}=await import('../node/postbank-financial-policy.mjs');const old=defaultBankRates();delete old.packages.pb_pro;old.packages.pb_flow.monthlyMinor=650; + const bank={first:async()=>({policy_json:JSON.stringify(old),version:4,updated_at:123})};const policy=await readFinancialPolicy(bank,'bank_rates');assert.equal(policy.value.packages.pb_flow.monthlyMinor,650);assert.equal(policy.value.packages.pb_pro.monthlyMinor,1500);assert.equal(policy.version,4); +}); diff --git a/website/web/rates-and-charges.html b/website/web/rates-and-charges.html index 371cd788..1bec3ecb 100644 --- a/website/web/rates-and-charges.html +++ b/website/web/rates-and-charges.html @@ -1 +1 @@ -Rates & Charges | Imperial Postbank
Imperial Postbank

YOUR MONEY. CLEAR TERMS.

Rates & Charges

A clear guide to your banking costs.

PUBLIC TARIFF GUIDE · d290bf6cb0
01 / EVERYDAY BANKING

Accounts & packages

One current account is included in each package.

PackageClientMonthly priceExtra current accounts¹Each / month¹Instant quota / month
Startperson0.00 DM0—0
Flowperson5.00 DM13.00 DM5
Connectclan / company10.00 DM23.00 DM15
Scaleclan / company25.00 DM92.00 DM40
Civichouse / office0.00 DM0—10
Publicstaff0.00 DM0—25

¹ Published additional-account limits and prices, subject to feature availability. Flow includes a savings account. Start has no instant payments. Instant quotas are server usage limits.

02 / BORROWING

Credit rates

Annual rates for new applications. Your accepted contract and repayment schedule govern your loan.

ProductAnnual ratePrincipal rangeAvailable terms
Launch Start0.00%2500.00–2500.00 DMUp to 12 months
Launch Build0.00%5000.00–5000.00 DMUp to 12 months
Launch Advance0.00%10000.00–10000.00 DMUp to 12 months
Personal Loan8.39%1000.00–25000.00 DM3, 6, 9, 12 months
One-Month Advance10.39%250.00–2500.00 DM1 months
Business Loan4.50%5000.00–100000.00 DM3, 6, 12, 18, 24 months
Civic Loan3.50%5000.00–100000.00 DM3, 6, 12 months
Personal Refinancing12.00%0.01–100000.00 DM3, 6, 9, 12, 18, 24 months
Business Refinancing6.50%0.01–500000.00 DM3, 6, 12, 18, 24 months
Civic Refinancing5.50%0.01–500000.00 DM3, 6, 12 months

Launch grants are repayable at 0% interest. Ordinary loans require review and 25% blocked DM collateral. Eligibility, available funding and refinancing conditions apply. Existing fixed-rate contracts retain their agreed rate. Revolving credit is not available.

03 / TRANSPARENCY

Services & taxes

Monthly statements

Free

Automatically archived PDF statements after month-end.

Balance Guard

1.00 DM / month

Published optional price per eligible account. Preference saving is available; protection and charging are not active yet.

Tax policy

Not yet published

VAT and account-tax rates await central configuration. No unconfirmed rate is presented as active.

Your tariff guide

Generated from the bank catalogues on each build. Version d290bf6cb0. Package terms: postbank-foundation-2026-11-13. Credit terms: postbank-credit-2026-11-14.

Catalogue references identify source terms, not a new effective date. Administrative rate editing and automatic downloadable PDF publication are planned. You can print or save this guide as PDF now.

No private account or transaction data is published here.

\ No newline at end of file +Rates & Charges | Imperial Postbank
Imperial Postbank

YOUR MONEY. CLEAR TERMS.

Rates & Charges

A clear guide to your banking costs.

PUBLIC TARIFF GUIDE · 9791d06344
01 / EVERYDAY BANKING

Accounts & packages

One current account is included in each package.

PackageClientMonthly priceExtra current accounts¹Each / month¹Instant quota / month
Startperson0.00 DM0—0
Flowperson5.00 DM13.00 DM5
Properson15.00 DM32.00 DMUnlimited
Connectclan / company10.00 DM23.00 DM15
Scaleclan / company25.00 DM92.00 DM40
Civichouse / office0.00 DM0—10
Publicstaff0.00 DM0—25

¹ Published additional-account limits and prices, subject to feature availability. Flow and Pro include a savings account. Pro includes unlimited instant payments with no per-transfer fee. Transfers have no package amount cap; available funds and payment security apply. Start has no instant payments. Instant quotas are server usage limits.

02 / BORROWING

Credit rates

Annual rates for new applications. Your accepted contract and repayment schedule govern your loan.

ProductAnnual ratePrincipal rangeAvailable terms
Launch Start0.00%2500.00–2500.00 DMUp to 12 months
Launch Build0.00%5000.00–5000.00 DMUp to 12 months
Launch Advance0.00%10000.00–10000.00 DMUp to 12 months
Personal Loan8.39%1000.00–25000.00 DM3, 6, 9, 12 months
One-Month Advance10.39%250.00–2500.00 DM1 months
Business Loan4.50%5000.00–100000.00 DM3, 6, 12, 18, 24 months
Civic Loan3.50%5000.00–100000.00 DM3, 6, 12 months
Personal Refinancing12.00%0.01–100000.00 DM3, 6, 9, 12, 18, 24 months
Business Refinancing6.50%0.01–500000.00 DM3, 6, 12, 18, 24 months
Civic Refinancing5.50%0.01–500000.00 DM3, 6, 12 months

Launch grants are repayable at 0% interest. Ordinary loans require review and 25% blocked DM collateral. Eligibility, available funding and refinancing conditions apply. Existing fixed-rate contracts retain their agreed rate. Revolving credit is not available.

03 / TRANSPARENCY

Services & taxes

Monthly statements

Free

Automatically archived PDF statements after month-end.

Balance Guard

1.00 DM / month

Published optional price per eligible account. Preference saving is available; protection and charging are not active yet.

Tax policy

Not yet published

VAT and account-tax rates await central configuration. No unconfirmed rate is presented as active.

Your tariff guide

Generated from the bank catalogues on each build. Version 9791d06344. Package terms: postbank-foundation-2026-11-13. Credit terms: postbank-credit-2026-11-14.

Catalogue references identify source terms, not a new effective date. Administrative rate editing and automatic downloadable PDF publication are planned. You can print or save this guide as PDF now.

No private account or transaction data is published here.

\ No newline at end of file