group BusinessInvoicePaymentField;

CHECK_TENANT() ::= "tenant_record_id = :tenantRecordId"
AND_CHECK_TENANT() ::= "AND <CHECK_TENANT()>"

getFieldsForInvoicePayment(payment_id) ::=<<
select
  payment_id
, name
, value
from bip_fields
where payment_id = :payment_id
<AND_CHECK_TENANT()>
;
>>

addField(payment_id, name, value) ::=<<
insert into bip_fields (
  payment_id
, name
, value
, account_record_id
, tenant_record_id
) values (
  :payment_id
, :name
, :value
, :accountRecordId
, :tenantRecordId
);
>>

removeField(payment_id, name) ::= <<
delete from bip_fields where payment_id = :payment_id and name = :name <AND_CHECK_TENANT()>;
>>

test() ::= <<
select 1 from bip_fields where <CHECK_TENANT()>;
>>
