File size: 854 Bytes
d9d7b41 | 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 | """Calculadoras de tributos brasileiros."""
from __future__ import annotations
from dataclasses import dataclass
from decimal import Decimal, ROUND_HALF_UP
def arred(valor: Decimal, casas: int = 2) -> Decimal:
quantizador = Decimal(10) ** -casas
return valor.quantize(quantizador, rounding=ROUND_HALF_UP)
@dataclass
class ResultadoCalculo:
base_calculo: Decimal
aliquota: Decimal
valor_tributo: Decimal
deducoes: Decimal = Decimal("0")
creditos: Decimal = Decimal("0")
valor_a_recolher: Decimal = Decimal("0")
detalhes: dict = None
def __post_init__(self):
if self.detalhes is None:
self.detalhes = {}
if self.valor_a_recolher == Decimal("0"):
self.valor_a_recolher = max(
Decimal("0"), self.valor_tributo - self.creditos - self.deducoes
)
|