PaymentAttemptSqlDao.sql.stg

79 lines | 1.87 kB Blame History Raw Download
group PaymentAttemptSqlDao: EntitySqlDao;


tableFields(prefix) ::= <<
  <prefix>payment_id
, <prefix>gateway_error_code
, <prefix>gateway_error_msg
, <prefix>processing_status
, <prefix>requested_amount
, <prefix>created_by
, <prefix>created_date
, <prefix>updated_by
, <prefix>updated_date
>>

tableValues() ::= <<
  :paymentId
, :gatewayErrorCode
, :gatewayErrorMsg
, :processingStatus
, :requestedAmount
, :createdBy
, :createdDate
, :updatedBy
, :updatedDate
>>


insertPaymentAttempt() ::= <<
    INSERT INTO payment_attempts (<paymentAttemptFields()>)
    VALUES (:id, :paymentId, :gatewayErrorCode, :gatewayErrorMsg, :processingStatus, :requestedAmount, :userName,
            :createdDate, :userName, :createdDate, :accountRecordId, :tenantRecordId);
>>

getPaymentAttempt() ::= <<
    SELECT <paymentAttemptFields("pa.")>
    , pa.created_date as effective_date
    , p.account_id as account_id
    , p.invoice_id as invoice_id
      FROM payment_attempts pa join payments p
     WHERE pa.id = :id 
     AND pa.payment_id = p.id
     <AND_CHECK_TENANT("pa.")>
     <AND_CHECK_TENANT("p.")>
     ;
>>

getPaymentAttempts() ::= <<
    SELECT <paymentAttemptFields("pa.")>
    , pa.created_date as effective_date
    , p.account_id as account_id
    , p.invoice_id as invoice_id
      FROM payment_attempts pa join payments p
     WHERE pa.payment_id = :paymentId
     AND p.id = :paymentId
     <AND_CHECK_TENANT("pa.")>
     <AND_CHECK_TENANT("p.")>
     ORDER BY effective_date ASC;
>>

updatePaymentAttemptStatus() ::= <<
    UPDATE payment_attempts
    SET processing_status = :processingStatus,
        gateway_error_code = :gatewayErrorCode,
        gateway_error_msg = :gatewayErrorMsg        
    WHERE  id = :id
    <AND_CHECK_TENANT()>
    ;
>>


getPaymentAttemptIdFromPaymentId() ::= <<
    SELECT id
    FROM payment_attempts
    WHERE payment_id = :paymentId
    <AND_CHECK_TENANT()>
    ;
>>