Skip to content

Commit

Permalink
[CBS-24108] - Replaced type checking by using putPojo function
Browse files Browse the repository at this point in the history
  • Loading branch information
singh-sukhvir committed Sep 9, 2024
1 parent 0e99ca5 commit 6a3ded8
Showing 1 changed file with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Object> additionalDetails = ImmutableMap.of("taxRate", taxRate, "parentItemId", parentItemID);
final String parentItemID = adjustmentItem == null ? taxableItem.getId().toString() : adjustmentItem.getId().toString();
final Map<String, Object> additionalDetails = ImmutableMap.of("taxRate", taxRate, "parentItemId", parentItemID);
final String taxItemDetails = appendItemDetails(taxItem.getItemDetails(), additionalDetails);

return new PluginInvoiceItem(new Builder<>()
Expand Down Expand Up @@ -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<String, Object> detail : additionalDetails.entrySet()) {
existingItemsDetailsJson.putPOJO(detail.getKey(), detail.getValue());
}
itemDetailsWithAdditionalInfo = existingItemsDetailsJson;
} else {
Expand Down

0 comments on commit 6a3ded8

Please sign in to comment.