{
  "info": "",
  "field": {
    "so": [],
    "so_sales_order_id": [
      ["so_VIITTEEMME"]
    ],
    "so_company_id": [
      ["so_scTILAAJA_ASI"],
      ["_str", "=", ["so_company_id"]],
      ["_qry_Fld", ["0", "co_company_id", "=", "_str", "", "false"]],
      ["_so_tErrText", "=", ["co__CreditLimitCheck", ["co_company_id", "co_credit_limit"]]],
      [
        "if", ["_so_tErrText", "=", ""],
        [
          ["_err_MESSAGE", [["concat", ["_so_tErrText", ": ", "co_company_id", "Current_method_name", "true"]]]],
          [
            "if", ["_el_InInput", "=", "true"],
            [
              ["REJECT", ["so_company_id"]]
            ]
          ]
        ]
      ]
    ],
    "so_sales_price_wo_discount": [],
    "so_info": [],
    "so_way_of_delivery": [],
    "so_our_reference": [],
    "so_your_reference": [
      ["IDLE"]
    ],
    "sp_type": [
      ["so_scPOPTYYPPI"]
    ],
    "so_terms_of_payment_id": [
      ["so_scTERMS_OF_PAYMENT"]
    ],
    "so_delivery_company_id": [
      ["so_TOIMITUSASIAK"]
    ],
    "so_delivery_address": [
      ["so_scDELIVERY_ADDRESS"]
    ],
    "so_invoicing_address": [],
    "so_row_discount_percentage": [],
    "so_row_discount": [],
    "so_sales_price_total": [],
    "so_currency_id": [
      ["so_scVALUUTTA"]
    ],
    "so_invoicing_company_id": [
      ["so_LASKUASIAKAS"],
      ["_str", "=", ["so_invoicing_company_id"]],
      ["_qry_Fld", ["0", "co_company_id", "=", "_str", "", "false"]],
      ["_so_tErrText", "=", ["co__CreditLimitCheck", ["co_company_id", "co_credit_limit"]]],
      [
        "if", ["_so_tErrText", "=", ""],
        [
          ["_err_MESSAGE", ["concat", ["_so_tErrText", ": ", "co_company_id", "Current_method_name", "true"]]],
          [
            "if", ["_el_InInput", "=", "true"],
            [
              ["REJECT", ["so_invoicing_company_id"]]
            ]
          ]
        ]
      ]
    ],
    "so_employee_id": [
      ["so_scMYYJA"]
    ],
    "so_country_of_origin": [],
    "so_country_of_destination": [],
    "so_precarriage": [],
    "so_discharge_place": [],
    "so_destination": [],
    "so_gross_weight": [],
    "so_net_weight": [],
    "so_volume": [],
    "so_place_of_departure": [],
    "tariff_heading": [],
    "so_mark": [
      ["so_scMARK"]
    ],
    "so_term_of_delivery": [],
    "so_cost_price": [],
    "so_order_date": [],
    "so_order_discount_percentage": [
      ["so_scTIL_ALE_PRO"]
    ],
    "so_order_discount": [
      ["so_scTIL_ALENNUS"]
    ],
    "so_notes": [],
    "so_vat_total": [],
    "so_first_delivery_date": [
      [
        "if", ["_fi_InFullpage", "=", "true"],
        [
          ["so_scENS_TO_PV"]
        ]
      ]
    ],
    "so_customer_project": [
      ["so_sc_PROJECT"]
    ],
    "so_eur_number": [],
    "so_supplier_id": [],
    "so_exchange_rate": [],
    "so_state": [
      ["so_scPOPTILA"]
    ],
    "so_firm_id": [],
    "so_collection_invoice": [],
    "so_your_reference_of_delivery": [],
    "so_your_reference_of_invoice": [],
    "so_offer_number": [],
    "so_euro_rate": [],
    "so_order_address": [
      [
        "if", ["_fi_InFullpage", "=", "true"],
        [
          ["so_scTILAUSOSOIT"]
        ]
      ]
    ],
    "so_confirmation_date": [],
    "so_freight_charges_payer": [],
    "so_dealer_company_id": [
      ["so_DEALER_ADDRESS"]
    ],
    "so_dealer_address": [],
    "so_customer_order_number": [
      ["so_scCUSTOMER_ORDER_NUMBER"]
    ],
    "so_cost_center": [],
    "so_transfer_id": [],
    "so_number_of_pallets": [],
    "so_covenant": [],
    "so_transfer_sate": [],
    "so_sales_margin_percentage": [],
    "so_sales_margin": [],
    "so_material_cost": [],
    "so_material_margin_percentage": [],
    "so_material_margin": [],
    "so_packing_state": [],
    "so_additional_date": [],
    "so_packing_info": [],
    "so_postcalc_date": []
  },
  "function": {
    "so_VIITTEEMME": [
      ["so_our_reference", "=", ["concat", ["so_sales_order_id", "/", "so_employee_id"]]]
    ],
    "so_scTILAAJA_ASI": [
      ["_err_LANG_DO"],
      ["so_sTilaaja", "=", ["co_name"]],
      ["so_tAccountablePerson", "=", ["co_accountable_person_id"]],
      ["so_tTelephoneNumber", "=", ""],
      [
        "if", ["co_telephone_area_code", "<>", ""],
        [
          ["so_tTelephoneNumber", "=", ["concat", ["co_telephone_area_code", "space"]]]
        ]
      ],
      ["so_tTelephoneNumber", "=", ["concat", ["so_tTelephoneNumber", "co_telephone_number"]]],
      ["so_your_reference", "=", ["co_your_reference"]],
      ["so_way_of_delivery", "=", ["co_way_of_delivery"]],
      ["so_terms_of_delivery", "=", ["co_term_of_delivery"]],
      ["so_order_address", "=", ["co_text_address"]],
      ["so_cost_center", "=", ["co_cost_center"]],
      ["so_freight_charges_payer", "=", ["co_freight_charges_payer"]],
      ["so_covenant", "=", ["co_covenant"]],
      [
        "if", ["g.so_lCopyCompanyInfoToSalesOrder", "=", "true"],
        [
          [
            "if", ["so_info", "<>", ""],
            [
              ["_so_lOK", "=", ["_info_YesNoCancel", ["kConfirm", ["_lang_Current", ["Copy_company_info_to_sales_order"]], "", "", "yes", "cancel"]]]
            ],
            "else",
            [
              ["_so_lOK", "=", "yes"]
            ]
          ],
          [
            "if", ["_so_lOK", "=", "yes"],
            [
              ["so_info", "=", ["co_info"]]
            ]
          ]
        ]
      ],
      [
        "if", ["so_employee_id", "=", ""],
        [
          [
            "if", ["g.so_lUseLoginIdAsSeller", "=", "true"],
            [
              ["so_employee_id", "=", "em__LoginUserId"]
            ],
            "else",
            [
              ["so_employee_id", "=", ["co_default_sales_person_id"]]
            ]
          ],
          ["so_VIITTEEMME"]
        ]
      ],
      [
        "if", [[["_str_AsciiSameCheck", ["so_company_id"]], "@"], "=", "true"],
        [
          ["so_company_id", "=", ""]
        ]
      ],
      [
        "if", ["co_delivery_company_id", "<>", ""],
        [
          ["so_delivery_company_id", "=", ["co_delivery_company_id"]],
          ["RELATE_ONE", ["so_delivery_company_id"]],
          [
            "if", [["Records_in_selection", ["co"]], "<>", "1"],
            [
              [
                "if", ["g.so_lSetCompanyToDelivCompany", "=", "true"],
                [
                  ["so_delivery_company_id", "=", ["so_company_id"]]
                ],
                "else",
                [
                  ["so_delivery_company_id", "=", ""]
                ]
              ]
            ]
          ]
        ],
        "else",
        [
          [
            "if", ["g.so_lSetCompanyToDelivCompany", "=", "true"],
            [
              ["so_delivery_company_id", "=", ["so_company_id"]]
            ]
          ]
        ]
      ],
      [
        "if", ["so_delivery_company_id", "<>", ""],
        [
          ["RELATE_ONE", ["so_delivery_company_id"]],
          ["so_TOIMITUSASIAK"]
        ]
      ],
      ["RELATE_ONE", ["so_company_id"]],
      [
        "if", ["co_invoice_company_id", "<>", ""],
        [
          ["so_invoicing_company_id", "=", ["co_invoice_company_id"]],
          ["so_your_reference_of_invoice", "=", ["co_your_reference"]],
          ["RELATE_ONE", ["so_invoicing_company_id"]],
          [
            "if", [["Records_in_selection", ["co"]], "<>", "1"],
            [
              [
                "if", ["g.so_lSetCompanyToInvCompany", "=", "true"],
                [
                  ["so_invoicing_company_id", "=", ["so_company_id"]],
                  ["RELATE_ONE", ["so_invoicing_company_id"]]
                ],
                "else",
                [
                  ["so_invoicing_company_id", "=", ""]
                ]
              ]
            ]
          ]
        ],
        "else",
        [
          [
            "if", ["g.so_lSetCompanyToInvCompany", "=", "true"],
            [
              ["so_invoicing_company_id", "=", ["so_company_id"]],
              ["RELATE_ONE", ["so_invoicing_company_id"]]
            ]
          ]
        ]
      ],
      ["so_LASKUASIAKAS"]
    ],
    "so_scPOPTYYPPI": [
      [
        "if", [["so_type", "=", "TI"], "and", ["so_order_date", "=", "00.00.0000"]],
        [
          ["so_order_date", "=", ["Current_date", ["*"]]]
        ]
      ],
      ["so_VIITTEEMME"],
      ["_fii__sel_apply_to", ["sor_ktype_", "so_type"]]
    ],
    "so_scTERMS_OF_PAYMENT": [
      ["so_tTermsOfPaymentName", "=", ""],
      [
        "if", [["_fld_ValueStr", ["so_terms_of_payment_id"]], "<>", ""],
        [
          ["_sel_RELATE_ONE", ["top_terms_of_payment_id", "so_terms_of_payment_id"]],
          ["so_tTermsOfPaymentName", ["_fld_ValueStr", ["top_name"]]]
        ]
      ]
    ],
    "so_TOIMITUSASIAK": [
      ["_so_tcompanyrecid", "=", ""],
      [
        "if", [["_rec__CurrentExist", ["co_tbl"]], "=", "true"],
        [
          ["_so_tCompanyRecId", "=", ["_fld_ValueStr", ["co_record_id"]]]
        ]
      ],
      ["_so_tcompany", "=", ["_fld_ValueStr", ["so_delivery_company_id"]]],
      [
        "if", ["_so_tCompany", "<>", ["_fld_ValueStr", ["so_company_id"]]],
        [
          [
            "if", ["co__DefaultAddressCheckOrder", "=", "0"],
            [
              ["_so_lCheckCoad_AddressFirst", "=", "false"]
            ],
            "else",
            [
              ["_so_lCheckCoad_AddressFirst", "=", "true"]
            ]
          ]
        ],
        "else",
        [
          ["_so_lCheckCoad_AddressFirst", "=", "true"]
        ]
      ],
      ["_so_taddresstype", "=", ["co__deliveryaddresstype"]],
      ["_so_taddress", "=", ["so_addressget", ["_so_tcompany", "_so_taddresstype", "_so_lcheckcoad_addressfirst"]]],
      ["_fld_VALUE_STR_SET", ["set", "so_delivery_address", "_so_taddress"]],
      [
        "if", ["g.bit", ["so_lDestinationFromCustomer", "0"]],
        [
          ["_so_tDestination", "=", ["so_DeliveryDestination", ["_so_tCompany"]]],
          ["_fld_VALUE_STR_SET", ["set", "so_destination", "_so_tDestination"]]
        ]
      ],
      [
        "if", [["co__CompanyRecGet", ["_so_tCompany", "_so_tAddressType"]], ">", "0"],
        [
          ["_so_tFldValue", "=", ["_fld_ValueStr", ["co_country"]]],
          ["_fld_VALUE_STR_SET", ["set", "so_country_of_destination", "_so_tFldValue"]],
          ["_so_tFldValue", "=", ["_fld_ValueStr", ["co_your_reference"]]],
          ["_fld_VALUE_STR_SET", ["set", "so_your_reference_of_delivery", "_so_tFldValue"]],
          ["_so_tFldValue", "=", ["_fld_ValueStr", ["co_term_of_delivery"]]],
          ["_fld_VALUE_STR_SET", ["set", "so_term_of_delivery", "_so_tFldValue"]],
          ["_so_tFldValue", "=", ["_fld_ValueStr", ["co_way_of_delivery"]]],
          ["_fld_VALUE_STR_SET", ["set", "so_way_of_delivery", "_so_tFldValue"]]
        ]
      ],
      [
        "if", ["_so_tCompanyRecId", "<>", ""],
        [
          ["_qry_Fld", ["0", ["co_record_id", "=", "_so_tCompanyRecId"], "", "false", "false"]]
        ]
      ]
    ],
    "so_scDELIVERY_ADDRESS": [
      [
        "if", [["so_destination", "<>", ""], "and", ["gBit", ["so_lDestinationFromCustomer", "1"]]],
        [
          [
            "if", ["Position", ["so_destination", "so_delivery_address"], "<", "1"],
            [
              ["_err_CRY", ["concat", [["_lang_Current", ["Destination_was_not_found_form_delivery_address, check_destination"]], ": ", "ksQuoteStart", "so_destination", "ksQuoteEnd", "true"]]]
            ]
          ]
        ]
      ]
    ],
    "so_scVALUUTTA": [
      ["_err_LANG_DO"],
      [
        "if", ["so_sVanhaVal", "<>", ""],
        [
          [
            "if", [[["Records_in_selection", ["sor"]], ">", "0"], "and", ["so_currency_id", "<>", ["so_sVanhaVal"]]],
            [
              ["_Str", "=", ["concat", ["Olet_muuttanut_valuuttaa.", "\n"]]],
              ["_Str", "=", ["concat", ["_Str", "Hae_jokaiselle_myyntiriville_tuotteet_uudestaan, jotta_niille_saadaan"]]],
              ["_Str", "=", ["concat", ["_Str", " uusi_ulkomainen_hinta."]]],
              ["xCRY", ["_Str"]]
            ]
          ]
        ]
      ],
      ["so_svanhaval", "=", ["so_currency_id"]],
      ["so_exchange_rate", "=", ["cur_selling_rate"]],
      ["so_C_CURRENCY"]
    ],
    "so_LASKUASIAKAS": [
      ["_so_tcompanyrecid", "=", ""],
      [
        "if", [["_rec__CurrentExist", ["co_tbl"]], "=", "true"],
        [
          ["_so_tCompanyRecId", "=", ["_fld_ValueStr", ["co_record_id"]]]
        ]
      ],
      ["_so_tcompany", "=", ["_fld_ValueStr", ["so_invoicing_company_id"]]],
      [
        "if", ["_so_tCompany", "<>", ["_fld_ValueStr", ["so_company_id"]]],
        [
          [
            "if", ["co__DefaultAddressCheckOrder", "=", "0"],
            [
              ["_so_lCheckCoad_AddressFirst", "=", "false"]
            ],
            "else",
            [
              ["_so_lCheckCoad_AddressFirst", "=", "true"]
            ]
          ]
        ],
        "else",
        [
          ["_so_lCheckCoad_AddressFirst", "=", "true"]
        ]
      ],
      ["_so_taddresstype", "=", ["co__invoicingaddresstype"]],
      ["_so_taddress", "=", ["so_addressget", ["_so_tcompany", "_so_taddresstype", "_so_lcheckcoad_addressfirst"]]],
      ["_fld_VALUE_STR_SET", ["set", "so_invoicing_address", "_so_taddress"]],
      [
        "if", [["co__CompanyRecGet", ["_so_tCompany", "_so_tAddressType"]], ">", "0"],
        [
          ["_so_tFldValue", "=", ["_fld_ValueStr", ["co_your_reference"]]],
          ["_fld_VALUE_STR_SET", ["set", "so_your_reference_of_invoice", "_so_tFldValue"]],
          ["_so_tFldValue", "=", ["_fld_ValueStr", ["co_terms_of_payment_id"]]],
          ["_fld_VALUE_STR_SET", ["set", "so_terms_of_payment_id", "_so_tFldValue"]],
          ["_so_fFldValue", "=", ["_fld_ValueBoolean", ["co_is_collection_invoice"]]],
          ["_fld_VALUE", ["set", "so_collection_invoice", "_so_fFldValue"]],
          ["_so_tCurrency", "=", ["_fld_ValueStr", ["co_currency_id"]]],
          ["_so_tCurrencyOld", "=", ["_fld_ValueStr", ["so_currency_id"]]],
          [
            "if", [["_sel_RecsInSel", ["sor_tbl"]], ">", "0"],
            [
              [
                "if", ["_so_tCurrencyOld", "<>", ["_so_tCurrency"]],
                [
                  ["_so_tMessage", "=", ["concat", [["_lang_Current", ["Currency_have_been_changed"]], ": ", "_so_tCurrencyOld", "  ", "_so_tCurrency", "\n"]]],
                  ["_so_tMessage", "=", ["concat", ["_so_tMessage", ["_lang_Current", ["Check_sales_order_row_prices"]], "\n"]]],
                  ["_err_MESSAGE", ["_so_tMessage", "Current_method_name", "false"]]
                ]
              ]
            ]
          ],
          ["_fld_VALUE_STR_SET", ["set", "so_currency_id", "_so_tcurrency"]],
          ["_sel_RELATE_ONE", ["cur_currency_id", "so_currency_id"]],
          ["_so_rrate", "=", ["_fld_valuereal", ["cur_selling_rate"]]],
          ["_fld_VALUE_REAL_SET", ["set", "so_exchange_rate", "_so_rrate"]],
          ["_so_rdiscountpercent", "=", ["_fld_valuereal", ["co_order_discount_percentage"]]],
          ["_so_rdiscountpercentold", "=", ["_fld_valuereal", ["so_order_discount_percentage"]]],
          [
            "if", ["_so_rDiscountPercentOld", "<>", ["_so_rDiscountPercent"]],
            [
              ["_so_lOK", "=", ["_info__Confirm", ["concat", [["_lang_Current", ["Customer_have_different_order_discount_percent. Do_you_want_to_set_it_to_sales_order"]], " (", ["String", ["_so_rDiscountPercent"]], "  ", ["String", ["_so_rDiscountPercent"]], ")?"]]]],
              [
                "if", ["_so_lOK", "=", "yes"],
                [
                  ["_fld_VALUE_REAL_SET", ["set", "so_order_discount_percentage", "_so_rDiscountPercent"]],
                  ["so_C_ALAR_MUUTTU"]
                ]
              ]
            ]
          ]
        ]
      ],
      [
        "if", ["_so_tCompanyRecId", "<>", ""],
        [
          ["_qry_Fld", ["0", ["co_record_id", "=", ["_so_tCompanyRecId"]], "", "false", "false"]]
        ]
      ]
    ],
    "so_C_ALAR_MUUTTU": [
      ["_so_lNew", "=", "false"],
      [
        "if", ["_fi_FormEvent", "<>", "On_Load"],
        [
          ["so_order_discount", "=", [["so_order_discount_percentage", "*", ["so_sales_price_wo_discount", "-", "so_row_discount"]], "/", "100"]],
          ["so_sales_price_total", "=", ["so_sales_price_wo_discount", "-", "so_row_discount", "-", "so_order_discount"]],
          [
            "if", ["_so_lNew", "=", "false"],
            [
              ["so_vat_total", "=", ["Sum", ["sor_vat_price"]]]
            ],
            "else",
            [
              ["so_vat_total", "=", ["_fld_ArrSum", ["sor_vat_price", "_so_lNew"]]]
            ]
          ],
          ["so_vat_total", "=", ["so_vat_total", "-", [["so_vat_total", "*", "so_order_discount_percentage"], "/", "100"]]],
          ["so_vat_total", "=", ["Round", ["so_vat_total", "2"]]]
        ]
      ],
      ["so_rAlennYht", "=", ["so_row_discount", "+", "so_order_discount"]],
      ["so_rMakseYht", "=", ["Round", [["so_sales_price_total", "+", "so_vat_total"], "2"]]],
      ["so_rAlePrYht", "=", [["so_rAlennYht", "/", "so_sales_price_wo_discount"], "*", "100"]],
      ["so_rRivMHYht", "=", ["so_sales_price_wo_discount", "-", "so_row_discount"]],
      ["so_rKate", "=", ["so_sales_price_total", "-", "so_cost_price"]],
      [
        "if", ["so_sales_price_total", "<>", "0"],
        [
          ["so_rKatePros", "=", [["so_rKate", "/", "so_sales_price_total"], "*", "100"]]
        ],
        "else",
        [
          ["so_rKatePros", "=", "0"]
        ]
      ],
      ["so_C_CURRENCY"]
    ],
    "so_C_CURRENCY": [
      ["COMPILER_cur"],
      [
        "if", [["_el_Tbl", "=", "so_tbl"], "and", ["_el_InInput", "=", "true"]],
        [
          ["so_rMakseVal", "=", ["cur__SellConvert", ["so_rMakseYht", "so_currency_id", "cur_aspopCurren[cur_aspopCurren]"]]]
        ]
      ]
    ],
    "so_scMYYJA": [
      ["so_VIITTEEMME"]
    ],
    "so_scMARK": [
      ["C_TEXT", ["_so_tName", "g.so_tSalesOrderToCheck", "g.so_tCustomerToCheck"]],
      ["_so_lCheck", "=", "true"],
      ["_so_tName", "=", ["_lang_Current", ["Check_mark-field_value"]]],
      [
        "if", [["_prs__SelfStartedByName", ["_so_tName"]], "=", "false"],
        [
          ["_so_lCheck", "=", "false"],
          [
            "if", ["g.so_lCheckMarkFldValue", ">", "0"],
            [
              [
                "if", ["so_mark", "<>", ""],
                [
                  ["g.so_tMarkToCheck", "=", "so_mark"],
                  ["g.so_tSalesOrderToCheck", "=", ["_fld_ValueStr", ["so_sales_order_id"]]],
                  ["g.so_tCustomerToCheck", "=", ["_fld_ValueStr", ["so_company_id"]]],
                  ["_so_lCheck", "=", "true"]
                ]
              ]
            ]
          ]
        ]
      ],
      [
        "if", ["_so_lCheck", "=", "true"],
        [
          [
            "if", [["_prs__SelfStartedByName", ["Current_method_name", "_so_tName", "_prs_kMemStack", "false"]], "=", "true"],
            [
              ["_so_tSalesOrderToCheck", "=", ["g.so_tSalesOrderToCheck"]],
              ["_so_tCustomerToCheck", "=", ["g.so_tCustomerToCheck"]],
              ["_so_tMarkToCheck", "=", ["g.so_tMarkToCheck"]],
              ["_prs_NEW_INIT"],
              ["_qry_Fld", ["0", ["so_company_id", "=", ["_so_tCustomerToCheck"]], "*", "false", "false"]],
              ["_qry_Fld", ["0", ["so_mark", "=", ["_so_tMarkToCheck"]], "&", "false", "false"]],
              ["ARRAY_TEXT", ["_so_atSalesOrderToCheck", "0"]],
              ["_sel__SEL_TO_ARR_ONE", ["so_sales_order_id", "_so_atSalesOrderToCheck"]],
              ["_so_lOrdersFound", ["Find_in_array", ["_so_atSalesOrderToCheck", "_so_tSalesOrderToCheck"]]],
              [
                "if", ["_so_lOrdersFound", ">", "0"],
                [
                  ["_so_lOrdersFound", "=", [["Size_of_array", ["_so_atSalesOrderToCheck"]], "-", "1"]]
                ],
                "else",
                [
                  ["_so_lOrdersFound", "=", ["Size_of_array", ["_so_atSalesOrderToCheck"]]]
                ]
              ],
              [
                "if", ["_so_lOrdersFound", ">", "0"],
                [
                  ["_err_CRY", ["concat", [["_lang_Current", ["Another_sales_order_have_same_Mark-field_value"]], ": ", "_so_tMarkToCheck"]]]
                ]
              ],
              ["_prs__NEW_QUIT"]
            ]
          ]
        ]
      ]
    ],
    "so_scTIL_ALE_PRO": [
      ["so_C_ALAR_MUUTTU"]
    ],
    "so_scTIL_ALENNUS": [
      [
        "if", [["so_sales_price_wo_discount", "-", "so_row_discount"], "<>", "0"],
        [
          ["so_order_discount_percentage", "=", ["so_order_discount", "/", [["so_sales_price_wo_discount", "-", "so_row_discount"], "*", "100"]]]
        ],
        "else",
        [
          ["so_order_discount_percentage", "=", "0"]
        ]
      ],
      ["so_C_ALAR_MUUTTU"]
    ],
    "so_scENS_TO_PV": [
      ["so_lEnsToVko", "=", ["aaC_Date_Week", ["so_first_delivery_date"]]]
    ],
    "so_sc_PROJECT": [
      ["IDLE"]
    ],
    "so_scPOPTILA": [
      [
        "if", [["so_state", "=", ["VA"]], "and", ["so_confirmation_date", "=", "00.00.0000"]],
        [
          ["so_confirmation_date", "=", ["Current_date", ["*"]]]
        ]
      ],
      ["_fii__SEL_APPLY_TO", ["sor_order_state", "so_state"]],
      [
        "if", ["false"],
        [
          ["_str", "=", ["_fld_ValueStr", ["sor_delivery_state"]]],
          [
            "if", ["_str", "=", ""],
            [
              ["xml_tCodeDate", "=", "0"]
            ],
            "elseif", ["_str", "=", "OT"],
            [
              [
                ["xml_tCodeDate", "=", "1"]
              ]
            ],
            "else",
            [
              ["xml_tCodeData", "=", "9"]
            ]
          ]
        ]
      ]
    ],
    "so_scTILAUSOSOIT": [
      [
        "if", [["so_delivery_company_id", "=", ["so_company_id"]], "and", ["so_delivery_address", "=", ""]],
        [
          ["so_delivery_address", "=", "so_order_address"]
        ]
      ],
      [
        "if", [["so_invoicing_company_id", "=", ["so_company_id"]], "and", ["so_invoicing_address", "=", ""]],
        [
          ["so_invoicing_address", "=", "so_order_address"]
        ]
      ]
    ],
    "so_DEALER_ADDRESS": [
      [
        "if", ["so_dealer_company_id", "=", ["so_company_id"]],
        [
          ["so_dealer_address", "=", ["so_order_address"]]
        ],
        "elseif", ["so_dealer_company_id", "=", ["so_invoicing_company_id"]],
        [
          ["so_dealer_address", "=", ["so_invoicing_address"]]
        ],
        "elseif", ["so_dealer_company_id", "=", ["so_delivery_company_id"]],
        [
          ["so_dealer_address", "=", ["so_delivery_address"]]
        ],
        "else",
        [
          ["_sel_RELATE_ONE", ["co_company_id", "so_dealer_company_id"]],
          ["so_dealer_address", "=", ["co_text_address"]]
        ]
      ]
    ],
    "so_scCUSTOMER_ORDER_NUMBER": [
      ["c_text", ["_so_tname", "g.so_tsalesordertocheck", "g.so_tcustomertocheck", "g.so_tcustomerordertocheck"]],
      ["_so_lcheck", "=", "true"],
      ["_so_tname", "=", ["_lang_Current", ["check_customer_order_number"]]],
      [
        "if", [["_prs__SelfStartedByName", ["_so_tName"]], "=", "false"],
        [
          ["_so_lCheck", "=", "false"],
          [
            "if", ["g.so_lCheckCustomerOrderNumber", ">", "0"],
            [
              [
                "if", ["so_customer_order_number", "<>", ""],
                [
                  ["g.so_tCustomerOrderToCheck", "=", ["_so_tCustomerOrderToCheck"]],
                  ["g.so_tSalesOrderToCheck", "=", ["_fld_ValueStr", ["so_sales_order_id"]]],
                  ["g.so_tCustomerToCheck", "=", ["so_company_id"]],
                  ["_so_lCheck", "=", "true"]
                ]
              ]
            ]
          ]
        ]
      ],
      [
        "if", ["_so_lCheck", "=", "true"],
        [
          [
            "if", [["_prs__SelfStartedByName", ["Current_method_name", "_so_tName", "_prs_kMemStack", "false"]], "=", "true"],
            [
              ["_so_tSalesOrderToCheck", "=", ["g.so_tSalesOrderToCheck"]],
              ["_so_tCustomerToCheck", "=", ["g.so_tCustomerToCheck"]],
              ["_so_tCustomerOrderToCheck", "=", ["g.so_tCustomerOrderToCheck"]],
              ["_prs_NEW_INIT"],
              ["_qry_Fld", ["0", ["so_company_id", "=", ["_so_tCustomerToCheck"]], "*", "false", "false"]],
              ["_qry_Fld", ["0", ["so_customer_order_number", "=", ["_so_tCustomerOrderToCheck"]], "&", "false", "false"]],
              ["ARRAY_TEXT", ["_so_atSalesOrderToCheck", "0"]],
              ["_sel__SEL_TO_ARR_ONE", ["so_sales_order_id", "_so_atSalesOrderToCheck"]],
              ["_so_lOrdersFound", "=", ["Find_in_array", ["_so_atSalesOrderToCheck", "_so_tSalesOrderToCheck"]]],
              [
                "if", ["_so_lOrdersFound", ">", "0"],
                [
                  ["_so_lOrdersFound", "=", [["Size_of_array", ["_so_atSalesOrderToCheck"]], "-", "1"]]
                ],
                "else",
                [
                  ["_so_lOrdersFound", "=", ["Size_of_array", ["_so_atSalesOrderToCheck"]]]
                ]
              ],
              [
                "if", ["_so_lOrdersFound", ">", "0"],
                [
                  ["_err_CRY", ["concat", [["_lang_Current", ["Another_sales_order_have_same_customer_order_number"]], ": ", "_so_tCustomerOrderToCheck"]]]
                ]
              ],
              ["_prs__NEW_QUIT"]
            ]
          ]
        ]
      ]
    ]
  }
}
