-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1d271c9
commit 15217c0
Showing
3 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
DanfeFluentBlazor/DanfeFluentBlazor/Components/Impostos/ImpostoICMS.razor
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
129 changes: 129 additions & 0 deletions
129
DanfeFluentBlazor/DanfeFluentBlazor/Components/Impostos/ImpostoPIS.razor
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,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; | ||
} | ||
} |
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