
org.killbill.billing.invoice.dao.InvoicePaymentSqlDao.sql.stg Maven / Gradle / Ivy
group InvoicePayment: EntitySqlDao;
tableName() ::= "invoice_payments"
tableFields(prefix) ::= <<
type
, invoice_id
, payment_id
, payment_date
, amount
, currency
, processed_currency
, payment_cookie_id
, linked_invoice_payment_id
, success
, created_by
, created_date
>>
tableValues() ::= <<
:type
, :invoiceId
, :paymentId
, :paymentDate
, :amount
, :currency
, :processedCurrency
, :paymentCookieId
, :linkedInvoicePaymentId
, :success
, :createdBy
, :createdDate
>>
getByPaymentId() ::= <<
SELECT
FROM
WHERE payment_id = :paymentId
;
>>
getPaymentsForCookieId() ::= <<
SELECT
FROM
WHERE payment_cookie_id = :paymentCookieId
;
>>
getPaymentsForInvoice() ::= <<
SELECT
FROM
WHERE invoice_id = :invoiceId
;
>>
getInvoicePayments() ::= <<
SELECT
FROM
WHERE payment_id = :paymentId
;
>>
getRemainingAmountPaid() ::= <<
SELECT SUM(amount)
FROM
WHERE (id = :invoicePaymentId OR linked_invoice_payment_id = :invoicePaymentId)
AND success
;
>>
getAccountIdFromInvoicePaymentId() ::= <<
SELECT i.account_id
FROM ip
INNER JOIN invoices i ON i.id = ip.invoice_id
WHERE ip.id = :invoicePaymentId
;
>>
getChargeBacksByAccountId() ::= <<
SELECT
FROM ip
INNER JOIN invoices i ON i.id = ip.invoice_id
WHERE ip.type = 'CHARGED_BACK' AND i.account_id = :accountId
;
>>
getChargebacksByPaymentId() ::= <<
SELECT
FROM
WHERE type = 'CHARGED_BACK'
AND linked_invoice_payment_id IN (SELECT id FROM invoice_payments WHERE payment_id = :paymentId)
;
>>
updateAttempt() ::= <<
UPDATE
SET payment_id := :paymentId,
payment_date = :paymentDate,
amount = :amount,
currency = :currency,
processed_currency = :processedCurrency,
payment_cookie_id = :paymentCookieId,
linked_invoice_payment_id := :linkedInvoicePaymentId,
success = true
WHERE record_id = :recordId
;
>>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy