From 6a3ded847c93767e5368df077d9124803ba4a94a Mon Sep 17 00:00:00 2001 From: Sukhvir Singh Date: Mon, 9 Sep 2024 11:08:36 -0500 Subject: [PATCH] [CBS-24108] - Replaced type checking by using putPojo function --- .../billing/plugin/vertex/VertexTaxCalculator.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/killbill/billing/plugin/vertex/VertexTaxCalculator.java b/src/main/java/org/killbill/billing/plugin/vertex/VertexTaxCalculator.java index e8fd5cf..5f8ad0b 100644 --- a/src/main/java/org/killbill/billing/plugin/vertex/VertexTaxCalculator.java +++ b/src/main/java/org/killbill/billing/plugin/vertex/VertexTaxCalculator.java @@ -325,8 +325,8 @@ private InvoiceItem createTaxInvoiceItem(final InvoiceItem taxableItem, final UU taxRate = calculatedTax.divide(taxableItem.getAmount(), 5, RoundingMode.FLOOR).doubleValue(); } - String parentItemID = adjustmentItem == null ? taxableItem.getId().toString() : adjustmentItem.getId().toString(); - Map additionalDetails = ImmutableMap.of("taxRate", taxRate, "parentItemId", parentItemID); + final String parentItemID = adjustmentItem == null ? taxableItem.getId().toString() : adjustmentItem.getId().toString(); + final Map additionalDetails = ImmutableMap.of("taxRate", taxRate, "parentItemId", parentItemID); final String taxItemDetails = appendItemDetails(taxItem.getItemDetails(), additionalDetails); return new PluginInvoiceItem(new Builder<>() @@ -379,14 +379,8 @@ private String appendItemDetails(@Nullable final String itemDetails, @Nonnull fi final Object itemDetailsWithAdditionalInfo; if (existingItemsDetailsJson != null) { - for(Map.Entry e : additionalDetails.entrySet()) { - if (e.getValue() instanceof String) { - existingItemsDetailsJson.put((String) e.getKey(), (String) e.getValue()); - } else if (e.getValue() instanceof Double) { - existingItemsDetailsJson.put((String) e.getKey(), (Double) e.getValue()); - } else { - logger.warn("Trying to add a value of unsupported type in tax item_details {}", additionalDetails.keySet()); - } + for(Map.Entry detail : additionalDetails.entrySet()) { + existingItemsDetailsJson.putPOJO(detail.getKey(), detail.getValue()); } itemDetailsWithAdditionalInfo = existingItemsDetailsJson; } else {