BillingRouter

Git Sourcearrow-up-right

Inherits: Initializable, ContextUpgradeable, HubOwnableUUPSUpgradeable, ERC165Upgradeable, IBillingRouter

Author: Daniel Yamagata & Jerry Qi

A contract for sending and paying invoices

This contract uses ContextUpgradeable to allow for future versions to use a gas relayer if desired

State Variables

BillingRouterStorageLocation

bytes32 private constant BillingRouterStorageLocation =
    0x37f3f3ea6bd3134a12f955ddfd4147e5790b22caaa1c2898646a2bd9d6b60b00;

Functions

_getBillingRouterStorage

function _getBillingRouterStorage() internal pure returns (BillingRouterStorage storage $);

onlyVendor

Reverts if the caller is not the vendor of 'invoiceId' or if the invoice does not exist

constructor

sendInvoice

Sends an invoice to a billable party. Returns the invoice ID

Anyone can pay the invoice on behalf of the billable party

Parameters

Name
Type
Description

billableParty

address

The address of the billable party

denominationAsset

address

The address of the denomination asset used for the invoice

amount

uint256

The amount of the denomination asset to be paid

dueDate

uint256

The due date of the invoice. Must be in the future

categoryId

bytes32

The category ID of the invoice. Should be the keccak256 hash of the category name. For example, the category ID of "Transportation Services" is keccak256("Transportation Services")

description

string

The description of the invoice

documentName

string

The name of the document associated with the invoice

documentUri

string

The URI of the document associated with the invoice

Returns

Name
Type
Description

<none>

bytes32

The ID of the invoice

payInvoice

Pays the invoice with 'invoiceId'

The amount paid to the vendor may be different from the amount specified in the invoice. This is due to some ERC20s having fees built into the transfer function of ERC20s.

Parameters

Name
Type
Description

invoiceId

bytes32

The ID of the invoice to be paid

Returns

Name
Type
Description

<none>

uint256

The amount of the denomination asset paid to the vendor

cancelInvoice

Cancels the invoice with 'invoiceId'

Can only be called by the invoice's vendor

Parameters

Name
Type
Description

invoiceId

bytes32

The ID of the invoice to be cancelled

updateInvoiceDocument

Updates the document related to the invoice with 'invoiceId' in the Document Registry

Can only be called by the invoice's vendor

Parameters

Name
Type
Description

invoiceId

bytes32

The ID of the invoice whose document is to be updated

updatedDocumentName

string

The updated name of the document

updatedDocumentUri

string

The updated URI of the document

Returns

Name
Type
Description

<none>

uint256

The new version of the document

hashInvoice

Returns the ID of an invoice given the invoice's parameters

The description hash can be queried via event emission

isInvoicePaid

Returns true if the invoice with 'invoiceId' has been paid, false otherwise

isInvoicePastDue

Returns true if the invoice with 'invoiceId' is past due, false otherwise

getInvoiceById

Returns the invoice with 'invoiceId' as a DataTypes.Invoice struct

_validateDenominationAsset

Reverts if 'denominationAsset' is invalid

_validateCallerIsVendor

_validateInvoiceExists

supportsInterface

ERC165 support

Structs

BillingRouterStorage