/**
* Find tax codes that apply to the items of a given invoice, looking for
* custom fields named {@value #TAX_CODES_FIELD_NAME} that can be attached
* to these items.
*
* @param invoice
* An invoice in which existing tax codes are to be found.
* @return The existing tax codes, grouped by the identifiers of their
* related invoice items. Never {@code null}, and guaranteed not
* having any {@code null} values.
* @throws NullPointerException
* when {@code invoice} is {@code null}.
*/
@Nonnull
public SetMultimap<UUID, TaxCode> findExistingTaxCodes(Invoice invoice) {
Set<CustomField> taxFields = taxFieldsOfInvoices.get(invoice.getId());
// Note: taxFields is not null, by Multimap contract
ImmutableSetMultimap.Builder<UUID, TaxCode> taxCodesOfInvoiceItems = ImmutableSetMultimap.builder();
for (CustomField taxField : taxFields) {
if (!TAX_CODES_FIELD_NAME.equals(taxField.getFieldName())) {
continue;
}
String taxCodesCSV = taxField.getFieldValue();
if (taxCodesCSV == null) {
continue;
}
UUID invoiceItemId = taxField.getObjectId();
Set<TaxCode> taxCodes = cfg.findTaxCodes(taxCodesCSV, "from custom field '" + TAX_CODES_FIELD_NAME
+ "' of invoice item [" + invoiceItemId + "]");
taxCodesOfInvoiceItems.putAll(invoiceItemId, taxCodes);
}
return taxCodesOfInvoiceItems.build();
}
TaxCodeService.java 文件源码
java
阅读 21
收藏 0
点赞 0
评论 0
项目:killbill-simple-tax-plugin
作者:
评论列表
文章目录