@seidor-cloud-produtos/tax-core 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/.idea/br-fiscal.iml +12 -0
  2. package/.idea/dictionaries/valdirjesus.xml +3 -0
  3. package/.idea/modules.xml +8 -0
  4. package/.idea/vcs.xml +6 -0
  5. package/dist/examples/efdContribuicoes/blockC.js +53 -0
  6. package/dist/examples/efdContribuicoes/blockC.js.map +1 -0
  7. package/dist/examples/efdContribuicoes/blockM.js +52 -0
  8. package/dist/examples/efdContribuicoes/blockM.js.map +1 -0
  9. package/dist/examples/efdContribuicoes/efdContribuicoes.js +46 -0
  10. package/dist/examples/efdContribuicoes/efdContribuicoes.js.map +1 -0
  11. package/dist/examples/efdContribuicoes/index.js +23 -0
  12. package/dist/examples/efdContribuicoes/index.js.map +1 -0
  13. package/dist/index.d.mts +2 -0
  14. package/dist/index.d.ts +2 -0
  15. package/dist/index.js +575 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/index.mjs +666 -0
  18. package/dist/index.mjs.map +1 -0
  19. package/dist/lib/taxReport/Block.js +41 -0
  20. package/dist/lib/taxReport/Block.js.map +1 -0
  21. package/dist/lib/taxReport/CounterBlock.js +16 -0
  22. package/dist/lib/taxReport/CounterBlock.js.map +1 -0
  23. package/dist/lib/taxReport/CounterRegister.js +32 -0
  24. package/dist/lib/taxReport/CounterRegister.js.map +1 -0
  25. package/dist/lib/taxReport/Decorators.js +79 -0
  26. package/dist/lib/taxReport/Decorators.js.map +1 -0
  27. package/dist/lib/taxReport/Register.js +46 -0
  28. package/dist/lib/taxReport/Register.js.map +1 -0
  29. package/dist/lib/taxReport/ReportGenerator.js +159 -0
  30. package/dist/lib/taxReport/ReportGenerator.js.map +1 -0
  31. package/dist/lib/taxReport/TagCounter.js +40 -0
  32. package/dist/lib/taxReport/TagCounter.js.map +1 -0
  33. package/dist/lib/taxReport/TaxReport.js +20 -0
  34. package/dist/lib/taxReport/TaxReport.js.map +1 -0
  35. package/dist/lib/taxReport/implementations/ConsoleOutput.js +16 -0
  36. package/dist/lib/taxReport/implementations/ConsoleOutput.js.map +1 -0
  37. package/dist/lib/taxReport/implementations/MemoryPersist.js +55 -0
  38. package/dist/lib/taxReport/implementations/MemoryPersist.js.map +1 -0
  39. package/dist/lib/taxReport/implementations/TaxRegisterGenerator.js +85 -0
  40. package/dist/lib/taxReport/implementations/TaxRegisterGenerator.js.map +1 -0
  41. package/dist/lib/taxReport/interfaces/OutputWriter.js +3 -0
  42. package/dist/lib/taxReport/interfaces/OutputWriter.js.map +1 -0
  43. package/dist/lib/taxReport/interfaces/RegisterEventNotifier.js +19 -0
  44. package/dist/lib/taxReport/interfaces/RegisterEventNotifier.js.map +1 -0
  45. package/dist/lib/taxReport/interfaces/RegisterGenerator.js +3 -0
  46. package/dist/lib/taxReport/interfaces/RegisterGenerator.js.map +1 -0
  47. package/dist/lib/taxReport/interfaces/RegisterPersist.js +3 -0
  48. package/dist/lib/taxReport/interfaces/RegisterPersist.js.map +1 -0
  49. package/dist/lib/taxReport/interfaces/RegisterSubscriber.js +3 -0
  50. package/dist/lib/taxReport/interfaces/RegisterSubscriber.js.map +1 -0
  51. package/lib/taxReport/Block.ts +58 -0
  52. package/lib/taxReport/CounterBlock.ts +14 -0
  53. package/lib/taxReport/CounterRegister.ts +18 -0
  54. package/lib/taxReport/Decorators.ts +161 -0
  55. package/lib/taxReport/Register.ts +39 -0
  56. package/lib/taxReport/ReportGenerator.ts +178 -0
  57. package/lib/taxReport/TagCounter.ts +45 -0
  58. package/lib/taxReport/TaxReport.ts +21 -0
  59. package/lib/taxReport/implementations/ConsoleOutput.ts +16 -0
  60. package/lib/taxReport/implementations/MemoryPersist.ts +63 -0
  61. package/lib/taxReport/implementations/TaxRegisterGenerator.ts +113 -0
  62. package/lib/taxReport/interfaces/OutputWriter.ts +4 -0
  63. package/lib/taxReport/interfaces/RegisterEventNotifier.ts +30 -0
  64. package/lib/taxReport/interfaces/RegisterGenerator.ts +6 -0
  65. package/lib/taxReport/interfaces/RegisterPersist.ts +11 -0
  66. package/lib/taxReport/interfaces/RegisterSubscriber.ts +5 -0
  67. package/package.json +1 -2
  68. package/pnpm-lock.yaml +0 -2047
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
6
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
7
+ <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
+ </content>
9
+ <orderEntry type="inheritedJdk" />
10
+ <orderEntry type="sourceFolder" forTests="false" />
11
+ </component>
12
+ </module>
@@ -0,0 +1,3 @@
1
+ <component name="ProjectDictionaryState">
2
+ <dictionary name="valdirjesus" />
3
+ </component>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/br-fiscal.iml" filepath="$PROJECT_DIR$/.idea/br-fiscal.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.C100 = void 0;
16
+ const Register_1 = require("../../lib/taxReport/Register");
17
+ const Block_1 = __importDefault(require("../../lib/taxReport/Block"));
18
+ const Decorators_1 = require("../../lib/taxReport/Decorators");
19
+ class C100 extends Register_1.Register {
20
+ // @ts-ignore
21
+ // @Alphanumeric(1)
22
+ indOper = "";
23
+ // @ts-ignore
24
+ // @Alphanumeric(1)
25
+ ser = "";
26
+ numDoc = 0;
27
+ // @ts-ignore
28
+ vlDoc = 0.0;
29
+ get total() {
30
+ return this.vlDoc;
31
+ }
32
+ constructor(notifier) {
33
+ super("C100", notifier);
34
+ }
35
+ }
36
+ exports.C100 = C100;
37
+ __decorate([
38
+ (0, Decorators_1.Decimal)(),
39
+ __metadata("design:type", Number)
40
+ ], C100.prototype, "vlDoc", void 0);
41
+ class BlockC extends Block_1.default {
42
+ constructor(regPersist) {
43
+ super("C", regPersist);
44
+ }
45
+ eventHandler(eventData) {
46
+ // throw new Error("Method not implemented.");
47
+ }
48
+ createC100() {
49
+ return new C100(this);
50
+ }
51
+ }
52
+ exports.default = BlockC;
53
+ //# sourceMappingURL=blockC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blockC.js","sourceRoot":"","sources":["../../../examples/efdContribuicoes/blockC.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2DAAsD;AACtD,sEAA8C;AAE9C,+DAAuD;AAGvD,MAAa,IAAK,SAAQ,mBAAQ;IAE9B,aAAa;IACb,mBAAmB;IACnB,OAAO,GAAW,EAAE,CAAC;IAErB,aAAa;IACb,mBAAmB;IACnB,GAAG,GAAW,EAAE,CAAC;IACjB,MAAM,GAAW,CAAC,CAAC;IAEnB,aAAa;IAEb,KAAK,GAAW,GAAG,CAAC;IAEpB,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,KAAK,CAAA;IACrB,CAAC;IAED,YAAY,QAA+B;QACvC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC5B,CAAC;CACJ;AAtBD,oBAsBC;AATG;IADC,IAAA,oBAAO,GAAE;;mCACU;AAWxB,MAAqB,MAAO,SAAQ,eAAK;IAErC,YAAY,UAA2B;QACnC,KAAK,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAC3B,CAAC;IAED,YAAY,CAAC,SAA2B;QACpC,8CAA8C;IAClD,CAAC;IAED,UAAU;QACN,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACJ;AAbD,yBAaC"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const Block_1 = __importDefault(require("../../lib/taxReport/Block"));
16
+ const Register_1 = require("../../lib/taxReport/Register");
17
+ const Decorators_1 = require("../../lib/taxReport/Decorators");
18
+ class M100 extends Register_1.Register {
19
+ // @ts-ignore
20
+ vl_bc_cont = 0;
21
+ }
22
+ __decorate([
23
+ (0, Decorators_1.Decimal)(15, 2),
24
+ __metadata("design:type", Number)
25
+ ], M100.prototype, "vl_bc_cont", void 0);
26
+ class BlockM extends Block_1.default {
27
+ constructor(regPersist) {
28
+ super("M", regPersist);
29
+ }
30
+ eventHandler(eventData) {
31
+ switch (eventData.dataTypeName) {
32
+ case 'C100':
33
+ this.sumC100(eventData.data);
34
+ break;
35
+ }
36
+ }
37
+ sumC100(data) {
38
+ let m100;
39
+ if (!this.registersPersist.has("M100")) {
40
+ m100 = new M100("M100", this);
41
+ m100.vl_bc_cont = data.vlDoc;
42
+ this.registersPersist.add(m100);
43
+ }
44
+ else {
45
+ const registers = this.registersPersist.get("M100");
46
+ m100 = registers[0];
47
+ m100.vl_bc_cont += data.vlDoc;
48
+ }
49
+ }
50
+ }
51
+ exports.default = BlockM;
52
+ //# sourceMappingURL=blockM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blockM.js","sourceRoot":"","sources":["../../../examples/efdContribuicoes/blockM.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sEAA8C;AAC9C,2DAAsD;AACtD,+DAAuD;AAKvD,MAAM,IAAK,SAAQ,mBAAQ;IACvB,aAAa;IAEb,UAAU,GAAW,CAAC,CAAC;CAC1B;AADG;IADC,IAAA,oBAAO,EAAC,EAAE,EAAC,CAAC,CAAC;;wCACS;AAG3B,MAAqB,MAAO,SAAQ,eAAK;IAErC,YAAY,UAA2B;QACnC,KAAK,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAC3B,CAAC;IACD,YAAY,CAAC,SAA4B;QACrC,QAAQ,SAAS,CAAC,YAAY,EAAE,CAAC;YAC7B,KAAK,MAAM;gBACP,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAY,CAAC,CAAC;gBACrC,MAAM;QACd,CAAC;IACL,CAAC;IAEO,OAAO,CAAC,IAAU;QACtB,IAAI,IAAU,CAAC;QAEf,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACrC,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC9B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAA;YAC5B,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACnC,CAAC;aAAM,CAAC;YACJ,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAe,CAAA;YACjE,IAAI,GAAG,SAAS,CAAC,CAAC,CAAS,CAAA;YAC3B,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,KAAK,CAAA;QACjC,CAAC;IACL,CAAC;CAEJ;AA3BD,yBA2BC"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const blockC_1 = __importDefault(require("./blockC"));
7
+ const TaxReport_1 = __importDefault(require("../../lib/taxReport/TaxReport"));
8
+ const MemoryPersist_1 = __importDefault(require("../../lib/taxReport/implementations/MemoryPersist"));
9
+ const blockM_1 = __importDefault(require("./blockM"));
10
+ const Register_1 = require("../../lib/taxReport/Register");
11
+ class OpenFile extends Register_1.Register {
12
+ }
13
+ class EFDContribuicoes extends TaxReport_1.default {
14
+ constructor() {
15
+ super();
16
+ this.registerBlock(new blockC_1.default(MemoryPersist_1.default.createInstance()));
17
+ this.registerBlock(new blockM_1.default(MemoryPersist_1.default.createInstance()));
18
+ //Relationships
19
+ this.BlockC.addSubscriber(this.BlockM);
20
+ }
21
+ createOpenFile() {
22
+ //Qualquer bloco só para funcionar!
23
+ return new OpenFile("0000", this.BlockC);
24
+ }
25
+ get BlockC() {
26
+ return this.getBlock("C");
27
+ }
28
+ get BlockM() {
29
+ return this.getBlock("M");
30
+ }
31
+ addDFe(instance) {
32
+ //Precisamos validar se este DFe precisa ir pro arquivo!
33
+ const item = this.BlockC.createC100();
34
+ item.ser = instance.series;
35
+ item.numDoc = instance.documentNumber;
36
+ item.vlDoc = instance.totalAmount;
37
+ switch (instance.operation) {
38
+ case "inbound":
39
+ item.indOper = "1";
40
+ break;
41
+ }
42
+ this.BlockC.addRegister(item);
43
+ }
44
+ }
45
+ exports.default = EFDContribuicoes;
46
+ //# sourceMappingURL=efdContribuicoes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"efdContribuicoes.js","sourceRoot":"","sources":["../../../examples/efdContribuicoes/efdContribuicoes.ts"],"names":[],"mappings":";;;;;AAAA,sDAA8B;AAC9B,8EAAsD;AACtD,sGAA8E;AAC9E,sDAA8B;AAC9B,2DAAsD;AAEtD,MAAM,QAAS,SAAQ,mBAAQ;CAE9B;AASD,MAAqB,gBAAiB,SAAQ,mBAAS;IAEnD;QACI,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,aAAa,CAAC,IAAI,gBAAM,CAAC,uBAAa,CAAC,cAAc,EAAE,CAAC,CAAC,CAAA;QAC9D,IAAI,CAAC,aAAa,CAAC,IAAI,gBAAM,CAAC,uBAAa,CAAC,cAAc,EAAE,CAAC,CAAC,CAAA;QAE9D,eAAe;QACf,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAEM,cAAc;QACjB,mCAAmC;QACnC,OAAO,IAAI,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IAC5C,CAAC;IAED,IAAc,MAAM;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAW,CAAA;IACtC,CAAC;IAED,IAAc,MAAM;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAW,CAAA;IACvC,CAAC;IAEM,MAAM,CAAC,QAAa;QAEvB,wDAAwD;QAGxD,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QACtC,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,cAAc,CAAA;QACrC,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,WAAW,CAAC;QAClC,QAAQ,QAAQ,CAAC,SAAS,EAAC,CAAC;YACxB,KAAK,SAAS;gBACV,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC;gBACnB,MAAM;QACd,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACJ;AAzCD,mCAyCC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const ReportGenerator_1 = __importDefault(require("../../lib/taxReport/ReportGenerator"));
7
+ const efdContribuicoes_1 = __importDefault(require("./efdContribuicoes"));
8
+ console.time("test");
9
+ const fileData = new efdContribuicoes_1.default();
10
+ //Database simulating
11
+ for (let i = 1; i <= 10; i++) {
12
+ const newDfe = {
13
+ operation: "inbound",
14
+ series: "A",
15
+ documentNumber: i,
16
+ totalAmount: parseFloat((Math.random() * 100).toFixed(2)),
17
+ };
18
+ fileData.addDFe(newDfe);
19
+ }
20
+ const generator = ReportGenerator_1.default.newWithDefaultOptions(fileData.createOpenFile());
21
+ generator.generateFile(fileData);
22
+ console.timeEnd("test");
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../examples/efdContribuicoes/index.ts"],"names":[],"mappings":";;;;;AAAA,0FAAkE;AAClE,0EAA2D;AAG3D,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AACpB,MAAM,QAAQ,GAAG,IAAI,0BAAgB,EAAE,CAAC;AAExC,qBAAqB;AACrB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;IAC3B,MAAM,MAAM,GAAQ;QAChB,SAAS,EAAE,SAAS;QACpB,MAAM,EAAE,GAAG;QACX,cAAc,EAAE,CAAC;QACjB,WAAW,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;KAC5D,CAAA;IACD,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,SAAS,GAAG,yBAAe,CAAC,qBAAqB,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC,CAAA;AAClF,SAAS,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;AAChC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+
2
+ export { }