本文整理汇总了Java中org.killbill.billing.invoice.api.InvoiceItem类的典型用法代码示例。如果您正苦于以下问题:Java InvoiceItem类的具体用法?Java InvoiceItem怎么用?Java InvoiceItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InvoiceItem类属于org.killbill.billing.invoice.api包,在下文中一共展示了InvoiceItem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: productNameForInvoiceItem
import org.killbill.billing.invoice.api.InvoiceItem; //导入依赖的package包/类
private String productNameForInvoiceItem(final InvoiceItem invoiceItem,
final Map<String, String> planToProductCache, final UUID kbTenantId) {
final String planName = invoiceItem.getPlanName();
if (planName == null) {
return null;
}
return planToProductCache.computeIfAbsent(planName, k -> {
try {
StaticCatalog catalog = killbillApi.getCatalogUserApi().getCurrentCatalog(null,
new EasyTaxTenantContext(kbTenantId, invoiceItem.getAccountId()));
Plan plan = catalog.findCurrentPlan(planName);
return (plan != null && plan.getProduct() != null ? plan.getProduct().getName()
: null);
} catch (CatalogApiException e) {
return null;
}
});
}
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:20,代码来源:EasyTaxTaxCalculator.java
示例2: buildInvoiceItems
import org.killbill.billing.invoice.api.InvoiceItem; //导入依赖的package包/类
private List<InvoiceItem> buildInvoiceItems(final Account account, final Invoice newInvoice,
final Invoice invoice, final Map<UUID, InvoiceItem> taxableItems,
@Nullable final Map<UUID, Collection<InvoiceItem>> adjustmentItems,
@Nullable final String originalInvoiceReferenceCode, final boolean dryRun,
final String taxZone, final Map<String, String> planToProductCache,
final UUID kbTenantId, final Map<UUID, Iterable<InvoiceItem>> kbInvoiceItems,
final LocalDate utcToday) throws SQLException {
final List<InvoiceItem> newTaxItems = new ArrayList<>();
for (final InvoiceItem taxableItem : taxableItems.values()) {
final Collection<InvoiceItem> adjustmentsForTaxableItem = adjustmentItems == null ? null
: adjustmentItems.get(taxableItem.getId());
final BigDecimal netItemAmount = adjustmentsForTaxableItem == null
? taxableItem.getAmount()
: sum(adjustmentsForTaxableItem);
newTaxItems.addAll(taxInvoiceItemsForInvoiceItem(account, newInvoice, taxableItem,
taxZone, netItemAmount, utcToday, kbTenantId, planToProductCache));
}
return newTaxItems;
}
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:21,代码来源:EasyTaxTaxCalculator.java
示例3: createInvoiceItem
import org.killbill.billing.invoice.api.InvoiceItem; //导入依赖的package包/类
public static InvoiceItem createInvoiceItem(Account account, Invoice invoice,
InvoiceItemType type, String planName, DateTime createdDate, LocalDate startDate,
LocalDate endDate, BigDecimal amount, Currency currency) {
UUID id = UUID.randomUUID();
UUID accountId = account.getId();
UUID invoiceId = invoice.getId();
InvoiceItem item = Mockito.mock(InvoiceItem.class,
Mockito.withSettings().defaultAnswer(RETURNS_SMART_NULLS.get()));
when(item.getId()).thenReturn(id);
when(item.getAccountId()).thenReturn(accountId);
when(item.getCreatedDate()).thenReturn(createdDate);
when(item.getCurrency()).thenReturn(currency);
when(item.getAmount()).thenReturn(amount);
when(item.getInvoiceId()).thenReturn(invoiceId);
when(item.getInvoiceItemType()).thenReturn(type);
when(item.getPlanName()).thenReturn(planName);
when(item.getStartDate()).thenReturn(startDate);
when(item.getEndDate()).thenReturn(endDate);
return item;
}
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:21,代码来源:EasyTaxTestUtils.java
示例4: endDateModeUsageWithStartEndDates
import org.killbill.billing.invoice.api.InvoiceItem; //导入依赖的package包/类
@Test(groups = "fast")
public void endDateModeUsageWithStartEndDates() {
// given
List<InvoiceItem> items = setupDefaultInvoice(TEST_INVOICE_DATE, TEST_START_DATE,
TEST_END_DATE);
// when
SimpleTaxDateResolver resolver = createResolver(
resolverPropertiesForDateMode(SimpleTaxDateResolver.DateMode.End));
DateTime result = resolver.taxDateForInvoiceItem(tenantId, account, invoice, items.get(0),
Collections.emptyList());
// then
Assert.assertEquals(result, TEST_END_DATE.toDateTimeAtStartOfDay(account.getTimeZone()),
"End mode resolves end date");
}
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:17,代码来源:SimpleTaxDateResolverTests.java
示例5: startDateModeUsageWithStartEndDates
import org.killbill.billing.invoice.api.InvoiceItem; //导入依赖的package包/类
@Test(groups = "fast")
public void startDateModeUsageWithStartEndDates() {
// given
List<InvoiceItem> items = setupDefaultInvoice(TEST_INVOICE_DATE, TEST_START_DATE,
TEST_END_DATE);
// when
SimpleTaxDateResolver resolver = createResolver(
resolverPropertiesForDateMode(SimpleTaxDateResolver.DateMode.Start));
DateTime result = resolver.taxDateForInvoiceItem(tenantId, account, invoice, items.get(0),
Collections.emptyList());
// then
Assert.assertEquals(result, TEST_START_DATE.toDateTimeAtStartOfDay(account.getTimeZone()),
"Start mode resolves start date");
}
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:17,代码来源:SimpleTaxDateResolverTests.java
示例6: startThenEndDateModeUsageWithStartEndDates
import org.killbill.billing.invoice.api.InvoiceItem; //导入依赖的package包/类
@Test(groups = "fast")
public void startThenEndDateModeUsageWithStartEndDates() {
// given
List<InvoiceItem> items = setupDefaultInvoice(TEST_INVOICE_DATE, TEST_START_DATE,
TEST_END_DATE);
// when
SimpleTaxDateResolver resolver = createResolver(
resolverPropertiesForDateMode(SimpleTaxDateResolver.DateMode.StartThenEnd));
DateTime result = resolver.taxDateForInvoiceItem(tenantId, account, invoice, items.get(0),
Collections.emptyList());
// then
Assert.assertEquals(result, TEST_START_DATE.toDateTimeAtStartOfDay(account.getTimeZone()),
"StartThenEnd mode resolves start date");
}
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:17,代码来源:SimpleTaxDateResolverTests.java
示例7: invoiceDateModeUsageWithStartEndDates
import org.killbill.billing.invoice.api.InvoiceItem; //导入依赖的package包/类
@Test(groups = "fast")
public void invoiceDateModeUsageWithStartEndDates() {
// given
List<InvoiceItem> items = setupDefaultInvoice(TEST_INVOICE_DATE, TEST_START_DATE,
TEST_END_DATE);
// when
SimpleTaxDateResolver resolver = createResolver(
resolverPropertiesForDateMode(SimpleTaxDateResolver.DateMode.Invoice));
DateTime result = resolver.taxDateForInvoiceItem(tenantId, account, invoice, items.get(0),
Collections.emptyList());
// then
Assert.assertEquals(result, TEST_INVOICE_DATE.toDateTimeAtStartOfDay(account.getTimeZone()),
"Invoice mode resolves invoice date");
}
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:17,代码来源:SimpleTaxDateResolverTests.java
示例8: noInvoiceDateFallbackUsage
import org.killbill.billing.invoice.api.InvoiceItem; //导入依赖的package包/类
@Test(groups = "fast")
public void noInvoiceDateFallbackUsage() {
// given
final DateTime invoiceItemCreatedDate = new DateTime();
List<InvoiceItem> items = setupDefaultInvoice(now, invoiceItemCreatedDate,
TEST_INVOICE_DATE, null, null);
// when
SimpleTaxDateResolver resolver = createResolver(
configureFallbackToInvoiceDate(new Properties(), false));
DateTime result = resolver.taxDateForInvoiceItem(tenantId, account, invoice, items.get(0),
Collections.emptyList());
// then
Assert.assertSame(result, invoiceItemCreatedDate,
"Disabling invoice date fallback resolves invoice item created date");
}
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:18,代码来源:SimpleTaxDateResolverTests.java
示例9: noInvoiceItemCreatedDateFallbackUsage
import org.killbill.billing.invoice.api.InvoiceItem; //导入依赖的package包/类
@Test(groups = "fast")
public void noInvoiceItemCreatedDateFallbackUsage() {
// given
final DateTime invoiceCreatedDate = new DateTime();
List<InvoiceItem> items = setupDefaultInvoice(invoiceCreatedDate, now, TEST_INVOICE_DATE,
null, null);
// when
SimpleTaxDateResolver resolver = createResolver(configureFallbackToInvoiceItemCreatedDate(
configureFallbackToInvoiceDate(new Properties(), false), false));
DateTime result = resolver.taxDateForInvoiceItem(tenantId, account, invoice, items.get(0),
Collections.emptyList());
// then
Assert.assertSame(result, invoiceCreatedDate,
"Disabling invoice item created date fallback resolves invoice created date");
}
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:18,代码来源:SimpleTaxDateResolverTests.java
示例10: noInvoiceCreatedDateFallbackUsage
import org.killbill.billing.invoice.api.InvoiceItem; //导入依赖的package包/类
@Test(groups = "fast")
public void noInvoiceCreatedDateFallbackUsage() {
// given
List<InvoiceItem> items = setupDefaultInvoice(now, now, TEST_INVOICE_DATE, null, null);
// when
SimpleTaxDateResolver resolver = createResolver(
configureFallbackToInvoiceCratedDate(
configureFallbackToInvoiceItemCreatedDate(
configureFallbackToInvoiceDate(new Properties(), false), false),
false));
DateTime result = resolver.taxDateForInvoiceItem(tenantId, account, invoice, items.get(0),
Collections.emptyList());
// then
Assert.assertNull(result, "Disabling invoice item created date fallback resolves null");
}
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:18,代码来源:SimpleTaxDateResolverTests.java
示例11: applicableCodeForItem
import org.killbill.billing.invoice.api.InvoiceItem; //导入依赖的package包/类
@Override
public TaxCode applicableCodeForItem(Iterable<TaxCode> taxCodes, InvoiceItem item) {
DateTimeZone accountTimeZone = account.getTimeZone();
DateTimeZone taxationTimeZone = cfg.getTaxationTimeZone();
LocalDate applicableDate = firstNonNull(item.getEndDate(), item.getStartDate());
final LocalDate taxationDate = taxationTimeZone == null ? applicableDate : convertTimeZone(applicableDate,
accountTimeZone, taxationTimeZone);
return tryFind(taxCodes, new Predicate<TaxCode>() {
@Override
public boolean apply(TaxCode taxCode) {
LocalDate startDay = taxCode.getStartingOn();
if ((startDay != null) && taxationDate.isBefore(startDay)) {
return false;
}
LocalDate stopDay = taxCode.getStoppingOn();
if ((stopDay != null) && (taxationDate.isEqual(stopDay) || taxationDate.isAfter(stopDay))) {
return false;
}
return true;
}
}).orNull();
}
开发者ID:bgandon,项目名称:killbill-simple-tax-plugin,代码行数:26,代码来源:InvoiceItemEndDateBasedResolver.java
示例12: shouldAlwaysReturnNull
import org.killbill.billing.invoice.api.InvoiceItem; //导入依赖的package包/类
@Test(groups = "fast")
public void shouldAlwaysReturnNull() {
// Given
NullTaxResolver resolver = new NullTaxResolver(null);
ImmutableSet<TaxCode> noTaxCodes = ImmutableSet.<TaxCode> of();
InvoiceItem mockItem = mock(InvoiceItem.class);
ImmutableSet<TaxCode> oneApplicableTaxCode = ImmutableSet.<TaxCode> of(new TaxCodeBuilder().build());
InvoiceItem itemWithDates = new InvoiceItemBuilder()//
.withStartDate(yesterday)//
.withEndDate(today)//
.build();
// Expect
assertNull(resolver.applicableCodeForItem(null, null));
assertNull(resolver.applicableCodeForItem(noTaxCodes, null));
assertNull(resolver.applicableCodeForItem(null, mockItem));
assertNull(resolver.applicableCodeForItem(noTaxCodes, mockItem));
assertNull(resolver.applicableCodeForItem(noTaxCodes, itemWithDates));
assertNull(resolver.applicableCodeForItem(oneApplicableTaxCode, mockItem));
assertNull(resolver.applicableCodeForItem(oneApplicableTaxCode, itemWithDates));
}
开发者ID:bgandon,项目名称:killbill-simple-tax-plugin,代码行数:22,代码来源:TestNullTaxResolver.java
示例13: fieldsRelatedTo
import org.killbill.billing.invoice.api.InvoiceItem; //导入依赖的package包/类
private List<CustomField> fieldsRelatedTo(Invoice... invoices) {
ImmutableSet.Builder<UUID> knownItemIdentifiers = ImmutableSet.builder();
for (Invoice invoice : invoices) {
for (InvoiceItem item : invoice.getInvoiceItems()) {
knownItemIdentifiers.add(item.getId());
}
}
final Set<UUID> knownItems = knownItemIdentifiers.build();
List<CustomField> fieldsForInvoices = newArrayList(filter(taxFields, new Predicate<CustomField>() {
@Override
public boolean apply(CustomField field) {
return knownItems.contains(field.getObjectId());
}
}));
return fieldsForInvoices;
}
开发者ID:bgandon,项目名称:killbill-simple-tax-plugin,代码行数:17,代码来源:TestSimpleTaxPlugin.java
示例14: shouldAdjustNegativelyIncorrectNewTaxItem
import org.killbill.billing.invoice.api.InvoiceItem; //导入依赖的package包/类
@Test(groups = "fast")
public void shouldAdjustNegativelyIncorrectNewTaxItem() throws Exception {
// Given
Invoice newInvoice = invoiceA;
withInvoices(newInvoice);
// When
List<InvoiceItem> items = plugin.getAdditionalInvoiceItems(newInvoice, properties, context);
// Then
assertTrue(items.size() >= 1);
InvoiceItem item1 = items.get(0);
assertEquals(item1.getInvoiceItemType(), ITEM_ADJ);
assertEquals(item1.getLinkedItemId(), tax1.get().getId());
assertEquals(item1.getAmount(), new BigDecimal("-0.20"));
assertEquals(item1.getInvoiceId(), invoiceA.getId());
assertEquals(item1.getStartDate(), invoiceA.getInvoiceDate());
assertEquals(items.size(), 1);
}
开发者ID:bgandon,项目名称:killbill-simple-tax-plugin,代码行数:21,代码来源:TestSimpleTaxPlugin.java
示例15: shouldAdjustPositivelyIncorrectNewTaxItem
import org.killbill.billing.invoice.api.InvoiceItem; //导入依赖的package包/类
@Test(groups = "fast")
public void shouldAdjustPositivelyIncorrectNewTaxItem() throws Exception {
// Given
initCatalogStub();
Invoice newInvoice = invoiceG;
withInvoices(newInvoice);
// When
List<InvoiceItem> items = plugin.getAdditionalInvoiceItems(newInvoice, properties, context);
// Then
assertTrue(items.size() >= 1);
InvoiceItem item1 = items.get(0);
assertEquals(item1.getInvoiceItemType(), ITEM_ADJ);
assertEquals(item1.getLinkedItemId(), tax2.get().getId());
assertEquals(item1.getAmount(), new BigDecimal("1.20"));
assertEquals(item1.getInvoiceId(), invoiceG.getId());
assertEquals(item1.getStartDate(), invoiceG.getInvoiceDate());
assertEquals(items.size(), 1);
}
开发者ID:bgandon,项目名称:killbill-simple-tax-plugin,代码行数:22,代码来源:TestSimpleTaxPlugin.java
示例16: shouldCreateMissingTaxItemInNewlyCreatedInvoice
import org.killbill.billing.invoice.api.InvoiceItem; //导入依赖的package包/类
@Test(groups = "fast")
public void shouldCreateMissingTaxItemInNewlyCreatedInvoice() throws Exception {
// Given
Invoice newInvoice = invoiceC;
withInvoices(invoiceD, newInvoice);
// When
List<InvoiceItem> items = plugin.getAdditionalInvoiceItems(newInvoice, properties, context);
// Then
assertEquals(items.size(), 1);
InvoiceItem item1 = items.get(0);
assertEquals(item1.getInvoiceId(), invoiceC.getId());
assertEquals(item1.getInvoiceItemType(), TAX);
assertEquals(item1.getLinkedItemId(), taxableC.get().getId());
assertEquals(item1.getAmount(), new BigDecimal("1.60"));
assertEquals(item1.getStartDate(), invoiceC.getInvoiceDate());
}
开发者ID:bgandon,项目名称:killbill-simple-tax-plugin,代码行数:20,代码来源:TestSimpleTaxPlugin.java
示例17: shouldCreateMissingTaxItemInNewlyCreatedInvoiceWithAdjustment
import org.killbill.billing.invoice.api.InvoiceItem; //导入依赖的package包/类
@Test(groups = "fast")
public void shouldCreateMissingTaxItemInNewlyCreatedInvoiceWithAdjustment() throws Exception {
// Given
Invoice newInvoice = invoiceE;
withInvoices(invoiceD, newInvoice);
// When
List<InvoiceItem> items = plugin.getAdditionalInvoiceItems(newInvoice, properties, context);
// Then
assertTrue(items.size() >= 1);
InvoiceItem item1 = items.get(0);
assertEquals(item1.getInvoiceId(), invoiceE.getId());
assertEquals(item1.getInvoiceItemType(), TAX);
assertEquals(item1.getLinkedItemId(), taxableE.get().getId());
assertEquals(item1.getAmount(), new BigDecimal("1.80"));
assertEquals(item1.getStartDate(), invoiceE.getInvoiceDate());
assertEquals(items.size(), 1);
}
开发者ID:bgandon,项目名称:killbill-simple-tax-plugin,代码行数:22,代码来源:TestSimpleTaxPlugin.java
示例18: shouldSupportNullListOfCustomFields
import org.killbill.billing.invoice.api.InvoiceItem; //导入依赖的package包/类
@Test(groups = "fast")
public void shouldSupportNullListOfCustomFields() throws Exception {
// Given
Account accountWithNullCustomFields = createAccount(FR);
UUID accountId = accountWithNullCustomFields.getId();
when(accountUserApi.getAccountById(accountId, context)).thenReturn(accountWithNullCustomFields);
Invoice invoice = new InvoiceBuilder(accountWithNullCustomFields)//
.withItem(new InvoiceItemBuilder().withType(RECURRING).withAmount(SIX)).build();
when(invoiceUserApi.getInvoicesByAccount(accountId, context))//
.thenReturn(asList(invoice));
when(customFieldUserApi.getCustomFieldsForAccountType(accountId, INVOICE_ITEM, context))//
.thenReturn(null);
// When
List<InvoiceItem> items = plugin.getAdditionalInvoiceItems(invoice, properties, context);
// Then
assertEquals(items.size(), 0);
}
开发者ID:bgandon,项目名称:killbill-simple-tax-plugin,代码行数:22,代码来源:TestSimpleTaxPlugin.java
示例19: shouldAllowEmptyListOfCustomFields
import org.killbill.billing.invoice.api.InvoiceItem; //导入依赖的package包/类
@Test(groups = "fast")
public void shouldAllowEmptyListOfCustomFields() throws Exception {
// Given
Account accountNoCustomFields = createAccount(FR);
UUID accountId = accountNoCustomFields.getId();
when(accountUserApi.getAccountById(accountId, context)).thenReturn(accountNoCustomFields);
Invoice invoice = new InvoiceBuilder(accountNoCustomFields)//
.withItem(new InvoiceItemBuilder().withType(RECURRING).withAmount(SIX)).build();
when(invoiceUserApi.getInvoicesByAccount(accountId, context))//
.thenReturn(asList(invoice));
when(customFieldUserApi.getCustomFieldsForAccountType(accountId, INVOICE_ITEM, context))//
.thenReturn(ImmutableList.<CustomField> of());
// When
List<InvoiceItem> items = plugin.getAdditionalInvoiceItems(invoice, properties, context);
// Then
assertEquals(items.size(), 0);
}
开发者ID:bgandon,项目名称:killbill-simple-tax-plugin,代码行数:22,代码来源:TestSimpleTaxPlugin.java
示例20: shouldAllowNonTaxRelatedCustomFields
import org.killbill.billing.invoice.api.InvoiceItem; //导入依赖的package包/类
@Test(groups = "fast")
public void shouldAllowNonTaxRelatedCustomFields() throws Exception {
// Given
Account accountNonTaxFields = createAccount(FR);
UUID accountId = accountNonTaxFields.getId();
when(accountUserApi.getAccountById(accountId, context)).thenReturn(accountNonTaxFields);
Promise<InvoiceItem> item = holder();
Invoice invoice = new InvoiceBuilder(accountNonTaxFields)//
.withItem(new InvoiceItemBuilder().withType(RECURRING).withAmount(SIX).thenSaveTo(item)).build();
when(invoiceUserApi.getInvoicesByAccount(accountId, context))//
.thenReturn(asList(invoice));
when(customFieldUserApi.getCustomFieldsForAccountType(accountId, INVOICE_ITEM, context))//
.thenReturn(asList(new CustomFieldBuilder()//
.withObjectType(INVOICE_ITEM).withObjectId(item.get().getId())//
.withFieldName("no-tax-field-name").withFieldValue(VAT_20_0).build()));
// When
List<InvoiceItem> items = plugin.getAdditionalInvoiceItems(invoice, properties, context);
// Then
assertEquals(items.size(), 0);
}
开发者ID:bgandon,项目名称:killbill-simple-tax-plugin,代码行数:25,代码来源:TestSimpleTaxPlugin.java
注:本文中的org.killbill.billing.invoice.api.InvoiceItem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论