-
-
Save totten/831da81e5d02918bcb9f to your computer and use it in GitHub Desktop.
Making a broad but concrete+simple interface to event registration + contributions + memberships. A few simplifications (which seem acceptable): there's no need to create arbitrary line items; line-items are only created in the context of a participant/membership/contribution. At most, you might tweak the line-item that's autogenerated.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface CiviInvoice { | |
/** | |
* Add details about a registration which a constituent would like to purchase. | |
* | |
* @param Participant $participant | |
* The event-registration which would be purchased. | |
* @return LineItem | |
* A new line item which represents the would-be registration. | |
*/ | |
function addParticipant($participant); | |
/** | |
* @param Contribution $contribution | |
* @return LineItem | |
*/ | |
function addContribution($contribution); | |
/** | |
* @param Membership $membership | |
* @return LineItem | |
*/ | |
function addMembership($membership); | |
/** | |
* @param Payment $payment | |
*/ | |
function addPayment($payment); | |
/** | |
* @return array<LineItem> | |
*/ | |
function getLineItems(); | |
/** | |
* @return LineItem | |
*/ | |
function getLineItem(int $lineItemID); | |
/** | |
* @return Participant|Membership|Contribution | |
*/ | |
function getLineItemTarget($int $lineItemID); | |
function getPayments(); | |
function removeLineItem(int $lineItemID) | |
} | |
// Usage | |
$ci = new CiviInvoice(); | |
$ci->addMembership(...membership1...); | |
$ci->addMembership(...membershp2...); | |
$ci->addContribution(...); | |
$entityManager->persist($ci); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment