#-*- coding: utf-8 -*-
import os

from sqlalchemy import *
from sqlalchemy import Column
from sqlalchemy.types import DateTime
from sqlalchemy.types import Integer
from sqlalchemy.types import Unicode
from vatsystem.model import *
from vatsystem.util.common import *
from vatsystem.util.db_extend import *

os.environ["NLS_LANG"] = "american_america.al32utf8"


class Table_SO(DeclarativeBase2):
    __tablename__ = 't_sales_contract_hdr'
    
    company_code          = Column(Unicode(30), nullable=False, primary_key=True)
    sales_contract_no     = Column(Unicode(30), nullable=False, primary_key=True)
    revision_no           = Column(Integer)
    revision_date         = Column(DateTime)
    issue_date            = Column(DateTime)
    order_dept            = Column(Unicode(30))
    status                = Column(Unicode(30))
    customer_code         = Column(Unicode(30))
    customer_name         = Column(Unicode(200))
    bill_address1         = Column(Unicode(200))
    bill_address2         = Column(Unicode(200))
    bill_address3         = Column(Unicode(200))
    bill_city             = Column(Unicode(200))
    bill_country          = Column(Unicode(200))
    bill_contact_per      = Column(Unicode(200))
    bill_tel              = Column(Unicode(200))
    bill_fax              = Column(Unicode(200))
    country_origin        = Column(Unicode(30))
    port_loading          = Column(Unicode(30))
    ship_mark             = Column(Unicode(2000))
    currency              = Column(Unicode(30))
    ship_addr_code        = Column(Unicode(30))
    ship_addr_desc        = Column(Unicode(200))
    ship_address1         = Column(Unicode(200))
    ship_address2         = Column(Unicode(200))
    ship_address3         = Column(Unicode(200))
    ship_city             = Column(Unicode(200))
    ship_country          = Column(Unicode(200))
    ship_contact_per      = Column(Unicode(200))
    ship_tel              = Column(Unicode(200))
    ship_fax              = Column(Unicode(200))
    destination           = Column(Unicode(30))
    port_discharge        = Column(Unicode(30))
    remarks               = Column(Unicode(2000))
    amendment             = Column(Unicode(2000))
    issue_by              = Column(Unicode(30))
    sales_contact         = Column(Unicode(200))
    cust_po_no            = Column(Unicode(30))
    cust_po_no_date       = Column(DateTime)
    reference             = Column(Unicode(30))
    other_ref             = Column(Unicode(100))
    delivery_date         = Column(DateTime)
    trade_term            = Column(Unicode(30))
    payment_terms         = Column(Unicode(30))
    ship_via              = Column(Unicode(30))
    rfq_no                = Column(Unicode(30))
    remarks_dist          = Column(Unicode(2000))
    order_amt             = Column(Numeric(17, 6))
    item_amt              = Column(Numeric(17, 6))
    total                 = Column(Numeric(17, 6))
    create_user           = Column(Unicode(30))
    create_date           = Column(DateTime)
    update_user           = Column(Unicode(30))
    update_date           = Column(DateTime)
    bill_address4         = Column(Unicode(200))
    ship_address4         = Column(Unicode(200))
    offer_sheet_no        = Column(Unicode(30))
    ae                    = Column(Unicode(30))
    exchange_rate         = Column(Numeric(17, 6))
    submitted_date        = Column(DateTime)
    cust_rev_no           = Column(Integer)
    cust_rev_date         = Column(DateTime)
    freight_paid          = Column(Unicode(30))
    freight_paid_cust     = Column(Unicode(30))
    so_type               = Column(Unicode(30))
    inv_handling          = Column(Unicode(30))
    inv_handling_remark   = Column(Unicode(2000))
    amendment_trad_chi    = Column(Unicode(2000))
    amendment_simp_chi    = Column(Unicode(2000))
    return_within_value   = Column(Numeric(17, 6))
    return_within_unit    = Column(Unicode(30))
    dr_type               = Column(Unicode(30))
    dr_pre_pack           = Column(Unicode(30))
    dr_sdd                = Column(Unicode(30))
    dr_est_delivery_time  = Column(DateTime)
    dr_delivery_time      = Column(DateTime)
    dr_forwarder          = Column(Unicode(200))
    dr_add_notes          = Column(Unicode(2000))
    dr_freight_paid_cust  = Column(Unicode(30))
    dr_freight_paid_supl  = Column(Unicode(30))
    dr_remark_for_dn      = Column(Unicode(2000))
    credit_status         = Column(Unicode(30))
    unblock               = Column(Unicode(5))
    artwork_approval_no   = Column(Unicode(30))
    open_order_amt        = Column(Numeric(17, 6))
    salesman              = Column(Unicode(30))
    old_order_dept        = Column(Unicode(30))
    inv_scheduling        = Column(Unicode(30))
    delivery_date_1       = Column(DateTime)
    delivery_date_2       = Column(DateTime)
    delivery_date_3       = Column(DateTime)
    delivery_date_4       = Column(DateTime)
    delivery_date_5       = Column(DateTime)
    delivery_date_6       = Column(DateTime)
    delivery_date_7       = Column(DateTime)
    delivery_date_8       = Column(DateTime)
    delivery_date_9       = Column(DateTime)
    delivery_date_10      = Column(DateTime)


class Table_SOD(DeclarativeBase2):
    __tablename__ = 't_sales_contract_dtl'

    company_code       = Column(Unicode(30), nullable=False, primary_key=True)
    sales_contract_no  = Column(Unicode(30), nullable=False, primary_key=True)
    line_no            = Column(Integer, nullable=False, primary_key=True) #modify by ray
    item_no            = Column(Unicode(30))
    cust_item_no       = Column(Unicode(30))
    int_item_code      = Column(Unicode(30))
    color              = Column(Unicode(30))
    siz                = Column(Unicode(30))
    description        = Column(Unicode(2000))
    qty                = Column(Numeric(17, 6))
    unit               = Column(Unicode(30))
    base_qty           = Column(Numeric(17, 6))
    base_unit          = Column(Unicode(30))
    unit_price         = Column(Numeric(17, 6))
    total_amt          = Column(Numeric(17, 6))
    item_remark        = Column(Unicode(2000))
    item_sidemark      = Column(Unicode(2000))
    item_shipmark      = Column(Unicode(2000))
    program            = Column(Unicode(50))
    brand              = Column(Unicode(50))
    item_cat           = Column(Unicode(30))
    sub_cat1           = Column(Unicode(30))
    sub_cat2           = Column(Unicode(30))
    create_user        = Column(Unicode(30))
    create_date        = Column(DateTime)
    update_user        = Column(Unicode(30))
    update_date        = Column(DateTime)
    item_status        = Column(Unicode(30))
    invoiced_qty       = Column(Numeric(17, 6))
    licensee           = Column(Unicode(30))
    user_line_no       = Column(Integer)
    brand_subline      = Column(Unicode(50))
    sub_cat3           = Column(Unicode(30))
    merchandise        = Column(Unicode(30))
    of_no              = Column(Unicode(35))
    of_item_line       = Column(Integer)
    fsc_flag           = Column(Unicode(1))


class Table_SOCharge(DeclarativeBase2):
    __tablename__ = 't_sales_contract_charges'

    company_code = Column(Unicode(30), nullable=False, primary_key=True)
    sales_contract_no = Column(Unicode(30), nullable=False, primary_key=True)
    line_no = Column(Integer, nullable=False, primary_key=True)
    charge_code = Column(Unicode(2000))
    percentage = Column(Numeric(17, 6))
    amount = Column(Numeric(17, 6))
    total = Column(Numeric(17, 6))
    create_user = Column(Unicode(30))
    create_date = Column(DateTime)
    update_user = Column(Unicode(30))
    update_date = Column(DateTime)
    desc_detail = Column(Unicode(2000))


class Table_SI(DeclarativeBase2):
    __tablename__ = 't_invoice_hdr'

    company_code          = Column(Unicode(30), nullable=False, primary_key=True)
    invoice_no            = Column(Unicode(30), nullable=False, primary_key=True)
    invoice_date          = Column(DateTime)
    invoice_due_date      = Column(DateTime)
    revision_no           = Column(Integer)
    revision_date         = Column(DateTime)
    status                = Column(Unicode(30))
    department            = Column(Unicode(30))
    dn_no                 = Column(Unicode(30))
    customer              = Column(Unicode(200))
    bill_to               = Column(Unicode(200))
    bill_to_remark        = Column(Unicode(2000))
    pay_term              = Column(Unicode(30))
    trade_term            = Column(Unicode(30))
    currency              = Column(Unicode(30))
    vessel                = Column(Unicode(30))
    ship_via              = Column(Unicode(30))
    port_of_loading       = Column(Unicode(30))
    port_of_discharge     = Column(Unicode(30))
    user_code             = Column(Unicode(30))
    sailing_date          = Column(DateTime)
    destination           = Column(Unicode(30))
    buyer                 = Column(Unicode(30))
    reference             = Column(Unicode(30))
    remark                = Column(Unicode(2000))
    create_user           = Column(Unicode(30))
    create_date           = Column(DateTime)
    update_user           = Column(Unicode(30))
    update_date           = Column(DateTime)
    sc_no                 = Column(Unicode(30))
    order_amt             = Column(Numeric(17, 6))
    item_amt              = Column(Numeric(17, 6))
    total                 = Column(Numeric(17, 6))
    base_outstanding_amt  = Column(Numeric(17, 6))
    outstanding_amt       = Column(Numeric(17, 6))
    exchange_rate         = Column(Numeric(17, 6))
    bill_address1         = Column(Unicode(200))
    bill_address2         = Column(Unicode(200))
    bill_address3         = Column(Unicode(200))
    bill_address4         = Column(Unicode(200))
    bill_city             = Column(Unicode(200))
    bill_country          = Column(Unicode(200))
    bill_contact_per      = Column(Unicode(200))
    bill_tel              = Column(Unicode(200))
    bill_fax              = Column(Unicode(200))
    ref_no                = Column(Unicode(200))
    auto_send_email       = Column(Unicode(30))
    inv_handling          = Column(Unicode(30))
    inv_handling_remark   = Column(Unicode(2000))
    customer_name         = Column(Unicode(200))
    cust_account_code     = Column(Unicode(30))
    cust_contact_acc      = Column(Unicode(100))
    cust_po_no            = Column(Unicode(30))
    so_sales_contact      = Column(Unicode(200))
    customer_short_name   = Column(Unicode(200))
    pay_term_credit_date  = Column(Integer)
    artwork_approval_no   = Column(Unicode(30))
    delivery_date         = Column(DateTime)
    salesman              = Column(Unicode(30))


class Table_SID(DeclarativeBase2):
    __tablename__ = 't_invoice_dtl'

    company_code     = Column(Unicode(30), nullable=False, primary_key=True)
    invoice_no       = Column(Unicode(30), nullable=False, primary_key=True)
    line_no          = Column(Integer, nullable=False, primary_key=True)
    sc_no            = Column(Unicode(30))
    item_no          = Column(Unicode(30))
    cust_item_no     = Column(Unicode(30))
    model_ref_no     = Column(Unicode(30))
    cust_po_no       = Column(Unicode(30))
    item_desc        = Column(Unicode(2000))
    qty              = Column(Numeric(17, 6))
    unit             = Column(Unicode(30))
    unit_price       = Column(Numeric(17, 6))
    item_total       = Column(Numeric(17, 6))
    country_origin   = Column(Unicode(30))
    create_user      = Column(Unicode(30))
    create_date      = Column(DateTime)
    update_user      = Column(Unicode(30))
    update_date      = Column(DateTime)
    sc_item_line_no  = Column(Integer)
    color            = Column(Unicode(30))
    siz              = Column(Unicode(30))
    int_item_code    = Column(Unicode(30))


class Table_SICharge(DeclarativeBase2):
    __tablename__ = 't_invoice_charges'

    company_code = Column(Unicode(30), nullable=False, primary_key=True)
    invoice_no = Column(Unicode(30), nullable=False, primary_key=True)
    line_no = Column(Integer, nullable=False, primary_key=True)
    charge_code = Column(Unicode(2000))
    percentage = Column(Numeric(17, 6))
    amount = Column(Numeric(17, 6))
    total = Column(Numeric(17, 6))
    create_user = Column(Unicode(30))
    create_date = Column(DateTime)
    update_user = Column(Unicode(30))
    update_date = Column(DateTime)
    desc_detail = Column(Unicode(2000))
    sc_charge_line_no = Column(Integer)
    sc_no = Column(Unicode(30))


class Table_RI(DeclarativeBase2):
    __tablename__ = 't_cust_note_hdr'

    company_code         = Column(Unicode(30), nullable=False, primary_key=True)
    note_no              = Column(Unicode(30), nullable=False, primary_key=True)
    note_type            = Column(Unicode(30))
    note_due_date        = Column(DateTime)
    revision_no          = Column(Integer)
    revision_date        = Column(DateTime)
    status               = Column(Unicode(30))
    sc_no                = Column(Unicode(30))
    customer             = Column(Unicode(30))
    department           = Column(Unicode(30))
    ccy                  = Column(Unicode(30))
    tot_item_amt         = Column(Numeric(17, 6))
    total_chg_discount   = Column(Numeric(17, 6))
    net_amt              = Column(Numeric(17, 6))
    remark               = Column(Unicode(2000))
    exchange_rate        = Column(Numeric(17, 6))
    create_user          = Column(Unicode(30))
    create_date          = Column(DateTime)
    update_user          = Column(Unicode(30))
    update_date          = Column(DateTime)
    note_date            = Column(DateTime)
    ref_code             = Column(Unicode(100))
    ref_code_2           = Column(Unicode(100))
    ref_code_3           = Column(Unicode(100))
    invoice_no           = Column(Unicode(30))
    dn_return            = Column(Unicode(30))
    cust_po_no           = Column(Unicode(30))
    designation          = Column(Unicode(30))
    auto_send_email      = Column(Unicode(30))
    customer_name        = Column(Unicode(200))
    artwork_approval_no  = Column(Unicode(30))
    stock_adjustment_no  = Column(Unicode(30))
 
    
    
class Table_RIDetail(DeclarativeBase2):
    __tablename__ = 't_cust_note_dtl'

    company_code          = Column(Unicode(30), nullable=False, primary_key=True)
    note_no               = Column(Unicode(30), nullable=False, primary_key=True)
    line_no               = Column(Integer, primary_key=True)
    item_no               = Column(Unicode(30))
    int_item_no           = Column(Unicode(30))
    ref_no                = Column(Unicode(30))
    cust_po_no            = Column(Unicode(30))
    item_desc             = Column(Unicode(2000))
    note_qty              = Column(Numeric(17, 6))
    unit                  = Column(Unicode(30))
    unit_price            = Column(Numeric(17, 6))
    item_total            = Column(Numeric(17, 6))
    country_origin        = Column(Unicode(30))
    create_user           = Column(Unicode(30))
    create_date           = Column(DateTime)
    update_user           = Column(Unicode(30))
    update_date           = Column(DateTime)
    siz                   = Column(Unicode(30))
    color                 = Column(Unicode(30))
    sc_item_line_no       = Column(Integer)
    sc_no                 = Column(Unicode(30))
    invoice_no            = Column(Unicode(30))
    invoice_item_line_no  = Column(Integer)
    int_item_code         = Column(Unicode(30))



class Table_RICharge(DeclarativeBase2):
    __tablename__ = 't_cust_note_charges'

    company_code = Column(Unicode(30), nullable=False, primary_key=True)
    note_no = Column(Unicode(30), nullable=False, primary_key=True)
    line_no = Column(Integer, nullable=False, primary_key=True)
    chg_discount_code = Column(Unicode(2000))
    description = Column(Unicode(2000))
    percentage = Column(Numeric(17, 6))
    amount = Column(Numeric(17, 6))
    total = Column(Numeric(17, 6))
    create_user = Column(Unicode(30))
    create_date = Column(DateTime)
    update_user = Column(Unicode(30))
    update_date = Column(DateTime)


class Table_Customer(DeclarativeBase2):
    __tablename__ = 't_cust_hdr'

    company_code          = Column(Unicode(30), nullable=False, primary_key=True)
    line_no               = Column(Integer, nullable=False, primary_key=True)
    cust_code             = Column(Unicode(30), nullable=False)
    account_code          = Column(Unicode(30))
    cust_name             = Column(Unicode(200))
    cust_short_name       = Column(Unicode(200))
    status                = Column(Unicode(30))
    cust_group            = Column(Unicode(30))
    cust_type             = Column(Unicode(30))
    address_1             = Column(Unicode(200))
    address_2             = Column(Unicode(200))
    address_3             = Column(Unicode(200))
    postal_code           = Column(Unicode(200))
    city                  = Column(Unicode(200))
    country               = Column(Unicode(200))
    banker                = Column(Unicode(200))
    br_no                 = Column(Unicode(30))
    discount              = Column(Numeric(17, 6))
    courier               = Column(Unicode(30))
    courier_acc           = Column(Unicode(30))
    tel_no                = Column(Unicode(200))
    extension             = Column(Unicode(30))
    fax_no                = Column(Unicode(200))
    contact_sales         = Column(Unicode(100))
    contact_ship          = Column(Unicode(100))
    contact_acc           = Column(Unicode(100))
    email                 = Column(Unicode(200))
    web_page              = Column(Unicode(200))
    base_ccy              = Column(Unicode(30))
    pay_term              = Column(Unicode(30))
    check_credit          = Column(Integer, default=1)
    trade_term            = Column(Unicode(30))
    destination           = Column(Unicode(30))
    discharge             = Column(Unicode(30))
    remark                = Column(Unicode(2000))
    address_4             = Column(Unicode(200))
    credit_days           = Column(Integer)
    create_user           = Column(Unicode(30))
    create_date           = Column(DateTime)
    update_user           = Column(Unicode(30))
    update_date           = Column(DateTime)
    cust_code_dummy       = Column(Unicode(30))
    invoice_spec          = Column(Unicode(30))
    auto_send_email       = Column(Unicode(30))
    email_to              = Column(Unicode(300))
    email_cc              = Column(Unicode(300))
    email_bcc             = Column(Unicode(300))
    inv_handling          = Column(Unicode(30))
    inv_handling_remark   = Column(Unicode(2000))
    blocking              = Column(Unicode(30))
    credit_status         = Column(Unicode(30))
    grace_percent         = Column(Numeric(17, 6))
    grace_amount          = Column(Numeric(17, 6))
    pay_term_credit_date  = Column(Integer)
    department            = Column(Unicode(30))
    finance_remarks       = Column(Unicode(2000))
    first_approval        = Column(Unicode(1))
    changed               = Column(Unicode(1))
    invoice_date          = Column(DateTime)
    open_order_amt        = Column(Numeric(17, 6))
    old_line_no           = Column(Integer)



class Table_Supplier(DeclarativeBase2):
    __tablename__ = 't_supl_hdr'
    
    company_code     = Column(Unicode(30), nullable=False, primary_key=True)
    line_no          = Column(Integer)
    supl_code        = Column(Unicode(30))
    supl_code_dummy  = Column(Unicode(30))
    account_code     = Column(Unicode(30))
    supl_name        = Column(Unicode(200))
    supl_short_name  = Column(Unicode(200))
    status           = Column(Unicode(30))
    input_date       = Column(DateTime)
    ownership        = Column(Unicode(2000))
    management       = Column(Unicode(2000))
    banker           = Column(Unicode(30))
    br_no            = Column(Unicode(30))
    web_page         = Column(Unicode(100))
    address_1        = Column(Unicode(200))
    address_2        = Column(Unicode(200))
    address_3        = Column(Unicode(200))
    postal_code      = Column(Unicode(200))
    city             = Column(Unicode(200))
    country          = Column(Unicode(200))
    tel_no           = Column(Unicode(200))
    extension        = Column(Unicode(30))
    fax_no           = Column(Unicode(200))
    contact_person1  = Column(Unicode(200))
    position1        = Column(Unicode(200))
    email1           = Column(Unicode(200))
    contact_person2  = Column(Unicode(200))
    position2        = Column(Unicode(200))
    email2           = Column(Unicode(200))
    contact_person3  = Column(Unicode(200))
    position3        = Column(Unicode(200))
    email3           = Column(Unicode(200))
    background       = Column(Unicode(2000))
    price_level      = Column(Unicode(30))
    base_ccy         = Column(Unicode(30))
    port_of_loading  = Column(Unicode(30))
    pay_term         = Column(Unicode(30))
    penalty_clauses  = Column(Unicode(30))
    create_user      = Column(Unicode(30))
    create_date      = Column(DateTime)
    update_user      = Column(Unicode(30))
    update_date      = Column(DateTime)
    beneficiary      = Column(Unicode(200))
    address_4        = Column(Unicode(200))
    trade_term       = Column(Unicode(30))
    department       = Column(Unicode(30))
    first_approval   = Column(Unicode(1))
    changed          = Column(Unicode(1))
    approval_date    = Column(DateTime)
    old_line_no      = Column(Integer) 
    fsc_flag         = Column(Unicode(1))
    fsc_cert_no      = Column(Unicode(30))
    
    
class Table_PI(DeclarativeBase2):
    __tablename__ = 't_purchase_invoice_hdr'

    company_code        = Column(Unicode(30), nullable=False, primary_key=True)
    purchase_invoice_no = Column(Unicode(30), nullable=False, primary_key=True)
    invoice_date        = Column(DateTime)
    invoice_due_date    = Column(DateTime)
    revision_no         = Column(Integer)
    revision_date       = Column(DateTime)
    status              = Column(Unicode(30))
    department          = Column(Unicode(30))
    supplier            = Column(Unicode(200))
    pay_term            = Column(Unicode(30))
    currency            = Column(Unicode(30))
    remark              = Column(Unicode(2000))
    create_user         = Column(Unicode(30))
    create_date         = Column(DateTime)
    update_user         = Column(Unicode(30))
    update_date         = Column(DateTime)
    order_amt           = Column(Numeric(17, 6))
    item_amt            = Column(Numeric(17, 6))
    total               = Column(Numeric(17, 6))
    po_no               = Column(Unicode(30))
    exchange_rate       = Column(Integer)
    ref_code            = Column(Unicode(100))
    ref_code_2          = Column(Unicode(100))
    ref_code_3          = Column(Unicode(100))
    supplier_name       = Column(Unicode(200))
    supplier_short_name = Column(Unicode(200))
    artwork_approval_no = Column(Unicode(30))
    delivery_date       = Column(DateTime)
    fsc_cert_no         = Column(Unicode(30))
    
     
class Table_PID(DeclarativeBase2):
    __tablename__ = 't_purchase_invoice_dtl'

    company_code        = Column(Unicode(30), nullable=False, primary_key=True)
    purchase_invoice_no = Column(Unicode(30), nullable=False, primary_key=True)
    line_no             = Column(Integer, nullable=False, primary_key=True)
    grn_line_no         = Column(Integer)
    item_no             = Column(Unicode(30))
    int_item_no         = Column(Unicode(30))
    po_no               = Column(Unicode(30))
    grn_no              = Column(Unicode(30))
    item_desc           = Column(Unicode(2000))
    qty                 = Column(Numeric(17, 6))
    unit                = Column(Unicode(30))
    unit_price          = Column(Numeric(17, 6))
    item_total          = Column(Numeric(17, 6))
    create_user         = Column(Unicode(30))
    create_date         = Column(DateTime)
    update_user         = Column(Unicode(30))
    update_date         = Column(DateTime)
    siz                 = Column(Unicode(30))
    color               = Column(Unicode(30))
    dtl_dept            = Column(Unicode(30))
    currency            = Column(Unicode(30))
    exchange_rate       = Column(Numeric(17, 6))
    po_line_no          = Column(Integer)
    supplier            = Column(Unicode(30))
    supplier_name       = Column(Unicode(200))
    supplier_short_name = Column(Unicode(200))
    po_type             = Column(Unicode(30))
    int_item_code       = Column(Unicode(30))
    sales_contract_no   = Column(Unicode(30))
    sc_line_no          = Column(Integer)
    sc_ship_line_no     = Column(Integer)


class Table_PICharge(DeclarativeBase2):
    __tablename__ = 't_purchase_invoice_charges'

    company_code        = Column(Unicode(30), nullable=False, primary_key=True)
    purchase_invoice_no = Column(Unicode(30), nullable=False, primary_key=True)
    line_no             = Column(Integer, nullable=False, primary_key=True)
    charge_code         = Column(Unicode(30))
    percentage          = Column(Numeric(17, 6))
    amount              = Column(Numeric(17, 6))
    total               = Column(Numeric(17, 6))
    create_user         = Column(Unicode(30))
    create_date         = Column(DateTime)
    update_user         = Column(Unicode(30))
    update_date         = Column(DateTime)
    desc_detail         = Column(Unicode(2000))
    po_no               = Column(Unicode(30))
    po_chrg_line_no     = Column(Integer)
    
      
class Table_PO(DeclarativeBase2):
    __tablename__ = 't_purchase_order_hdr'

    company_code        = Column(Unicode(30), nullable=False, primary_key=True)
    purchase_order_no   = Column(Unicode(30), nullable=False, primary_key=True)
    revision_no         = Column(Integer)
    revision_date       = Column(DateTime)
    issue_date          = Column(DateTime)
    order_dept          = Column(Unicode(30))
    status              = Column(Unicode(30))
    supplier            = Column(Unicode(200))
    factory             = Column(Unicode(30))
    po_type             = Column(Unicode(30))
    bill_address1       = Column(Unicode(200))
    bill_address2       = Column(Unicode(200))
    bill_address3       = Column(Unicode(200))
    bill_city           =  Column(Unicode(200))
    bill_country        = Column(Unicode(200))
    bill_contact_per    = Column(Unicode(200))
    bill_tel            = Column(Unicode(200))
    bill_fax            = Column(Unicode(200))
    country_origin      = Column(Unicode(30))
    port_loading        = Column(Unicode(30))
    currency            = Column(Unicode(30))
    ship_address1       = Column(Unicode(200))
    ship_address2       = Column(Unicode(200))
    ship_address3       = Column(Unicode(200))
    ship_city           = Column(Unicode(200))
    ship_country        = Column(Unicode(200))
    ship_contact_per    = Column(Unicode(200))
    ship_tel            = Column(Unicode(200))
    ship_fax            = Column(Unicode(200))
    destination         = Column(Unicode(30))
    port_discharge      = Column(Unicode(30))
    direct_ship         = Column(Unicode(30))
    beneficiary         = Column(Unicode(30))
    reference           = Column(Unicode(30))
    other_ref           = Column(Unicode(30))
    delivery_date       = Column(DateTime)
    trade_terms         = Column(Unicode(30))
    payment_terms       = Column(Unicode(30))
    ship_via            = Column(Unicode(30))
    designation         = Column(Unicode(30))
    conf_arr_date       = Column(DateTime)
    confirmed_by        = Column(Unicode(30))
    confirmed_date      = Column(DateTime)
    ship_mark           = Column(Unicode(2000))
    amendment           = Column(Unicode(2000))
    remark              = Column(Unicode(2000))
    order_amt           = Column(Numeric(17, 6))
    item_amt            = Column(Numeric(17, 6))
    total               = Column(Numeric(17, 6))
    create_user         = Column(Unicode(30))
    create_date         = Column(DateTime)
    update_user         = Column(Unicode(30))
    update_date         = Column(DateTime)
    warehouse           = Column(Unicode(30))
    type                = Column(Unicode(30))
    bill_address4       = Column(Unicode(200))
    ship_address4       = Column(Unicode(200))
    sc_no               = Column(Unicode(30))
    issue_by            = Column(Unicode(30))
    ae                  = Column(Unicode(30))
    intake_sheet_no     = Column(Unicode(30))
    cust_po_no          = Column(Unicode(30))
    exchange_rate       = Column(Numeric(17, 6))
    submitted_date      = Column(DateTime)
    supplier_name       = Column(Unicode(200))
    cust_rev_no         = Column(Integer)
    cust_rev_date       = Column(DateTime)
    order_type          = Column(Unicode(30))
    supplier_short_name = Column(Unicode(200))
    amendment_trad_chi  = Column(Unicode(2000))
    amendment_simp_chi  = Column(Unicode(2000))
    artwork_approval_no = Column(Unicode(30))
    cust_name           = Column(Unicode(200))
    cust_po_qty         = Column(Numeric(17, 6))
    dest                = Column(Unicode(200))
    turnover_day        = Column(Numeric(17, 6))
    order_reason        = Column(Unicode(2000))
    salesman            = Column(Unicode(30))
    fsc_cert_no         = Column(Unicode(30))
    
    
class Table_POD(DeclarativeBase2):
    __tablename__ = 't_purchase_order_dtl'

    company_code        = Column(Unicode(30), nullable=False, primary_key=True)
    purchase_order_no   = Column(Unicode(30), nullable=False, primary_key=True)
    line_no             = Column(Integer, nullable=False, primary_key=True)
    sales_contract_code = Column(Unicode(30))
    stock_item_no       = Column(Unicode(30))
    description         = Column(Unicode(2000))
    qty                 = Column(Numeric(17, 6))
    unit                = Column(Unicode(30))
    unit_price          = Column(Numeric(17, 6))
    total_amt           = Column(Numeric(17, 6))
    item_remark         = Column(Unicode(2000))
    item_shipmark       = Column(Unicode(2000))
    item_sidemark       = Column(Unicode(2000))
    total_recv_qty      = Column(Numeric(17, 6))
    program             = Column(Unicode(50))
    brand               = Column(Unicode(50))
    item_cat            = Column(Unicode(30))
    sub_cat1            = Column(Unicode(30))
    sub_cat2            = Column(Unicode(30))
    create_user         = Column(Unicode(30))
    create_date         = Column(DateTime)
    update_user         = Column(Unicode(30))
    update_date         = Column(DateTime)
    sc_line_no          = Column(Integer)
    cust_item_no        = Column(Unicode(30))
    int_item_no         = Column(Unicode(30))
    color               = Column(Unicode(30))
    siz                 = Column(Unicode(30))
    base_qty            = Column(Numeric(17, 6))
    base_unit           = Column(Unicode(30))
    country_origin      = Column(Unicode(200))
    brand_subline       = Column(Unicode(50))
    sub_cat3            = Column(Unicode(30))
    merchandise         = Column(Unicode(30))
    master_po_line_no   = Column(Integer)
    invoiced_qty        = Column(Numeric(17, 6))

   
class Table_POCharge(DeclarativeBase2):
    __tablename__ = 't_purchase_order_charges'

    company_code        = Column(Unicode(30), nullable=False, primary_key=True)
    purchase_order_no   = Column(Unicode(30), nullable=False, primary_key=True)
    line_no             = Column(Integer, nullable=False, primary_key=True)
    charge_code         = Column(Unicode(30))
    percentage          = Column(Numeric(17, 6))
    amount              = Column(Numeric(17, 6))
    total               = Column(Numeric(17, 6))
    create_user         = Column(Unicode(30))
    create_date         = Column(DateTime)
    update_user         = Column(Unicode(30))
    update_date         = Column(DateTime)
    desc_detail         = Column(Unicode(2000))


class Table_UI(DeclarativeBase2):
    __tablename__ = 't_supl_note_hdr'

    company_code         = Column(Unicode(30), nullable=False, primary_key=True)
    note_no              = Column(Unicode(30), nullable=False, primary_key=True)
    note_type            = Column(Unicode(30))
    note_due_date        = Column(DateTime)
    revision_no          = Column(Integer)
    revision_date        = Column(DateTime)
    status               = Column(Unicode(30))
    supplier             = Column(Unicode(30))
    department           = Column(Unicode(30))
    ccy                  = Column(Unicode(30))
    tot_item_amt         = Column(Numeric(17, 6))
    total_chg_discount   = Column(Numeric(17, 6))
    net_amt              = Column(Numeric(17, 6))
    remark               = Column(Unicode(2000))
    exchange_rate        = Column(Numeric(17, 6))
    create_user          = Column(Unicode(30))
    create_date          = Column(DateTime)
    update_user          = Column(Unicode(30))
    update_date          = Column(DateTime)
    note_date            = Column(DateTime)
    ref_code             = Column(Unicode(100))
    ref_code_2           = Column(Unicode(100))
    ref_code_3           = Column(Unicode(100))
    pi_no                = Column(Unicode(30))
    grn_return           = Column(Unicode(30))
    artwork_approval_no  = Column(Unicode(30))
    stock_adjustment_no  = Column(Unicode(30))
    fsc_cert_no          = Column(Unicode(30))
    
    
class Table_UIDetail(DeclarativeBase2):
    __tablename__ = 't_supl_note_dtl'

    company_code          = Column(Unicode(30), nullable=False, primary_key=True)
    note_no               = Column(Unicode(30), nullable=False, primary_key=True)
    line_no               = Column(Integer, primary_key=True)
    item_no               = Column(Unicode(30))
    int_item_no           = Column(Unicode(30))
    ref_no                = Column(Unicode(30))
    cust_po_no            = Column(Unicode(30))
    item_desc             = Column(Unicode(2000))
    note_qty              = Column(Numeric(17, 6))
    unit                  = Column(Unicode(30))
    unit_price            = Column(Numeric(17, 6))
    item_total            = Column(Numeric(17, 6))
    country_origin        = Column(Unicode(30))
    create_user           = Column(Unicode(30))
    create_date           = Column(DateTime)
    update_user           = Column(Unicode(30))
    update_date           = Column(DateTime)
    siz                   = Column(Unicode(30))
    color                 = Column(Unicode(30))
    po_item_line_no       = Column(Integer)
    po_no                 = Column(Unicode(30))
    pi_no                 = Column(Unicode(30))
    pi_line_no            = Column(Integer)
    grn_no                = Column(Unicode(30))
    grn_line_no           = Column(Integer)


class Table_UICharge(DeclarativeBase2):
    __tablename__ = 't_supl_note_charges'

    company_code      = Column(Unicode(30), nullable=False, primary_key=True)
    note_no           = Column(Unicode(30), nullable=False, primary_key=True)
    line_no           = Column(Integer, nullable=False, primary_key=True)
    chg_discount_code = Column(Unicode(2000))
    description       = Column(Unicode(2000))
    percentage        = Column(Numeric(17, 6))
    amount            = Column(Numeric(17, 6))
    total             = Column(Numeric(17, 6))
    create_user       = Column(Unicode(30))
    create_date       = Column(DateTime)
    update_user       = Column(Unicode(30))
    update_date       = Column(DateTime)

class Table_ItemCode(DeclarativeBase2):
    __tablename__ = 't_item_set_master'
    
    company_code            = Column(Unicode(30), nullable=False, primary_key=True)
    item_code               = Column(Unicode(30), nullable=False, primary_key=True)
    line_no                 = Column(Integer, nullable=False, primary_key=True)
    component_item_code     = Column(Unicode(30))
    component_int_item_code = Column(Unicode(30))
    component_short_desc    = Column(Unicode(100))
    component_full_desc     = Column(Unicode(2000))
    qty                     = Column(Numeric(17, 6))
    unit                    = Column(Unicode(30))
    create_user             = Column(Unicode(30))
    create_date             = Column(DateTime)
    update_user             = Column(Unicode(30))
    update_date             = Column(DateTime)
    is_primary              = Column(Unicode(30))
    component_fsc_flag      = Column(Unicode(1))
    
class Table_DN(DeclarativeBase2):
    __tablename__     = 't_dn_product'
    
    company_code      = Column(Unicode(30), nullable=False, primary_key=True)
    dn_no             = Column(Unicode(30), nullable=False, primary_key=True)
    line_no           = Column(Integer, nullable=False, primary_key=True)
    delivery_req_no   = Column(Unicode(30))
    sc_no             = Column(Unicode(30))
    item_no           = Column(Unicode(30))
    cust_item_no      = Column(Unicode(30))
    item_desc         = Column(Unicode(30))
    qty               = Column(Numeric(17, 6))
    unit              = Column(Unicode(30))
    create_user       = Column(Unicode(30))
    create_date       = Column(DateTime)
    update_user       = Column(Unicode(30))
    update_date       = Column(DateTime)
    siz               = Column(Unicode(30))
    color             = Column(Unicode(30))
    int_item_no       = Column(Unicode(30))
    sc_line_no        = Column(Integer)
    transfer_qty      = Column(Numeric(17, 6))
    
    
    
    
    
    