fix old mxik

    0

    0

    Muhammadali-gold

    The code updates the document product's catalog code and states.

    update sm_seller_products
    set identification_code= :new_mxik
    where id in (select product_id from sm_document_products where document_id = :document_id and catalog_code = :old_mxik);
    
    update sm_document_products
    set catalog_code = :new_mxik
    where id in (select dp.id as p_id
      from sm_document_products dp
        left join sm_document_contracts dc on dp.document_id = dc.id
        left join sm_document_facturas df on dp.document_id = df.id
      where dp.catalog_code = :old_mxik
        and ((dc.id = :document_id and dc.state = 1 and
        (dc.doc_status is null or dc.doc_status in ('CREATED'))) or
        (df.id = :document_id and df.state = 1 and (df.doc_status is null or df.doc_status in ('CREATED'))))
    );
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.