# Custom Report For invoice Paid

**URL:** <https://discuss.tryton.org/t/custom-report-for-invoice-paid/8432>\
**Category:** Developer\
**Tags:** accounting\
**Created:** [March 21, 2025, 7:28pm UTC](https://discuss.tryton.org/t/custom-report-for-invoice-paid/8432 "2025-03-21T19:28:13Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![iehoshia](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/iehoshia/32/243_2.png) [@iehoshia](https://discuss.tryton.org/u/iehoshia)\
**Post date:** [March 21, 2025, 7:28pm UTC](https://discuss.tryton.org/t/custom-report-for-invoice-paid/8432/1 "2025-03-21T19:28:13Z")

</div>

Hi,

I want to create a report that give me information about invoices paid in certain time.

I have the follow code

```python
class IncomeReport(ModelSQL, ModelView):
    "Income Report"
    __name__ = 'income.reporting.main'

    date = fields.Date('Date')
    amount = fields.Numeric('Total Amount')

    @staticmethod
    def table_query():
        pool = Pool()

        Invoice = pool.get('account.invoice')
        InvoiceLine = pool.get('account.invoice.line')

        invoice = Invoice. __table__ ()
        invoice_line = InvoiceLine. __table__ ()

        context = Transaction().context
        company = context.get('company')
        start_date = context.get('from_date')
        end_date = context.get('to_date')
        period = context.get('period')

        period_map = {
            'year': DateTrunc('year', invoice.invoice_date),
            'month': DateTrunc('month', invoice.invoice_date),
            'day': DateTrunc('day', invoice.invoice_date),
        }
        date_field = period_map.get(period, period_map['day'])

        wheredate = invoice.state == 'paid'
        wheredate &= invoice.company == company

        if start_date:
            wheredate &= invoice.invoice_date >= start_date
        if end_date:
            wheredate &= invoice.invoice_date <= end_date

        query = invoice.join(invoice_line,
            condition=invoice.id == invoice_line.invoice).select(
            Max(invoice.id * 1000).as_('id'),
            Max(invoice.create_uid).as_('create_uid'),
            Max(invoice.create_date).as_('create_date'),
            Max(invoice.write_uid).as_('write_uid'),
            Max(invoice.write_date).as_('write_date'),
            date_field.as_('date'),
            Sum(invoice_line.unit_price * invoice_line.quantity).as_('amount'),
            where=wheredate,
            group_by=[invoice.id, date_field]
        )

        return query

```

But it doesn’t display the correct info. Any suggest?

Best.

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [March 21, 2025, 10:32pm UTC](https://discuss.tryton.org/t/custom-report-for-invoice-paid/8432/2 "2025-03-21T22:32:30Z")

</div>

What are you expected and what do you get?

---

<div class="post-metadata">

**Author:** ![iehoshia](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/iehoshia/32/243_2.png) [@iehoshia](https://discuss.tryton.org/u/iehoshia)\
**Post date:** [March 24, 2025, 11:55pm UTC](https://discuss.tryton.org/t/custom-report-for-invoice-paid/8432/3 "2025-03-24T23:55:34Z")

</div>

I want a report that tells me the amount of invoices paid in a given period of time, and that I can group them by day, month, and year.

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [March 25, 2025, 8:13am UTC](https://discuss.tryton.org/t/custom-report-for-invoice-paid/8432/4 "2025-03-25T08:13:13Z")

</div>

Why do not you use the “Journals Cash” reports?

---

<div class="post-metadata">

**Author:** ![iehoshia](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/iehoshia/32/243_2.png) [@iehoshia](https://discuss.tryton.org/u/iehoshia)\
**Post date:** [March 25, 2025, 4:22pm UTC](https://discuss.tryton.org/t/custom-report-for-invoice-paid/8432/5 "2025-03-25T16:22:12Z")

</div>

I don’t know how to use them, usually the report with balance 0.

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [March 25, 2025, 4:24pm UTC](https://discuss.tryton.org/t/custom-report-for-invoice-paid/8432/6 "2025-03-25T16:24:37Z")

</div>

I do not understand your comment.

Anyway I’m wondering now if your requirements are not indeed just the [_Account Tax Cash Module_](https://docs.tryton.org/latest/modules-account-tax-cash/index.html).

---

<div class="post-metadata">

**Author:** ![iehoshia](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/iehoshia/32/243_2.png) [@iehoshia](https://discuss.tryton.org/u/iehoshia)\
**Post date:** [March 26, 2025, 4:26am UTC](https://discuss.tryton.org/t/custom-report-for-invoice-paid/8432/7 "2025-03-26T04:26:48Z")

</div>

I’m not sure how to use Cash Reports

 ![image](https://discuss-cdn.tryton.org/uploads/default/original/2X/9/9223d3e05daf0cd2015e20da7bb49b92c244f2eb.png)

I have account moves in that date range, but the credits and debits appear as zero.

---

<div class="post-metadata">

**Author:** ![yangoon](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/y/67e7ee/32.png) [@yangoon](https://discuss.tryton.org/u/yangoon)\
**Post date:** [March 26, 2025, 7:11am UTC](https://discuss.tryton.org/t/custom-report-for-invoice-paid/8432/8 "2025-03-26T07:11:10Z")

</div>

The account\_tax\_cash module can only work after its activation.

- Did you do those moves before the activation of the module?
- Did you configure the necessary tax groups on the fiscal year?
- Did you configure the necessary tax groups on the accounting period (in case the periods were created before the activation of the module)?

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [March 26, 2025, 8:20am UTC](https://discuss.tryton.org/t/custom-report-for-invoice-paid/8432/9 "2025-03-26T08:20:13Z")

</div>

> [@iehoshia](#):
>
> I have account moves in that date range, but the credits and debits appear as zero.

Are they using this journal?

---

<div class="post-metadata">

**Author:** ![iehoshia](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/iehoshia/32/243_2.png) [@iehoshia](https://discuss.tryton.org/u/iehoshia)\
**Post date:** [March 26, 2025, 12:18pm UTC](https://discuss.tryton.org/t/custom-report-for-invoice-paid/8432/10 "2025-03-26T12:18:12Z")

</div>

I haven’t installed the module yet, I don’t think it’s necessary for what I’m working on.

---

<div class="post-metadata">

**Author:** ![iehoshia](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/iehoshia/32/243_2.png) [@iehoshia](https://discuss.tryton.org/u/iehoshia)\
**Post date:** [March 26, 2025, 12:20pm UTC](https://discuss.tryton.org/t/custom-report-for-invoice-paid/8432/11 "2025-03-26T12:20:37Z")

</div>

Yes, I’ve already reviewed the account moves and they’re journaled. I’ve also already reviewed the jounral account and they’re cash equivalents.

I think it’s a configuration issue, but I’m not sure what I should check, since I’ve already reviewed the journal settings.

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [March 26, 2025, 12:36pm UTC](https://discuss.tryton.org/t/custom-report-for-invoice-paid/8432/12 "2025-03-26T12:36:44Z")

</div>

The accounts tracked must of course not be payable nor receivable.

---

<div class="post-metadata">

**Author:** ![iehoshia](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/iehoshia/32/243_2.png) [@iehoshia](https://discuss.tryton.org/u/iehoshia)\
**Post date:** [March 27, 2025, 12:53am UTC](https://discuss.tryton.org/t/custom-report-for-invoice-paid/8432/13 "2025-03-27T00:53:48Z")

</div>

I’ve already checked the settings, and the accounts I use aren’t payable or receivable, but the report shows zero.  
What else could I check?

---

<div class="post-metadata">

**Author:** ![iehoshia](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/iehoshia/32/243_2.png) [@iehoshia](https://discuss.tryton.org/u/iehoshia)\
**Post date:** [April 10, 2025, 10:31pm UTC](https://discuss.tryton.org/t/custom-report-for-invoice-paid/8432/14 "2025-04-10T22:31:04Z")

</div>

After debugging and testing, I found that the types for payable and receivable are not recognized if they are null and were excluded

> **[modules/account/journal.py · branch/default · Tryton / Tryton · GitLab](https://foss.heptapod.net/tryton/tryton/-/blob/branch/default/modules/account/journal.py#L110)**
>
> Business Software Modularity, scalability & security for your business Documentation Contribute

I change this

```auto

where = ((move.date >= context.get('start_date'))
            & (move.date <= context.get('end_date'))
            & ~account_type.receivable
            & ~account_type.payable
            & (move.company == company.id))

```

For this one

```auto
where = (
            (move.date >= context.get('start_date')) &
            (move.date <= context.get('end_date')) &
            ((account_type.receivable == False) | (account_type.receivable == None)) &
            ((account_type.payable == False) | (account_type.payable == None)) &
            (move.company == company.id)
        )

```

After this the Journals Cash report works fine.

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [April 11, 2025, 7:22am UTC](https://discuss.tryton.org/t/custom-report-for-invoice-paid/8432/15 "2025-04-11T07:22:21Z")

</div>

I filled [Journal debit/credit balance does not work when receivable or payable account type are NULL (#13967) · Issues · Tryton / Tryton · GitLab](https://bugs.tryton.org/13967)

---

<div class="post-metadata">

**Author:** ![system](https://discuss-cdn.tryton.org/uploads/default/original/1X/c6f8ec0a40525cdcd50058c734283450a4b3d38b.png) [@system](https://discuss.tryton.org/u/system)\
**Post date:** [April 12, 2025, 7:22am UTC](https://discuss.tryton.org/t/custom-report-for-invoice-paid/8432/16 "2025-04-12T07:22:25Z")

</div>

Closed on April 12, 2025, 7:22am UTC

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
