01 Refactor currency handling to store amounts in GTQ: Removed currency conversion utilities, updated models and API endpoints to directly handle GTQ amounts, and modified transaction processing logic for consistency. Enhanced frontend to reflect these changes, ensuring accurate display and submission of GTQ values across the application.
Refactor GTQ storage migration: Moved the conversion logic for centavo amounts to GTQ into a new migration function, m004_convert_to_gtq_storage, ensuring proper data type changes and updates across relevant tables. This enhances clarity and maintains the integrity of the migration process.
This commit is contained in:
parent
aa71321c84
commit
c83ebf43ab
8 changed files with 157 additions and 162 deletions
|
|
@ -134,4 +134,88 @@ async def m003_add_max_daily_limit_config(db):
|
|||
ALTER TABLE satoshimachine.lamassu_config
|
||||
ADD COLUMN max_daily_limit_gtq INTEGER NOT NULL DEFAULT 2000
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
async def m004_convert_to_gtq_storage(db):
|
||||
"""
|
||||
Convert centavo storage to GTQ storage by changing data types and converting existing data.
|
||||
"""
|
||||
# Convert dca_deposits amounts from centavos to GTQ
|
||||
await db.execute(
|
||||
"""
|
||||
UPDATE satoshimachine.dca_deposits
|
||||
SET amount = CAST(amount AS DECIMAL(10,2)) / 100.0
|
||||
WHERE currency = 'GTQ'
|
||||
"""
|
||||
)
|
||||
|
||||
# Convert dca_payments amounts from centavos to GTQ
|
||||
await db.execute(
|
||||
"""
|
||||
UPDATE satoshimachine.dca_payments
|
||||
SET amount_fiat = CAST(amount_fiat AS DECIMAL(10,2)) / 100.0
|
||||
"""
|
||||
)
|
||||
|
||||
# Convert lamassu_transactions amounts from centavos to GTQ
|
||||
await db.execute(
|
||||
"""
|
||||
UPDATE satoshimachine.lamassu_transactions
|
||||
SET fiat_amount = CAST(fiat_amount AS DECIMAL(10,2)) / 100.0
|
||||
"""
|
||||
)
|
||||
|
||||
# Convert fixed_mode_daily_limit from centavos to GTQ
|
||||
await db.execute(
|
||||
"""
|
||||
UPDATE satoshimachine.dca_clients
|
||||
SET fixed_mode_daily_limit = CAST(fixed_mode_daily_limit AS DECIMAL(10,2)) / 100.0
|
||||
WHERE fixed_mode_daily_limit IS NOT NULL
|
||||
"""
|
||||
)
|
||||
|
||||
# Convert max_daily_limit_gtq in config (if already in centavos)
|
||||
await db.execute(
|
||||
"""
|
||||
UPDATE satoshimachine.lamassu_config
|
||||
SET max_daily_limit_gtq = CAST(max_daily_limit_gtq AS DECIMAL(10,2)) / 100.0
|
||||
WHERE max_daily_limit_gtq > 1000
|
||||
"""
|
||||
)
|
||||
|
||||
# Change column types to DECIMAL
|
||||
await db.execute(
|
||||
"""
|
||||
ALTER TABLE satoshimachine.dca_deposits
|
||||
ALTER COLUMN amount TYPE DECIMAL(10,2)
|
||||
"""
|
||||
)
|
||||
|
||||
await db.execute(
|
||||
"""
|
||||
ALTER TABLE satoshimachine.dca_payments
|
||||
ALTER COLUMN amount_fiat TYPE DECIMAL(10,2)
|
||||
"""
|
||||
)
|
||||
|
||||
await db.execute(
|
||||
"""
|
||||
ALTER TABLE satoshimachine.lamassu_transactions
|
||||
ALTER COLUMN fiat_amount TYPE DECIMAL(10,2)
|
||||
"""
|
||||
)
|
||||
|
||||
await db.execute(
|
||||
"""
|
||||
ALTER TABLE satoshimachine.dca_clients
|
||||
ALTER COLUMN fixed_mode_daily_limit TYPE DECIMAL(10,2)
|
||||
"""
|
||||
)
|
||||
|
||||
await db.execute(
|
||||
"""
|
||||
ALTER TABLE satoshimachine.lamassu_config
|
||||
ALTER COLUMN max_daily_limit_gtq TYPE DECIMAL(10,2)
|
||||
"""
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue