How to use the ihatemoney.models.Bill.query.join function in ihatemoney

To help you get started, we’ve selected a few ihatemoney examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spiral-project / ihatemoney / ihatemoney / models.py View on Github external
def get_bills(self):
        """Return the list of bills related to this project"""
        return (
            Bill.query.join(Person, Project)
            .filter(Bill.payer_id == Person.id)
            .filter(Person.project_id == Project.id)
            .filter(Project.id == self.id)
            .order_by(Bill.date.desc())
            .order_by(Bill.creation_date.desc())
            .order_by(Bill.id.desc())
        )
github spiral-project / ihatemoney / ihatemoney / models.py View on Github external
def get_member_bills(self, member_id):
        """Return the list of bills related to a specific member"""
        return (
            Bill.query.join(Person, Project)
            .filter(Bill.payer_id == Person.id)
            .filter(Person.project_id == Project.id)
            .filter(Person.id == member_id)
            .filter(Project.id == self.id)
            .order_by(Bill.date.desc())
            .order_by(Bill.id.desc())
        )