group InvoicePayment;
invoicePaymentFields(prefix) ::= <<
<prefix>invoice_id,
<prefix>payment_attempt_id,
<prefix>payment_attempt_date,
<prefix>amount,
<prefix>currency,
<prefix>created_date
>>
create() ::= <<
INSERT INTO invoice_payments(<invoicePaymentFields()>)
VALUES(:invoiceId, :paymentAttemptId, :paymentAttemptDate, :amount, :currency, :createdDate);
>>
batchCreateFromTransaction() ::= <<
INSERT INTO invoice_payments(<invoicePaymentFields()>)
VALUES(:invoiceId, :paymentAttemptId, :paymentAttemptDate, :amount, :currency, :createdDate);
>>
getByPaymentAttemptId() ::= <<
SELECT <invoicePaymentFields()>
FROM invoice_payments
WHERE payment_id = :paymentAttemptId;
>>
get() ::= <<
SELECT <invoicePaymentFields()>
FROM invoice_payments;
>>
getPaymentsForInvoice() ::= <<
SELECT <invoicePaymentFields()>
FROM invoice_payments
WHERE invoice_id = :invoiceId;
>>
notifyOfPaymentAttempt() ::= <<
INSERT INTO invoice_payments(<invoicePaymentFields()>)
VALUES(:invoiceId, :paymentAttemptId, :paymentAttemptDate, :amount, :currency, NOW());
>>
getInvoicePayment() ::= <<
SELECT <invoicePaymentFields()>
FROM invoice_payments
WHERE payment_id = :payment_id;
>>
test() ::= <<
SELECT 1 FROM invoice_payments;
>>
;