Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Export to PDF #3

Closed
nlogozzo opened this issue Oct 30, 2022 · 25 comments · Fixed by #194
Closed

Implement Export to PDF #3

nlogozzo opened this issue Oct 30, 2022 · 25 comments · Fixed by #194
Assignees
Labels
feature New feature or request in-beta This issue is fixed in a beta version
Milestone

Comments

@nlogozzo
Copy link
Member

No description provided.

@nlogozzo nlogozzo added the feature New feature or request label Oct 30, 2022
@nlogozzo
Copy link
Member Author

@nlogozzo nlogozzo added this to the V2022.11.2 milestone Nov 24, 2022
@RuboGubo
Copy link

For ideas that might be good to graph:
I think that the application should give two sections to the PDF "Report". It should provide a summary page, with simple data such as:

  • Total Income vs. Total Expenses.
  • Percentage of money in assets/how assets are doing (if this is ever supported)
  • etc.

While the further pages should contain more advanced information and graphs, which could be useful for people who are using this application as a way to manage a company/more complex finances. These sort of more advanced statistics would be a good step forward if the aim of this application was to replace non FOSS accounting software.
An example of a "more advanced statistic" would be a break down of losses (e.g. inflation, spending and investment returns (if this is ever supported)).

Another option should be to remove hard financial figures, and replace them with percentages, allowing the user to share their financial data, without relieving their wealth, which would be a good extra feature.

I also thing that it would be a good idea to present this data in-app. Either way, I'll look into some more ideas
that would be good to implement.

@zhrexl
Copy link

zhrexl commented Nov 26, 2022

I also thing that it would be a good idea to present this data in-app. Either way, I'll look into some more ideas that would be good to implement.

An initial page with graphs like a dashboard would be really great. One graph with my expenses as an example would help me see where I'm using more money in a faster way in comparison with other groups (medicines, travels, food, etc.).

@nlogozzo
Copy link
Member Author

You can track PDF progress on this branch: https://github.com/nlogozzo/NickvisionMoney/tree/pdf-reports

So far we have a basic blank page:
image
Test.pdf

If someone would like to open the PDF in LibreOffice Draw and create a mockup of how you would like everything drawn out that would be nice :)

I know @fsobolev is great at UI design but idk about Document Design 😄

@RuboGubo
Copy link

A question i would have for the PDF is if it should follow the GNOME Style? I personally think so, but at the same time applications like apostrophe don't, so I guess it is up for debate?

@nlogozzo
Copy link
Member Author

A question i would have for the PDF is if it should follow the GNOME Style? I personally think so, but at the same time applications like apostrophe don't, so I guess it is up for debate?

I don't really know how to create a "GNOME-Styled" PDF since all i can draw are lines and text.
The most i could do is use the default gnome font for the PDF.

@RuboGubo
Copy link

Oh, that is understandable, but will you be able to plot graphs?

@nlogozzo
Copy link
Member Author

I should be able to although I may need to draw the whole graph manually. I'm using libharu as the pdf library, which I'm slowly learning as I go along.

@nlogozzo
Copy link
Member Author

image

Love drawing PDFs with C code 😆

//Initialize PDF
HPDF_Doc pdf{ HPDF_New([](HPDF_STATUS, HPDF_STATUS, void* data){ *reinterpret_cast<bool*>(data) = false; }, &success) };
//First Page
HPDF_Page page1{ HPDF_AddPage(pdf) };
HPDF_Page_SetSize(page1, HPDF_PAGE_SIZE_LETTER, HPDF_PAGE_PORTRAIT);
//First Page - Main Box
HPDF_Page_SetLineWidth(page1, 0.5);
HPDF_Page_Rectangle(page1, 10, 10, HPDF_Page_GetWidth(page1) - 20, HPDF_Page_GetHeight(page1) - 20);
HPDF_Page_Stroke(page1);
//First Page - Font
HPDF_Font fontTitle{ HPDF_GetFont(pdf, "Helvetica", nullptr) };
//First Page - Title
HPDF_Page_SetFontAndSize(page1, fontTitle, 11);
HPDF_Page_BeginText(page1);
HPDF_Page_MoveTextPos(page1, 14, HPDF_Page_GetHeight(page1) - 24);
HPDF_Page_ShowText(page1, std::filesystem::path(m_path).filename().c_str());
HPDF_Page_EndText(page1);
//First Page - Icon
HPDF_Image imageIcon{ HPDF_LoadJpegImageFromFile(pdf, pathToSymbolicIcon.c_str()) };
HPDF_Page_DrawImage(page1, imageIcon, HPDF_Page_GetWidth(page1) - 50, HPDF_Page_GetHeight(page1) - 50, 32, 32);
//First Page - Income
HPDF_Page_SetFontAndSize(page1, fontTitle, 9);
HPDF_Page_BeginText(page1);
HPDF_Page_MoveTextPos(page1, 20, HPDF_Page_GetHeight(page1) - 54);
HPDF_Page_ShowText(page1, std::string("Income: " + MoneyHelpers::boostMoneyToLocaleString(getIncome(), locale)).c_str());
HPDF_Page_EndText(page1);
//First Page - Expense
HPDF_Page_BeginText(page1);
HPDF_Page_MoveTextPos(page1,20, HPDF_Page_GetHeight(page1) - 70);
HPDF_Page_ShowText(page1, std::string("Expense: " + MoneyHelpers::boostMoneyToLocaleString(getExpense(), locale)).c_str());
HPDF_Page_EndText(page1);
//First Page - Total
HPDF_Page_BeginText(page1);
HPDF_Page_MoveTextPos(page1, 20, HPDF_Page_GetHeight(page1) - 86);
HPDF_Page_ShowText(page1, std::string("Total: " + MoneyHelpers::boostMoneyToLocaleString(getTotal(), locale)).c_str());
HPDF_Page_EndText(page1);
//Save and Close PDF
HPDF_SaveToFile(pdf, path.c_str());
HPDF_Free(pdf);

@RuboGubo
Copy link

RuboGubo commented Nov 26, 2022 via email

@CoderThomasB
Copy link

The PHP library FPDF has a lot of examples of scripts that you might find helpful as a reference/resource when making the pdf generation tool.

http://www.fpdf.org/en/script/ex20.pdf
http://www.fpdf.org/en/script/script20.php
http://www.fpdf.org/en/script/ex101.pdf
http://www.fpdf.org/en/script/script101.php
http://www.fpdf.org/en/script/index.php
http://www.fpdf.org/

While it is a completely different library in a completely different languish, I hope that you will find something there that might help you.

@zhrexl
Copy link

zhrexl commented Nov 26, 2022

Love drawing PDFs with C code laughing

I can help you write a wrapper around that! It would be great if someone could make or find a beautiful template for financial information.

I'll be able to work on it after Dec 8th in case you haven't done it by then.

@nlogozzo
Copy link
Member Author

nlogozzo commented Nov 27, 2022

Love drawing PDFs with C code laughing

I can help you write a wrapper around that! It would be great if someone could make or find a beautiful template for financial information.

I'll be able to work on it after Dec 8th in case you haven't done it by then.

Thanks for the idea! I built a light wrapper for a PDF page and document that I am building as I go along.

PDFDocument
PDFPage

@vanillajonathan
Copy link
Contributor

Perhaps the diagram could also be drawn in the application using the DrawingArea widget.

@nlogozzo nlogozzo modified the milestones: V2022.12.0, V2023.1.0 Dec 21, 2022
@ghost
Copy link

ghost commented Dec 29, 2022

report_template.odt

I know this is low-effort production but see if this inspires you. Public domain/CC-BY.

Pros:

  • Data on this template can be edited by LibreOffice Draw
  • custom changes can be easily made

@ghost
Copy link

ghost commented Dec 30, 2022

Here's some information that could be generated and used.

Basic, doesn't require new function

Income-Expense Ratio
Average Income/day
Average Expense/day
Net Income
Top Expense Groups 

These could be calculated by the selected range

Extensions---would require new function(s) and may not be useful for some users

Overdraft | requires (saving) target
Debts | requires data type "debts" #90
Foreign Currency Balance | requires foreign currency (re-)support #128 
Estimated Credit Interest | requires input of interest rate

There's 12 columns in the report template. The basics ones requires 7 columns (assuming Top Expense Group lists 3). Or we could use every other column.


The indent of the income and expense could be modified from -0.06 (both before-text and after) to -0.16 to fit 100 vertical bar for easier calculation. You'd need to change the indent of "income" and "expense" to -0.10 before-text as well.

@fsobolev
Copy link
Member

Foreign Currency Balance | requires foreign currency (re-)support #128

Custom currency option shown in #128 is not about additional currency for an account, but about setting a currency that is not the one defined by a user locale. And even if we would add ability to show balance in multiple currencies, it's very problematic to convert (see #130 (comment)).

@ghost
Copy link

ghost commented Dec 30, 2022

And even if we would add ability to show balance in multiple currencies, it's very problematic to convert (see #130 (comment)).

It's not about converting to local currency. That's another feature (Local currency equivalent). We could instead just use the currency sign (take £ as example) and display it like £300.00. I guess this is common in saving accounts?

And for the multiple currencies part, it could probably be a hidden group (sorry I only know a bit python so can't really help there)

report_template.odt
report_template.pdf
I can make one in landscape too if you need

@nlogozzo nlogozzo self-assigned this Dec 30, 2022
@nlogozzo nlogozzo changed the title Implement Cool PDF Reports and Graphs Implement Export to PDF Jan 9, 2023
@nlogozzo
Copy link
Member Author

nlogozzo commented Jan 9, 2023

image

Feature all most done! Just need to find a place to put receipt images.

(Fancy reporting with graphs and PDFs for reports will come in a future version. I'll make an issue to track that soon)

@nlogozzo nlogozzo added the in-beta This issue is fixed in a beta version label Jan 10, 2023
@nlogozzo
Copy link
Member Author

@ghost
Copy link

ghost commented Feb 26, 2023

I'm sorry, but is this feature implemented? I cannot find it in the app.

@fsobolev
Copy link
Member

I'm sorry, but is this feature implemented? I cannot find it in the app.

Yes, it is, open an account -> "Actions" menu -> "Export to File" -> "PDF"

@ghost
Copy link

ghost commented Feb 26, 2023

Thanks!

@vanillajonathan
Copy link
Contributor

Maybe the PDF could include diagrams?

A pie chart that shows expenses for each group.

A line chart that shows expenses for each month.

A heat map that shows expenses for every day of the year.

@nlogozzo
Copy link
Member Author

Maybe the PDF could include diagrams?

A pie chart that shows expenses for each group.

A line chart that shows expenses for each month.

A heat map that shows expenses for every day of the year.

That will come with #289

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request in-beta This issue is fixed in a beta version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants