sageserpent-open / plutonium

CQRS providing bitemporal object modelling for Java POJOs and Scala too.
MIT License
5 stars 0 forks source link

Set up account for new customer. #65

Open sageserpent-open opened 5 years ago

sageserpent-open commented 5 years ago

This is a story for the epic #64.

sageserpent-open commented 5 years ago

To open an account for a new customer, we need to receive details that identify a customer; the name and billing address being sufficient for now.

The account should also refer to a metered address that may or may not be the same as the customer's billing address.

The question arises, how does the system know about metered addresses? Does it need to know anything other than the address to set up a customer?

How do we prove that a customer has been set up? Could we query by customer name and billing address, or just by customer name, or by metered address?

We certainly shouldn't be able to set up the same customer with the same billing address more than once.

Hmm, it seems reasonable that an account refers to one and only one metered address (possibly several meters at that metered address). Should a customer therefore be able to setup several accounts using the same billing address but for different metered properties - the landlord option?

Yes, but here we are setting up an account for a new customer.

There is not much point in having a customer with no addresses that are metered (this includes the possibility of the billing address being metered, but the customer not having an account for it, at least not with the utility company), so this should not be a legitimate use case - although for the future, we might want to keep track of a customer / billing address combination even though all of their accounts are closed.

sageserpent-open commented 5 years ago

Feature: Set up account for new customer

An account connects a unique customer to a metered address, which could be a separate address to the customer's billing address.

Scenario: Successful set up

In this use case, the business has never dealt with this customer before, and the metered address is not already claimed by some other account. For now, we do not consider the possibility that some other utility may have an account for this metered address.

Given new <customer> with <billingAddress>
And a <meteredAddress> that is not connected to an existing account
When an account is opened
Then an account id is produced

Scenario: Query new account by account id

Given a new <accountId> for new <customer> with <billingAddress> and <meteredAddress>
When a query is made via <accountId>
Then the account details will reference <customer> with <billingAddress> and <meteredAddress>

Scenario: Failure due to an existing account

In this use case, the business already has an account set up for the same customer / billing address combination for the same metered address.

Given an existing <accountId> for new <customer> with <billingAddress> and <meteredAddress>
When an account is opened
Then an exception is raised stating the existing <accountId>