@senior-gestao-empresarial/erpx-components 3.26.0 → 3.27.0

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 (37) hide show
  1. package/bundles/senior-gestao-empresarial-erpx-components.umd.js +305 -91
  2. package/bundles/senior-gestao-empresarial-erpx-components.umd.js.map +1 -1
  3. package/bundles/senior-gestao-empresarial-erpx-components.umd.min.js +2 -2
  4. package/bundles/senior-gestao-empresarial-erpx-components.umd.min.js.map +1 -1
  5. package/components/tributos/erp-tributos.types.d.ts +2 -1
  6. package/components/tributos/rules/calculation/calculation-rules.registry.d.ts +6 -2
  7. package/components/tributos/rules/calculation/manual-tax-calculation-rule.d.ts +5 -0
  8. package/components/tributos/rules/calculation/tax-calculation-type-calculation-rule.d.ts +5 -0
  9. package/components/tributos/rules/calculation/tax-rate-calculation-rule.d.ts +0 -3
  10. package/components/tributos/rules/types/schema.d.ts +60 -60
  11. package/components/tributos/rules/validation/required/tax-rate-required-validation-rule.d.ts +1 -1
  12. package/components/tributos/rules/validation/required/taxable-base-required-validation-rule.d.ts +1 -1
  13. package/esm2015/components/tributos/erp-tributos.types.js +2 -1
  14. package/esm2015/components/tributos/rules/calculation/calculation-rules.registry.js +109 -5
  15. package/esm2015/components/tributos/rules/calculation/manual-tax-calculation-rule.js +58 -0
  16. package/esm2015/components/tributos/rules/calculation/tax-calculation-type-calculation-rule.js +61 -0
  17. package/esm2015/components/tributos/rules/calculation/tax-rate-calculation-rule.js +8 -32
  18. package/esm2015/components/tributos/rules/types/schema.js +121 -61
  19. package/esm2015/components/tributos/rules/validation/required/tax-rate-required-validation-rule.js +14 -5
  20. package/esm2015/components/tributos/rules/validation/required/taxable-base-required-validation-rule.js +14 -5
  21. package/esm2015/senior-gestao-empresarial-erpx-components.js +8 -6
  22. package/esm5/components/tributos/erp-tributos.types.js +2 -1
  23. package/esm5/components/tributos/rules/calculation/calculation-rules.registry.js +109 -5
  24. package/esm5/components/tributos/rules/calculation/manual-tax-calculation-rule.js +65 -0
  25. package/esm5/components/tributos/rules/calculation/tax-calculation-type-calculation-rule.js +70 -0
  26. package/esm5/components/tributos/rules/calculation/tax-rate-calculation-rule.js +11 -34
  27. package/esm5/components/tributos/rules/types/schema.js +121 -61
  28. package/esm5/components/tributos/rules/validation/required/tax-rate-required-validation-rule.js +15 -6
  29. package/esm5/components/tributos/rules/validation/required/taxable-base-required-validation-rule.js +15 -6
  30. package/esm5/senior-gestao-empresarial-erpx-components.js +8 -6
  31. package/fesm2015/senior-gestao-empresarial-erpx-components.js +276 -81
  32. package/fesm2015/senior-gestao-empresarial-erpx-components.js.map +1 -1
  33. package/fesm5/senior-gestao-empresarial-erpx-components.js +300 -88
  34. package/fesm5/senior-gestao-empresarial-erpx-components.js.map +1 -1
  35. package/package.json +3 -3
  36. package/senior-gestao-empresarial-erpx-components.d.ts +7 -5
  37. package/senior-gestao-empresarial-erpx-components.metadata.json +1 -1
@@ -589,6 +589,7 @@
589
589
  EnumCampoTributo["AplicarValorLiquidoDocumento"] = "AplicarValorLiquidoDocumento";
590
590
  EnumCampoTributo["ClassificacaoTributariaCreditoPresumido"] = "classificacao_tributaria_credito_presumido";
591
591
  EnumCampoTributo["TipoCalculoImposto"] = "TipoCalculoImposto";
592
+ EnumCampoTributo["ImpostoManual"] = "impostoManual";
592
593
  })(exports.EnumCampoTributo || (exports.EnumCampoTributo = {}));
593
594
 
594
595
  (function (EnumGrupoTributo) {
@@ -1247,6 +1248,62 @@
1247
1248
  return GrossAmountCalculationRule;
1248
1249
  }());
1249
1250
 
1251
+ var ManualTaxCalculationRule = /** @class */ (function () {
1252
+ function ManualTaxCalculationRule() {
1253
+ }
1254
+ ManualTaxCalculationRule.prototype.apply = function (_a) {
1255
+ var documentType = _a.documentType, group = _a.group, _b = _a.item, taxType = _b.name, formGroup = _b.formGroup;
1256
+ switch (taxType) {
1257
+ case exports.EnumTipoTributo.CBS:
1258
+ case exports.EnumTipoTributo.IBS_ESTADUAL:
1259
+ case exports.EnumTipoTributo.IBS_MUNICIPAL:
1260
+ {
1261
+ switch (documentType) {
1262
+ case exports.EnumTipoDocumento.NF_ENTRADA:
1263
+ case exports.EnumTipoDocumento.NF_SAIDA:
1264
+ case exports.EnumTipoDocumento.PEDIDO_COMPRA:
1265
+ case exports.EnumTipoDocumento.PEDIDO_VENDA:
1266
+ {
1267
+ var _c = getGovernamentalTaxItemFromGroup({ group: group }), governamentalFormGroup = _c.formGroup, governamentalFormFields_1 = _c.formField;
1268
+ var governamentalStartingValue_1 = governamentalFormGroup.getRawValue();
1269
+ rxjs.combineLatest([governamentalFormGroup.valueChanges])
1270
+ .pipe(operators.skip(1), operators.map(function (_a) {
1271
+ var _b = __read(_a, 1), currentValue = _b[0];
1272
+ return Object.keys(currentValue)
1273
+ .filter(function (key) { return key !== 'impostoManual' && key !== exports.EnumCampoTributo.TipoCalculoImposto; })
1274
+ .every(function (key) {
1275
+ var _a, _b;
1276
+ var formField = governamentalFormFields_1.find(function (field) { return field.name === key; });
1277
+ if ((formField === null || formField === void 0 ? void 0 : formField.type) === angularComponents$1.FieldType.Lookup) {
1278
+ var dataKey = governamentalFormFields_1.find(function (field) { return field.name === key; }).dataKey;
1279
+ return (((_a = governamentalStartingValue_1 === null || governamentalStartingValue_1 === void 0 ? void 0 : governamentalStartingValue_1[key]) === null || _a === void 0 ? void 0 : _a[dataKey]) === ((_b = currentValue === null || currentValue === void 0 ? void 0 : currentValue[key]) === null || _b === void 0 ? void 0 : _b[dataKey]));
1280
+ }
1281
+ return governamentalStartingValue_1[key] === currentValue[key];
1282
+ })
1283
+ ? governamentalStartingValue_1[exports.EnumCampoTributo.ImpostoManual]
1284
+ : true;
1285
+ }), operators.filter(function (manualTax) { return manualTax !== formGroup.get(exports.EnumCampoTributo.ImpostoManual).value; }))
1286
+ .subscribe(function (manualTax) {
1287
+ formGroup.get(exports.EnumCampoTributo.ImpostoManual).setValue(manualTax, { emitEvent: false });
1288
+ });
1289
+ }
1290
+ break;
1291
+ default:
1292
+ throw new Error("Regra ManualTaxCalculationRule n\u00E3o implementada para o imposto " + taxType + ", documento " + documentType + ".");
1293
+ }
1294
+ }
1295
+ break;
1296
+ default:
1297
+ throw new Error("Regra ManualTaxCalculationRule n\u00E3o implementada para o imposto " + taxType + ", documento " + documentType + ".");
1298
+ }
1299
+ };
1300
+ ManualTaxCalculationRule.ɵprov = core.ɵɵdefineInjectable({ factory: function ManualTaxCalculationRule_Factory() { return new ManualTaxCalculationRule(); }, token: ManualTaxCalculationRule, providedIn: "root" });
1301
+ ManualTaxCalculationRule = __decorate([
1302
+ core.Injectable({ providedIn: 'root' })
1303
+ ], ManualTaxCalculationRule);
1304
+ return ManualTaxCalculationRule;
1305
+ }());
1306
+
1250
1307
  var TaxAmountCalculator = /** @class */ (function () {
1251
1308
  function TaxAmountCalculator(effectiveTaxRateCalculator) {
1252
1309
  this.effectiveTaxRateCalculator = effectiveTaxRateCalculator;
@@ -1471,12 +1528,113 @@
1471
1528
  return TaxAmountCalculationRule;
1472
1529
  }());
1473
1530
 
1531
+ var TaxCalculationTypeCalculationRule = /** @class */ (function () {
1532
+ function TaxCalculationTypeCalculationRule() {
1533
+ }
1534
+ TaxCalculationTypeCalculationRule.prototype.apply = function (_a) {
1535
+ var documentType = _a.documentType, group = _a.group, _b = _a.item, taxType = _b.name, formGroup = _b.formGroup;
1536
+ switch (taxType) {
1537
+ case exports.EnumTipoTributo.CBS:
1538
+ case exports.EnumTipoTributo.IBS_ESTADUAL:
1539
+ case exports.EnumTipoTributo.IBS_MUNICIPAL:
1540
+ {
1541
+ switch (documentType) {
1542
+ case exports.EnumTipoDocumento.NF_ENTRADA:
1543
+ case exports.EnumTipoDocumento.NF_SAIDA:
1544
+ case exports.EnumTipoDocumento.PEDIDO_COMPRA:
1545
+ case exports.EnumTipoDocumento.PEDIDO_VENDA:
1546
+ {
1547
+ var _c = getGovernamentalTaxItemFromGroup({ group: group }), governamentalFormGroup = _c.formGroup, governamentalFormFields_1 = _c.formField;
1548
+ var startingValue_1 = governamentalFormGroup.getRawValue();
1549
+ rxjs.combineLatest([governamentalFormGroup.valueChanges])
1550
+ .pipe(operators.skip(1), operators.map(function (_a) {
1551
+ var _b = __read(_a, 1), currentValue = _b[0];
1552
+ return Object.keys(currentValue)
1553
+ .filter(function (key) { return key !== 'impostoManual' && key !== exports.EnumCampoTributo.TipoCalculoImposto; })
1554
+ .every(function (key) {
1555
+ var _a, _b;
1556
+ var formField = governamentalFormFields_1.find(function (field) { return field.name === key; });
1557
+ if ((formField === null || formField === void 0 ? void 0 : formField.type) === angularComponents$1.FieldType.Lookup) {
1558
+ var dataKey = governamentalFormFields_1.find(function (field) { return field.name === key; }).dataKey;
1559
+ return ((_a = startingValue_1 === null || startingValue_1 === void 0 ? void 0 : startingValue_1[key]) === null || _a === void 0 ? void 0 : _a[dataKey]) === ((_b = currentValue === null || currentValue === void 0 ? void 0 : currentValue[key]) === null || _b === void 0 ? void 0 : _b[dataKey]);
1560
+ }
1561
+ return startingValue_1[key] === currentValue[key];
1562
+ })
1563
+ ? startingValue_1[exports.EnumCampoTributo.TipoCalculoImposto]
1564
+ : EnumTipoCalculoImposto.MANUAL;
1565
+ }), operators.filter(function (taxCalculationType) {
1566
+ return taxCalculationType !== formGroup.get(exports.EnumCampoTributo.TipoCalculoImposto).value;
1567
+ }))
1568
+ .subscribe(function (taxCalculationType) {
1569
+ formGroup
1570
+ .get(exports.EnumCampoTributo.TipoCalculoImposto)
1571
+ .setValue(taxCalculationType, { emitEvent: false });
1572
+ });
1573
+ }
1574
+ break;
1575
+ default:
1576
+ throw new Error("Regra TaxCalculationTypeCalculationRule n\u00E3o implementada para o imposto " + taxType + ", documento " + documentType + ".");
1577
+ }
1578
+ }
1579
+ break;
1580
+ default:
1581
+ throw new Error("Regra TaxCalculationTypeCalculationRule n\u00E3o implementada para o imposto " + taxType + ", documento " + documentType + ".");
1582
+ }
1583
+ };
1584
+ TaxCalculationTypeCalculationRule.ɵprov = core.ɵɵdefineInjectable({ factory: function TaxCalculationTypeCalculationRule_Factory() { return new TaxCalculationTypeCalculationRule(); }, token: TaxCalculationTypeCalculationRule, providedIn: "root" });
1585
+ TaxCalculationTypeCalculationRule = __decorate([
1586
+ core.Injectable({ providedIn: 'root' })
1587
+ ], TaxCalculationTypeCalculationRule);
1588
+ return TaxCalculationTypeCalculationRule;
1589
+ }());
1590
+
1591
+ var TaxClassificationCalculationRule = /** @class */ (function () {
1592
+ function TaxClassificationCalculationRule() {
1593
+ }
1594
+ TaxClassificationCalculationRule.prototype.apply = function (_a) {
1595
+ var documentType = _a.documentType, _b = _a.item, taxType = _b.name, formGroup = _b.formGroup, formField = _b.formField;
1596
+ switch (taxType) {
1597
+ case exports.EnumTipoTributo.CBS:
1598
+ case exports.EnumTipoTributo.IBS_ESTADUAL:
1599
+ case exports.EnumTipoTributo.IBS_MUNICIPAL:
1600
+ case exports.EnumTipoTributo.IS:
1601
+ {
1602
+ switch (documentType) {
1603
+ case exports.EnumTipoDocumento.NF_ENTRADA:
1604
+ case exports.EnumTipoDocumento.NF_SAIDA:
1605
+ case exports.EnumTipoDocumento.PEDIDO_COMPRA:
1606
+ case exports.EnumTipoDocumento.PEDIDO_VENDA:
1607
+ {
1608
+ var dataKey_1 = formField.find(function (field) { return field.name === 'situacaoTributaria'; }).dataKey;
1609
+ rxjs.combineLatest([
1610
+ formGroup.get('situacaoTributaria').valueChanges.pipe(operators.startWith(formGroup.get('situacaoTributaria').value), operators.distinctUntilChanged(function (old, current) { return (old === null || old === void 0 ? void 0 : old[dataKey_1]) === (current === null || current === void 0 ? void 0 : current[dataKey_1]); }))
1611
+ ])
1612
+ .pipe(operators.skip(1), operators.map(function () { return null; }), operators.filter(function (taxClassification) { var _a; return (taxClassification === null || taxClassification === void 0 ? void 0 : taxClassification.id) !== ((_a = formGroup.get('classificacaoTributaria').value) === null || _a === void 0 ? void 0 : _a.id); }))
1613
+ .subscribe(function (taxClassification) {
1614
+ formGroup.get('classificacaoTributaria').setValue(taxClassification);
1615
+ });
1616
+ }
1617
+ break;
1618
+ default:
1619
+ throw new Error("Regra TaxClassificationCalculationRule n\u00E3o implementada para o imposto " + taxType + ", documento " + documentType + ".");
1620
+ }
1621
+ }
1622
+ break;
1623
+ default:
1624
+ throw new Error("Regra TaxClassificationCalculationRule n\u00E3o implementada para o imposto " + taxType + ", documento " + documentType + ".");
1625
+ }
1626
+ };
1627
+ TaxClassificationCalculationRule.ɵprov = core.ɵɵdefineInjectable({ factory: function TaxClassificationCalculationRule_Factory() { return new TaxClassificationCalculationRule(); }, token: TaxClassificationCalculationRule, providedIn: "root" });
1628
+ TaxClassificationCalculationRule = __decorate([
1629
+ core.Injectable({ providedIn: 'root' })
1630
+ ], TaxClassificationCalculationRule);
1631
+ return TaxClassificationCalculationRule;
1632
+ }());
1633
+
1474
1634
  var TaxRateCalculationRule = /** @class */ (function () {
1475
- function TaxRateCalculationRule(effectiveTaxRateCalculator) {
1476
- this.effectiveTaxRateCalculator = effectiveTaxRateCalculator;
1635
+ function TaxRateCalculationRule() {
1477
1636
  }
1478
1637
  TaxRateCalculationRule.prototype.apply = function (_a) {
1479
- var _this = this;
1480
1638
  var documentType = _a.documentType, group = _a.group, _b = _a.item, taxType = _b.name, formGroup = _b.formGroup;
1481
1639
  switch (taxType) {
1482
1640
  case exports.EnumTipoTributo.CBS_GOVERNAMENTAL:
@@ -1492,33 +1650,17 @@
1492
1650
  var baseTaxFormGroup = getBaseTaxItemFromGroup({ group: group }).formGroup;
1493
1651
  rxjs.combineLatest([
1494
1652
  baseTaxFormGroup
1495
- .get('aliquota')
1496
- .valueChanges.pipe(operators.startWith(baseTaxFormGroup.get('aliquota').value), operators.distinctUntilChanged()),
1497
- baseTaxFormGroup
1498
- .get('reducaoAliquota')
1499
- .valueChanges.pipe(operators.startWith(baseTaxFormGroup.get('reducaoAliquota').value), operators.distinctUntilChanged()),
1500
- baseTaxFormGroup
1501
- .get('reducaoAliquotaGovernamental')
1502
- .valueChanges.pipe(operators.startWith(baseTaxFormGroup.get('reducaoAliquotaGovernamental').value), operators.distinctUntilChanged())
1653
+ .get('aliquotaEfetiva')
1654
+ .valueChanges.pipe(operators.startWith(baseTaxFormGroup.get('aliquotaEfetiva').value), operators.distinctUntilChanged())
1503
1655
  ])
1504
1656
  .pipe(operators.skip(1), operators.map(function (_a) {
1505
- var _b = __read(_a, 3), baseTaxTaxRate = _b[0], baseTaxTaxRateReduction = _b[1], governamentalTaxRateReduction = _b[2];
1506
- return [
1507
- new BigNumber(baseTaxTaxRate),
1508
- new BigNumber(baseTaxTaxRateReduction),
1509
- new BigNumber(governamentalTaxRateReduction)
1510
- ];
1657
+ var _b = __read(_a, 1), effectiveTaxRate = _b[0];
1658
+ return [new BigNumber(effectiveTaxRate)];
1511
1659
  }), operators.map(function (_a) {
1512
- var _b = __read(_a, 3), baseTaxTaxRate = _b[0], baseTaxTaxRateReduction = _b[1], governamentalTaxRateReduction = _b[2];
1513
- if (governamentalTaxRateReduction.isNaN())
1660
+ var _b = __read(_a, 1), effectiveTaxRate = _b[0];
1661
+ if (effectiveTaxRate.isNaN())
1514
1662
  return null;
1515
- var taxRate = baseTaxTaxRateReduction.isFinite()
1516
- ? _this.effectiveTaxRateCalculator.calculateEffectiveTaxRateWithoutGovernamentalTaxRateReduction({
1517
- taxRate: baseTaxTaxRate,
1518
- taxRateReduction: baseTaxTaxRateReduction
1519
- })
1520
- : baseTaxTaxRate;
1521
- return taxRate.decimalPlaces(2).toNumber();
1663
+ return effectiveTaxRate.decimalPlaces(4).toNumber();
1522
1664
  }), operators.filter(function (taxRate) { return taxRate !== formGroup.get('aliquota').value; }))
1523
1665
  .subscribe(function (taxRate) {
1524
1666
  formGroup.get('aliquota').setValue(taxRate);
@@ -1534,10 +1676,7 @@
1534
1676
  throw new Error("Regra TaxRateCalculationRule n\u00E3o implementada para o imposto " + taxType + ", documento " + documentType + ".");
1535
1677
  }
1536
1678
  };
1537
- TaxRateCalculationRule.ctorParameters = function () { return [
1538
- { type: EffectiveTaxRateCalculator }
1539
- ]; };
1540
- TaxRateCalculationRule.ɵprov = core.ɵɵdefineInjectable({ factory: function TaxRateCalculationRule_Factory() { return new TaxRateCalculationRule(core.ɵɵinject(EffectiveTaxRateCalculator)); }, token: TaxRateCalculationRule, providedIn: "root" });
1679
+ TaxRateCalculationRule.ɵprov = core.ɵɵdefineInjectable({ factory: function TaxRateCalculationRule_Factory() { return new TaxRateCalculationRule(); }, token: TaxRateCalculationRule, providedIn: "root" });
1541
1680
  TaxRateCalculationRule = __decorate([
1542
1681
  core.Injectable({ providedIn: 'root' })
1543
1682
  ], TaxRateCalculationRule);
@@ -1762,51 +1901,8 @@
1762
1901
  return TaxableBaseCalculationRule;
1763
1902
  }());
1764
1903
 
1765
- var TaxClassificationCalculationRule = /** @class */ (function () {
1766
- function TaxClassificationCalculationRule() {
1767
- }
1768
- TaxClassificationCalculationRule.prototype.apply = function (_a) {
1769
- var documentType = _a.documentType, _b = _a.item, taxType = _b.name, formGroup = _b.formGroup, formField = _b.formField;
1770
- switch (taxType) {
1771
- case exports.EnumTipoTributo.CBS:
1772
- case exports.EnumTipoTributo.IBS_ESTADUAL:
1773
- case exports.EnumTipoTributo.IBS_MUNICIPAL:
1774
- case exports.EnumTipoTributo.IS:
1775
- {
1776
- switch (documentType) {
1777
- case exports.EnumTipoDocumento.NF_ENTRADA:
1778
- case exports.EnumTipoDocumento.NF_SAIDA:
1779
- case exports.EnumTipoDocumento.PEDIDO_COMPRA:
1780
- case exports.EnumTipoDocumento.PEDIDO_VENDA:
1781
- {
1782
- var dataKey_1 = formField.find(function (field) { return field.name === 'situacaoTributaria'; }).dataKey;
1783
- rxjs.combineLatest([
1784
- formGroup.get('situacaoTributaria').valueChanges.pipe(operators.startWith(formGroup.get('situacaoTributaria').value), operators.distinctUntilChanged(function (old, current) { return (old === null || old === void 0 ? void 0 : old[dataKey_1]) === (current === null || current === void 0 ? void 0 : current[dataKey_1]); }))
1785
- ])
1786
- .pipe(operators.skip(1), operators.map(function () { return null; }), operators.filter(function (taxClassification) { var _a; return (taxClassification === null || taxClassification === void 0 ? void 0 : taxClassification.id) !== ((_a = formGroup.get('classificacaoTributaria').value) === null || _a === void 0 ? void 0 : _a.id); }))
1787
- .subscribe(function (taxClassification) {
1788
- formGroup.get('classificacaoTributaria').setValue(taxClassification);
1789
- });
1790
- }
1791
- break;
1792
- default:
1793
- throw new Error("Regra TaxClassificationCalculationRule n\u00E3o implementada para o imposto " + taxType + ", documento " + documentType + ".");
1794
- }
1795
- }
1796
- break;
1797
- default:
1798
- throw new Error("Regra TaxClassificationCalculationRule n\u00E3o implementada para o imposto " + taxType + ", documento " + documentType + ".");
1799
- }
1800
- };
1801
- TaxClassificationCalculationRule.ɵprov = core.ɵɵdefineInjectable({ factory: function TaxClassificationCalculationRule_Factory() { return new TaxClassificationCalculationRule(); }, token: TaxClassificationCalculationRule, providedIn: "root" });
1802
- TaxClassificationCalculationRule = __decorate([
1803
- core.Injectable({ providedIn: 'root' })
1804
- ], TaxClassificationCalculationRule);
1805
- return TaxClassificationCalculationRule;
1806
- }());
1807
-
1808
1904
  var CalculationRulesRegistry = /** @class */ (function () {
1809
- function CalculationRulesRegistry(taxableBaseCalculationRule, taxRateCalculationRule, effectiveTaxRateCalculationRule, taxAmountCalculationRule, grossAmountCalculationRule, taxClassificationCalculationRule) {
1905
+ function CalculationRulesRegistry(taxableBaseCalculationRule, taxRateCalculationRule, effectiveTaxRateCalculationRule, taxAmountCalculationRule, grossAmountCalculationRule, taxClassificationCalculationRule, taxCalculationTypeCalculationRule, manualTaxCalculationRule) {
1810
1906
  var _a, _b, _c, _d, _e;
1811
1907
  this.taxableBaseCalculationRule = taxableBaseCalculationRule;
1812
1908
  this.taxRateCalculationRule = taxRateCalculationRule;
@@ -1814,6 +1910,8 @@
1814
1910
  this.taxAmountCalculationRule = taxAmountCalculationRule;
1815
1911
  this.grossAmountCalculationRule = grossAmountCalculationRule;
1816
1912
  this.taxClassificationCalculationRule = taxClassificationCalculationRule;
1913
+ this.taxCalculationTypeCalculationRule = taxCalculationTypeCalculationRule;
1914
+ this.manualTaxCalculationRule = manualTaxCalculationRule;
1817
1915
  this.strategies = (_a = {},
1818
1916
  _a[exports.EnumTipoDocumento.NF_ENTRADA] = (_b = {},
1819
1917
  _b[exports.EnumTipoTributo.CBS] = [
@@ -1832,6 +1930,14 @@
1832
1930
  {
1833
1931
  field: exports.EnumCampoTributo.ClassificacaoTributaria,
1834
1932
  rule: this.taxClassificationCalculationRule
1933
+ },
1934
+ {
1935
+ field: exports.EnumCampoTributo.TipoCalculoImposto,
1936
+ rule: this.taxCalculationTypeCalculationRule
1937
+ },
1938
+ {
1939
+ field: exports.EnumCampoTributo.ImpostoManual,
1940
+ rule: this.manualTaxCalculationRule
1835
1941
  }
1836
1942
  ],
1837
1943
  _b[exports.EnumTipoTributo.CBS_DIFERIDO] = [
@@ -1894,6 +2000,14 @@
1894
2000
  {
1895
2001
  field: exports.EnumCampoTributo.ClassificacaoTributaria,
1896
2002
  rule: this.taxClassificationCalculationRule
2003
+ },
2004
+ {
2005
+ field: exports.EnumCampoTributo.TipoCalculoImposto,
2006
+ rule: this.taxCalculationTypeCalculationRule
2007
+ },
2008
+ {
2009
+ field: exports.EnumCampoTributo.ImpostoManual,
2010
+ rule: this.manualTaxCalculationRule
1897
2011
  }
1898
2012
  ],
1899
2013
  _b[exports.EnumTipoTributo.IBS_ESTADUAL_DIFERIDO] = [
@@ -1946,6 +2060,14 @@
1946
2060
  {
1947
2061
  field: exports.EnumCampoTributo.ClassificacaoTributaria,
1948
2062
  rule: this.taxClassificationCalculationRule
2063
+ },
2064
+ {
2065
+ field: exports.EnumCampoTributo.TipoCalculoImposto,
2066
+ rule: this.taxCalculationTypeCalculationRule
2067
+ },
2068
+ {
2069
+ field: exports.EnumCampoTributo.ImpostoManual,
2070
+ rule: this.manualTaxCalculationRule
1949
2071
  }
1950
2072
  ],
1951
2073
  _b[exports.EnumTipoTributo.IBS_MUNICIPAL_DIFERIDO] = [
@@ -2020,6 +2142,14 @@
2020
2142
  {
2021
2143
  field: exports.EnumCampoTributo.ClassificacaoTributaria,
2022
2144
  rule: this.taxClassificationCalculationRule
2145
+ },
2146
+ {
2147
+ field: exports.EnumCampoTributo.TipoCalculoImposto,
2148
+ rule: this.taxCalculationTypeCalculationRule
2149
+ },
2150
+ {
2151
+ field: exports.EnumCampoTributo.ImpostoManual,
2152
+ rule: this.manualTaxCalculationRule
2023
2153
  }
2024
2154
  ],
2025
2155
  _c[exports.EnumTipoTributo.CBS_DIFERIDO] = [
@@ -2082,6 +2212,14 @@
2082
2212
  {
2083
2213
  field: exports.EnumCampoTributo.ClassificacaoTributaria,
2084
2214
  rule: this.taxClassificationCalculationRule
2215
+ },
2216
+ {
2217
+ field: exports.EnumCampoTributo.TipoCalculoImposto,
2218
+ rule: this.taxCalculationTypeCalculationRule
2219
+ },
2220
+ {
2221
+ field: exports.EnumCampoTributo.ImpostoManual,
2222
+ rule: this.manualTaxCalculationRule
2085
2223
  }
2086
2224
  ],
2087
2225
  _c[exports.EnumTipoTributo.IBS_ESTADUAL_DIFERIDO] = [
@@ -2134,6 +2272,14 @@
2134
2272
  {
2135
2273
  field: exports.EnumCampoTributo.ClassificacaoTributaria,
2136
2274
  rule: this.taxClassificationCalculationRule
2275
+ },
2276
+ {
2277
+ field: exports.EnumCampoTributo.TipoCalculoImposto,
2278
+ rule: this.taxCalculationTypeCalculationRule
2279
+ },
2280
+ {
2281
+ field: exports.EnumCampoTributo.ImpostoManual,
2282
+ rule: this.manualTaxCalculationRule
2137
2283
  }
2138
2284
  ],
2139
2285
  _c[exports.EnumTipoTributo.IBS_MUNICIPAL_DIFERIDO] = [
@@ -2204,6 +2350,14 @@
2204
2350
  {
2205
2351
  field: exports.EnumCampoTributo.Valor,
2206
2352
  rule: this.taxAmountCalculationRule
2353
+ },
2354
+ {
2355
+ field: exports.EnumCampoTributo.TipoCalculoImposto,
2356
+ rule: this.taxCalculationTypeCalculationRule
2357
+ },
2358
+ {
2359
+ field: exports.EnumCampoTributo.ImpostoManual,
2360
+ rule: this.manualTaxCalculationRule
2207
2361
  }
2208
2362
  ],
2209
2363
  _d[exports.EnumTipoTributo.CBS_DIFERIDO] = [
@@ -2262,6 +2416,14 @@
2262
2416
  {
2263
2417
  field: exports.EnumCampoTributo.Valor,
2264
2418
  rule: this.taxAmountCalculationRule
2419
+ },
2420
+ {
2421
+ field: exports.EnumCampoTributo.TipoCalculoImposto,
2422
+ rule: this.taxCalculationTypeCalculationRule
2423
+ },
2424
+ {
2425
+ field: exports.EnumCampoTributo.ImpostoManual,
2426
+ rule: this.manualTaxCalculationRule
2265
2427
  }
2266
2428
  ],
2267
2429
  _d[exports.EnumTipoTributo.IBS_ESTADUAL_DIFERIDO] = [
@@ -2310,6 +2472,14 @@
2310
2472
  {
2311
2473
  field: exports.EnumCampoTributo.Valor,
2312
2474
  rule: this.taxAmountCalculationRule
2475
+ },
2476
+ {
2477
+ field: exports.EnumCampoTributo.TipoCalculoImposto,
2478
+ rule: this.taxCalculationTypeCalculationRule
2479
+ },
2480
+ {
2481
+ field: exports.EnumCampoTributo.ImpostoManual,
2482
+ rule: this.manualTaxCalculationRule
2313
2483
  }
2314
2484
  ],
2315
2485
  _d[exports.EnumTipoTributo.IBS_MUNICIPAL_DIFERIDO] = [
@@ -2376,6 +2546,14 @@
2376
2546
  {
2377
2547
  field: exports.EnumCampoTributo.Valor,
2378
2548
  rule: this.taxAmountCalculationRule
2549
+ },
2550
+ {
2551
+ field: exports.EnumCampoTributo.TipoCalculoImposto,
2552
+ rule: this.taxCalculationTypeCalculationRule
2553
+ },
2554
+ {
2555
+ field: exports.EnumCampoTributo.ImpostoManual,
2556
+ rule: this.manualTaxCalculationRule
2379
2557
  }
2380
2558
  ],
2381
2559
  _e[exports.EnumTipoTributo.CBS_DIFERIDO] = [
@@ -2434,6 +2612,14 @@
2434
2612
  {
2435
2613
  field: exports.EnumCampoTributo.Valor,
2436
2614
  rule: this.taxAmountCalculationRule
2615
+ },
2616
+ {
2617
+ field: exports.EnumCampoTributo.TipoCalculoImposto,
2618
+ rule: this.taxCalculationTypeCalculationRule
2619
+ },
2620
+ {
2621
+ field: exports.EnumCampoTributo.ImpostoManual,
2622
+ rule: this.manualTaxCalculationRule
2437
2623
  }
2438
2624
  ],
2439
2625
  _e[exports.EnumTipoTributo.IBS_ESTADUAL_DIFERIDO] = [
@@ -2482,6 +2668,14 @@
2482
2668
  {
2483
2669
  field: exports.EnumCampoTributo.Valor,
2484
2670
  rule: this.taxAmountCalculationRule
2671
+ },
2672
+ {
2673
+ field: exports.EnumCampoTributo.TipoCalculoImposto,
2674
+ rule: this.taxCalculationTypeCalculationRule
2675
+ },
2676
+ {
2677
+ field: exports.EnumCampoTributo.ImpostoManual,
2678
+ rule: this.manualTaxCalculationRule
2485
2679
  }
2486
2680
  ],
2487
2681
  _e[exports.EnumTipoTributo.IBS_MUNICIPAL_DIFERIDO] = [
@@ -2547,9 +2741,11 @@
2547
2741
  { type: EffectiveTaxRateCalculationRule },
2548
2742
  { type: TaxAmountCalculationRule },
2549
2743
  { type: GrossAmountCalculationRule },
2550
- { type: TaxClassificationCalculationRule }
2744
+ { type: TaxClassificationCalculationRule },
2745
+ { type: TaxCalculationTypeCalculationRule },
2746
+ { type: ManualTaxCalculationRule }
2551
2747
  ]; };
2552
- CalculationRulesRegistry.ɵprov = core.ɵɵdefineInjectable({ factory: function CalculationRulesRegistry_Factory() { return new CalculationRulesRegistry(core.ɵɵinject(TaxableBaseCalculationRule), core.ɵɵinject(TaxRateCalculationRule), core.ɵɵinject(EffectiveTaxRateCalculationRule), core.ɵɵinject(TaxAmountCalculationRule), core.ɵɵinject(GrossAmountCalculationRule), core.ɵɵinject(TaxClassificationCalculationRule)); }, token: CalculationRulesRegistry, providedIn: "root" });
2748
+ CalculationRulesRegistry.ɵprov = core.ɵɵdefineInjectable({ factory: function CalculationRulesRegistry_Factory() { return new CalculationRulesRegistry(core.ɵɵinject(TaxableBaseCalculationRule), core.ɵɵinject(TaxRateCalculationRule), core.ɵɵinject(EffectiveTaxRateCalculationRule), core.ɵɵinject(TaxAmountCalculationRule), core.ɵɵinject(GrossAmountCalculationRule), core.ɵɵinject(TaxClassificationCalculationRule), core.ɵɵinject(TaxCalculationTypeCalculationRule), core.ɵɵinject(ManualTaxCalculationRule)); }, token: CalculationRulesRegistry, providedIn: "root" });
2553
2749
  CalculationRulesRegistry = __decorate([
2554
2750
  core.Injectable({ providedIn: 'root' })
2555
2751
  ], CalculationRulesRegistry);
@@ -3344,7 +3540,7 @@
3344
3540
  function TaxRateRequiredValidationRule() {
3345
3541
  }
3346
3542
  TaxRateRequiredValidationRule.prototype.apply = function (_a) {
3347
- var documentType = _a.documentType, _b = _a.item, taxType = _b.name, formGroup = _b.formGroup;
3543
+ var documentType = _a.documentType, _b = _a.item, taxType = _b.name, formGroup = _b.formGroup, group = _a.group;
3348
3544
  switch (taxType) {
3349
3545
  case exports.EnumTipoTributo.CBS:
3350
3546
  case exports.EnumTipoTributo.IBS_ESTADUAL:
@@ -3777,7 +3973,11 @@
3777
3973
  case exports.EnumTipoDocumento.PEDIDO_COMPRA:
3778
3974
  case exports.EnumTipoDocumento.PEDIDO_VENDA:
3779
3975
  {
3976
+ var baseTaxFormGroup = getBaseTaxItemFromGroup({ group: group }).formGroup;
3780
3977
  rxjs.combineLatest([
3978
+ baseTaxFormGroup
3979
+ .get('reducaoAliquotaGovernamental')
3980
+ .valueChanges.pipe(operators.startWith(baseTaxFormGroup.get('reducaoAliquotaGovernamental').value), operators.distinctUntilChanged()),
3781
3981
  formGroup
3782
3982
  .get('baseCalculo')
3783
3983
  .valueChanges.pipe(operators.startWith(formGroup.get('baseCalculo').value), operators.distinctUntilChanged()),
@@ -3786,13 +3986,17 @@
3786
3986
  .valueChanges.pipe(operators.startWith(formGroup.get('aliquota').value), operators.distinctUntilChanged())
3787
3987
  ])
3788
3988
  .pipe(operators.map(function (_a) {
3789
- var _b = __read(_a, 2), taxableBase = _b[0], taxRate = _b[1];
3790
- return [new BigNumber(taxableBase), new BigNumber(taxRate)];
3989
+ var _b = __read(_a, 3), governamentalTaxRateReduction = _b[0], taxableBase = _b[1], taxRate = _b[2];
3990
+ return [
3991
+ new BigNumber(governamentalTaxRateReduction),
3992
+ new BigNumber(taxableBase),
3993
+ new BigNumber(taxRate)
3994
+ ];
3791
3995
  }))
3792
3996
  .subscribe(function (_a) {
3793
- var _b = __read(_a, 2), taxableBase = _b[0], taxRate = _b[1];
3997
+ var _b = __read(_a, 3), governamentalTaxRateReduction = _b[0], taxableBase = _b[1], taxRate = _b[2];
3794
3998
  var validators = [];
3795
- if (taxableBase.isFinite() || taxRate.isFinite()) {
3999
+ if (governamentalTaxRateReduction.isFinite() || taxableBase.isFinite() || taxRate.isFinite()) {
3796
4000
  validators = [forms.Validators.max(999.9999), forms.Validators.required];
3797
4001
  }
3798
4002
  else {
@@ -3998,7 +4202,7 @@
3998
4202
  function TaxableBaseRequiredValidationRule() {
3999
4203
  }
4000
4204
  TaxableBaseRequiredValidationRule.prototype.apply = function (_a) {
4001
- var documentType = _a.documentType, _b = _a.item, taxType = _b.name, formGroup = _b.formGroup;
4205
+ var documentType = _a.documentType, _b = _a.item, taxType = _b.name, formGroup = _b.formGroup, group = _a.group;
4002
4206
  switch (taxType) {
4003
4207
  case exports.EnumTipoTributo.CBS:
4004
4208
  case exports.EnumTipoTributo.IBS_ESTADUAL:
@@ -4417,7 +4621,11 @@
4417
4621
  case exports.EnumTipoDocumento.PEDIDO_COMPRA:
4418
4622
  case exports.EnumTipoDocumento.PEDIDO_VENDA:
4419
4623
  {
4624
+ var baseTaxFormGroup = getBaseTaxItemFromGroup({ group: group }).formGroup;
4420
4625
  rxjs.combineLatest([
4626
+ baseTaxFormGroup
4627
+ .get('reducaoAliquotaGovernamental')
4628
+ .valueChanges.pipe(operators.startWith(baseTaxFormGroup.get('reducaoAliquotaGovernamental').value), operators.distinctUntilChanged()),
4421
4629
  formGroup
4422
4630
  .get('baseCalculo')
4423
4631
  .valueChanges.pipe(operators.startWith(formGroup.get('baseCalculo').value), operators.distinctUntilChanged()),
@@ -4426,13 +4634,17 @@
4426
4634
  .valueChanges.pipe(operators.startWith(formGroup.get('aliquota').value), operators.distinctUntilChanged())
4427
4635
  ])
4428
4636
  .pipe(operators.map(function (_a) {
4429
- var _b = __read(_a, 2), taxableBase = _b[0], taxRate = _b[1];
4430
- return [new BigNumber(taxableBase), new BigNumber(taxRate)];
4637
+ var _b = __read(_a, 3), governamentalTaxRateReduction = _b[0], taxableBase = _b[1], taxRate = _b[2];
4638
+ return [
4639
+ new BigNumber(governamentalTaxRateReduction),
4640
+ new BigNumber(taxableBase),
4641
+ new BigNumber(taxRate)
4642
+ ];
4431
4643
  }))
4432
4644
  .subscribe(function (_a) {
4433
- var _b = __read(_a, 2), taxableBase = _b[0], taxRate = _b[1];
4645
+ var _b = __read(_a, 3), governamentalTaxRateReduction = _b[0], taxableBase = _b[1], taxRate = _b[2];
4434
4646
  var validators = [];
4435
- if (taxableBase.isFinite() || taxRate.isFinite()) {
4647
+ if (governamentalTaxRateReduction.isFinite() || taxableBase.isFinite() || taxRate.isFinite()) {
4436
4648
  validators = [forms.Validators.max(9999999999999.99), forms.Validators.required];
4437
4649
  }
4438
4650
  else {
@@ -11704,8 +11916,10 @@
11704
11916
  exports.nonNullish = nonNullish;
11705
11917
  exports.ɵa = ErpResumoComponent;
11706
11918
  exports.ɵb = ErpResumoService;
11707
- exports.ɵba = EntityService;
11708
- exports.ɵbb = QuantidadeDisponivelDemandaModule;
11919
+ exports.ɵba = ErpLoteSeriesService;
11920
+ exports.ɵbb = QuantidadeDisponivelDemandaService;
11921
+ exports.ɵbc = EntityService;
11922
+ exports.ɵbd = QuantidadeDisponivelDemandaModule;
11709
11923
  exports.ɵc = ErpTributosService;
11710
11924
  exports.ɵd = RulesService;
11711
11925
  exports.ɵe = StatusRulesRegistry;
@@ -11727,9 +11941,9 @@
11727
11941
  exports.ɵu = GrossAmountCalculationRule;
11728
11942
  exports.ɵv = GrossAmountCalculator;
11729
11943
  exports.ɵw = TaxClassificationCalculationRule;
11730
- exports.ɵx = FocusService;
11731
- exports.ɵy = ErpLoteSeriesService;
11732
- exports.ɵz = QuantidadeDisponivelDemandaService;
11944
+ exports.ɵx = TaxCalculationTypeCalculationRule;
11945
+ exports.ɵy = ManualTaxCalculationRule;
11946
+ exports.ɵz = FocusService;
11733
11947
 
11734
11948
  Object.defineProperty(exports, '__esModule', { value: true });
11735
11949