diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-08-22 23:15:08 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-08-22 23:15:08 +0200 |
commit | c98d960d1badd1eeb834bacbc133960e2f86d304 (patch) | |
tree | fc94b246475ff387cf5aa4d8bbc3f0aa2f4b7d65 /src/backenddb/merchant-0001.sql | |
parent | 525426db10c179fcacd19487f6c22cac837b2d40 (diff) |
add currency to amounts in merchant DB
Diffstat (limited to 'src/backenddb/merchant-0001.sql')
-rw-r--r-- | src/backenddb/merchant-0001.sql | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/src/backenddb/merchant-0001.sql b/src/backenddb/merchant-0001.sql index 1c9a8aaf..bbc97828 100644 --- a/src/backenddb/merchant-0001.sql +++ b/src/backenddb/merchant-0001.sql @@ -30,12 +30,13 @@ COMMENT ON SCHEMA merchant IS 'taler-merchant data'; SET search_path TO merchant; -CREATE TYPE taler_amount +CREATE TYPE taler_amount_currency AS (val INT8 ,frac INT4 + ,curr VARCHAR(12) ); -COMMENT ON TYPE taler_amount +COMMENT ON TYPE taler_amount_currency IS 'Stores an amount, fraction is in units of 1/100000000 of the base value'; ---------------- Exchange information --------------------------- @@ -46,8 +47,8 @@ CREATE TABLE IF NOT EXISTS merchant_exchange_wire_fees ,h_wire_method BYTEA NOT NULL CHECK (LENGTH(h_wire_method)=64) ,start_date INT8 NOT NULL ,end_date INT8 NOT NULL - ,wire_fee taler_amount NOT NULL - ,closing_fee taler_amount NOT NULL + ,wire_fee taler_amount_currency NOT NULL + ,closing_fee taler_amount_currency NOT NULL ,master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64) ,UNIQUE (master_pub,h_wire_method,start_date) ); @@ -86,9 +87,7 @@ CREATE TABLE IF NOT EXISTS merchant_instances ,logo BYTEA ,address BYTEA NOT NULL ,jurisdiction BYTEA NOT NULL - ,default_max_deposit_fee taler_amount NOT NULL - ,default_max_wire_fee taler_amount NOT NULL - ,default_wire_fee_amortization INT4 NOT NULL + ,use_stefan BOOLEAN NOT NULL DEFAULT TRUE ,default_wire_transfer_delay INT8 NOT NULL ,default_pay_delay INT8 NOT NULL ,user_type INT4 @@ -100,17 +99,19 @@ COMMENT ON COLUMN merchant_instances.merchant_id COMMENT ON COLUMN merchant_instances.merchant_name IS 'legal name of the merchant as a simple string (required)'; COMMENT ON COLUMN merchant_instances.address - IS 'physical address of the merchant as a Location in JSON format (required)'; + IS 'physical address of the merchant as a location in JSON format (required)'; COMMENT ON COLUMN merchant_instances.jurisdiction - IS 'jurisdiction of the merchant as a Location in JSON format (required)'; + IS 'jurisdiction of the merchant as a location in JSON format (required)'; COMMENT ON COLUMN merchant_instances.website IS 'merchant site URL'; +COMMENT ON COLUMN merchant_instances.use_stefan + IS 'use STEFAN curve of exchange to determine acceptable fees (unless given explicitly)'; COMMENT ON COLUMN merchant_instances.email IS 'email'; COMMENT ON COLUMN merchant_instances.logo IS 'data image url'; COMMENT ON COLUMN merchant_instances.auth_hash - IS 'hash used for merchant back office Authorization, NULL for no check'; + IS 'hash used for merchant back office authorization, NULL for no check'; COMMENT ON COLUMN merchant_instances.auth_salt IS 'salt to use when hashing Authorization header before comparing with auth_hash'; COMMENT ON COLUMN merchant_instances.user_type @@ -170,7 +171,7 @@ CREATE TABLE IF NOT EXISTS merchant_inventory ,unit TEXT NOT NULL ,image BYTEA NOT NULL ,taxes BYTEA NOT NULL - ,price taler_amount NOT NULL + ,price taler_amount_currency NOT NULL ,total_stock BIGINT NOT NULL ,total_sold BIGINT NOT NULL DEFAULT 0 ,total_lost BIGINT NOT NULL DEFAULT 0 @@ -361,10 +362,10 @@ CREATE TABLE IF NOT EXISTS merchant_deposits ,deposit_timestamp INT8 NOT NULL ,coin_pub BYTEA NOT NULL CHECK (LENGTH(coin_pub)=32) ,exchange_url TEXT NOT NULL - ,amount_with_fee taler_amount NOT NULL - ,deposit_fee taler_amount NOT NULL - ,refund_fee taler_amount NOT NULL - ,wire_fee taler_amount NOT NULL + ,amount_with_fee taler_amount_currency NOT NULL + ,deposit_fee taler_amount_currency NOT NULL + ,refund_fee taler_amount_currency NOT NULL + ,wire_fee taler_amount_currency NOT NULL ,signkey_serial BIGINT NOT NULL REFERENCES merchant_exchange_signing_keys (signkey_serial) ON DELETE CASCADE ,exchange_sig BYTEA NOT NULL CHECK (LENGTH(exchange_sig)=64) @@ -391,7 +392,7 @@ CREATE TABLE IF NOT EXISTS merchant_refunds ,refund_timestamp INT8 NOT NULL ,coin_pub BYTEA NOT NULL ,reason TEXT NOT NULL - ,refund_amount taler_amount NOT NULL + ,refund_amount taler_amount_currency NOT NULL ,UNIQUE (order_serial, coin_pub, rtransaction_id) ); COMMENT ON TABLE merchant_deposits @@ -420,7 +421,7 @@ CREATE TABLE IF NOT EXISTS merchant_transfers (credit_serial INT8 GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY ,exchange_url TEXT NOT NULL ,wtid BYTEA CHECK (LENGTH(wtid)=32) - ,credit_amount taler_amount NOT NULL + ,credit_amount taler_amount_currency NOT NULL ,account_serial INT8 NOT NULL REFERENCES merchant_accounts (account_serial) ON DELETE CASCADE ,ready_time INT8 NOT NULL DEFAULT (0) @@ -456,8 +457,8 @@ CREATE TABLE IF NOT EXISTS merchant_transfer_signatures REFERENCES merchant_transfers (credit_serial) ON DELETE CASCADE ,signkey_serial BIGINT NOT NULL REFERENCES merchant_exchange_signing_keys (signkey_serial) ON DELETE CASCADE - ,wire_fee taler_amount NOT NULL - ,credit_amount taler_amount NOT NULL + ,wire_fee taler_amount_currency NOT NULL + ,credit_amount taler_amount_currency NOT NULL ,execution_time INT8 NOT NULL ,exchange_sig BYTEA NOT NULL CHECK (LENGTH(exchange_sig)=64) ); @@ -475,8 +476,8 @@ CREATE TABLE IF NOT EXISTS merchant_transfer_to_coin ,credit_serial BIGINT NOT NULL REFERENCES merchant_transfers (credit_serial) ON DELETE CASCADE ,offset_in_exchange_list INT8 NOT NULL - ,exchange_deposit_value taler_amount NOT NULL - ,exchange_deposit_fee taler_amount NOT NULL + ,exchange_deposit_value taler_amount_currency NOT NULL + ,exchange_deposit_fee taler_amount_currency NOT NULL ); CREATE INDEX IF NOT EXISTS merchant_transfers_by_credit ON merchant_transfer_to_coin @@ -491,7 +492,7 @@ COMMENT ON COLUMN merchant_transfer_to_coin.exchange_deposit_fee CREATE TABLE IF NOT EXISTS merchant_deposit_to_transfer (deposit_serial BIGINT NOT NULL REFERENCES merchant_deposits (deposit_serial) ON DELETE CASCADE - ,coin_contribution_value taler_amount NOT NULL + ,coin_contribution_value taler_amount_currency NOT NULL ,credit_serial BIGINT NOT NULL REFERENCES merchant_transfers (credit_serial) ,execution_time INT8 NOT NULL @@ -515,10 +516,10 @@ CREATE TABLE IF NOT EXISTS merchant_reward_reserves REFERENCES merchant_instances (merchant_serial) ON DELETE CASCADE ,creation_time INT8 NOT NULL ,expiration INT8 NOT NULL - ,merchant_initial_balance taler_amount NOT NULL - ,exchange_initial_balance taler_amount NOT NULL DEFAULT (0,0) - ,rewards_committed taler_amount NOT NULL DEFAULT (0,0) - ,rewards_picked_up taler_amount NOT NULL DEFAULT (0,0) + ,merchant_initial_balance taler_amount_currency NOT NULL + ,exchange_initial_balance taler_amount_currency NOT NULL + ,rewards_committed taler_amount_currency NOT NULL + ,rewards_picked_up taler_amount_currency NOT NULL ); COMMENT ON TABLE merchant_reward_reserves IS 'balances of the reserves available for rewards'; @@ -566,8 +567,8 @@ CREATE TABLE IF NOT EXISTS merchant_rewards ,justification TEXT NOT NULL ,next_url TEXT NOT NULL ,expiration INT8 NOT NULL - ,amount taler_amount NOT NULL - ,picked_up taler_amount NOT NULL DEFAULT (0, 0) + ,amount taler_amount_currency NOT NULL + ,picked_up taler_amount_currency NOT NULL ,was_picked_up BOOLEAN NOT NULL DEFAULT FALSE ); CREATE INDEX IF NOT EXISTS merchant_rewards_by_pickup_and_expiration @@ -589,7 +590,7 @@ CREATE TABLE IF NOT EXISTS merchant_reward_pickups ,reward_serial BIGINT NOT NULL REFERENCES merchant_rewards (reward_serial) ON DELETE CASCADE ,pickup_id BYTEA NOT NULL UNIQUE CHECK (LENGTH(pickup_id)=64) - ,amount taler_amount NOT NULL + ,amount taler_amount_currency NOT NULL ); COMMENT ON TABLE merchant_reward_pickups IS 'rewards that have been picked up'; |