本文整理汇总了Java中org.killbill.billing.invoice.api.Invoice类的典型用法代码示例。如果您正苦于以下问题:Java Invoice类的具体用法?Java Invoice怎么用?Java Invoice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Invoice类属于org.killbill.billing.invoice.api包,在下文中一共展示了Invoice类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: sendEmailForUpComingInvoice
import org.killbill.billing.invoice.api.Invoice; //导入依赖的package包/类
private void sendEmailForUpComingInvoice(final Account account, final ExtBusEvent killbillEvent, final TenantContext context) throws IOException, InvoiceApiException, EmailException, TenantApiException, EmailNotificationException {
Preconditions.checkArgument(killbillEvent.getEventType() == ExtBusEventType.INVOICE_NOTIFICATION, String.format("Unexpected event %s", killbillEvent.getEventType()));
final String dryRunTimePropValue = configProperties.getString(INVOICE_DRY_RUN_TIME_PROPERTY);
Preconditions.checkArgument(dryRunTimePropValue != null, String.format("Cannot find property %s", INVOICE_DRY_RUN_TIME_PROPERTY));
final TimeSpan span = new TimeSpan(dryRunTimePropValue);
final DateTime now = clock.getClock().getUTCNow();
final DateTime targetDateTime = now.plus(span.getMillis());
final PluginCallContext callContext = new PluginCallContext(EmailNotificationActivator.PLUGIN_NAME, now, context.getTenantId());
final Invoice invoice = osgiKillbillAPI.getInvoiceUserApi().triggerInvoiceGeneration(account.getId(), new LocalDate(targetDateTime, account.getTimeZone()), NULL_DRY_RUN_ARGUMENTS, callContext);
if (invoice != null) {
final EmailContent emailContent = templateRenderer.generateEmailForUpComingInvoice(account, invoice, context);
sendEmail(account, emailContent, context);
}
}
开发者ID:killbill,项目名称:killbill-email-notifications-plugin,代码行数:20,代码来源:EmailNotificationListener.java
示例2: getAlreadyTaxedItemsWithTaxes
import org.killbill.billing.invoice.api.Invoice; //导入依赖的package包/类
/**
* Get a mapping of existing taxable invoice item IDs to associated tax invoice items on an
* invoice.
*
* @param invoice
* the invoice to inspect
* @param kbTenantId
* the tenant ID
* @return the mapping, or an empty {@code Map} if no existing items available
*/
private Map<UUID, Set<UUID>> getAlreadyTaxedItemsWithTaxes(Invoice invoice, UUID kbTenantId) {
Map<UUID, Set<UUID>> alreadyTaxed = null;
try {
List<EasyTaxTaxation> taxations = dao.getTaxation(kbTenantId, invoice.getAccountId(),
invoice.getId());
if (!taxations.isEmpty()) {
if (taxations.size() == 1) {
alreadyTaxed = taxations.get(0).getInvoiceItemIds();
} else {
alreadyTaxed = new HashMap<>();
for (EasyTaxTaxation taxation : taxations) {
for (Map.Entry<UUID, Set<UUID>> entry : taxation.getInvoiceItemIds()
.entrySet()) {
alreadyTaxed.computeIfAbsent(entry.getKey(), k -> new HashSet<>())
.addAll(entry.getValue());
}
}
}
}
} catch (final SQLException e) {
log.warn("Unable to compute tax for account {}", invoice.getAccountId(), e);
}
return alreadyTaxed != null ? alreadyTaxed : Collections.emptyMap();
}
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:35,代码来源:EasyTaxTaxCalculator.java
示例3: buildInvoiceItems
import org.killbill.billing.invoice.api.Invoice; //导入依赖的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
示例4: fromPropertyValue
import org.killbill.billing.invoice.api.Invoice; //导入依赖的package包/类
/**
* Get a value from a string property value.
*
* <p>
* This will always return a value, falling back to {@code EndThenStart} if the value is
* unknown.
* </p>
*
* @param value
* the value
* @return the enum, never {@literal null}
*/
public static DateMode fromPropertyValue(String value) {
String lcValue = (value == null ? "" : value.toLowerCase());
switch (lcValue) {
case "invoice":
return DateMode.Invoice;
case "start":
return DateMode.Start;
case "startthenend":
return DateMode.StartThenEnd;
case "end":
return DateMode.End;
default:
return DateMode.EndThenStart;
}
}
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:32,代码来源:SimpleTaxDateResolver.java
示例5: createInvoiceItem
import org.killbill.billing.invoice.api.Invoice; //导入依赖的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
示例6: invoiceDateModeUsageWithStartEndDates
import org.killbill.billing.invoice.api.Invoice; //导入依赖的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
示例7: findExistingTaxCodes
import org.killbill.billing.invoice.api.Invoice; //导入依赖的package包/类
/**
* 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();
}
开发者ID:bgandon,项目名称:killbill-simple-tax-plugin,代码行数:35,代码来源:TaxCodeService.java
示例8: fieldsRelatedTo
import org.killbill.billing.invoice.api.Invoice; //导入依赖的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
示例9: shouldAdjustNegativelyIncorrectNewTaxItem
import org.killbill.billing.invoice.api.Invoice; //导入依赖的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
示例10: shouldAdjustPositivelyIncorrectNewTaxItem
import org.killbill.billing.invoice.api.Invoice; //导入依赖的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
示例11: shouldCreateMissingTaxItemInNewlyCreatedInvoice
import org.killbill.billing.invoice.api.Invoice; //导入依赖的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
示例12: shouldCreateMissingTaxItemInNewlyCreatedInvoiceWithAdjustment
import org.killbill.billing.invoice.api.Invoice; //导入依赖的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
示例13: shouldSupportNullListOfCustomFields
import org.killbill.billing.invoice.api.Invoice; //导入依赖的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
示例14: shouldAllowEmptyListOfCustomFields
import org.killbill.billing.invoice.api.Invoice; //导入依赖的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
示例15: shouldAllowNonTaxRelatedCustomFields
import org.killbill.billing.invoice.api.Invoice; //导入依赖的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
示例16: shouldSupportRemovingTaxCodesOnHistoricalInvoices
import org.killbill.billing.invoice.api.Invoice; //导入依赖的package包/类
@Test(groups = "fast")
public void shouldSupportRemovingTaxCodesOnHistoricalInvoices() throws Exception {
// Given
initCatalogStub();
Invoice newInvoice = invoiceD;
withInvoices(invoiceH, 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(), tax3.get().getId());
assertEquals(item1.getAmount(), new BigDecimal("-2.00"));
assertEquals(item1.getInvoiceId(), invoiceH.getId());
assertEquals(item1.getStartDate(), invoiceH.getInvoiceDate());
assertEquals(items.size(), 1);
}
开发者ID:bgandon,项目名称:killbill-simple-tax-plugin,代码行数:22,代码来源:TestSimpleTaxPlugin.java
示例17: taxInvoiceItemsForInvoiceItem
import org.killbill.billing.invoice.api.Invoice; //导入依赖的package包/类
private List<InvoiceItem> taxInvoiceItemsForInvoiceItem(final Account account,
final Invoice newInvoice, final InvoiceItem taxableItem, final String taxZone,
final BigDecimal netItemAmount, final LocalDate utcToday, final UUID kbTenantId,
final Map<String, String> planToProductCache) throws SQLException {
DateTime taxDate = taxDateForInvoiceItem(kbTenantId, account, newInvoice, taxableItem);
if (taxDate == null) {
// use the current date; should this be configurable (i.e. to bail if not found)?
taxDate = clock.getUTCNow();
}
String productName = productNameForInvoiceItem(taxableItem, planToProductCache, kbTenantId);
List<EasyTaxTaxCode> taxCodes = dao.getTaxCodes(kbTenantId, taxZone, productName, null,
taxDate);
if (taxCodes == null || taxCodes.isEmpty()) {
return Collections.emptyList();
}
final EasyTaxConfig config = configurationHandler.getConfigurable(kbTenantId);
final int scale = config.getTaxScale();
final RoundingMode roundingMode = config.getTaxRoundingMode();
List<InvoiceItem> newTaxItems = new ArrayList<>();
for (EasyTaxTaxCode taxCode : taxCodes) {
InvoiceItem taxItem = buildTaxItem(taxableItem, newInvoice.getId(), utcToday,
taxCode.getTaxRate().multiply(netItemAmount).setScale(scale, roundingMode),
taxCode.getTaxCode());
if (taxItem != null) {
newTaxItems.add(taxItem);
}
}
return newTaxItems;
}
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:30,代码来源:EasyTaxTaxCalculator.java
示例18: taxZoneForInvoice
import org.killbill.billing.invoice.api.Invoice; //导入依赖的package包/类
@Override
public String taxZoneForInvoice(UUID kbTenantId, Account account, Invoice invoice,
Iterable<PluginProperty> properties) {
// look first for property-specified zone
String taxZone = checkForTaxZoneInCustomFields(account,
new EasyTaxTenantContext(kbTenantId, account.getId()));
if (taxZone == null && isUseAccountCountryAsTaxZone() && account != null) {
// fall back to account country
taxZone = account.getCountry();
}
return taxZone;
}
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:15,代码来源:AccountCustomFieldTaxZoneResolver.java
示例19: createInvoice
import org.killbill.billing.invoice.api.Invoice; //导入依赖的package包/类
public static Invoice createInvoice(DateTime createdDate, LocalDate invoiceDate,
List<InvoiceItem> invoiceItems) {
UUID id = UUID.randomUUID();
Invoice invoice = Mockito.mock(Invoice.class,
Mockito.withSettings().defaultAnswer(RETURNS_SMART_NULLS.get()));
when(invoice.getId()).thenReturn(id);
when(invoice.getCreatedDate()).thenReturn(createdDate);
when(invoice.getInvoiceDate()).thenReturn(invoiceDate);
when(invoice.getInvoiceItems()).thenReturn(invoiceItems);
return invoice;
}
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:12,代码来源:EasyTaxTestUtils.java
示例20: invoiceItemForTestPlan
import org.killbill.billing.invoice.api.Invoice; //导入依赖的package包/类
private InvoiceItem invoiceItemForTestPlan(Invoice invoice, InvoiceItemType type,
BigDecimal amount, UUID linkedItemId) {
InvoiceItem item = TestUtils.buildInvoiceItem(invoice, type, amount, linkedItemId);
when(item.getDescription()).thenReturn(UUID.randomUUID().toString());
when(item.getPlanName()).thenReturn(TEST_PLAN_NAME);
return item;
}
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:8,代码来源:EasyTaxTaxCalculatorTests.java
注:本文中的org.killbill.billing.invoice.api.Invoice类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论