{
	"name": "form/nc/erp-sync/ksef/save/ksef-order-invoice-xml-convert.json",
	"line_break": "\n",
	"indent": "\t",
	"main_data_tag": "ord",
	"charset": "UTF-8",
	"decimal_separator": ".",
	"create_empty_tag": false,
	"xml_header": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
	"namespace": "xmlns=\"http://crd.gov.pl/wzor/2025/06/25/13775/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://crd.gov.pl/wzor/2025/06/25/13775/ http://crd.gov.pl/wzor/2025/06/25/13775/schemat.xsd\"",
	"convert": [
		{
			"field": "ord",
			"tag": "Faktura",
			"mandatory": "M",
			"content": [
				{
					"tag": "Naglowek",
					"content": [
						{
							"tag": "KodFormularza",
							"attribute": {
								"kodSystemowy": "FA (3)",
								"wersjaSchemy": "1-0E"
							},
							"from_static": "FA"
						},
						{
							"tag": "WariantFormularza",
							"from_static": "3"
						},
						{
							"tag": "DataWytworzeniaFa",
							"field": "order_date",
							"data_type": "date",
							"format": "%Y-%m-%dT00:00:00Z"
						},
						{
							"tag": "SystemInfo",
							"from_static": "Capacic ERP"
						}
					]
				},
				{
					"tag": "Podmiot1",
					"content": [
						{
							"tag": "DaneIdentyfikacyjne",
							"content": [
								{
									"tag": "NIP",
									"code": [
										{
											"function": "parseToNumber",
											"parameter": ["json_data.seller.vat_number"],
											"result": "json_data.seller.vat_number"
										}
									],
									"field": "json_data.seller.vat_number",
									"mandatory": "M",
									"info": "Seller Polish tax ID NIP - 10 digits"
								},
								{
									"tag": "Nazwa",
									"field": "json_data.seller.name",
									"mandatory": "M",
									"info": "Seller company full official name"
								}
							]
						},
						{
							"tag": "Adres",
							"content": [
								{ "tag": "KodKraju", "field": "json_data.seller.country_code" },
								{ "tag": "AdresL1", "field": "json_data.seller.address" },
								{ "tag": "AdresL2", "field": "json_data.seller.address2" }
							]
						}
					]
				},
				{
					"tag": "Podmiot2",
					"key": "PL",
					"in_use": true,
					"code": [
						{
							"function": "if",
							"parameter": ["json_data.buyer.country_code", "<>", "PL"],
							"then": [{ "result": "in_use", "function": "=", "parameter": [false] }]
						},
						{
							"function": "if",
							"parameter": ["json_data.buyer.is_private", "=", "1"],
							"then": [{ "result": "in_use", "function": "=", "parameter": [false] }]
						}
					],
					"content": [
						{
							"tag": "DaneIdentyfikacyjne",
							"content": [
								{
									"tag": "NIP",
									"field": "json_data.buyer.vat_number",
									"code": [
										{
											"function": "parseToNumber",
											"parameter": ["json_data.buyer.vat_number"],
											"result": "json_data.buyer.vat_number"
										}
									],
									"mandatory": "",
									"alternative_tag": "KodUE"
								},
								{ "tag": "Nazwa", "field": "json_data.buyer.name", "mandatory": "M" }
							]
						},
						{
							"tag": "Adres",
							"content": [
								{ "tag": "KodKraju", "field": "json_data.buyer.country_code" },
								{ "tag": "AdresL1", "field": "json_data.buyer.address" },
								{ "tag": "AdresL2", "field": "json_data.buyer.address2" }
							]
						},
						{
							"tag": "JST",
							"from_static": "2",
							"info": "JST flag: 1=invoice for JST subordinate unit (requires Podmiot3), 2=not for JST unit"
						},
						{
							"tag": "GV",
							"from_static": "2",
							"info": "VAT group flag: 1=invoice for VAT group member (requires Podmiot3), 2=not for VAT group"
						}
					]
				},
				{
					"tag": "Podmiot2",
					"key": "PRIVATE",
					"in_use": true,
					"code": [
						{
							"function": "if",
							"parameter": ["json_data.buyer.is_private", "<>", "1"],
							"then": [{ "result": "in_use", "function": "=", "parameter": [false] }]
						}
					],
					"content": [
						{
							"tag": "DaneIdentyfikacyjne",
							"content": [
								{
									"tag": "BrakID",
									"from_static": "1",
									"info": "Private buyer has no tax identifier",
									"mandatory": ""
								},
								{ "tag": "Nazwa", "field": "json_data.buyer.name", "mandatory": "" }
							]
						},
						{
							"tag": "Adres",
							"content": [
								{ "tag": "KodKraju", "field": "json_data.buyer.country_code" },
								{ "tag": "AdresL1", "field": "json_data.buyer.address" },
								{ "tag": "AdresL2", "field": "json_data.buyer.address2" }
							]
						},
						{
							"tag": "JST",
							"from_static": "2",
							"info": "JST flag: 1=invoice for JST subordinate unit (requires Podmiot3), 2=not for JST unit"
						},
						{
							"tag": "GV",
							"from_static": "2",
							"info": "VAT group flag: 1=invoice for VAT group member (requires Podmiot3), 2=not for VAT group"
						}
					]
				},
				{
					"tag": "Podmiot2",
					"key": "EU",
					"in_use": true,
					"code": [
						{
							"function": "if",
							"parameter": ["json_data.buyer.country_code", "=", "PL"],
							"then": [{ "result": "in_use", "function": "=", "parameter": [false] }]
						},
						{
							"function": "if",
							"parameter": ["json_data.buyer.is_private", "=", "1"],
							"then": [{ "result": "in_use", "function": "=", "parameter": [false] }]
						}
					],
					"content": [
						{
							"tag": "DaneIdentyfikacyjne",
							"content": [
								{
									"tag": "KodUE",
									"field": "json_data.buyer.country_code",
									"mandatory": "",
									"alternative_tag": "NIP",
									"info": "PL country_code does not exist, we NIP tag as alternative to prevent xml paring error"
								},
								{
									"tag": "NrVatUE",
									"field": "json_data.buyer.vat_number",
									"code": [
										{
											"function": "parseToNumber",
											"parameter": ["json_data.buyer.vat_number"],
											"result": "json_data.buyer.vat_number"
										}
									],
									"mandatory": "",
									"alternative_tag": "NIP"
								},
								{ "tag": "Nazwa", "field": "json_data.buyer.name", "mandatory": "M" }
							]
						},
						{
							"tag": "Adres",
							"content": [
								{ "tag": "KodKraju", "field": "json_data.buyer.country_code" },
								{ "tag": "AdresL1", "field": "json_data.buyer.address" },
								{ "tag": "AdresL2", "field": "json_data.buyer.address2" }
							]
						},
						{
							"tag": "JST",
							"from_static": "2",
							"info": "JST flag: 1=invoice for JST subordinate unit (requires Podmiot3), 2=not for JST unit"
						},
						{
							"tag": "GV",
							"from_static": "2",
							"info": "VAT group flag: 1=invoice for VAT group member (requires Podmiot3), 2=not for VAT group"
						}
					]
				},
				{
					"tag": "Fa",
					"content": [
						{
							"tag": "KodWaluty",
							"field": "currency_id",
							"default_value": "PLN"
						},
						{
							"tag": "P_1",
							"field": "order_date",
							"data_type": "date",
							"format": "%Y-%m-%d",
							"mandatory": "M",
							"info": "Invoice issue date"
						},
						{
							"tag": "P_2",
							"field": "order_id",
							"mandatory": "M",
							"info": "Invoice sequential number"
						},
						{
							"field": "json_data.wz_number_array",
							"tag": "WZ",
							"info": "Dispatch note numbers (WZ) related to invoice"
						},
						{
							"tag": "P_6",
							"field": "json_data.destination_date",
							"data_type": "date",
							"format": "%Y-%m-%d",
							"mandatory": "O",
							"info": "Sale/delivery date"
						},
						{
							"tag": "P_13_1",
							"field": "json_data.poland_net_1",
							"format": "%.2f",
							"mandatory": "",
							"info": "Net amount for basic rate (currently 23%/22%)"
						},
						{
							"tag": "P_14_1",
							"field": "json_data.poland_vat_original_1",
							"format": "%.2f",
							"mandatory": "",
							"info": "VAT amount in invoice currency for basic rate (currently 23%/22%)"
						},
						{
							"tag": "P_14_1W",
							"field": "json_data.poland_vat_1",
							"format": "%.2f",
							"mandatory": "",
							"info": "VAT in PLN for basic rate (currently 23%/22%). Foreign currency invoices per art. 106e ust. 11"
						},
						{
							"tag": "P_13_2",
							"field": "json_data.poland_net_2",
							"format": "%.2f",
							"mandatory": "",
							"info": "Net amount for reduced rate 1 (currently 8%/7%)"
						},
						{
							"tag": "P_14_2",
							"field": "json_data.poland_vat_original_2",
							"format": "%.2f",
							"mandatory": "",
							"info": "VAT amount in invoice currency for reduced rate 1 (currently 8%/7%)"
						},
						{
							"tag": "P_14_2W",
							"field": "json_data.poland_vat_2",
							"format": "%.2f",
							"mandatory": "",
							"info": "VAT in PLN for reduced rate 1 (currently 8%/7%). Foreign currency invoices per art. 106e ust. 11"
						},
						{
							"tag": "P_13_3",
							"field": "json_data.poland_net_3",
							"format": "%.2f",
							"mandatory": "",
							"info": "Net amount for reduced rate 2 (currently 5%)"
						},
						{
							"tag": "P_14_3",
							"field": "json_data.poland_vat_original_3",
							"format": "%.2f",
							"mandatory": "",
							"info": "VAT amount in invoice currency for reduced rate 2 (currently 5%)"
						},
						{
							"tag": "P_14_3W",
							"field": "json_data.poland_vat_3",
							"format": "%.2f",
							"mandatory": "",
							"info": "VAT in PLN for reduced rate 2 (currently 5%). Foreign currency invoices per art. 106e ust. 11"
						},
						{
							"tag": "P_13_4",
							"field": "json_data.poland_net_4",
							"format": "%.2f",
							"mandatory": "",
							"info": "Net amount for taxi lump sum"
						},
						{
							"tag": "P_14_4",
							"field": "json_data.poland_vat_original_4",
							"format": "%.2f",
							"mandatory": "",
							"info": "VAT amount in invoice currency for taxi VAT (fixed %)"
						},
						{
							"tag": "P_14_4W",
							"field": "json_data.poland_vat_4",
							"format": "%.2f",
							"mandatory": "",
							"info": "VAT in PLN for taxi VAT (fixed %). Foreign currency invoices per art. 106e ust. 11"
						},
						{
							"tag": "P_13_5",
							"field": "json_data.poland_net_5",
							"format": "%.2f",
							"mandatory": "",
							"info": "Net amount for special procedure per section XII chapter 6a"
						},
						{
							"tag": "P_14_5",
							"field": "json_data.poland_vat_5",
							"format": "%.2f",
							"mandatory": "",
							"info": "VAT amount for special procedure per section XII chapter 6a"
						},
						{
							"tag": "P_13_6_1",
							"field": "json_data.poland_net_6_1",
							"format": "%.2f",
							"mandatory": "",
							"info": "Net amount for 0% rate (excluding WDT and export)"
						},
						{
							"tag": "P_13_6_2",
							"field": "json_data.poland_net_6_2",
							"format": "%.2f",
							"mandatory": "",
							"info": "Net amount for 0% intra-community supply (WDT)"
						},
						{
							"tag": "P_13_6_3",
							"field": "json_data.poland_net_6_3",
							"format": "%.2f",
							"mandatory": "",
							"info": "Net amount for 0% export"
						},
						{
							"tag": "P_13_7",
							"field": "json_data.poland_net_7",
							"format": "%.2f",
							"mandatory": "",
							"info": "Total net amount for exempt sales"
						},
						{
							"tag": "P_13_8",
							"field": "json_data.poland_net_8",
							"format": "%.2f",
							"mandatory": "",
							"info": "Net amount for services outside Poland territory"
						},
						{
							"tag": "P_13_9",
							"field": "json_data.poland_net_9",
							"format": "%.2f",
							"mandatory": "",
							"info": "Net amount for services per art. 100"
						},
						{
							"tag": "P_13_10",
							"field": "json_data.poland_net_10",
							"format": "%.2f",
							"mandatory": "",
							"info": "Net amount for reverse charge procedure"
						},
						{
							"tag": "P_13_11",
							"field": "json_data.poland_net_11",
							"format": "%.2f",
							"mandatory": "",
							"info": "Net amount for margin procedure per art. 119 and 120"
						},
						{
							"tag": "P_15",
							"field": "price_with_vat",
							"format": "%.2f",
							"mandatory": "M",
							"info": "Total gross amount"
						},
						{
							"tag": "KursWalutyZ",
							"field": "json_data.poland_vat_rate",
							"format": "%.4f",
							"mandatory": "",
							"in_use": true,
							"code": [
								{
									"function": "if",
									"parameter": ["currency_id", "=", "PLN"],
									"then": [{ "result": "in_use", "function": "=", "parameter": [false] }]
								}
							],
							"info": "Exchange rate for PLN VAT calculation per art. 106e ust. 11, only for foreign currency invoices"
						},
						{
							"tag": "Adnotacje",
							"content": [
								{
									"tag": "P_16",
									"from_static": "2"
								},
								{
									"tag": "P_17",
									"from_static": "2"
								},
								{
									"tag": "P_18",
									"from_static": "2"
								},
								{
									"tag": "P_18A",
									"from_static": "2"
								},
								{
									"tag": "Zwolnienie",
									"content": [
										{
											"tag": "P_19N",
											"from_static": "1"
										}
									]
								},
								{
									"tag": "NoweSrodkiTransportu",
									"content": [
										{
											"tag": "P_22N",
											"from_static": "1"
										}
									]
								},
								{
									"tag": "P_23",
									"from_static": "2"
								},
								{
									"tag": "PMarzy",
									"content": [
										{
											"tag": "P_PMarzyN",
											"from_static": "1"
										}
									]
								}
							]
						},
						{
							"tag": "RodzajFaktury",
							"from_static": "VAT",
							"mandatory": "M",
							"info": "Invoice type code VAT=normal, WDT=export, etc"
						},
						{
							"field": "ordr",
							"tag": "FaWiersz",
							"content": [
								{
									"tag": "NrWierszaFa",
									"field": "ordr.row_number",
									"info": "Line number"
								},
								{
									"tag": "P_6A",
									"in_use": false,
									"field": "ordr.delivery_date",
									"data_type": "date",
									"format": "%Y-%m-%d",
									"info": "Delivery date per line (when dates differ between lines)"
								},
								{
									"tag": "P_7",
									"field": "ordr.description",
									"info": "Product name or description"
								},
								{
									"tag": "Indeks",
									"field": "ordr.product_id"
								},
								{
									"tag": "CN",
									"in_use": false,
									"field": "ordr.cn_code",
									"info": "CN code for product classification, not in current data"
								},
								{
									"tag": "P_8A",
									"field": "ordr.unit",
									"value_map": "form/nc/erp-sync/ksef/value-map.json/unit_convert",
									"default_value": "szt",
									"info": "Unit of measure code"
								},
								{
									"tag": "P_8B",
									"field": "ordr.delivery_amount",
									"format": "%.2f",
									"mandatory": "M",
									"info": "Quantity delivered"
								},
								{
									"tag": "P_9A",
									"field": "ordr.unit_price",
									"format": "%.2f",
									"info": "Unit price net amount"
								},
								{
									"tag": "P_9B",
									"in_use": false,
									"field": "ordr.unit_price_with_vat",
									"format": "%.2f",
									"info": "Unit price gross amount, not in current data"
								},
								{
									"tag": "P_11",
									"field": "ordr.price_without_vat",
									"format": "%.2f",
									"mandatory": "M",
									"info": "Line item net amount total"
								},
								{
									"tag": "P_11A",
									"in_use": false,
									"field": "ordr.price_with_vat",
									"format": "%.2f",
									"mandatory": "M",
									"info": "Line item gross amount total"
								},
								{
									"tag": "P_12",
									"field": "ordr.json_data.ksef_vat_code",
									"mandatory": "M",
									"info": "VAT rate: 23/22/8/7/5/4/3/0 KR/0 WDT/0 EX/zw/oo/np I/np II"
								},
								{
									"tag": "KursWaluty",
									"field": "ordr.json_data.poland_vat_rate",
									"format": "%.4f",
									"mandatory": "",
									"in_use": true,
									"code": [
										{
											"function": "if",
											"parameter": ["currency_id", "=", "PLN"],
											"then": [{ "result": "in_use", "function": "=", "parameter": [false] }]
										}
									],
									"info": "Exchange rate for foreign currency line item, only for non-PLN invoices"
								}
							]
						},
						{
							"tag": "Platnosc",
							"content": [
								{
									"tag": "TerminPlatnosci",
									"content": [
										{
											"tag": "Termin",
											"field": "due_date",
											"data_type": "date",
											"format": "%Y-%m-%d"
										},
										{
											"tag": "TerminOpis",
											"in_use": true,
											"code": [
												{
													"function": "if",
													"parameter": ["json_data.poland_payment_term_amount", "=", ""],
													"then": [{ "result": "in_use", "function": "=", "parameter": [false] }]
												}
											],
											"content": [
												{
													"tag": "Ilosc",
													"field": "json_data.poland_payment_term_amount",
													"mandatory": "",
													"info": "Number of days for payment term"
												},
												{
													"tag": "Jednostka",
													"field": "json_data.poland_payment_term_unit",
													"mandatory": "",
													"info": "Unit of measurement for payment term"
												},
												{
													"tag": "ZdarzeniePoczatkowe",
													"field": "json_data.poland_payment_term_term",
													"mandatory": "",
													"info": "Payment term condition"
												}
											]
										}
									]
								},
								{
									"tag": "FormaPlatnosci",
									"field": "json_data.poland_payment_method"
								},
								{
									"tag": "RachunekBankowy",
									"mandatory": "",
									"content": [
										{
											"tag": "NrRB",
											"field": "json_data.seller.bank_account",
											"info": "Seller bank account number (26 digits for PL)"
										},
										{
											"tag": "SWIFT",
											"field": "json_data.seller.swift_code",
											"info": "Bank SWIFT code (optional)"
										},
										{
											"tag": "NazwaBanku",
											"field": "json_data.seller.bank_name",
											"mandatory": "",
											"info": "Bank name (optional)"
										}
									]
								}
							]
						},
						{
							"tag": "WarunkiTransakcji",
							"content": [
								{
									"tag": "Zamowienia",
									"content": [
										{
											"tag": "NrZamowienia",
											"field": "company_reference_number",
											"info": "Customer purchase order number"
										}
									]
								}
							]
						}
					]
				}
			]
		}
	]
}
