group BusinessInvoicePayment;

getInvoicePayment(payment_id) ::= <<
select
  payment_id
, created_date
, updated_date
, ext_payment_ref_id
, account_key
, invoice_id
, effective_date
, amount
, currency
, payment_error
, processing_status
, requested_amount
, plugin_name
, payment_type
, payment_method
, card_type
, card_country
, invoice_payment_type
, linked_invoice_payment_id
from bip
where payment_id = :payment_id
limit 1
;
>>

getInvoicePaymentsForAccountByKey(account_key) ::= <<
select
  payment_id
, created_date
, updated_date
, ext_payment_ref_id
, account_key
, invoice_id
, effective_date
, amount
, currency
, payment_error
, processing_status
, requested_amount
, plugin_name
, payment_type
, payment_method
, card_type
, card_country
, invoice_payment_type
, linked_invoice_payment_id
from bip
where account_key = :account_key
order by created_date asc
;
>>

createInvoicePayment() ::= <<
insert into bip (
  payment_id
, created_date
, updated_date
, ext_payment_ref_id
, account_key
, invoice_id
, effective_date
, amount
, currency
, payment_error
, processing_status
, requested_amount
, plugin_name
, payment_type
, payment_method
, card_type
, card_country
, invoice_payment_type
, linked_invoice_payment_id
) values (
  :payment_id
, :created_date
, :updated_date
, :ext_payment_ref_id
, :account_key
, :invoice_id
, :effective_date
, :amount
, :currency
, :payment_error
, :processing_status
, :requested_amount
, :plugin_name
, :payment_type
, :payment_method
, :card_type
, :card_country
, :invoice_payment_type
, :linked_invoice_payment_id
);
>>

deleteInvoicePayment(payment_id) ::= <<
delete from bip where payment_id = :payment_id
>>

test() ::= <<
select 1 from bip;
>>
