group BusinessAccount;

getAccount(account_key) ::= <<
  select
    account_key
  , created_date
  , updated_date
  , balance
  , tags
  , last_invoice_date
  , total_invoice_balance
  , last_payment_status
  , payment_method
  , credit_card_type
  , billing_address_country
  from bac
  where account_key=:account_key
  limit 1
  ;
>>

createAccount() ::= <<
  insert into bac(
    account_key
  , created_date
  , updated_date
  , balance
  , tags
  , last_invoice_date
  , total_invoice_balance
  , last_payment_status
  , payment_method
  , credit_card_type
  , billing_address_country
  ) values (
    :account_key
  , :created_date
  , :updated_date
  , :balance
  , :tags
  , :last_invoice_date
  , :total_invoice_balance
  , :last_payment_status
  , :payment_method
  , :credit_card_type
  , :billing_address_country
  );
>>

saveAccount() ::= <<
  update bac set
    updated_date=:updated_date
  , balance=:balance
  , tags=:tags
  , last_invoice_date=:last_invoice_date
  , total_invoice_balance=:total_invoice_balance
  , last_payment_status=:last_payment_status
  , payment_method=:payment_method
  , credit_card_type=:credit_card_type
  , billing_address_country=:billing_address_country
  where account_key=:account_key
  ;
>>

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