Skip to content

Commit

Permalink
Add ImpostoPIS
Browse files Browse the repository at this point in the history
  • Loading branch information
rodolfoghi committed Aug 24, 2024
1 parent 1d271c9 commit 15217c0
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@using NFe.Classes.Informacoes.Detalhe.Tributacao.Estadual

<Imposto NomeDoImposto="ICMS" CST="@_cst" BaseDeCalculo="@_baseDeCalculo" Aliquota="@_aliquota" Valor="@_valor" />

@code {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
@using NFe.Classes.Informacoes.Detalhe.Tributacao.Federal
@using System.Reflection
@using System.Xml.Serialization

<Imposto NomeDoImposto="PIS" CST="@_cst" BaseDeCalculo="@_baseDeCalculo" Aliquota="@_aliquota" Valor="@_valor" />

@code {
[Parameter]
public PIS DadosPIS { get; set; }

private string _cst = string.Empty;
private decimal _baseDeCalculo;
private decimal _aliquota;
private decimal _valor;

protected override void OnInitialized()
{
_cst = ObterCST();
_baseDeCalculo = ObterBaseDeCalculo();
_aliquota = ObterAliquota();
_valor = ObterValor();
}

private string ObterCST()
{
var tipoPIS = DadosPIS.TipoPIS;

if (tipoPIS is PISAliq pisAliq)
{
return GetXmlEnumValue(pisAliq.CST);
}

if (tipoPIS is PISQtde pisQtde)
{
return GetXmlEnumValue(pisQtde.CST);
}

if (tipoPIS is PISNT pisNT)
{
return GetXmlEnumValue(pisNT.CST);
}

if (tipoPIS is PISOutr pisOutr)
{
return GetXmlEnumValue(pisOutr.CST);
}

return string.Empty;
}

private decimal ObterBaseDeCalculo()
{
var tipoPIS = DadosPIS.TipoPIS;

if (tipoPIS is PISAliq pisAliq)
{
return pisAliq.vBC;
}

if (tipoPIS is PISQtde pisQtde)
{
return pisQtde.qBCProd;
}

if (tipoPIS is PISOutr pisOutr)
{
return pisOutr.vBC ?? 0;
}

return 0;
}

private decimal ObterAliquota()
{
var tipoPIS = DadosPIS.TipoPIS;

if (tipoPIS is PISAliq pisAliq)
{
return pisAliq.pPIS;
}

if (tipoPIS is PISQtde pisQtde)
{
return pisQtde.vAliqProd;
}

if (tipoPIS is PISOutr pisOutr)
{
return pisOutr.pPIS ?? 0;
}

return 0;
}

private decimal ObterValor()
{
var tipoPIS = DadosPIS.TipoPIS;

if (tipoPIS is PISAliq pisAliq)
{
return pisAliq.vPIS;
}

if (tipoPIS is PISQtde pisQtde)
{
return pisQtde.vPIS;
}

if (tipoPIS is PISOutr pisOutr)
{
return pisOutr.vPIS ?? 0;
}

return 0;
}

public static string GetXmlEnumValue(Enum enumValue)
{
FieldInfo fieldInfo = enumValue.GetType().GetField(enumValue.ToString());
XmlEnumAttribute[] attributes = (XmlEnumAttribute[])fieldInfo.GetCustomAttributes(typeof(XmlEnumAttribute), false);

if (attributes.Length > 0)
{
return attributes[0]?.Name!;
}

return string.Empty;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
</FluentGridItem>

<ImpostoICMS DadosICMS="@detalhe.imposto.ICMS" />
<ImpostoPIS DadosPIS="@detalhe.imposto.PIS" />
</FluentGrid>
</FluentAccordionItem>
}
Expand Down

0 comments on commit 15217c0

Please sign in to comment.