Interface BillingDatabaseClient
- All Known Implementing Classes:
BillingDatabaseClientMock
public interface BillingDatabaseClient
Interface that talks about bills in the billing API. It is a layer on top of the SQL
database where we store data about bills.
- Author:
- olaa, ogronnesby
-
Method Summary
Modifier and TypeMethodDescriptionaddLineItem(com.yahoo.config.provision.TenantName tenantName, Bill.LineItem lineItem, Optional<Bill.Id> billId) Add a line item to an open billvoidcommitLineItems(com.yahoo.config.provision.TenantName tenantName, Bill.Id billId) Associate all uncommitted line items to a given bill This is only allowed if the line item has not already been associated with an billcreateBill(com.yahoo.config.provision.TenantName tenant, ZonedDateTime startTime, ZonedDateTime endTime, String agent) Create a completely new Bill in the open state with no LineItems.voiddeactivateDefaultPaymentInstrument(com.yahoo.config.provision.TenantName tenant) Deactivates the default payment instrument for a tenant, if it exists.voiddeleteLineItem(String lineItemId) Delete a line item This is only allowed if the line item has not yet been associated with an billgetCollectionMethod(com.yahoo.config.provision.TenantName tenantName) Get the current collection method for the tenant - if one has persistedgetDefaultPaymentInstrumentForTenant(com.yahoo.config.provision.TenantName from) getPlan(com.yahoo.config.provision.TenantName tenantName) Return the plan for the given tenantgetPlanCount(List<com.yahoo.config.provision.TenantName> tenants, Plan defaultPlan) Returns a map with the count of plan usage.Return the plan for the given tenants if present.getUnusedLineItems(com.yahoo.config.provision.TenantName tenantName) voidmaintain()Performs necessary maintenance operationsRead the given bill from the data sourceRead all bills, ordered by datereadBillsForTenant(com.yahoo.config.provision.TenantName tenant) Get all bills for a given tenant, ordered by datebooleansetActivePaymentInstrument(InstrumentOwner paymentInstrument) voidsetCollectionMethod(com.yahoo.config.provision.TenantName tenantName, CollectionMethod collectionMethod) Set the collection method for the tenantvoidsetExportedInvoiceId(Bill.Id billId, String invoiceId) Set the invoice id from an external system for the given billvoidsetExportedInvoiceItemId(String lineItemId, String invoiceItemId) Set the invoice item id from an external system for the given line itemvoidSet the current plan for the given tenantvoidsetStatus(Bill.Id billId, String agent, BillStatus status) Set status for the given bill
-
Method Details
-
setActivePaymentInstrument
-
getDefaultPaymentInstrumentForTenant
Optional<InstrumentOwner> getDefaultPaymentInstrumentForTenant(com.yahoo.config.provision.TenantName from) -
createBill
Bill.Id createBill(com.yahoo.config.provision.TenantName tenant, ZonedDateTime startTime, ZonedDateTime endTime, String agent) Create a completely new Bill in the open state with no LineItems.- Parameters:
tenant- The name of the tenant the bill is foragent- The agent that created the bill- Returns:
- The Id of the new bill
-
readBill
Read the given bill from the data source- Parameters:
billId- The Id of the bill to retrieve- Returns:
- The Bill if it exists, Optional.empty() if not.
-
readBillsForTenant
Get all bills for a given tenant, ordered by date- Parameters:
tenant- The name of the tenant- Returns:
- List of all bills ordered by date
-
readBills
Read all bills, ordered by date- Returns:
- List of all bills ordered by date
-
addLineItem
String addLineItem(com.yahoo.config.provision.TenantName tenantName, Bill.LineItem lineItem, Optional<Bill.Id> billId) Add a line item to an open bill- Parameters:
lineItem- The line item to addbillId- The optional ID of the bill this line item is for- Returns:
- The Id of the new line item
- Throws:
RuntimeException- if the bill is not in OPEN state
-
setStatus
Set status for the given bill- Parameters:
billId- The ID of the bill this status is foragent- The agent that added the statusstatus- The new status of the bill
-
getUnusedLineItems
-
deleteLineItem
Delete a line item This is only allowed if the line item has not yet been associated with an bill- Parameters:
lineItemId- The ID of the line item- Throws:
RuntimeException- if the line item is associated with an bill
-
commitLineItems
Associate all uncommitted line items to a given bill This is only allowed if the line item has not already been associated with an bill- Parameters:
tenantName- The tenant we want to commit line items forbillId- The ID of the line item- Throws:
RuntimeException- if the line item is already associated with an bill
-
getPlan
Return the plan for the given tenant- Parameters:
tenantName- The tenant to retrieve the plan for- Returns:
- Optional.of the plan if present in DN, else Optional.empty
-
getPlans
Map<com.yahoo.config.provision.TenantName,Optional<Plan>> getPlans(List<com.yahoo.config.provision.TenantName> tenants) Return the plan for the given tenants if present. If the database does not know of the tenant, the tenant is not included in the result. -
getPlanCount
default Map<Plan,Long> getPlanCount(List<com.yahoo.config.provision.TenantName> tenants, Plan defaultPlan) Returns a map with the count of plan usage. Plans that are not in use will not appear in this result. -
setPlan
Set the current plan for the given tenant- Parameters:
tenantName- The tenant to set the plan forplan- The plan to use
-
deactivateDefaultPaymentInstrument
void deactivateDefaultPaymentInstrument(com.yahoo.config.provision.TenantName tenant) Deactivates the default payment instrument for a tenant, if it exists. Used during tenant deletion -
getCollectionMethod
Get the current collection method for the tenant - if one has persisted- Returns:
- Optional.empty if no collection method has been persisted for the tenant
-
setCollectionMethod
void setCollectionMethod(com.yahoo.config.provision.TenantName tenantName, CollectionMethod collectionMethod) Set the collection method for the tenant- Parameters:
tenantName- The name of the tenant to set collection method forcollectionMethod- The collection method for the tenant
-
maintain
void maintain()Performs necessary maintenance operations -
setExportedInvoiceId
Set the invoice id from an external system for the given bill -
setExportedInvoiceItemId
Set the invoice item id from an external system for the given line item
-