kevinpapst / ImportBundle

A Kimai plugin to import data from the Web UI
https://www.kimai.org/store/keleo-importer-bundle.html
Other
4 stars 1 forks source link

If project with same name exists multiple times, importer will create even more #11

Closed codiflow closed 8 months ago

codiflow commented 8 months ago

Describe the issue

This is just a small bug which I tested with a recent installation of Kimai Docker, with the newest Importer plugin version and with the CSV import. Don't know if the JSON import is affected too.

If the project name contains a dash (e.g. like in the German word IT-Dienstleistungen) the Importer plugin always creates a new project for all timesheet entries with this name on each import.

What I did: I precreated a project named IT-Dienstleistungen in Kimai and specified the same project name in my CSV file. But the Importer always creates a new project named IT-Dienstleistungen which is linked to the specific customer for every import (not every record).

As soon as I remove the dash from the precreated project name and adjust the CSV file accordingly it behaves correctly and appends the records to the already existing project in Kimai.

Kimai version

2.9.0

How do you run Kimai?

Docker

kevinpapst commented 8 months ago

Tested with this file: timesheet (1).csv

First import created 2 projects (as expected). Next import created 0 projects.

You could debug this place, maybe something is odd with the customer name (try commenting line 419)? https://github.com/kevinpapst/ImportBundle/blob/424279914bef11c5b10fe6a6e462383a7fb1b502/Importer/AbstractTimesheetImporter.php#L413-L421

codiflow commented 8 months ago

That's right and that never was an issue. 😉

But as soon as those projects are already existing in Kimai (having created them manually AND beforehand and not by an import) the bug appears 😎

codiflow commented 8 months ago

I really don't get it. I did some more tests on this issue as the dash does not seem to be the cause. But as soon as the project is named IT-Dienstleistungen the issue appears. Also with a completely new created customer.

In my installation there are multiple projects named IT-Dienstleistungen but they are all assigned to another customer and during my tests I could confirm that two projects with the same name on different customers are not triggering this.

kevinpapst commented 8 months ago

Just tested, only 4 rows are imported if I create the projects manually before. Add a working test-case CSV please, otherwise I am not putting more of lifetime into this.

codiflow commented 8 months ago

I'm working on it – just a few minutes :-)

kevinpapst commented 8 months ago

Posting at the same time usually is weird. Take your time, it is Saturday evening anyway...

codiflow commented 8 months ago

This is my project list with a test customer Testkunde and one letter stripped from the end of IT-Dienstleistungen so it is only IT-Dienstleistunge:

image

This is the CSV file where the import works:

Date,From,To,Duration,Rate,User,Customer,Project,Activity,Description,Exported,Tags,HourlyRate,FixedRate,InternalRate
2024-01-05,15:15:00,15:30:00,900,,user@domain.de,Testkunde,IT-Dienstleistunge,Arbeitszeit,Some work description,0,,,,
2024-01-05,16:15:00,16:30:00,900,,user@domain.de,Testkunde,IT-Dienstleistunge,Arbeitszeit,Some work description,0,,,,

Result – all fine: image


Changing the name to IT-Dienstleistungen in Kimai now (I also noticed that they all get the same color – don't know if thats a hint helping to track this down) and copying it to the clipboard:

image

Pasting it to the CSV file and checking twice that there are no spaces before/after the string.

This is the CSV file where the import is creating a new project:

Date,From,To,Duration,Rate,User,Customer,Project,Activity,Description,Exported,Tags,HourlyRate,FixedRate,InternalRate
2024-01-05,15:15:00,15:30:00,900,,user@domain.de,Testkunde,IT-Dienstleistungen,Arbeitszeit,Some work description,0,,,,
2024-01-05,16:15:00,16:30:00,900,,user@domain.de,Testkunde,IT-Dienstleistungen,Arbeitszeit,Some work description,0,,,,

Result - project is being created although it already exists:

image

kevinpapst commented 8 months ago

Alright, with that test case, I could reproduce. Already have an idea, not sure if it is 100% fixable. I hope in the real world, there are no two customer with the same name...

codiflow commented 8 months ago

Great to hear that and glad that I could be of some help here 😎

I work around it by just renaming the project temporarily for the import and renaming it back afterwards. As I've just a few customers to import the additional efford is acceptable.

By the way: THANKS for this great piece of software. It's a pleasure to use it ðŸĨ°

I hope in the real world, there are no two customer with the same name...

As long as people don't use first and last name as customer names this should not be the case ðŸĪŠ

If that's not fixable a note in the importer would be enough I think. Every migration needs some manual adjustments so I don't think all edge cases must be addressed at any time by the software.

kevinpapst commented 8 months ago

https://github.com/kevinpapst/ImportBundle/releases/tag/2.9.0