Skip to content

Feature Add positions DTOs and enhance invoicing #32

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kaspernowak
Copy link
Contributor

@kaspernowak kaspernowak commented Jun 15, 2025

This PR introduces complete support for creating and sending invoices using structured DTOs, including all supported Bexio position types.

✅ What’s Included

  • New DTOs for all invoice position types:
    • AddDefaultPositionDTO
    • AddTextPositionDTO
    • ...and others under src/Dto/*
  • New request classes:
    • CreateAnInvoiceRequestNew
    • EditAnInvoiceRequestNew
    • SendAnInvoiceRequest
    • MarkAnInvoiceAsSentRequest
    • ...and Create, Edit, Delete, Fetch, and FetchList requests for all position types
  • New test coverage for the above requests and DTOs
  • Support for sending and marking invoices as sent via SendInvoiceDTO

💡 Usage Example

$invoiceDto = new CreateInvoiceDTO(
    title: 'Test',
    contact_id: $contacts->first()->id,
    // ...
    positions: [
        new AddTextPositionDTO(
            type: 'KbPositionText',
            text: (string) Str::uuid(),
            show_pos_nr: true
        ),
        new AddDefaultPositionDTO(
            type: 'KbPositionCustom',
            amount: 1,
            unit_id: $units->first()->id,
            account_id: 145,
            tax_id: $taxes->first()->id,
            text: Str::uuid(),
            unit_price: 100,
        ),
    ],
);

$invoice = $connector->send(new CreateAnInvoiceRequestNew(invoice: $invoiceDto))->dto();

$send = $connector->send(new SendAnInvoiceRequest(...));
$markAsSent = $connector->send(new MarkAnInvoiceAsSentRequest(...));

⚠️ Compatibility Note

The existing CreateAnInvoiceRequest class appears to be incompatible with the documented example due to a type mismatch in the filterPositions() method:

Argument #1 ($positions) must be of type Collection, array given

To avoid breaking changes, I've added new request classes (CreateAnInvoiceRequestNew, etc.) that work with the new DTO structure.
We may want to decide whether to:

  • Fix and maintain the old request for compatibility
  • Or deprecate it and focus solely on the updated approach

closes #7

@StanBarrows StanBarrows self-assigned this Jun 15, 2025
@StanBarrows StanBarrows marked this pull request as draft June 15, 2025 17:11
@kaspernowak kaspernowak marked this pull request as ready for review June 17, 2025 12:46
@kaspernowak kaspernowak force-pushed the feature/add-dtos-for-positions-and-enhance-invoicing branch from 20011fd to 14fefa3 Compare June 20, 2025 12:37
@StanBarrows StanBarrows requested a review from RhysLees June 30, 2025 22:46
@StanBarrows StanBarrows assigned RhysLees and unassigned StanBarrows Jun 30, 2025
@StanBarrows
Copy link
Contributor

@kaspernowak
We’ve just completed the OAuth PR and will take a closer look at this in the coming weeks.

@kaspernowak
Copy link
Contributor Author

kaspernowak commented Jul 2, 2025

@StanBarrows Thank you! Looking forward to it. I think this would have higher prio than #34, as the structured addresses won't really be required before December.

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

Successfully merging this pull request may close these issues.

Feature Request | Invoice Endpoints
3 participants