Skip to content

[OBPIH-6666] unit tests on generating prepayment invoice#4828

Merged
ewaterman merged 2 commits intofeature/OBPIH-6398-partial-invoices-for-prepaid-pofrom
ft/OBPIH-6666-partial-prepayment-tests
Sep 5, 2024
Merged

[OBPIH-6666] unit tests on generating prepayment invoice#4828
ewaterman merged 2 commits intofeature/OBPIH-6398-partial-invoices-for-prepaid-pofrom
ft/OBPIH-6666-partial-prepayment-tests

Conversation

@ewaterman
Copy link
Member

@ewaterman ewaterman commented Sep 4, 2024

✨ Description of Change

A concise summary of what is being changed. Please provide enough context for reviewers to be able to understand the change and why it is necessary. If the issue/ticket already provides enough information, you can put "See ticket" as the description.

Link to GitHub issue or Jira ticket: https://pihemr.atlassian.net/browse/OBPIH-6666

Description: Add unit tests on PrepaymentInvoiceService.generatePrepaymentInvoice. We'll ideally also write tests on the other methods in the service but this can be a starting point.


📈 Test Plan

We require that all code changes come paired with a method of testing them. Please select which of the following testing approaches you've included with this change:

  • Frontend automation tests (unit)
  • Backend automation tests (unit, API, smoke)
  • End-to-end tests (Playwright)
  • Manual tests (please describe below)
  • Not Applicable

Description of test plan (if applicable):


✅ Quality Checks

Please confirm and check each of the following to ensure that your change conforms to the coding standards of the project:

  • The pull request title is prefixed with the issue/ticket number (Ex: [OBS-123] for Jira, [#0000] for GitHub, or [OBS-123, OBPIH-123] if there are multiple), or with [N/A] if not applicable
  • The pull request description has enough information for someone without context to be able to understand the change and why it is needed
  • The change has tests that prove the issue is fixed / the feature works as intended

@ewaterman ewaterman self-assigned this Sep 4, 2024
@github-actions github-actions bot added the type: feature A new piece of functionality for the app label Sep 4, 2024
private List<InvoiceItem> getInvoiceItemsOnOrderItems(Invoice invoice) {
return invoice.invoiceItems.stream()
.filter {ii -> ii.orderItems != null && !ii.orderItems.isEmpty()}
.collect(Collectors.toList())
Copy link
Collaborator

Choose a reason for hiding this comment

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

it's Java's approach for such operations, but in groovy you can just do:

invoice.invoiceItems.findAll { it.ordersItems != null && !it.orderItems.isEmpty() }

btw. I assume this can't be null, because it's 1:N association that is by default an empty set.

Copy link
Member Author

@ewaterman ewaterman Sep 5, 2024

Choose a reason for hiding this comment

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

You're right. Even better would be to rely on groovy truth:

invoice.invoiceItems.findAll{ it.orderItems }

@ewaterman ewaterman merged commit d1e0eac into feature/OBPIH-6398-partial-invoices-for-prepaid-po Sep 5, 2024
@ewaterman ewaterman deleted the ft/OBPIH-6666-partial-prepayment-tests branch September 5, 2024 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature A new piece of functionality for the app

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants