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

Add export feature #176

Merged
merged 1 commit into from
Mar 11, 2017
Merged

Add export feature #176

merged 1 commit into from
Mar 11, 2017

Conversation

0livd
Copy link
Member

@0livd 0livd commented Feb 23, 2017

This adds the possibility to export the bills and the transactions of a project as json or csv
The exported fields are the following:
transactions: amount, receiver, ower
bills: what, payer_name, payer_weight, owers, amount, date

The link to export the project is located in the options menu

Original feature request #28

@@ -54,7 +54,7 @@ def balance(self):
def uses_weights(self):
return len([i for i in self.members if i.weight != 1]) > 0

def get_transactions_to_settle_bill(self):
def get_transactions_to_settle_bill(self, pretty_output=False):
"""Return a list of transactions that could be made to settle the bill"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to have a better readability, I would create a prettify function (inside this method) which will do the conversion if needed.

Copy link
Member

@almet almet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really great, thanks a lot for your work on this!

I approve the changes but I tend to prefer to have the export feature on the settings page in order to avoid adding a new menu.

If you prefer to have them separated on another page like you did, please can you elaborate on why it's better in your opinion? or, if you agree with this proposal, could you make the change?

Thanks 👍

budget/models.py Outdated
"date": str(bill.date),
"payer_name": Person.query.get(bill.payer_id).name,
"payer_weight": Person.query.get(bill.payer_id).weight,
"owers": [ower.name for ower in bill.owers]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having an intermediary variable here for the owers would improve readability.

{{ input(form.export_format) }}
</fieldset>
<div class="actions">
<button class="btn">{{ _("Export this project") }}</button>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the action, consider: "Download this project's data"

@@ -51,6 +51,7 @@ <h1 class="col-2"><a class="navbar-brand" href="{{ url_for(".home") }}">#! money
<a href="#" class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><strong>{{ g.project.name }}</strong> {{ _("options") }} <b class="caret"></b></a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<li><a class="dropdown-item" href="{{ url_for(".edit_project") }}">{{ _("Project settings") }}</a></li>
<li><a class="dropdown-item" href="{{ url_for(".export_project") }}">{{ _("Export project") }}</a></li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure where this should be: what about having a section in the project's settings instead?

@@ -624,6 +624,116 @@ def test_settle_zero(self):
self.assertNotEqual(0.0, rounded_amount,
msg='%f is equal to zero after rounding' % t['amount'])

def test_export(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for taking the time to write tests for this!

Bills and transactions can now be exported to json or csv

ref spiral-project#28
@0livd
Copy link
Member Author

0livd commented Mar 9, 2017

Ok I amended the commit to improve readability and made some rewording. I also moved the export form to project's settings, the choice of a separate page was purely arbitrary :)

@almet
Copy link
Member

almet commented Mar 10, 2017

This looks good to me!

@almet almet merged commit 42854bd into spiral-project:master Mar 11, 2017
@almet almet mentioned this pull request Mar 11, 2017
@almet almet mentioned this pull request Jun 11, 2017
Jojo144 pushed a commit to Jojo144/ihatemoney that referenced this pull request Mar 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants