group RefundSqlDao: EntitySqlDao;

tableName() ::= "refunds"

historyTableName() ::= "refund_history"

tableFields(prefix) ::= <<
  <prefix>account_id
, <prefix>payment_id
, <prefix>amount
, <prefix>currency
, <prefix>processed_amount
, <prefix>processed_currency
, <prefix>is_adjusted
, <prefix>refund_status
, <prefix>created_by
, <prefix>created_date
, <prefix>updated_by
, <prefix>updated_date
>>

tableValues() ::= <<
:accountId
, :paymentId
, :amount
, :currency
, :processedAmount
, :processedCurrency
, :isAdjusted
, :refundStatus
, :createdBy
, :createdDate
, :updatedBy
, :updatedDate
>>

updateStatus(refundStatus) ::= <<
update <tableName()>
set refund_status = :refundStatus
, processed_amount = :processedAmount
, processed_currency = :processedCurrency
where id = :id
<AND_CHECK_TENANT()>
;
>>

getRefundsForPayment(paymentId)  ::= <<
select <allTableFields()>
from <tableName()>
where payment_id = :paymentId
<AND_CHECK_TENANT()>
;
>>

getRefundsForAccount(accountId)  ::= <<
select <allTableFields()>
from <tableName()>
where account_id = :accountId
<AND_CHECK_TENANT()>
;
>>
