<div class="notebook"> <div class="nb-cell markdown" name="md4"> ### Altering a report with user facts and formulas </div> <div class="nb-cell markdown" name="md8"> The system allows the user to add or delete facts and formulas to the loaded report, thus "tweaking" it. This is achieved simply by evaluating the report in the context of a small Prolog program which contains the changes, a "delta" that is applied locally to the original report and DTS. We'll now "make" the first PROOF derivation rule to work, by subtracting a couple PROOF facts and redefining the formula, so it no longer has a fallback value: </div> <div class="nb-cell program" name="p1"> % We need these 2 facts to go; _ is a wildcard fact(proof:'Liabilities','I-2020','U-3B1D-4EF9-AD74-5402',_,_) delete. fact(proof:'Liabilities','I-2019','U-3B1D-4EF9-AD74-5402',_,_) delete. % This is a complete, executable XBRL formula in PROLOG, replacing the original; notice the commented out fallback: 'IMPUTE_BS_Impute_01' formula if exists(Assets)and exists(Equity)and Liabilities eq null then Assets-Equity else null variables Liabilities: [output('\'INF\'', null), /*fallback(0), */ concept(proof:'Liabilities')], Equity: [fallback(0), concept(proof:'Equity')], Assets: [fallback(0), concept(proof:'Assets')]. </div> <div class="nb-cell markdown" name="md12"> The next report-checking goal now takes the above rule alterations into account; at the end there will be a text listing of all formulas effectively considered - including the above. That ugly listing (_which you'll kindly scroll over please_) is a good source for copying your favorite formulas into the alterations field above and edit them: </div> <div class="nb-cell query" name="q9"> xbrl:checkReport("http://xbrlsite.azurewebsites.net/2020/master/proof/instance.xml", ["Rule-Derivation-Code-BS-Impute-01-formula.xml", "Rule-Derivation-Code-BS-Impute-02-formula.xml", "Rule-Derivation-Code-BS-Impute-03-formula.xml"]), xbrl:printEffectiveFormulas. </div> <div class="nb-cell markdown" name="md13"> If you survived all the scrolling up required, you finally should have seen some blue facts, at the very beginning of the report. Facts were derived as intended. </div> <div class="nb-cell markdown" name="md14"> *NOTE*: You can also check a report with alterations in the Prolog query field on the right (outside this notebook), and may suffer less with scrolling. You'll just need to create a Prolog editor window with the rule alterations. You can start with all the examples of this notebook together [here](https://pacioli.auditchain.finance/example/AlteringPROOF.pl). </div> <div class="nb-cell markdown" name="md20"> ### Another example of user facts and assertions Let's look at another hypothetical possibility for altering a reports' facts and assertions. Suppose someone would like to see if more cash could be handed over to the company owners...: </div> <div class="nb-cell program" name="p3"> % Instead of the original % fact(proof:'DistributionsToOwners','D-2020','U-3B1D-4EF9-AD74-5402',null,'INF',500,reported). % ...let's imagine we could get away with more money; delete the above and replace it: fact(proof:'DistributionsToOwners','D-2020','U-3B1D-4EF9-AD74-5402','INF',500) delete. fact(proof:'DistributionsToOwners','D-2020','U-3B1D-4EF9-AD74-5402','INF',50000). </div> <div class="nb-cell markdown" name="md7"> Let's see if we got away with it: </div> <div class="nb-cell query" name="q7"> xbrl:checkReport("http://xbrlsite.azurewebsites.net/2020/master/proof/instance.xml"). </div> <div class="nb-cell markdown" name="md21"> Too bad, lots of red facts, assertion violations! As they well should. So let's push the envelope and make the system ignore it: </div> <div class="nb-cell program" name="p4"> % Instead of the original % fact(proof:'DistributionsToOwners','D-2020','U-3B1D-4EF9-AD74-5402',null,'INF',500,reported). % ...let's imagine we could get away with more money; delete the above and replace it: fact(proof:'DistributionsToOwners','D-2020','U-3B1D-4EF9-AD74-5402','INF',500) delete. fact(proof:'DistributionsToOwners','D-2020','U-3B1D-4EF9-AD74-5402','INF',50000). % The above breaks some assertions, so let's delete them to get away with our huge DistributionsToOwners: 'CONSISTENCY_SFAC6_ElementsOfFinancialStatement' valueAssertion delete. 'RollForward_SHE01' valueAssertion delete. </div> <div class="nb-cell query" name="q8"> xbrl:checkReport("http://xbrlsite.azurewebsites.net/2020/master/proof/instance.xml"). </div> <div class="nb-cell markdown" name="md22"> VoilĂ , no more violations - but this happens only in your own local altered report, of course! </div> </div>