{
	"name": "convert/manager/order/order/invoice/custom/netvisor/netvisor_out_in_to_in.json",
	"convert": [
		[
			"/root/salesinvoice",
			"=",
			[
				"ord",
				[
					[
						"salesinvoicenumber",
						"=",
						"ord.order_id"
					],
					[
						"salesinvoicedate[@format=\"ansi\"]",
						"=",
						"ord.order_date"
					],
					[
						"salesinvoicereferencenumber",
						"=",
						"ord.json_data.bank_reference_number"
					],
					[
						"{{currencycode}}",
						"=",
						[
							"linkedFieldValue",
							[
								"ord.currency_id",
								"cur.json_data.export_code"
							]
						]
					],
					[
						"salesinvoiceamount[@iso4217currencycode={{currencycode}}]",
						"=",
						"ord.price_with_vat"
					],
					[
						"invoicetype",
						"=",
						"order"
					],
					[
						"salesinvoicestatus[@type=\"netvisor\"]",
						"=",
						"unsent"
					],
					[
						"salesinvoicefreetextbeforelines",
						"=",
						[
							"concatWith",
							[
								[
									"",
									"Order number/tilausnumero: ",
									"ord.company_reference_number",
									", Mark/merkki: ",
									"ord.json_data.mark",
									", Dispatch note/lähetyslista: ",
									"invr.1.ordr.dispatch_note_id"
								]
							]
						]
					],
					[
						"salesinvoicefreetextafterlines",
						"=",
						"ord.note"
					],
					[
						"salesinvoiceourreference",
						"=",
						"ord.our_reference"
					],
					[
						"salesinvoiceyourreference",
						"=",
						"ord.your_reference"
					],
					[
						"invoicingcustomeridentifier[@type=\"customer\"]",
						"=",
						"ord.invoicing_company_id"
					],
					[
						"invoicingcustomername",
						"=",
						"ord.json_data.invoicing_address.name"
					],
					[
						"invoicingcustomernameextension",
						"=",
						"ord.json_data.invoicing_address.name_2"
					],
					[
						"invoicingcustomeraddressline",
						"=",
						"ord.json_data.invoicing_address.address"
					],
					[
						"invoicingcustomerpostnumber",
						"=",
						"ord.json_data.invoicing_address.post_code"
					],
					[
						"invoicingcustomertown",
						"=",
						"ord.json_data.invoicing_address.post_office"
					],
					[
						"invoicingcustomercountrycode[@type=\"ISO-3316\"]",
						"=",
						[
							"from_preference",
							"custom/netvisor/netvisor_export_invoice.country_code[ord.json_data.invoicing_address.country]",
							"FI"
						]
					],
					[
						"deliveryaddressname",
						"=",
						"ord.json_data.delivery_address.name"
					],
					[
						"deliveryaddressline",
						"=",
						"ord.json_data.delivery_address.address"
					],
					[
						"deliveryaddresspostnumber",
						"=",
						"ord.json_data.delivery_address.post_code"
					],
					[
						"deliveryaddresstown",
						"=",
						"ord.json_data.delivery_address.post_office"
					],
					[
						"deliveryaddresscountrycode[@type=\"ISO-3316\"]",
						"=",
						[
							"from_preference",
							"custom/netvisor/netvisor_export_invoice.country_code[ord.json_data.delivery_address.country]",
							"FI"
						]
					],
					[
						"deliverymethod",
						"=",
						[
							"ord.way_of_delivery"
						]
					],
					[
						"deliveryterm",
						"=",
						[
							"ord.term_of_delivery"
						]
					],
					[
						"paymenttermnetdays",
						"=",
						[
							"linkedFieldValue",
							[
								"ord.terms_of_payment_id",
								"top.net_days"
							]
						]
					],
					[
						"paymenttermcashdiscountdays",
						"=",
						[
							"linkedFieldValue",
							[
								"ord.terms_of_payment_id",
								"top.discount_days"
							]
						]
					],
					[
						"paymenttermcashdiscount[@type=\"percentage\"]",
						"=",
						[
							"linkedFieldValue",
							[
								"ord.terms_of_payment_id",
								"top.json_data.discount_percentage"
							]
						]
					],
					[
						"/root/salesinvoice/invoicelines/invoiceline",
						"=",
						[
							"ordr",
							[
								[
									"salesinvoiceproductline/productidentifier[@type=\"customer\"]",
									"=",
									"ordr.product_id"
								],
								[
									"salesinvoiceproductline/productname",
									"=",
									[
										"linkedFieldValue",
										[
											"ordr.product_id",
											"pr.name"
										]
									]
								],
								[
									"salesinvoiceproductline/productunitprice[@type=\"net\"]",
									"=",
									"ordr.unit_price"
								],
								[
									"{{vatcode}}",
									"=",
									[
										"linkedFieldValue",
										[
											"ordr.order_code_id",
											"ordc.json_data.export_code"
										]
									]
								],
								[
									"salesinvoiceproductline/productvatpercentage[@vatcode={{vatcode}}]",
									"=",
									"ordr.vat_percent"
								],
								[
									"salesinvoiceproductline/salesinvoiceproductlinequantity",
									"=",
									"ordr.delivery_amount"
								],
								[
									"salesinvoiceproductline/salesinvoiceproductlinediscountpercentage",
									"=",
									"ordr.discount_percent"
								],
								[
									"salesinvoiceproductline/salesinvoiceproductlinefreetext",
									"=",
									"ordr.description"
								]
							]
						]
					]
				]
			]
		]
	]
}