Update ofxrecord amount to valid monetary numeric type
We don't want no floats around here, this is money. This stuff matters. I also took the time to align up my comments so they are purtier
This commit is contained in:
parent
d479ca3850
commit
459a1b2960
|
@ -0,0 +1,27 @@
|
|||
"""fix currency type
|
||||
|
||||
Revision ID: eac3a08698a7
|
||||
Revises: 00f2b77f1d2c
|
||||
Create Date: 2016-07-01 11:54:56.272364
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'eac3a08698a7'
|
||||
down_revision = '00f2b77f1d2c'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
if not op.get_context().as_sql:
|
||||
connection = op.get_bind()
|
||||
connection.execution_options(isolation_level='AUTOCOMMIT')
|
||||
|
||||
op.execute('ALTER TABLE ofxrecord ALTER COLUMN amount TYPE NUMERIC(20, 2) USING amount::numeric;')
|
||||
|
||||
def downgrade():
|
||||
pass
|
|
@ -1,6 +1,6 @@
|
|||
import chryso.constants
|
||||
from sqlalchemy import (Column, Date, DateTime, Float, ForeignKey, Integer,
|
||||
MetaData, String, Table, UniqueConstraint, func, text)
|
||||
from sqlalchemy import (Column, Date, DateTime, ForeignKey, Integer, MetaData,
|
||||
Numeric, String, Table, UniqueConstraint, func, text)
|
||||
from sqlalchemy.dialects.postgresql import UUID
|
||||
|
||||
metadata = MetaData(naming_convention=chryso.constants.CONVENTION)
|
||||
|
@ -66,12 +66,12 @@ OFXUpdate = table('ofxupdate',
|
|||
)
|
||||
|
||||
OFXRecord = table('ofxrecord',
|
||||
Column('amount', Float(), nullable=False), # The amount of the record, like -177.91
|
||||
Column('available', Date(), nullable=True), # The date the record was available
|
||||
Column('amount', Numeric(precision=20, scale=2, asdecimal=True), nullable=False), # The amount of the record, like -177.91
|
||||
Column('available', Date(), nullable=True), # The date the record was available
|
||||
Column('fid', String(255), nullable=False), # The Financial institution's ID
|
||||
Column('name', String(1024), nullable=False), # The name of the record, like 'UT SLC SAMSCLUB #4719'
|
||||
Column('memo', String(2048), nullable=True), # The memo of the transaction, like 'POINT OF SALE PURCHASE #0005727'
|
||||
Column('memo', String(2048), nullable=True), # The memo of the transaction, like 'POINT OF SALE PURCHASE #0005727'
|
||||
Column('ofxaccount', None, ForeignKey(OFXAccount.c.uuid, name='fk_ofxaccount'), nullable=False),
|
||||
Column('posted', Date(), nullable=True), # The date the record posted
|
||||
Column('type', String(255), nullable=True), # The type of the record, like 'POS'
|
||||
Column('posted', Date(), nullable=True), # The date the record posted
|
||||
Column('type', String(255), nullable=True), # The type of the record, like 'POS'
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue