InvoicePaymentSqlDao.sql.stg

83 lines | 1.934 kB Blame History Raw Download
group InvoicePayment;

invoicePaymentFields(prefix) ::= <<
  <prefix>id,
  <prefix>invoice_id,
  <prefix>payment_attempt_id,
  <prefix>payment_attempt_date,
  <prefix>amount,
  <prefix>currency,
  <prefix>created_by,
  <prefix>created_date
>>

create() ::= <<
  INSERT INTO invoice_payments(<invoicePaymentFields()>)
  VALUES(:id, :invoiceId, :paymentAttemptId, :paymentAttemptDate, :amount, :currency, :userName, :createdDate);
>>

batchCreateFromTransaction() ::= <<
  INSERT INTO invoice_payments(<invoicePaymentFields()>)
  VALUES(:id, :invoiceId, :paymentAttemptId, :paymentAttemptDate, :amount, :currency, :userName, :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(:id, :invoiceId, :paymentAttemptId, :paymentAttemptDate, :amount, :currency, :userName, :createdDate);
>>

getInvoicePayment() ::= <<
    SELECT <invoicePaymentFields()>
    FROM invoice_payments
    WHERE payment_id = :payment_id;
>>

getRecordId() ::= <<
    SELECT record_id
    FROM invoice_payments
    WHERE id = :id;
>>

getRecordIds() ::= <<
    SELECT record_id, id
    FROM invoice_payments
    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, :reasonCode, :comment, :userToken);
>>

test() ::= <<
  SELECT 1 FROM invoice_payments;
>>
;