com.ning.billing.invoice.dao.InvoiceSqlDao.sql.stg Maven / Gradle / Ivy
group InvoiceDao: EntitySqlDao;
tableName() ::= "invoices"
tableFields(prefix) ::= <<
account_id
, invoice_date
, target_date
, currency
, migrated
, created_by
, created_date
>>
tableValues() ::= <<
:accountId
, :invoiceDate
, :targetDate
, :currency
, :migrated
, :createdBy
, :createdDate
>>
extraTableFieldsWithComma(prefix) ::= <<
, record_id as invoice_number
>>
getInvoicesByAccount() ::= <<
SELECT
FROM
WHERE account_id = :accountId AND migrated = '0'
ORDER BY target_date ASC;
>>
getAllInvoicesByAccount() ::= <<
SELECT
FROM
WHERE account_id = :accountId
ORDER BY target_date ASC;
>>
getInvoicesByAccountAfterDate() ::= <<
SELECT
FROM
WHERE account_id = :accountId AND target_date >= :fromDate AND migrated = '0'
ORDER BY target_date ASC;
>>
getInvoicesBySubscription() ::= <<
SELECT
FROM i
JOIN invoice_items ii ON i.id = ii.invoice_id
WHERE ii.subscription_id = :subscriptionId AND i.migrated = '0'
;
>>
getInvoiceIdByPaymentId() ::= <<
SELECT i.id
FROM i, invoice_payments ip
WHERE ip.invoice_id = i.id
AND ip.payment_id = :paymentId
>>