group FixedPriceInvoiceItemSqlDao;
fields(prefix) ::= <<
<prefix>id,
<prefix>invoice_id,
<prefix>account_id,
<prefix>bundle_id,
<prefix>subscription_id,
<prefix>plan_name,
<prefix>phase_name,
<prefix>start_date,
<prefix>end_date,
<prefix>amount,
<prefix>currency,
<prefix>created_by,
<prefix>created_date
>>
getById() ::= <<
SELECT <fields()>
FROM fixed_invoice_items
WHERE id = :id;
>>
getInvoiceItemsByInvoice() ::= <<
SELECT <fields()>
FROM fixed_invoice_items
WHERE invoice_id = :invoiceId;
>>
getInvoiceItemsByAccount() ::= <<
SELECT <fields("rii.")>
FROM fixed_invoice_items rii
INNER JOIN invoices i ON i.id = rii.invoice_id
WHERE i.account_id = :accountId;
>>
getInvoiceItemsBySubscription() ::= <<
SELECT <fields()>
FROM fixed_invoice_items
WHERE subscription_id = :subscriptionId;
>>
create() ::= <<
INSERT INTO fixed_invoice_items(<fields()>)
VALUES(:id, :invoiceId, :accountId, :bundleId, :subscriptionId, :planName, :phaseName,
:startDate, :endDate, :amount, :currency, :userName, :createdDate);
>>
batchCreateFromTransaction() ::= <<
INSERT INTO fixed_invoice_items(<fields()>)
VALUES(:id, :invoiceId, :accountId, :bundleId, :subscriptionId, :planName, :phaseName,
:startDate, :endDate, :amount, :currency, :userName, :createdDate);
>>
getRecordIds() ::= <<
SELECT record_id, id
FROM fixed_invoice_items
WHERE invoice_id = :invoiceId;
>>
auditFields(prefix) ::= <<
<prefix>table_name,
<prefix>record_id,
<prefix>change_type,
<prefix>change_date,
<prefix>changed_by,
<prefix>reason_code,
<prefix>comments,
<prefix>user_token
>>
insertAuditFromTransaction() ::= <<
INSERT INTO audit_log(<auditFields()>)
VALUES(:tableName, :recordId, :changeType, :createdDate, :userName, NULL, NULL, NULL);
>>
test() ::= <<
SELECT 1
FROM fixed_invoice_items;
>>
;