JSFiddle - React, Tailwind, and code Playground

JavaScript

function d(n,d) {
    t=parseInt;
    p=function(v){return(s+v).substring(v.length)};
    a=function(v,c){return v.replace(/\d/g,c)};
    w='\n';
    q=b=o=c=e='';
    s=a(d,' ')+' ';
    f=true;
    i=-1;
    z='0';
    
    while(++i<n.length){
        s += ' ';
        if (t(c += n[i]) >= t(d)) {
            q += r = Math.floor(t(c) / t(d));
            o += (!f?p(c)+w:e)+p(''+r*t(d)) + w + p(a(c,'-')) + w;
            
            c = t(c) % t(d);
            f = false
        }else if(!f){q+=z}
        c = (c==0)?e:e+c;
    }
    
    return p(!q?z:q)+w+p(a(n,'-'))+w+d+'|'+n+w+o+p(c)
}

document.writeln("<pre>");
document.writeln(d("1234","56"));
document.writeln();
document.writeln(d("1002012","12"));
document.writeln();
document.writeln(d("0","35"));
document.writeln();
document.writeln(d("123000123000123","123"));
document.writeln("</pre>");