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

Export "hourly_rate" instead "rate" #6

Open
gises opened this issue Feb 6, 2021 · 11 comments
Open

Export "hourly_rate" instead "rate" #6

gises opened this issue Feb 6, 2021 · 11 comments

Comments

@gises
Copy link

gises commented Feb 6, 2021

Currently, a calculated hourly rate is transferred to GrandTotal. This leads to different hourly rates being shown in the invoice.
According to the database, the field "hourly_rate" should be used instead of "rate" for the entry "Cost".

Many thanks

for (var aEntry of aItems)
{
var aItemResult = {
'startDate': aEntry['begin'],
'client': '',
'project': '',
'minutes': Math.round(aEntry['duration'] / 60),
'notes': aEntry['description'] !== null ? aEntry['description'] : '',
'label': aEntry['tags'].join(", "),
'user': aEntry['user'],
'cost': aEntry['rate'],
'uid': 'com.kimai2.' + aEntry['id'],

@kevinpapst
Copy link
Member

kevinpapst commented Feb 6, 2021

I don't think so. Grandtotal calculates the unit cost from cost and minutes.
The Kimai import view in Grandtotal shows the correct values for "Quantity, Unit, Unitprice, Cost".
Are you sure your invoice template is correct?

Bildschirmfoto 2021-02-06 um 16 36 51

@gises
Copy link
Author

gises commented Feb 6, 2021

Hi Kevin,
I quickly made two test entries for better understanding.
An hourly rate of 75.25 is stored in Kimai with time entries of 15 and 30 minutes. When importing into GrandTotal, i.e. before the invoice is created, it looks like this.

image

Screenshot aus der Kimai DB
image

@kevinpapst
Copy link
Member

Yes, and what is the problem now?
Einzelpreis = 72,25 for one complete item. Grandtotal sees that it is just half of an item (30 minutes) so it Kosten is 37,63.
Looks correct to me.

@gises
Copy link
Author

gises commented Feb 6, 2021

The hourly rate is fixed but is now displayed differently. Even if the differences are only minor, they are not accepted.
If the expenses are then summed up in GrandTotal, it looks like this. This is wrong and leads to questions from the client.
That is why I asked why the hourly rate stored cannot be transmitted.
In addition, the rounding in Switzerland is to 5 centimes and this works in GrandTotal.

image

@kevinpapst
Copy link
Member

Aha, I was concentrating on the logic, not the cents. Kimai rounds to 2 decimals, that can't be changed.
I would transfer the hourly rate, but Grandtotal cannot use it AFAIK.

Talk to the Grandtotal developer please and explain the problem, maybe he allows to set the Einzelpreis instead of the costs in plugins.

@gises
Copy link
Author

gises commented Feb 8, 2021

Hi Kevin, i talked to Stefan from GrandTotal.
His answer
Das müsste es fixen:
'cost': aEntry['hourly_rate'] * (aItemResult["minutes"] / 60);

Could you check this

@kevinpapst
Copy link
Member

You can try it yourself. Clone the repository, change the line and then double click the directory Kimai2.grandtotalplugin.
This will import the plugin into Grandtotal.

@gises
Copy link
Author

gises commented Feb 9, 2021

Hi Kevin

Following results:
If i use the fix as proposed from Stefan i got an error message.
image

Then i tried this, and i can import in GrandTotal, but still with the false Rate since i use "rate" instead" of "hourly_rate"
image

When i switch from "rate" to "hourly_rate" there is no log or import in GrandTotal. Seems that "hourly_rate" is not transferd or maybe the wrong format.
Do you have any further idea?
Thanks in advance!

@kevinpapst
Copy link
Member

Hm, true. The hourly_rate is missing in these objects. That needs to be fixed in Kimai first.
You could try to calculate the hourly_rate first (var hourlyRate = aEntry['rate'] / aEntry['duration'] * 3600) and then apply the next steps.

@gises
Copy link
Author

gises commented Feb 9, 2021

Hi Kevin

I think this is a dead end. Even if I calculate it this way, the rounding problem remains. The only solution in my eyes would be if the "hourly_rate" can be transferred to GrandTotal as stored in Kimai. I write this again to Stefan from GrandTotal

@kevinpapst
Copy link
Member

Maybe I am wrong, but I don't think that it matter if you calculate the hourly rate or if it comes from Kimai. There should be no difference for the algorithm.

       var hourlyRate = aEntry['rate'] / aEntry['duration'] * 3600
       var minutes = Math.round(aEntry['duration'] / 60);
        var aItemResult = {
            'startDate': aEntry['begin'],
            'client': '',
            'project': '',
            'minutes': minutes,
            'notes': aEntry['description'] !== null ? aEntry['description'] : '',
            'label': aEntry['tags'].join(", "),
            'user': aEntry['user'],
            'cost': hourlyRate * minutes / 60,
            'uid': 'com.kimai2.' + aEntry['id'],
        };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants