Skip to content

Conversation

@wscourge
Copy link
Contributor

@wscourge wscourge commented Dec 30, 2025

Testing instructions:

config = Config("API_KEY")
invoice = Invoice.retrieve(
    config,
    uuid="inv_{uuid}",
    validation_type="all",
    include_edit_histories=True,
    with_disabled=True
).get()
invoice.disabled
invoice.disabled_at
invoice.disabled_by
invoice.errors
invoice.edit_history_summary

@wscourge wscourge force-pushed the wiktor/ome-418-add-validation_type-support-to-invoices-line-items-and branch from 45cc3fb to b21f44a Compare December 30, 2025 13:46
@wscourge wscourge requested a review from Copilot December 30, 2025 13:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds test coverage for query parameter handling in invoice retrieval operations. The tests verify that the retrieve() and all() methods correctly accept and pass query parameters like validation_type, include_edit_histories, and with_disabled to the API.

Key Changes

  • Added tests for single query parameter (validation_type) handling in both retrieve() and all() methods
  • Added comprehensive tests verifying multiple query parameters are correctly passed in API requests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

wscourge and others added 4 commits December 30, 2025 15:29
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@wscourge wscourge requested a review from loomchild December 31, 2025 11:53
@loomchild loomchild self-assigned this Dec 31, 2025
Copy link

@loomchild loomchild left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks OK, I have some minor comments.

But I don't know how to test it and whether adding extra fields was intentional.

Copy link
Contributor

@pkopac pkopac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address @loomchild 's comments.

@wscourge wscourge changed the title Add tests confirming that retrieve accepts query params Add disabled, disabled_at, edit_history_summary and errors fields to Invoice Jan 2, 2026
Copy link

@loomchild loomchild left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment and changes.

All fields work for me except edit_history_summary (see below)

Could you also provide some examples of failed invoices (in alpha or production), as I was only getting empty results?

disabled = fields.Boolean(allow_none=True)
disabled_at = fields.DateTime(allow_none=True)
disabled_by = fields.String(allow_none=True)
edit_history_summary = fields.Dict(allow_none=True)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[major] When trying to retrieve this field from few random invoices in production, I get:

AttributeError: 'Invoice' object has no attribute 'edit_history_summary'

Could you confirm that it works for you in production using any invoice?

@loomchild
Copy link

I was able to find an invalid invoice, and the errors field is correctly reported. Don't know about disabled invoices - please check if they work as expected.

@wscourge
Copy link
Contributor Author

wscourge commented Jan 5, 2026

@loomchild thank you for the test, it helped me discover the issue. It is the same that I had with my previous PR related to listing and retrieving DataSources 😅.

I added the generic boolean query params handler to the Resource to address this in the latest commit - please take another look.

You can call Invoices / Disable an Invoice public API endpoint on any of your invoices: it produces both an edit_history_summary and the disabled* fields values.

>>> from chartmogul import Config, Invoice
>>> config = Config('XYZ')
>>> invoice = Invoice.retrieve(config, uuid='inv_2744344f-831f-4fb7-9d69-abd36e104d34', validation_type='all', include_edit_histories=True, with_disabled=True).get()
>>> invoice.edit_history_summary
{'values_changed': {'disabled_at': {'original_value': None, 'edited_value': '2026-01-05T14:03:52.498Z'}}, 'latest_edit_author': 'wiktor+onboarding@chartmogul.com', 'latest_edit_performed_at': '2026-01-05T14:03:52.544Z'}
>>> invoice.disabled
True
>>> invoice.disabled_at
datetime.datetime(2026, 1, 5, 14, 3, 52, 498000, tzinfo=UTC)
>>> invoice.disabled_by
'wiktor+onboarding@chartmogul.com'

@wscourge wscourge requested a review from loomchild January 5, 2026 14:28
Copy link

@loomchild loomchild left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I can retrieve edit histories.

See couple more comments (probably not critical):

@wscourge wscourge requested a review from loomchild January 6, 2026 11:16
@wscourge wscourge merged commit 8a860e7 into main Jan 6, 2026
6 checks passed
@wscourge wscourge deleted the wiktor/ome-418-add-validation_type-support-to-invoices-line-items-and branch January 6, 2026 13:24
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.

3 participants