group PaymentMethodSqlDao: EntitySqlDao;



tableName() ::= "payment_methods"

historyTableName() ::= "payment_method_history"

andCheckSoftDeletionWithComma(prefix) ::= "and <prefix>is_active"

tableFields(prefix) ::= <<
  <prefix>account_id
, <prefix>plugin_name
, <prefix>is_active
, <prefix>created_by
, <prefix>created_date
, <prefix>updated_by
, <prefix>updated_date
>>

tableValues() ::= <<
  :accountId
, :pluginName
, :isActive
, :createdBy
, :createdDate
, :updatedBy
, :updatedDate
>>


markPaymentMethodAsDeleted(id) ::= <<
update <tableName()>
set is_active = 0
where  id = :id
<AND_CHECK_TENANT()>
;
>>

unmarkPaymentMethodAsDeleted(id) ::= <<
update <tableName()>
set is_active = 1
where  id = :id
<AND_CHECK_TENANT()>
;
>>

getPaymentMethodIncludedDelete(accountId) ::= <<
select <allTableFields()>
from <tableName()>
where id = :id
;
>>

getByAccountId(accountId) ::= <<
select
<allTableFields()>
from <tableName()>
where account_id = :accountId
and is_active = 1
;
>>

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