{
	"name": "convert/inv/custom/netvisor/netvisor_out_in_to_in.json",
	"convert": [
		[
			"/root/salesinvoice",
			"=",
			[
				"inv",
				[
					[
						"salesinvoicenumber",
						"=",
						"inv_invoice_id"
					],
					[
						"salesinvoicedate[@format=\"ansi\"]",
						"=",
						"inv_date_"
					],
					[
						"salesinvoicereferencenumber",
						"=",
						"inv_reference_number"
					],
					[
						"{{currencycode}}",
						"=",
						["linkedFieldValue",["inv_currency_id", "cur_export_code"]]
					],
					[
						"salesinvoiceamount[@iso4217currencycode={{currencycode}}]",
						"=",
						"inv_total_amount"
					],
					[
						"invoicetype",
						"=",
						"invoice"
					],
					[
						"salesinvoicestatus[@type=\"netvisor\"]",
						"=",
						"unsent"
					],
					[
						"salesinvoicefreetextbeforelines",
						"=",
						["concatWith",[["", "Order number/tilausnumero: ", "inv_customer_order_number", ", Mark/merkki: ", "inv_mark", ", Dispatch note/lähetyslista: ", "invr.1.invr_dispatch_note"]]]
					],
					[
						"salesinvoicefreetextafterlines",
						"=",
						"inv_invoice_text"
					],
					[
						"salesinvoiceourreference",
						"=",
						"inv_our_reference"
					],
					[
						"salesinvoiceyourreference",
						"=",
						"inv_your_reference"
					],
					[
						"invoicingcustomeridentifier[@type=\"customer\"]",
						"=",
						"inv_company_id"
					],
					[
						"invoicingcustomername",
						"=",
						"inv_additional_data.invoicing_address.name"
					],
					[
						"invoicingcustomernameextension",
						"=",
						"inv_additional_data.invoicing_address.name_2"
					],
					[
						"invoicingcustomeraddressline",
						"=",
						"inv_additional_data.invoicing_address.address"
					],
					[
						"invoicingcustomerpostnumber",
						"=",
						"inv_additional_data.invoicing_address.post_code"
					],
					[
						"invoicingcustomertown",
						"=",
						"inv_additional_data.invoicing_address.post_office"
					],
					[
						"invoicingcustomercountrycode[@type=\"ISO-3316\"]",
						"=",
						["from_preference","custom/netvisor/netvisor_export_invoice.country_code[inv_additional_data.invoicing_address.country]", "FI"]
					],
					[
						"deliveryaddressname",
						"=",
						"inv_additional_data.delivery_address.name"
					],
					[
						"deliveryaddressline",
						"=",
						"inv_additional_data.delivery_address.address"
					],
					[
						"deliveryaddresspostnumber",
						"=",
						"inv_additional_data.delivery_address.post_code"
					],
					[
						"deliveryaddresstown",
						"=",
						"inv_additional_data.delivery_address.post_office"
					],
					[
						"deliveryaddresscountrycode[@type=\"ISO-3316\"]",
						"=",
						["from_preference","custom/netvisor/netvisor_export_invoice.country_code[inv_additional_data.delivery_address.country]", "FI"]
					],
					[
						"deliverymethod",
						"=",
						["inv_way_of_delivery"]
					],
					[
						"deliveryterm",
						"=",
						["inv_term_of_delivery"]
					],
					[
						"paymenttermnetdays",
						"=",
						["linkedFieldValue",["inv_terms_of_payment_id", "top_net_days"]]
					],
					[
						"paymenttermcashdiscountdays",
						"=",
						["linkedFieldValue",["inv_terms_of_payment_id", "top_discount_days"]]
					],
					[
						"paymenttermcashdiscount[@type=\"percentage\"]",
						"=",
						["linkedFieldValue",["inv_terms_of_payment_id", "top_discount_percentage"]]
					],
					[
						"/root/salesinvoice/invoicelines/invoiceline",
						"=",
						[
							"invr",
							[
								[
									"salesinvoiceproductline/productidentifier[@type=\"customer\"]",
									"=",
									"invr_product_id"
								],
								[
									"salesinvoiceproductline/productname",
									"=",
									["linkedFieldValue",["invr_product_id", "pr_name"]]
								],
								[
									"salesinvoiceproductline/productunitprice[@type=\"net\"]",
									"=",
									"invr_price__unit"
								],
								[
									"{{vatcode}}",
									"=",
									["linkedFieldValue",["invr_sales_order_code_id", "soc_export_code"]]
								],
								[
									"salesinvoiceproductline/productvatpercentage[@vatcode={{vatcode}}]",
									"=",
									"invr_vat_percentage"
								],
								[
									"salesinvoiceproductline/salesinvoiceproductlinequantity",
									"=",
									"invr_delivered_quantity"
								],
								[
									"salesinvoiceproductline/salesinvoiceproductlinediscountpercentage",
									"=",
									"invr_discount_percentage"
								],
								[
									"salesinvoiceproductline/salesinvoiceproductlinefreetext",
									"=",
									"invr_explanation"
								]
							]
						]
					]
				]
			]
		]
	]
}
