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

Question on Invoice without Templates #1

Open
labor4 opened this issue Nov 30, 2019 · 3 comments
Open

Question on Invoice without Templates #1

labor4 opened this issue Nov 30, 2019 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@labor4
Copy link

labor4 commented Nov 30, 2019

Hi Kevin
Thanks for this extensive hero demo of a plugin.
I was able to achieve some things with it, and learn how to survive better, in general...
Still, Symfony is a long way to go.

I'm now trying to re-implement my old Indesign XML Exporter from V1.

But at this stage I think I need to ask directly, since I seem to hit a solid wall, and from the past hours of trial'n'error it seems wise:

I extended the plugin with an exporter, that I think will serve as a minimum to get Indesign XML out in the end. However I also tried the "Invoice" route, since it allows userland'ish restrictions.

  • Is it true that all of the up-to-now implemented ways to do Invoice are (forced) template based?
  • Is it true that everything based on RendererInterface does require a template?
  • Is final class ServiceInvoice the place where templates-are-mandatory is hardcoded? Or where would be the place to build a hook on?

I'm not sure if there is a benefit in a template for this kind of playout, but maybe I'm wrong.

Best wishes
Manu

@kevinpapst
Copy link
Member

kevinpapst commented Dec 1, 2019

Yes, all public invoice renderer are template based, but you don't have to use a template when creating the actual invoice. You can do whatever you want in your invoice renderer.

The template is just the way to tell Kimai that it should use your renderer.
Create an empty file indesign.xml and then implement a renderer:

public function supports(InvoiceDocument $document): bool
{
     return $document->getFilename() === 'indesign.xml';
}
public function render(InvoiceDocument $document, InvoiceModel $model): Response
{
    // do whatever you want, simply ignore the $document... you could even
    // send the invoice data to a web service and let them create the invoice
    // the only "limitation" is: you have to return some kind of response
    $response =  new Response();
     // ....
    return $response;
}

Is final class ServiceInvoice the place where templates-are-mandatory is hardcoded? Or where would be the place to build a hook on?

I don't think that I understand this question.

@labor4
Copy link
Author

labor4 commented Dec 1, 2019

I see thanks.
So Kimai seeing the possibility of using a template makes Kimai include it in the choice list, even though that template is empty. There's the hook!

Is final class ServiceInvoice the place where templates-are-mandatory is hardcoded? Or where would be the place to build a hook on?

I don't think that I understand this question.

I saw that I cannot change the template behaviour without going into Kimai code (and didn't know I can trick it like you say), so I thought there is no way to build on the existing methods.

I'll go on. Thanks

@labor4
Copy link
Author

labor4 commented Dec 1, 2019

Thanks for the note on the webhook. Extremely powerful indeed.

@kevinpapst kevinpapst added the documentation Improvements or additions to documentation label May 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants