-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.ts
94 lines (83 loc) · 2.93 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
const Jsonix = require('jsonix').Jsonix;
const JPK = require('./mappings/JPK').JPK;
var format = require('xml-formatter');
import * as KodyCECHKRAJOW from './xmlns/http/crd.gov.pl/xml/schematy/dziedzinowe/mf/2013/05/23/eD/KodyCECHKRAJOW';
import * as DefinicjeTypy from './xmlns/http/crd.gov.pl/xml/schematy/dziedzinowe/mf/2016/01/25/eD/DefinicjeTypy';
import {JPKType} from './xmlns/http/jpk.mf.gov.pl/wzor/2016/03/09/03095';
// JPKTypy.
/**
*
* https://www.npmjs.com/package/cxsd
*
* https://github.com/highsource/jsonix-schema-compiler/issues/51
*
* https://github.com/highsource/jsonix-schema-compiler/wiki/EnumMemberSizeCap-Limit
* https://github.com/highsource/jsonix-schema-compiler/wiki/Command-Line-Usage
* https://github.com/highsource/jsonix-schema-compiler/issues/81
*
*
* https://github.com/charto/cxsd/issues/19
* ./node_modules/.bin/cxsd file://./Schemat_JPK_FA\(1\)_v1-0.xsd
*
* java --add-modules java.xml.bind -jar node_modules/jsonix/lib/jsonix-schema-compiler-full.jar -d mappings -p JPK Schemat_JPK_FA\(1\)_v1-0.xsd -b bindings.xjb
*
*/
// console.log(JPK);
const value = {
naglowek: {},
podmiot1: {
identyfikatorPodmiotu: {
nip : "3213213213",
pelnaNazwa: "dsadas adas Z dsadsa dsadsad",
regon : "32123213333"
},
adresPodmiotu : {
kodKraju: 'PL'
}
},
faktura : [
{
"p1" : "2018-01-12",
"p2A" : "FV SP / 198 / 01 / 2018",
"p3A" : "rewrwer erwerw-r rew",
"p3B" : "dsfdsfgfdh dfsfds f sdfds",
"p3C" : "zzzzzz",
"p3D" : "eeeee",
"p4B" : "1232132133",
"p5B" : "1232132133",
"p6" : "2018-01-10",
"p131" : "5316.00",
"p141" : "1222.68",
"p132" : "0.00",
"p142" : "0.00",
"p133" : "0.00",
"p143" : "0.00",
"p135" : "0.00",
"p145" : "0.00",
"p136" : "0.00",
"p137" : "0.00",
"p15" : "6538.68",
"p16" : "false",
"p17" : "false",
"p18" : "false",
"p19" : "false",
"p20" : "false",
"p21" : "false",
"p23" : "false",
"p106E2" : "false",
"p106E3" : "false",
"rodzajFaktury": "VAT"
}
]
}
const context = new Jsonix.Context([JPK], {
namespacePrefixes: {
"http://jpk.mf.gov.pl/wzor/2016/03/09/03095/": "",
"http://crd.gov.pl/xml/schematy/dziedzinowe/mf/2016/01/25/eD/DefinicjeTypy/": "ns2"
}
});
const marshaller = context.createMarshaller();
const result = marshaller.marshalString({
JPK: value
});
console.log(format(result));