NathanaelA / fluentreports

:page_facing_up: Fluent Reports - Data Driven Reporting Engine for Node.js and Browsers :page_facing_up:
https://fluentreports.com
MIT License
376 stars 84 forks source link

[FRG] Fix creating sub-reports through the GUI #197

Closed beauwest closed 2 years ago

beauwest commented 4 years ago

I have a report that I'm trying to convert to FRG.

Screen Shot 2020-07-29 at 3 58 48 PM copy

What I'd like to do, is have 2 separate datasets that I pass into FRG. Each would have it's own header, detail, & footer.

I can write the report in such a way that only the bottom section is actually report detail, but it greatly simplifies writing the report if I can pass the first section in as data as well. That allows me to use the report totaling system, only add a single detail band instead of 12, etc.

What are your thoughts on this, and in your opinion, is wanting those both to be data-driven problematic?

NathanaelA commented 4 years ago

Hmm, that is an interesting issue on how to do this easily in the FRG, it is trivial in FR.
I think you should be able to pass it in like this: Data = {name: "Juror Expenses", Vouchers: [... all voucher data... ], Appropriations: [ ..All Appropriations data..]} This way FRG treats it as

= Primary Report
-> SubReport (Vouchers, Red)
-> SubReport (Appropriations, Green)

So that way each sub report can have totals; headers and footers, but because you create a wrapping parent report it handles the whole page header and printing the Budget Item

beauwest commented 4 years ago

Conceptually, I really like that idea, but I'm having trouble making it work. I keep getting an error

REPORTAPI: data is empty, try adding a .data([{field: 'value',...}]) to the report.

I tried trimming it all the way down to bare bones, but I still have that issue.

const structure = {"name":"appropriation-ledger.pdf","type":"report","fonts":[],"version":1,"fontSize":10,"autoPrint":false,"paperSize":"letter","variables":{},"subReports":[{"data":"vouchers","groupBy":[{"type":"group","detail":{"children":[{"type":"print","field":"name","settings":{"absoluteX":0,"absoluteY":0}}]},"groupOn":"quarter"}]},{"data":"appropriations","type":"report","detail":{"children":[{"type":"print","field":"date","settings":{"absoluteX":0,"absoluteY":0}}]}}],"paperOrientation":"portrait"};
const data = [{"date":"08/13/2020 8:52 AM","countyname":"Washington","fiscalyear":"2019-2020","accountname":"Court Fund","budgetitemname":"Juror Expenses","budgetitemcode":"211010","vouchers":[{"quarter":3,"name":"July","vouchers":1,"refunds":null,"balance":-1},{"quarter":3,"name":"August","vouchers":null,"refunds":null,"balance":-1},{"quarter":3,"name":"September","vouchers":11857.77,"refunds":null,"balance":-11858.77},{"quarter":4,"name":"October","vouchers":null,"refunds":null,"balance":-11858.77},{"quarter":4,"name":"November","vouchers":4874.6,"refunds":null,"balance":-16733.370000000003},{"quarter":4,"name":"December","vouchers":null,"refunds":null,"balance":-16733.370000000003},{"quarter":1,"name":"January","vouchers":null,"refunds":null,"balance":-16733.370000000003},{"quarter":1,"name":"February","vouchers":8925.81,"refunds":null,"balance":-25659.18},{"quarter":1,"name":"March","vouchers":null,"refunds":null,"balance":-25659.18},{"quarter":2,"name":"April","vouchers":null,"refunds":null,"balance":-25659.18},{"quarter":2,"name":"May","vouchers":null,"refunds":null,"balance":-25659.18},{"quarter":2,"name":"June","vouchers":null,"refunds":null,"balance":-25659.18}],"appropriations":[]}];
beauwest commented 4 years ago

Just for info, I tried to re-create the demo19 report purely through the GUI, and I was unable to. If I add a group by "week" on the emphours data, I get no option to create a header/footer/detail for that group. Only for the emphours subreport.

beauwest commented 4 years ago

Sub-reports is coming up again on another report. I took another simple stab at recreating the demo19 report in this repo, here's my structure that it generated.

const structure = {"name":"demo19.pdf","type":"report","fonts":[],"footer":{"children":[]},"header":{"children":[]},"groupBy":[{"type":"group","footer":{"children":[]},"header":{"children":[{"type":"print","field":"name","settings":{"absoluteX":0,"absoluteY":0}}]},"groupOn":"name"}],"version":1,"fontSize":0,"autoPrint":false,"paperSize":"letter","variables":{},"subReports":[{"data":"emphours","type":"report","calcs":{"sum":["hours"]},"detail":{"children":[{"type":"band","fields":[{"type":"print","field":"name","width":100,"dataUUID":10939},{"type":"print","field":"day","width":100,"dataUUID":10940},{"type":"print","field":"hours","width":100,"dataUUID":10940}],"settings":{"absoluteX":0,"absoluteY":0,"fillOpacity":1}}]},"groupBy":[{"type":"group","groupOn":"week"}]}],"paperOrientation":"portrait"};const structure = {"name":"demo19.pdf","type":"report","fonts":[],"footer":{"children":[]},"header":{"children":[]},"groupBy":[{"type":"group","footer":{"children":[]},"header":{"children":[{"type":"print","field":"name","settings":{"absoluteX":0,"absoluteY":0}}]},"groupOn":"name"}],"version":1,"fontSize":0,"autoPrint":false,"paperSize":"letter","variables":{},"subReports":[{"data":"emphours","type":"report","calcs":{"sum":["hours"]},"detail":{"children":[{"type":"band","fields":[{"type":"print","field":"name","width":100,"dataUUID":10939},{"type":"print","field":"day","width":100,"dataUUID":10940},{"type":"print","field":"hours","width":100,"dataUUID":10940}],"settings":{"absoluteX":0,"absoluteY":0,"fillOpacity":1}}]},"groupBy":[{"type":"group","groupOn":"week"}]}],"paperOrientation":"portrait"};

In the latest version, I still get:

REPORTAPI: data is empty, try adding a .data([{field: 'value',...}]) to the report.

And I cannot seem to get sub-reports to work.

Some additional info: It actually looks like bands in the sub-report are referencing the parent data somehow. If I have fields that are named the same in the parent data, and the sub-report data, the parent data shows.

beauwest commented 4 years ago

Something else I'm noticing, is if I go to the "Sections" prompt, create sub-report sections, click "OK", the next time I open the "Sections" prompt, my sub-report sections are no longer there.

If I hit "OK" again, it deletes my sub-report sections.

beauwest commented 3 years ago

Some more sub-report problems:

Structure

{"name":"claim-form.pdf","type":"report","fonts":[],"groupBy":[{"type":"group","footer":{"children":[{"text":"Receiving","type":"print","settings":{"width":215,"fontSize":14,"absoluteX":0,"absoluteY":0}},{"text":"Governing Board","type":"print","settings":{"width":215,"fontSize":14,"absoluteX":280,"absoluteY":0}},{"text":"I hereby certify receipt of above stated goods in quantity indicated. The delivery documentation has been compared to the purchase order and any discrepancies have been reconciled.","type":"print","settings":{"width":215,"fontSize":7,"absoluteX":0,"absoluteY":18}},{"text":"The claim is approved for payment in the amount indicated above.","type":"print","settings":{"width":215,"fontSize":7,"absoluteX":280,"absoluteY":18}},{"text":"_______________________________________","type":"print","settings":{"absoluteX":0,"absoluteY":60}},{"text":"_______________________________________","type":"print","settings":{"absoluteX":280,"absoluteY":60}},{"text":"Date","type":"print","settings":{"absoluteX":0,"absoluteY":72}},{"text":"Date","type":"print","settings":{"width":215,"absoluteX":280,"absoluteY":72}},{"text":"_______________________________________","type":"print","settings":{"absoluteX":0,"absoluteY":100}},{"text":"_______________________________________","type":"print","settings":{"absoluteX":280,"absoluteY":100}},{"text":"Receiving Officer","type":"print","settings":{"absoluteX":0,"absoluteY":114}},{"text":"District Judge","type":"print","settings":{"width":215,"absoluteX":280,"absoluteY":114}},{"text":"_______________________________________","type":"print","settings":{"absoluteX":280,"absoluteY":140}},{"name":"Print Function","type":"print","function":{"name":"Print Function","type":"function","async":false,"function":"return data.comment ? 'Comment on Voucher' : undefined;"},"settings":{"fontSize":14,"absoluteX":0,"absoluteY":142}},{"text":"Associate District Judge","type":"print","settings":{"width":215,"absoluteX":280,"absoluteY":154}},{"name":"Print Function","type":"print","function":{"name":"Print Function","type":"function","async":false,"function":"return data.comment ? data.comment : undefined;"},"settings":{"width":215,"absoluteX":0,"absoluteY":160}},{"text":"_______________________________________","type":"print","settings":{"absoluteX":280,"absoluteY":180}},{"text":"Court Clerk","type":"print","settings":{"width":215,"absoluteX":280,"absoluteY":194}}],"pageBreak":"after"},"header":{"children":[{"name":"Print Function","type":"print","function":{"name":"Print Function","type":"function","async":false,"function":"return `${data.fund_name} Claim`;"},"settings":{"fontSize":16,"absoluteX":200,"absoluteY":0}},{"name":"Printed On","type":"print","function":{"name":"Printed On","type":"function","async":false,"function":"return `Printed on\n${vars.printedOn}`;"},"settings":{"align":"right","fontSize":7,"absoluteX":658,"absoluteY":0}},{"type":"band","fields":[{"text":"County Name","type":"print","width":"18%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"fontSize":9},{"type":"print","align":"left","width":"42%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"variable":"county"}],"settings":{"absoluteX":0,"absoluteY":26,"fillOpacity":1}},{"type":"band","fields":[{"text":"Claim Number","type":"print","width":"16%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}}},{"type":"print","align":"left","field":"claim_number","width":"20%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"dataUUID":10756}],"settings":{"absoluteX":340,"absoluteY":26,"fillOpacity":1}},{"type":"band","fields":[{"text":"Name of Court Clerk","type":"print","width":"18%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"fontSize":9},{"type":"print","align":"left","width":"42%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"variable":"courtClerk"}],"settings":{"absoluteX":0,"absoluteY":39,"fillOpacity":1}},{"type":"band","fields":[{"text":"Claim Date","type":"print","width":"16%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}}},{"type":"print","align":"left","field":"encumber_date","width":"20%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"dataUUID":10756}],"settings":{"absoluteX":340,"absoluteY":39,"fillOpacity":1}},{"type":"band","fields":[{"text":"Address of Court Clerk","type":"print","width":"18%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"fontSize":9},{"type":"print","align":"left","width":"42%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"variable":"courtAddress"}],"settings":{"absoluteX":0,"absoluteY":52,"fillOpacity":1}},{"type":"band","fields":[{"text":"Fiscal Year","type":"print","width":"16%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}}},{"type":"print","align":"left","field":"year","width":"20%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"dataUUID":10756}],"settings":{"absoluteX":340,"absoluteY":52,"fillOpacity":1}},{"type":"band","fields":[{"text":"City, State, Zip","type":"print","width":"18%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"fontSize":9},{"type":"print","align":"left","width":"42%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"variable":"courtPostal"}],"settings":{"absoluteX":0,"absoluteY":65,"fillOpacity":1}},{"type":"band","fields":[{"text":"Voucher Number","type":"print","width":"16%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}}},{"type":"print","align":"left","field":"voucher_number","width":"20%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"dataUUID":10756}],"settings":{"absoluteX":340,"absoluteY":65,"fillOpacity":1}},{"type":"band","fields":[{"text":"Phone Number","type":"print","width":"18%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"fontSize":9},{"type":"print","align":"left","width":"42%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"variable":"courtPhone"}],"settings":{"absoluteX":0,"absoluteY":78,"fillOpacity":1}},{"type":"band","fields":[{"text":"Email","type":"print","width":"18%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"fontSize":9},{"type":"print","align":"left","width":"42%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"variable":"courtEmail"}],"settings":{"absoluteX":0,"absoluteY":91,"fillOpacity":1}},{"type":"band","fields":[{"text":"Invoice Number","type":"print","width":"18%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"fontSize":9},{"type":"print","align":"left","field":"invoice_number","width":"42%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"dataUUID":10756}],"settings":{"absoluteX":0,"absoluteY":126,"fillOpacity":1}},{"text":"Purchasing Officer Approval","type":"print","settings":{"fontSize":14,"absoluteX":340,"absoluteY":126}},{"type":"band","fields":[{"text":"Vendor ID Number","type":"print","width":"18%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"fontSize":9},{"text":"","type":"print","align":"left","width":"42%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}}}],"settings":{"absoluteX":0,"absoluteY":139,"fillOpacity":1}},{"text":"I hereby certify that the claim has been verified for adequate funding and compliance with the procurement laws (20 O. S.§ 1304 and , if applicable 61 O. S. § 102 et. Seq. for improvements to public buildings.)","type":"print","settings":{"width":168,"fontSize":7,"absoluteX":340,"absoluteY":142}},{"type":"band","fields":[{"text":"Vendor Name","type":"print","width":"18%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"fontSize":9},{"type":"print","align":"left","field":"claimant","width":"42%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"dataUUID":10756}],"settings":{"absoluteX":0,"absoluteY":152,"fillOpacity":1}},{"type":"band","fields":[{"text":"Vendor Address","type":"print","width":"18%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"fontSize":9},{"type":"print","align":"left","field":"address_1","width":"42%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"dataUUID":10756}],"settings":{"absoluteX":0,"absoluteY":165,"fillOpacity":1}},{"type":"band","fields":[{"text":"City, State, Zip","type":"print","width":"18%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"fontSize":9},{"type":"print","align":"left","field":"postal","width":"42%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"dataUUID":10756}],"settings":{"absoluteX":0,"absoluteY":178,"fillOpacity":1}},{"type":"band","fields":[{"text":"Phone Number","type":"print","width":"18%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"fontSize":9},{"type":"print","align":"left","field":"primary_phone","width":"42%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"dataUUID":10756}],"settings":{"absoluteX":0,"absoluteY":191,"fillOpacity":1}},{"text":"_________________________________","type":"print","settings":{"absoluteX":340,"absoluteY":196}},{"type":"band","fields":[{"text":"Fax Number","type":"print","width":"18%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"fontSize":9},{"type":"print","align":"left","field":"alternate_phone","width":"42%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"dataUUID":10756}],"settings":{"absoluteX":0,"absoluteY":204,"fillOpacity":1}},{"text":"Purchasing Officer/Court Clerk","type":"print","settings":{"width":168,"absoluteX":360,"absoluteY":210}},{"type":"band","fields":[{"text":"Email","type":"print","width":"18%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"fontSize":9},{"text":"","type":"print","align":"left","width":"42%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}}}],"settings":{"absoluteX":0,"absoluteY":217,"fillOpacity":1}},{"type":"band","fields":[{"text":"Tax ID","type":"print","width":"18%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"fontSize":9},{"type":"print","align":"left","field":"identifier_number","width":"42%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"dataUUID":10756}],"settings":{"absoluteX":0,"absoluteY":230,"fillOpacity":1}},{"type":"newLine","settings":{"top":249}},{"type":"newLine","settings":{"top":257}}]},"groupOn":"id"}],"margins":{"top":40,"left":40,"right":40,"bottom":40},"version":2,"fontSize":10,"autoPrint":false,"paperSize":"letter","variables":{"year":"2020-2021","claim":"000069","county":"JOHNSTON","comment":"This is a test comment","invoice":null,"voucher":null,"fundName":"Court Fund","vendorId":"","claimDate":"10/28/2020","printedOn":"12/04/2020 12:16","vendorFax":"","courtClerk":"CASSANDRA SLOVER","courtEmail":"cassandra.slover@oscn.net","courtPhone":"(580) 371-3281","vendorName":"STATE JUDICIAL FUND","courtPostal":"TISHOMINGO, OK 73460","vendorEmail":"","vendorPhone":"","vendorTaxId":"","courtAddress":"403 W. MAIN, STE. 201","vendorPostal":"OKLAHOMA CITY, OK. 73105","vendorAddress":"1915 N. STILES"},"subReports":[{"data":"detail","type":"report","calcs":{"sum":["total_cost"]},"detail":{"children":[{"type":"band","fields":[{"type":"print","align":3,"field":"quantity","width":"8%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"dataUUID":10757},{"type":"print","field":"item_description","width":"22%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"dataUUID":10757},{"type":"print","align":3,"field":"unit_price","width":"12%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"dataUUID":10757,"formatFunction":"money"},{"type":"print","align":3,"field":"total_cost","width":"12%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"dataUUID":10757,"formatFunction":"money"},{"type":"print","align":3,"field":"code","width":"10%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"dataUUID":10757},{"type":"print","field":"name","width":"22%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"dataUUID":10757},{"text":"","type":"print","width":"14%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}}}],"settings":{"wrap":true,"absoluteX":0,"absoluteY":0,"fillOpacity":1}}]},"footer":{"children":[{"type":"band","fields":[{"text":"Subtotal","type":"print","align":"right","width":"42%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}}},{"type":"print","align":3,"total":"total_cost","width":"12%","border":{"type":"object","object":{"top":1,"left":1,"right":1,"bottom":1}},"formatFunction":"money"}],"settings":{"absoluteX":0,"absoluteY":0,"fillOpacity":1}},{"type":"newLine","settings":{"top":13}},{"type":"newLine","settings":{"top":21}}]},"header":{"children":[{"type":"band","fields":[{"text":"Qty.","type":"print","align":"right","width":"8%"},{"text":"Description","type":"print","width":"22%"},{"text":"Unit Price","type":"print","align":"right","width":"12%"},{"text":"Total Costs","type":"print","align":"right","width":"12%"},{"text":"Acct. No","type":"print","align":"right","width":"10%"},{"text":"Acct. Name","type":"print","width":"22%"},{"text":"Rec. Use Only","type":"print","width":"14%"}],"settings":{"wrap":true,"absoluteX":0,"absoluteY":0,"fillOpacity":1}}]}}],"paperOrientation":"portrait"}

Data

[{"id":"ba40bfb8-e972-4367-b53a-1b12d67d9bd5","claim_number":"000039","encumber_date":"11/12/2020","invoice_number":null,"year":"2020-2021","fund_name":"Court Fund","voucher_number":"000039","claimant":"SOUTHWESTERN STATIONERY & BANK SUPPLY","address_1":"P.O. BOX 18697","address_2":"OKLAHOMA CITY, OKLAHOMA  73154","postal":"OKLAHOMA CITY, OKLAHOMA  73154","primary_phone":"(800) 356-9905","alternate_phone":"(877) 551-9100","identifier_number":"","show_comment_on_claim_form":false,"comment":"","detail":[{"quantity":1,"item_description":null,"unit_price":338.25,"total_cost":338.25,"name":"GENERAL OFFICE SUPPLIES","code":"2170"}]},{"id":"d13b4113-1f0c-4b49-8300-05ac85f16a23","claim_number":"000040","encumber_date":"11/18/2020","invoice_number":null,"year":"2020-2021","fund_name":"Court Fund","voucher_number":"000040","claimant":"COURT FUND PAYROLL","address_1":"","address_2":"","postal":"","primary_phone":"","alternate_phone":"","identifier_number":"","show_comment_on_claim_form":false,"comment":"","detail":[{"quantity":1,"item_description":null,"unit_price":3361.65,"total_cost":3361.65,"name":"COURT CLERK EMPLOYEES","code":"2640"}]},{"id":"f9d641f5-0e2b-45cb-b8c8-164ceccff3a0","claim_number":"000038","encumber_date":"11/12/2020","invoice_number":null,"year":"2020-2021","fund_name":"Court Fund","voucher_number":"000038","claimant":"AT&T","address_1":"P.O. BOX 105414","address_2":"ATLANTA, GEORGIA  30348-5414","postal":"ATLANTA, GEORGIA  30348-5414","primary_phone":"","alternate_phone":"","identifier_number":"","show_comment_on_claim_form":false,"comment":"","detail":[{"quantity":1,"item_description":null,"unit_price":290.28,"total_cost":290.28,"name":"TELEPHONE EXPENSE","code":"2220"}]}]

Problems:

claim-form.79cf9bf2-a894-47e4-8bfc-f22c8fda1231.pdf

beauwest commented 3 years ago

This problem is being encountered on a lot of our reports. I really like the concept laid out, where the data would be:

[{
  "report_one": [{}, {}, {}],
  "report_two": [{}, {}, {}],
}]

But while that structure shows sub-report options in the report section editor, it does not seem to work.