When deleting an article is accounting time also corrected

I just added an article that was actually already added before.
So I deleted the second article but the accouting time does not seem to change.
Is this a bug or a feature? :slight_smile:
Regards, Jeroen

As far as I’m aware from how Zammad stores accounting information, this is a feature (@thorsteneckel might correct me here).

Reason for this:
Articles are not directly linked to time accounting values, so with deleting an article, you’re actually not removing time. :slight_smile:

Ticket Articles are actually directly linked to TimeAccounting entries:

So I’d agree that this is a bug and should get fixed. A contribution / Pull Request would be awesome!

1 Like

Hm, Love to. Have to learn Ruby first though. Sorry.

I bet you’d enjoy it :slight_smile: However, we should create an issue so anyone fixing it will have a reference and know what to do.

Sure. In the meantime, I already have the Ruby books to start learning. :grin:. It’s just… time.

2 Likes

Issue opened, see: https://github.com/zammad/zammad/issues/2620

1 Like

How did you delete the second article?

Below the article on the right side is a delete icon.

Ah, thank you! (Seems like email articles can’t be deleted though.)

Correct, via UI, you can only delete Notes(no telephony notes) if you are the creator of this article.

I couldn’t find anything on how to delete an article via API – or better: rails console. Would you mind sharing a snippet? :slight_smile:

Console:

Ticket::Article.find({Article-ID}).destroy

As for API:

DELETE               /api/v1/ticket_articles/:id(.:format)                                                   ticket_articles#destroy
1 Like

Great, thank you—but how would I know the article ID? :slight_smile:

1 Like

Hmm… well

Ticket.find({Ticket-ID}).article_ids

or if you don’t know the Ticket-ID

Ticket.find_by(number: {Ticket-Number}).article_ids

:wink:

2 Likes

Sorry for asking once again, but:

irb(main):006:0> Ticket.find_by({33039056}).article_ids
Traceback (most recent call last):
SyntaxError ((irb):6: syntax error, unexpected ‘}’, expecting =>)
Ticket.find_by({33039056}).article_ids
^
irb(main):007:0> Ticket.find_by(33039056).article_ids
Traceback (most recent call last):
1: from (irb):7
ArgumentError (Unsupported argument type: 33039056 (Integer))

What am I doing wrong?

You might want to remove {} which was just my example to show you that you want to replace this value with the real value.

Edit: As for the find_by, that’s my bad, you’ll want to add number: in front of the ticket number. Sorry.

1 Like

Thank you very much! :slight_smile:

1 Like

Hi there! :wave:t2: I just found out that you can use negative values to subtract from the accounted time.

(Of course this is not exactly the thing you (or maybe others) want and I’m glad the team ist working on the issue, but in the meantime this could be a viable workaround for some of you.)

1 Like

As far as I’m aware adding negative numbers of timeaccounting is a wanted behaviour from our point of view. Honestly it saved me dozens of times already, when my fat fingers were doing things they weren’t supposed to.

1 Like