-
Notifications
You must be signed in to change notification settings - Fork 6
Validate if we can create tax item with custom details #41
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,8 @@ | |
| import org.killbill.billing.osgi.libs.killbill.OSGIKillbillAPI; | ||
| import org.killbill.billing.payment.api.PluginProperty; | ||
| import org.killbill.billing.plugin.api.PluginProperties; | ||
| import org.killbill.billing.plugin.api.invoice.PluginInvoiceItem; | ||
| import org.killbill.billing.plugin.api.invoice.PluginInvoiceItem.Builder; | ||
| import org.killbill.billing.plugin.api.invoice.PluginTaxCalculator; | ||
| import org.killbill.billing.plugin.vertex.dao.VertexDao; | ||
| import org.killbill.billing.plugin.vertex.gen.ApiException; | ||
|
|
@@ -298,7 +300,38 @@ private Collection<InvoiceItem> toInvoiceItems(final UUID invoiceId, | |
| final BigDecimal calculatedTax = transactionLineDetailModel.getCalculatedTax() != null ? BigDecimal.valueOf(transactionLineDetailModel.getCalculatedTax()) : null; | ||
| final InvoiceItem taxItem = buildTaxItem(taxableItem, invoiceId, adjustmentItem, calculatedTax, description); | ||
| if (taxItem != null) { | ||
| invoiceItems.add(taxItem); | ||
| final InvoiceItem taxItemWithEffectiveRate = transactionLineDetailModel.getEffectiveRate() != null | ||
| ? new PluginInvoiceItem(new Builder<>() | ||
| .withId(taxItem.getId()) | ||
| .withInvoiceItemType(taxItem.getInvoiceItemType()) | ||
| .withInvoiceId(taxItem.getInvoiceId()) | ||
| .withAccountId(taxItem.getAccountId()) | ||
| .withChildAccountId(taxItem.getChildAccountId()) | ||
| .withStartDate(taxItem.getStartDate()) | ||
| .withEndDate(taxItem.getEndDate()) | ||
| .withAmount(taxItem.getAmount()) | ||
| .withCurrency(taxItem.getCurrency()) | ||
| .withDescription(taxItem.getDescription()) | ||
| .withSubscriptionId(taxItem.getSubscriptionId()) | ||
| .withBundleId(taxItem.getBundleId()) | ||
| .withCatalogEffectiveDate(taxItem.getCatalogEffectiveDate()) | ||
| .withProductName(taxItem.getProductName()) | ||
| .withPrettyProductName(taxItem.getPrettyProductName()) | ||
| .withPlanName(taxItem.getPlanName()) | ||
| .withPrettyPlanName(taxItem.getPrettyPlanName()) | ||
| .withPhaseName(taxItem.getPhaseName()) | ||
| .withPrettyPhaseName(taxItem.getPrettyPhaseName()) | ||
| .withRate(taxItem.getRate()) | ||
| .withLinkedItemId(taxItem.getLinkedItemId()) | ||
| .withUsageName(taxItem.getUsageName()) | ||
| .withPrettyUsageName(taxItem.getPrettyUsageName()) | ||
| .withQuantity(taxItem.getQuantity()) | ||
| .withItemDetails(String.valueOf(transactionLineDetailModel.getEffectiveRate())) | ||
| .withCreatedDate(taxItem.getCreatedDate()) | ||
| .withUpdatedDate(taxItem.getUpdatedDate()) | ||
| .validate().build()) | ||
|
Comment on lines
+303
to
+332
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we move this to a separate function. Something like below -
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think having value "null" as a result of valueOf(null) is not what we want in this case |
||
| : taxItem; | ||
| invoiceItems.add(taxItemWithEffectiveRate); | ||
| } | ||
| } | ||
| return invoiceItems; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we discussed to save it as json considering we may want to add additional details in future.
Current format won't support that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vlaskhilkevich This PR was experimental. Feel free to create a separate PR with your changes.