-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(descuentos globales): add descuentos globales (#179)
* feat(descuentos globales): add descuentos globales * Update snapshots * Fix quarkus snapshot * Fix quarkus snapshot * Add homologacion group4 tests
- Loading branch information
1 parent
1978ae2
commit ffe17e8
Showing
72 changed files
with
3,643 additions
and
45 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
...n/java/io/github/project/openubl/xbuilder/content/catalogs/Catalog53_DescuentoGlobal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2019 Project OpenUBL, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License - 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.github.project.openubl.xbuilder.content.catalogs; | ||
|
||
public enum Catalog53_DescuentoGlobal implements Catalog { | ||
DESCUENTO_GLOBAL_AFECTA_BASE_IMPONIBLE_IGV_IVAP("02"), | ||
DESCUENTO_GLOBAL_NO_AFECTA_BASE_IMPONIBLE_IGV_IVAP("03"); | ||
|
||
private final String code; | ||
|
||
Catalog53_DescuentoGlobal(String code) { | ||
this.code = code; | ||
} | ||
|
||
@Override | ||
public String getCode() { | ||
return code; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...in/java/io/github/project/openubl/xbuilder/content/models/standard/general/Descuento.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2019 Project OpenUBL, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License - 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.github.project.openubl.xbuilder.content.models.standard.general; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
import java.math.BigDecimal; | ||
|
||
@Data | ||
@SuperBuilder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class Descuento { | ||
|
||
@Schema(requiredMode = Schema.RequiredMode.REQUIRED, description = "Catalogo 53") | ||
private String tipoDescuento; | ||
|
||
@Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
private BigDecimal factor; | ||
|
||
@Schema(requiredMode = Schema.RequiredMode.REQUIRED) | ||
private BigDecimal monto; | ||
|
||
@Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
private BigDecimal montoBase; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
.../github/project/openubl/xbuilder/enricher/kie/rules/enrich/body/descuento/FactorRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2019 Project OpenUBL, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License - 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.github.project.openubl.xbuilder.enricher.kie.rules.enrich.body.descuento; | ||
|
||
import io.github.project.openubl.xbuilder.content.models.standard.general.Descuento; | ||
import io.github.project.openubl.xbuilder.enricher.kie.AbstractBodyRule; | ||
import io.github.project.openubl.xbuilder.enricher.kie.RulePhase; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.function.Consumer; | ||
|
||
import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.isDescuento; | ||
import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.whenDescuento; | ||
|
||
@RulePhase(type = RulePhase.PhaseType.ENRICH) | ||
public class FactorRule extends AbstractBodyRule { | ||
|
||
@Override | ||
public boolean test(Object object) { | ||
return isDescuento.test(object) && whenDescuento.apply(object) | ||
.map(descuento -> descuento.getFactor() == null) | ||
.orElse(false); | ||
} | ||
|
||
@Override | ||
public void modify(Object object) { | ||
Consumer<Descuento> consumer = descuento -> { | ||
descuento.setFactor(BigDecimal.ONE); | ||
}; | ||
whenDescuento.apply(object).ifPresent(consumer); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...thub/project/openubl/xbuilder/enricher/kie/rules/enrich/body/descuento/MontoBaseRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2019 Project OpenUBL, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License - 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.github.project.openubl.xbuilder.enricher.kie.rules.enrich.body.descuento; | ||
|
||
import io.github.project.openubl.xbuilder.content.models.standard.general.Descuento; | ||
import io.github.project.openubl.xbuilder.enricher.kie.AbstractBodyRule; | ||
import io.github.project.openubl.xbuilder.enricher.kie.RulePhase; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.function.Consumer; | ||
|
||
import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.isDescuento; | ||
import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.whenDescuento; | ||
|
||
@RulePhase(type = RulePhase.PhaseType.ENRICH) | ||
public class MontoBaseRule extends AbstractBodyRule { | ||
|
||
@Override | ||
public boolean test(Object object) { | ||
return isDescuento.test(object) && whenDescuento.apply(object) | ||
.map(descuento -> descuento.getMontoBase() == null && descuento.getMonto() != null) | ||
.orElse(false); | ||
} | ||
|
||
@Override | ||
public void modify(Object object) { | ||
Consumer<Descuento> consumer = descuento -> { | ||
descuento.setMontoBase(descuento.getMonto()); | ||
}; | ||
whenDescuento.apply(object).ifPresent(consumer); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
.../project/openubl/xbuilder/enricher/kie/rules/enrich/body/descuento/TipoDescuentoRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2019 Project OpenUBL, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License - 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.github.project.openubl.xbuilder.enricher.kie.rules.enrich.body.descuento; | ||
|
||
import io.github.project.openubl.xbuilder.content.catalogs.Catalog; | ||
import io.github.project.openubl.xbuilder.content.catalogs.Catalog53_DescuentoGlobal; | ||
import io.github.project.openubl.xbuilder.content.models.standard.general.Descuento; | ||
import io.github.project.openubl.xbuilder.enricher.kie.AbstractBodyRule; | ||
import io.github.project.openubl.xbuilder.enricher.kie.RulePhase; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.isDescuento; | ||
import static io.github.project.openubl.xbuilder.enricher.kie.rules.utils.Helpers.whenDescuento; | ||
|
||
/** | ||
* Rule for: {@link Descuento#tipoDescuento} | ||
* | ||
* @author <a href="mailto:carlosthe19916@gmail.com">Carlos Feria</a> | ||
*/ | ||
@RulePhase(type = RulePhase.PhaseType.ENRICH) | ||
public class TipoDescuentoRule extends AbstractBodyRule { | ||
|
||
@Override | ||
public boolean test(Object object) { | ||
return isDescuento.test(object); | ||
} | ||
|
||
@Override | ||
public void modify(Object object) { | ||
Consumer<Descuento> consumer = descuento -> { | ||
String tipoDescuento; | ||
if (descuento.getTipoDescuento() == null) { | ||
tipoDescuento = Catalog53_DescuentoGlobal.DESCUENTO_GLOBAL_NO_AFECTA_BASE_IMPONIBLE_IGV_IVAP.getCode(); | ||
} else { | ||
Catalog53_DescuentoGlobal catalog53 = Catalog | ||
.valueOfCode(Catalog53_DescuentoGlobal.class, descuento.getTipoDescuento()) | ||
.orElseThrow(Catalog.invalidCatalogValue); | ||
tipoDescuento = catalog53.getCode(); | ||
} | ||
|
||
descuento.setTipoDescuento(tipoDescuento); | ||
}; | ||
whenDescuento.apply(object).ifPresent(consumer); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.