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

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

Closed
codiflow opened this issue Jan 13, 2024 · 10 comments

Comments

@codiflow
Copy link

codiflow commented Jan 13, 2024

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
Copy link
Owner

kevinpapst commented Jan 13, 2024

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)?

if (!\array_key_exists($cacheKey, $this->projectCache)) {
$tmpCustomer = $this->getCustomer($customer, $dryRun);
$tmpProject = $this->projectService->findProjectByName($project);
if (null !== $tmpProject && $tmpProject->getCustomer() !== null) {
if ($tmpProject->getCustomer()->getName() !== null && $tmpCustomer->getName() !== null && strcasecmp($tmpProject->getCustomer()->getName(), $tmpCustomer->getName()) !== 0) {
$tmpProject = null;
}
}

@codiflow
Copy link
Author

codiflow commented Jan 13, 2024

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
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

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

@kevinpapst
Copy link
Owner

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

@codiflow
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

codiflow commented Jan 13, 2024

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 kevinpapst changed the title If existing project has dash in name while importing timesheet new project is created If project with same name exists multiple times, importer will create even more Jan 14, 2024
@kevinpapst
Copy link
Owner

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

No branches or pull requests

2 participants