Dashboard Graph One Day Behind

Just noticed that the Invoice/Payment/Expense graph on the dashboard seems to be a day behind. To test it out, I created an invoice, saved it, then entered a payment for the same day (12/28). On the graph, it shows both the invoice and payment amounts as being on 12/27.

Also, when I clicked “mark paid” on the invoice page, it apparently entered a payment date of 12/29 (similar issue to invoices not originally taking timezones into account, perhaps?). But when I manually change the payment date back to 12/28, it still shows on the graph as being 12/27, just like the invoice.

I’m not sure, I’m not yet able to replicate the problem.

Any news on this, btw? Still happening in 3.0.5, regardless of what company I’m using, or what I set the view to.

I’m not savvy enough to figure out if it’s just the overview graph having an “off by 1” problem, or if it’s something else, but the entire graph seems a day behind as well. That screenshot was taken about 10 minutes ago (still the 10th here), and the graph only goes up to the 9th.

Not a huge deal, but still odd nonetheless.

I’m assuming you’re self hosting the app.

I’d suggest checking that the app timezone is UTC and you’ve set your local timezone on /settings/localization

Yep. Self-hosted 3.0.5 on Ubuntu 16.0.4.1

Timezone setting on the server doesn’t seem to have any bearing, and that particular invoice was marked paid in the middle of the day, so a 5 hour offset either way shouldn’t have changed what day it thought it was.

Can you double check your setting on /settings/localization

The chart uses the payment date without the time. If the timezone setting is wrong it could show the wrong value depending on the time of day you’re running the report.

settings/localization is set to GMT-5.

It’s not just the payment date that seems off, it seems like the entire chart is off by one day. The last day shown is always the day before whatever day it actually is.

Try showing the browser console and running moment(); to check the end date we’re using.

Is everything correct here: http://browserspy.dk/date.php

Never mind, I just reviewed the earlier screenshots.

I’m not able to make it fail, any chance you defined APP_TIMEZONE in your .env file?

It may be worth checking moment and browserspy.

No entry for APP_TIMEZONE in the .env file.

moment shows

which matches with what browserspy is reporting.

Can you compare the SQL query select now(); against your current day/time.

I think the next step would be checking the raw data is correct, here’s the SQL query:

select sum(invoices.amount) as total, sum(invoices.balance) as balance, count(invoices.id) as count, concat(YEAR(invoice_date), DAYOFYEAR(invoice_date)) as DAYOFYEAR from invoices left join clients on clients.id = invoices.client_id where (clients.id IS NULL OR clients.is_deleted = 0) and invoices.account_id = ‘1’ and invoices.is_deleted = ‘0’ and invoices.invoice_date >= ‘2017-01-18’ and invoices.invoice_date <= ‘2017-02-16’ and (clients.currency_id = 1 or coalesce(clients.currency_id, 0) = 0) and invoice_type_id = ‘1’ and invoices.is_public = ‘1’ and is_recurring = ‘0’ group by DAYOFYEAR

mysql> SELECT SUM(invoices.amount) as total,
    -> SUM(invoices.balance) as balance,
    -> count(invoices.id) as count, concat(YEAR(invoice_date), DAYOFYEAR(invoice_date))
    -> as DAYOFYEAR
    -> FROM invoices left join clients on clients.id = invoices.client_id
    -> WHERE (clients.id IS NULL OR clients.is_deleted = 0)
    -> AND invoices.is_deleted = '0'
    -> AND invoices.invoice_date >= '2017-01-18'
    -> AND invoices.invoice_date <= '2017-02-16'
    -> GROUP BY DAYOFYEAR;
+--------+---------+-------+-----------+
| total  | balance | count | DAYOFYEAR |
+--------+---------+-------+-----------+
| 140.00 |    0.00 |     1 | 201740    |
+--------+---------+-------+-----------+

So definitely shows the invoice as the 9th, which is correct. And it shows the correct date in the “Recent Payments” window under the chart. But the chart still vexes me.

Just on a hunch, I went over to the test-drive portion of the hosted version, clicked on the dashboard, and noticed the graph seems to only display up to the previous day there as well.

That’s helpful to know, can you check later in the day if it’s still off.

It seems likely this is a timezone problem. The chart looks correct to me however I should be able to make it incorrect by changing the timezone but that isn’t happening.

Just gave it another go (2150 EST, 2/16/17) and both the online and self-hosted versions are still showing the last day on the chart as the 15th.

I’m at a loss, I’m not able to reproduce the problem.

If you want to try to debug the code here’s where the end date is set:

https://github.com/invoiceninja/invoiceninja/blob/master/resources/views/dashboard.blade.php#L89


ranges: {
          "{{ trans('texts.last_7_days') }}": [moment().subtract(6, 'days'), moment()],
          "{{ trans('texts.last_30_days') }}": [moment().subtract(29, 'days'), moment()],
          "{{ trans('texts.this_month') }}": [moment().startOf('month'), moment().endOf('month')],
          "{{ trans('texts.last_month') }}": [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')],
          "{{ trans('texts.last_year') }}": [moment().subtract(1, 'year'), moment()],
        }

Tried every variation in this block in the console. Every single one returns the correct values. And in the date-range picker itself on the dashboard, it displays the correct ranges for whatever is selected.

As far as my meager skills can tell, your code is fine. It’s when Chart.js takes those values and plots them that there seems to be an issue. At the moment, I can’t figure out if Moment.js is part of the foul-up or not, as I’m even worse with JS than I am with PHP, but I’m gonna keep digging. Granted, this isn’t a deal-breaking issue by any means, but it’s just annoying enough that it’ll keep me occupied for a while, probably.

I just noticed that this happens to me as well (running 3.1.2 self hosted). However, I usually prefer the month view instead of the day view. Check this out:
http://prntscr.com/emmu20

Even though there were invoices, payments and expenses from Mar 01 until today (Mar 21), the chart shows zero for Mar 2017.

But it gets worse: the numbers from the Jan 2017 column match with the report covering February, and the numbers from the Feb 2017 column don’t match with the report covering March - it shows R$ 353,72 in expenses, when the report shows R$ 986,53.

The same thing happens when I select the ‘previous year’ period. Every month shows their numbers except December for which it shows zero.