{
	"info": ", ei mitään epäselvää",
	"field": {
		"inv_company_id": [
			["inv_ASIAKAS"]
		],
		"inv_invoice_id": [
			[
				"if", ["inv_our_reference", "=", ""],
				[
					["inv_our_reference", "=", ["concat", ["inv_invoice_id", "/", "inv_handler_id"]]]
				],
				"else",
				[
					["inv_our_reference", "=", ["Delete_string", ["inv_our_reference", "1", "Length", ["inv_invoice_id"]]]],
					["inv_our_reference", "=", ["Insert_string", ["inv_our_reference", "inv_invoice_id", "1"]]]
				]
			],
			["inv_VIITENUMERO"]
		],
		"inv_date": [
			["inv_sMAKSUEHTO"]
		],
		"inv_due_date": [
			["inv_scERAPAIVA"]
		],
		"inv_terms_of_payment_id": [
			["inv_sMAKSUEHTO"]
		],
		"inv_currency_id": [
			["inv_sVALUUTTA_MUU"],
			["xpRealFile", "=", "_el_pTbl"]
		],
		"inv_order_discount_percentage": [
			["inv_scTIL_ALE_PRO"]
		],
		"inv_order_discount_total": [
			["inv_scTIL_ALENNUS"]
		],
		"inv_type": [
			["inv_scpopTYYPPI"]
		],
		"inv_delivery_company_id": [
			["inv_TOIMITASIAKAS"]
		],
		"inv_firm_id": [
			["inv_sYRITYS"]
		],
		"inv_collection_started": [
			[
				"if", ["!aaIsAdministrat"],
				[
					["xCRY", ["Vain_yllapitoryhmaan_kuuluva_voi_muuttaa_perintatietoja."]]
				]
			]
		],
		"inv_last_collection_date": [
			[
				"if", ["!aaIsAdministrat"],
				[
					["xCRY", ["Vain_yllapitoryhmaan_kuuluva_voi_muuttaa_perintatietoja."]]
				]
			]
		]
	},
	"function": {
		"inv_ASIAKAS": [
			["RELATE_ONE", ["inv_company_id"]],
			["inv_send_type", "=", ["co_send_type"]],
			["_inv_tFinancingCompanySymbol", "=", ["concat", [",", "g.inv_tFinancingInvoiceSendType"]]],
			["_inv_tSendType", "=", ["concat", [",", "inv_send_type", ","]]],
			[
				"if", [["Position", ["_inv_tFinancingCompanySymbol", "_inv_tSendType"]], ">", "0"],
				[
					["inv_invoice_text", "=", ["Replace_string", ["inv_invoice_text", "g.gtLaskuntek", "g.inv_tRahYhtio"]]],
					[
						"if", ["g.inv_tRahYhtio", "<>", ""],
						[
							[
								"if", [[["Position", ["g.inv_tRahYhtio"]], ["inv_invoice_text"]], "<=", "0"],
								[
									[
										"if", ["inv_invoice_text", "<>", ""],
										[
											["inv_invoice_text", "=", ["concat", ["g._inv_tRahYhtio", "\n", "\n", "inv_invoice_text"]]]
										],
										"else",
										[
											["inv_invoice_text", "=", ["g.inv_tRahYhtio"]]
										]
									]
								]
							]
						]
					]
				],
				"else",
				[
					["inv_invoice_text", "=", ["Replace_string", ["inv_invoice_text", "g.inv_tRahYhtio", "g.gtLaskuntek"]]],
					[
						"if", ["g.gtLaskuntek", "<>", ""],
						[
							[
								"if", [["Position", ["g.gtLaskuntek", "inv_invoice_text"]], "<=", "0"],
								[
									[
										"if", ["inv_invoice_text", "<>", ""],
										[
											["inv_invoice_text", "=", ["concat", ["g.gtLaskuntek", "\n", "\n", "inv_invoice_text"]]]
										],
										"else",
										[
											["inv_invoice_text", "=", ["g.gtLaskuntek"]]
										]
									]
								]
							]
						]
					]
				]
			],
			["inv_VIITENUMERO"],
			[
				"if", ["co_invoice_company_id", "<>", ""],
				[
					["QUERY", ["coad", ["coad_company_id", "=", ["co_invoice_company_id"]], "*"]],
					["QUERY", ["coad", "&", ["coad_address_type", "=", ["g.mgsLASK_OSO"]]]],
					[
						"if", [["Records_in_selection", ["coad"]], "=", "1"],
						[
							["inv_invoice_address", "=", ["coad_text_address"]]
						],
						"else",
						[
							["inv_invoice_address", "=", ["co_text_address"]]
						]
					]
				],
				"else",
				[
					["QUERY", ["coad", ["coad_company_id", "=", ["inc_company_id"]], "*"]],
					["QUERY", ["coad", "&", ["coad_address_type", "=", ["g.mgsLASK_OSO"]]]],
					[
						"if", [["Records_in_selection", ["coad"]], "<>", "0"],
						[
							["inv_invoice_address", "=", ["coad_text_address"]]
						],
						"else",
						[
							["inv_invoice_address", "=", ["co_text_address"]]
						]
					]
				]
			],
			[
				"if", [["_rec_NewRecord", ["inv"]], "=", "true"],
				[
					[
						"if", [["co_invoice_number_serie", "<>", ""], "and", [["inv_type", "=", "HY"], "or", ["inv_type", "=", "NO"], "or", ["inv_type", "=", ["g.in_tFinancingInvoiceType"]]]],
						[
							["inv_invoice_id", "=", ["co_invoice_number_serie"]]
						],
						"else",
						[
							["IDLE"]
						]
					],
					["IDLE"]
				]
			],
			["inv_terms_of_payment_id", "=", ["co_terms_of_payment_id"]],
			["inv_sMAKSUEHTO"],
			["inv_currency_id", "=", ["co_currency_id"]],
			["RELATE_ONE", ["inv_currency_id"]],
			["inv_exchange_rate", "=", ["cu_selling_rate"]],
			["inv_way_of_delivery", "=", ["co_way_of_delivery"]],
			[
				"if", ["co_term_of_delivery", "<>", ""],
				[
					["inv_term_of_delivery", "=", ["co_term_of_delivery"]]
				]
			],
			["inv_your_reference", "=", ["co_your_reference"]],
			[
				"if", [["Record_number", ["inv"]], "=", "3"],
				[
					["inv_order_discount_percentage", "=", ["co_order_discount_percentage"]],
					["inv_ALARIVIN_KENT"],
					["inv_ALAVIITE_KASS"]
				]
			],
			[
				"if", ["inv_delivery_company_id", "=", ""],
				[
					[
						"if", ["co_delivery_company_id", "<>", ""],
						[
							["inv_delivery_company_id", "=", ["co_delivery_company_id"]],
							["RELATE_ONE", ["inv_delivery_company_id"]],
							["QUERY", ["coad", ["coad_company_id", "=", ["co_delivery_company_id"]], "*"]],
							["QUERY", ["coad", "&", ["coad_address_type", "=", ["g.mgsTOIM_OSO"]]]],
							[
								"if", [["Records_in_selection", ["coad"]], "=", "1"],
								[
									["inv_delivery_address", "=", ["coad_text_address"]]
								],
								"else",
								[
									["inv_delivery_address", "=", ["co_text_address"]]
								]
							],
							["RELATE_ONE", ["inv_company_id"]]
						],
						"else",
						[
							["inv_delivery_company_id", "=", ["inv_company_id"]],
							["QUERY", ["coad", ["coad_company_id", "=", ["inv_company_id"]]], "*"],
							["QUERY", ["coad", "&", ["coad_address_type", "=", ["g.mgsTOIM_OSO"]]]],
							[
								"if", [["Records_in_selection", ["coad"]], "<>", "0"],
								[
									["inv_delivery_address", "=", ["coad_text_address"]]
								],
								"else",
								[
									["inv_delivery_address", "=", ["co_text_address"]]
								]
							]
						]
					]
				]
			]
		],
		"inv_ALARIVIN_KENT": [
			[
				"if", [["_el_Tbl", "<>", ["inr_kTbl"]], "or", ["_el_InInput", "=", "false"]],
				[
					["inv_price_total", "=", ["Sum", ["invr_price_total"]]],
					["inv_vat_total", "=", ["Round", [["Sum", ["inv_vat_price"]], "2"]]],
					[
						"if", [["inv_price_total", "+", "inv_vat_total"], "<>", "0"],
						[
							["inv_discount_amount", "=", ["Sum", ["invr_discount_amount"]]],
							["inv_order_discount_total", "=", ["Round", [[["inv_order_discount_percentage", "*", "inv_price_total"], "/", "100"], "2"]]],
							["inv_vat_total", "=", ["Round", [["inv_vat_total", "-", [["inv_vat_total", "*", "inv_order_discount_percentage"], "/", "100"]], "2"]]],
							["inv_discount_percentage", "=", [["inv_discount_amount", "/", ["inv_price_total", "+", "inv_discount_amount"]], "*", "100"]]
						],
						"else",
						[
							["inv_discount_amount", "=", "0"],
							["inv_order_discount_total", "=", "0"],
							["inv_vat_total", "=", "0"],
							["inv_discount_percentage", "=", "0"]
						]
					],
					["inv_total_amount", "=", ["Round", [["inv_price_total", "+", "inv_vat_total", "-", "inv_order_discount_total"], "2"]]],
					["inv_total_rounding", "=", ["Round", [[["Round", ["inv_total_amount", "1"]], "-", "inv_total_amount"], "2"]]],
					[
						"if", [["Abs", ["inv_total_rounding"], "<=", "g.in_rPenninPy"]],
						[
							["inv_total_amount", "=", ["Round", ["inv_total_amount", "1"]]]
						],
						"else",
						[
							["inv_total_rounding", "=", "0"]
						]
					],
					["inv_coming_total", "=", ["cur_C_Currency", ["true", "inv_exchange_rate", "1", "inv_currency_id", "inv_total_amount", "cur__DefaultCurre"]]],
					["inv_coming_total", "=", ["Round", [["inv_coming_total", "-", "inv_paid_total", "-", "inv_discount_total"], "2"]]],
					["inv_C_CURRENCY", ["cur_aspopCurren[cur_aspopCurren]"]]
				]
			]
		],
		"inv_ALAVIITE_KASS": [
			["_sel_RELATE_ONE", ["top_kTerms_Of_Payment_ID", "in_kTerms_Of_Payment_id"]],
			[
				"if", ["g.in_tFootnote_Definition", "<>", ""],
				[
					[
						"if", [["g.in_lZeroVatShow", "=", "false"], "and", ["inv_vat_total", "=", "0"]],
						[
							["inv_footnote", "=", ""]
						],
						"else",
						[
							["_sel_RELATE_ONE", ["co_company_id", "inv_company_id"]],
							["_in_tLanguage", "=", ["_fld_ValueStr", ["co_language"]]],
							["_in_tDefinition", "=", ["in__FootnoteDefinitionGet", ["_in_tLanguage"]]],
							["ARRAY_REAL", ["_in_arCD_VAT_Sum", "0"]],
							[
								"if", ["top_discount_days", "<", "top_net_days"],
								[
									["_in_rCD_DiscountSum", "=", ["Round", [[["inv_total_amount", "*", "top_discount_percentage"], "/", "100"], "2"]]],
									["_in_rCD_DiscountSum", "=", ["Round", [["inv_vat_total", "-", [["inv_vat_total", "*", "top_discount_percentage"], "/", "100"]], "2"]]]
								],
								"else",
								[
									["_in_rCD_DiscountSum", "=", "0"],
									["_in_rCD_DiscountVatSum", "=", "0"]
								]
							],
							["_in_rCD_DiscountSum", "=", ["inv_total_amount", "-", "_in_rCD_DiscountSum"]],
							["ARRAY_REAL", ["in_arVAT_Percentage_tmp", "0"]],
							["ARRAY_REAL", ["in_arVAT_Price_tmp", "0"]],
							["in__VAT_ARR_CREATE", ["in_arVAT_Price_tmp", "in_arVAT_Price_tmp"]],
							[
								"if", ["false"],
								[
									["_in_lArrSize", "=", ["Size_of_array", ["in_arVAT_Price_tmp"]]],
									[
										"for", [["_in_lIndex", "=", "1"], "_in_lArrSize"], "do",
										[
											[]
										]
									]
								]
							],
							["SORT_ARRAY", ["in_arVAT_Price_tmp", "in_arVAT_Price_tmp", ">"]],
							["_in_rCD_VAT_Sum_check", "=", "0"],
							["_in_lArrSize", "=", ["Size_of_array", ["in_arVAT_Percentage_tmp"]]],
							["ARRAY_REAL", ["_in_arCD_VAT_Sum", "_in_lArrSize"]],
							[
								"for", [["_in_lIndex", "=", "1"], "_in_lArrSize"], "do",
								[
									["in_arVAT_Price_tmp[_in_lIndex]", "=", ["Round", ["in_arVAT_Price_tmp[_in_lIndex]", "2"]]],
									["_in_arCD_VAT_Sum[_in_lIndex]", "=", ["_in_arCD_VAT_Sum[_in_lIndex]", "+", ["Round", [["in_arVAT_Price_tmp[_in_lIndex]", "-", [["in_arVAT_Price_tmp[_in_lIndex]", "*", "top_discount_percentage"], "/", "100"]], "2"]]]],
									["_in_rCD_VAT_Sum_check", "=", ["_in_rCD_VAT_Sum_check", "+", "_in_arCD_VAT_Sum"]]
								]
							],
							[
								"if", ["_in_rCD_DiscountVatSum", "<>", "_in_rCD_VAT_Sum_check"],
								[
									["_in_lArrSize", "=", ["Size_of_array", ["in_arVAT_Percentage_tmp"]]],
									["_in_arCD_VAT_Sum[_in_lArrSize]", "=", ["_in_arCD_VAT_Sum[_in_lArrSize]", "+", ["_in_rCD_DiscountVatSum", "-", "_in_rCD_VAT_Sum_check"]]]
								]
							],
							["_in_tVAT_text", "=", ""],
							["_in_tCD_VAT_text", "=", ""],
							["_in_lArrSize", "=", ["Size_of_array", ["in_arVAT_Percentage_tmp"]]],
							["_in_tDefinition_original", "=", ["xml_ValueGet", ["_in_tDefinition", "VAT_Definition"]]],
							[
								"for", [["_in_lIndex", "=", "1"], "_in_lArrSize"], "do",
								[
									["_in_tVAT_Definition", "=", ["_in_tDefinition_original"]],
									["_in_tVAT_Definition", "=", ["Replace_string", ["_in_tVAT_Definition", "VAT_Percent", ["String", ["in_arVAT_Percentage_tmp[_in_lIndex]"]], "|0-2d"]]],
									["_in_tVAT_Definition", "=", ["Replace_string", ["_in_tVAT_Definition", "VAT_Sum", ["String", ["in_arVAT_Price_tmp[_in_lIndex]"]], "|2d"]]],
									["_in_tVAT_text", "=", ["_in_tVAT_text", "+", "_in_tVAT_Definition"]],
									["_in_tVAT_Definition", "=", ["_in_tDefinition_original"]],
									["_in_tVAT_Definition", "=", ["Replace_string", ["_in_tVAT_Definition", "VAT_Percent", ["String", ["in_arVAT_Percentage_tmp[_in_lIndex]"]], "|0-2d"]]],
									["_in_tVAT_Definition", "=", ["Replace_string", ["_in_tVAT_Definition", "VAT_Sum", ["String", ["_in_arCD_VAT_Sum[_in_lIndex]"]], "|2d"]]],
									["_in_tCD_VAT_text", "=", ["_in_tCD_VAT_text", "+", "_in_tVAT_Definition"]]
								]
							],
							["_in_tVAT_text", "=", ["Substring", ["_in_tVAT_text", "1", [["Length", ["_in_tVAT_text"]], "-", "2"]]]],
							["_in_tCD_VAT_text", "=", ["Substring", ["_in_tCD_VAT_text", "1", [["Length", ["_in_tCD_VAT_text"]], "-", "2"]]]],
							["_in_tFootnote_vat_text", "=", ["xml_ValueGet", ["_in_tDefinition", "VAT_Text"]]],
							["_in_tFootnote_vat_text", "=", ["Replace_string", ["_in_tFootnote_vat_text", "VAT_Definition", "_in_tVAT_text"]]],
							[
								"if", ["top_discount_days", ">", "0"],
								[
									["_in_tFootnote_cd_text", "=", ["xml_ValueGet", ["_in_tDefinition", "CD_Text"]]],
									["_in_tFootnote_cd_text", "=", ["Replace_string", ["_in_tFootnote_cd_text", "CD_Date", ["String", ["in_cash_discount_due_date"]]]]],
									["_in_tFootnote_cd_text", "=", ["Replace_string", ["_in_tFootnote_cd_text", "CD_Percent", ["String", ["top_discount_percentage"]], "|0-2d"]]],
									["_in_tFootnote_cd_text", "=", ["Replace_string", ["_in_tFootnote_cd_text", "CD_DiscountSum", ["String", ["_in_rCD_DiscountVatSum"]], "|2d"]]],
									["_in_tFootnote_cd_text", "=", ["Replace_string", ["in_tFootnote_cd_text", "CD_TotalSum", ["String", ["_in_rCD_TotalSum"]], "|2d"]]],
									["_in_tFootnote_cd_text", "=", ["Replace_string", ["_in_tFootnote_cd_text", "VAT_CD_Definition", "_in_tCD_VAT_text"]]]
								],
								"else",
								[
									["_in_tFootnote_cd_text", "=", ""]
								]
							],
							["inv_footnote", "=", ["_in_tFootnote_vat_text", "+", "_in_tFootnote_cd_text"]],
							["inv_footnote", "=", ["Replace_string", ["inv_footnote", "CD_Currency", "inv_currency_id"]]]
						]
					]
				],
				"else",
				[
					["_so_rMaksetta", "=", "0"],
					[
						"if", [["g.in_kassa_al"], "and", ["inv_total_amount", "<>", "0"]],
						[
							[
								"if", ["top_discount_days", ">", "0"],
								[
									["inv_footnote", "=", ["concat", ["Maksettava: ", ["String", ["inv_date"]], "top_discount_days", "\n"]]],
									["_so_rMaksetta", "=", ["inv_total_amount"]],
									[
										"if", ["top_discount_days", "<", ["top_net_days"]],
										[
											["inv_footnote", "=", ["inv_footnote", "+", ["String", ["Round", [["_so_rMaksetta", "-", [["_so_rMaksetta", "*", "top_discount_percentage"], "/", "100"]], "2"]]], "|2d"]]
										],
										"else",
										[
											["inv_footnote", "=", ["inv_footnote", "+", ["String", ["Round", ["_so_rMaksetta", "2"]]], "|2d"]]
										]
									],
									["inv_footnote", "=", ["concat", ["inv_footnote", " ", "inv_currency_id", "\n", "\n"]]],
									["inv_footnote", "=", ["concat", ["inv_footnote", "Maksettava: ", ["String", ["inv_due_date"]], "\n"]]],
									["inv_footnote", "=", ["concat", ["inv_footnote", ["String", ["Round", ["_so_rMaksetta", "2"]]], "|2d"]]]
								]
							]
						],
						"else",
						[
							["inv_footnote", "=", ""]
						]
					]
				]
			],
			["ARRAY_REAL", ["in_arVAT_Percentage_tmp", "0"]],
			["ARRAY_REAL", ["in_arVAT_Price_tmp", "0"]]
		],
		"inv_VIITENUMERO": [
			["_inv_tFinancingCompanySymbol", "=", ["concat", [",", "g.in_tFinancingInvoiceSendType", ","]]],
			["_inv_tSendType", "=", ["concat", [",", "inc_send_type", ","]]],
			[
				"if", [["Position", ["_inv_tFinancingCompanySymbol", "_inv_tSendType"]], ">", "0"],
				[
					[
						"if", [["g.inv_sSovellus", "=", "LA01"], "and", ["g.inv_sSovellusvakio", "=", ""]],
						[
							["_err_MESSAGE", [["concat", ["Laskun_viitenumero_on_todennakoisesti_vaara", "\n", "Korjaa_oletusarvoihin_sovellusvakion_arvo(oikea_arvo_on_joko_301_tai_001)"]], "Current_method_name", "false"]]
						]
					],
					["_inv_InvoiceNumber", "=", ["aaC_Lisaa_Nolla", ["inv_invoice_id", "0", "0", "9"]]],
					["inv_reference_number", "=", ["in__ReferenceNumber", ["g.inv_sRahSopNr", "+", "g.inv_sSovellusvakio", "+", "_inv_InvoiceNumber"]]]
				],
				"else",
				[
					[
						"if", ["co_supplier_number", "=", ""],
						[
							["inv_reference_number", "=", ["inv__ReferenceNumber", ["inv_invoice_id", "+", "co_company_number"]]]
						],
						"else",
						[
							["inv_reference_number", "=", ["inv__ReferenceNumber", ["co_supplier_number", "+", "inv_invoice_id"]]]
						]
					]
				]
			]
		],
		"inv_sMAKSUEHTO": [
			["RELATE_ONE", ["inv_terms_of_payment_id"]],
			[
				"if", ["!top_no_due_date"],
				[
					["inv_C_PAIVAT"]
				],
				"else",
				[
					[
						"if", ["inv_due_date", "<", ["inv_date"]],
						[
							["inv_due_date", "=", ["inv_date"]]
						]
					]
				]
			],
			["inv_vosAPaiva", "=", ["aaViikonpaiva", ["inv_due_date"]]]
		],
		"inv_scERAPAIVA": [
			["RELATE_ONE", ["inv_terms_of_payment_id"]],
			[
				"if", ["!top_no_due_date"],
				[
					["inv_C_PAIVAT"]
				],
				"else",
				[
					[
						"if", ["inv_date", ">", ["inv_due_date"]],
						[
							["inv_date", "=", ["inv_due_date"]]
						]
					]
				]
			],
			["inv_cosAPaiva", "=", ["aaViikonpaiva", ["inv_due_date"]]]
		],
		"inv_C_PAIVAT": [
			["RELATE_ONE", ["inv_terms_of_payment_id"]],
			["inv_destination_date", "=", ["inv_date", "+", "top_target_date_difference"]],
			["inv_due_date", "=", ["inv_destination_date", "+", "top_net_days"]],
			[
				"if", ["top_discount_days", ">", "0"],
				[
					["inv_cash_discount_due_date", "=", ["inv_destination_date", "+", "top_discount_days"]]
				],
				"else",
				[
					["inv_cash_discount_due_date", "=", ["inv_due_date"]]
				]
			],
			["inv_ALAVIITE_KASS"]
		],
		"inv_sVALUUTTA_MUU": [
			["_fOK", "=", "false"],
			["_err_LANG_DO"],
			[
				"if", [["inv_paid_total", "=", "0"], "and", ["inv_voucher_id", "=", ""]],
				[
					["_fOK", "=", "true"]
				],
				"else",
				[
					["_Str", "=", ""],
					[
						"if", ["inv_paid_total", "<>", "0"],
						[
							["_Str", "=", ["concat", ["Laskuun_on_tullut_suorituksia.", "\n"]]]
						]
					],
					[
						"if", ["inv_voucher_id", "<>", ""],
						[
							["_Str", "=", ["concat", ["_Str", "Lasku_on_viety_kirjanpitoon.", "\n"]]]
						]
					],
					["_Str", "=", ["concat", ["_Str", "Valuuttaa_ja/tai_kurssia_ei_voi_muuttaa."]]],
					["xCRY", ["_Str"]]
				]
			],
			[
				"if", ["_fOK"],
				[
					["inv_exchange_rate", "=", ["cur_selling_rate"]],
					[
						"if", [["Records_in_selection", ["invr"]], ">", "0"],
						[
							[
								"if", ["inv_currency_id", "<>", "so_sVanhaVal"],
								[
									["_Str", "=", ["concat", ["Olet_muuttanut_valuuttaa.", "\n"]]],
									["_Str", "=", ["concat", ["_Str", "Hae_jokaiselle_laskuriville_tuotteet_uudestaan, jotta_niille_saadaan"]]],
									["_Str", "=", ["concat", ["_Str", " uusi_ulkomainen_hinta."]]],
									["xCry", ["_Str"]],
									["so_sVanhaVal", "=", ["inv_currency_id"]]
								]
							],
							["inv_ALARIVIN_KENT"],
							["inv_ALAVIITE_KASS"]
						]
					]
				],
				"else",
				[
					["inv_currency_id", "=", ["so_sVanhaVal"]],
					["GOTO_OBJECT", ["inv_currency_id"]],
					["xCRY", ["_Str"]]
				]
			]
		],
		"inv_scTIL_ALE_PRO": [
			["inv_ALARIVIN_KENT"],
			["inv_ALAVIITE_KASS"]
		],
		"inv_scTIL_ALENNUS": [
			[
				"if", ["inv_price_total", "<>", "0"],
				[
					["inv_order_discount_percentage", "=", [["inv_order_discount_total", "/", "inv_price_total"], "*", "100"]]
				],
				"else",
				[
					["inv_order_discount_percentage", "=", "0"]
				]
			],
			["inv_ALARIVIN_KENT"],
			["inv_ALAVIITE_KASS"]
		],
		"inv_scpopTYYPPI": [
			["_in_sOldPop", "=", ["inv_type"]],
			[
				"if", ["true"],
				[
					["_pop_FLD", ["0", "in_kType_", "0"]]
				],
				"else",
				[]
			],
			["_sUusi", "=", ["inv_type"]],
			[
				"if", ["_in_sOldPop", "<>", "_sUusi"],
				[
					[
						"if", ["_in_sOldPop", "=", "KO"],
						[
							["inv_invoice_text", "=", ["Replace_string", ["inv_invoice_text", "g.gtLaskukork", ""]]]
						]
					],
					[
						"if", ["inv_exported_to_ar"],
						[
							["in_aspopTyyppi", "=", ["Find_in_array", ["in_asTyyppi", "_in_sOldPop"]]],
							["inv_type", "=", ["_in_sOldPop"]],
							["_err_LANG_DO"],
							["XCRY", ["Reskontraan_viedyn_laskun_tilaa_ei_voida_vaihtaa."]]
						],
						"else",
						[
							[
								"if", ["_sUusi", "=", "KO"],
								[
									["inv_invoice_text", "=", ["inv_invoice_text", "+", "g.gtLaskukork"]]
								]
							]
						]
					]
				]
			],
			["_fii__SEL_APPLY_TO", ["inr_kType_", "inv_type"]]
		],
		"inv_TOIMITASIAKAS": [
			[
				"if", ["co_delivery_company_id", "<>", ""],
				[
					["xMESSAGES_OFF"],
					["QUERY", ["coad", ["coad_company_id", "=", ["inv_delivery_company_id"]], "*"]],
					["QUERY", ["coad", "&", ["coad_address_type", "=", ["g.mgsTOIM_OSO"]]]],
					["xMESSAGES_ON"],
					[
						"if", [["Records_in_selection", ["coad"]], "=", "1"],
						[
							["inv_delivery_address", "=", ["coad_text_address"]]
						],
						"else",
						[
							["inv_delivery_address", "=", ["co_text_address"]]
						]
					]
				],
				"else",
				[
					["inv_delivery_address", "=", ["co_text_address"]]
				]
			],
			["RELATE_MANY", ["inv"]],
			["RELATE_ONE", ["inv_terms_of_payment_id"]]
		],
		"inv_sYRITYS": [
			["in_NUMBER", ["g.aalNR_LOFF", "inv_type", "inv_firm_id"]],
			["inv_scTUNNUS_NUM"]
		],
		"inv_scTUNNUS_NUM": [
			[
				"if", [[["g.in_sNro2Tyyp", "<>", ""], "and", ["inv_type", "=", ["g.in_sNro2Tyyp"]]], "or", [["g.in_sNro2Tyyp", "=", ""], "and", ["inv_type", "=", "PR"]]],
				[
					["inv_invoice_id", "=", ["_code_Build", ["in_sS_ProEtu", "in_lTunNro", "in_lS_LasPit"]]],
					["in_sS_ProTun", "=", ["inv_invoice_id"]]
				],
				"elseif", ["inv_type", "=", "KO"],
				[
					["inv_invoice_id", "=", ["_code_Build", ["in_sS_KorEtu", "in_lTunNro", "in_lS_LasPit"]]],
					["in_sS_KorTun", "=", ["inv_invoice_id"]]
				],
				"else",
				[
					["inv_invoice_id", "=", ["_code_Build", ["in_sS_LasEtu", "in_lTunNro", "in_lS_LasPit"]]],
					["in_sS_LasTun", "=", ["inv_invoice_id"]]
				]
			],
			["inv_VIITENUMERO"]
		]
	}
}
