Atualiza conversão de valores em células da planilha#43
Merged
albertomandlate merged 1 commit intomainfrom Jun 20, 2025
Merged
Conversation
Modifica a forma como os valores são definidos nas células, substituindo o uso de `ToString()` por `Convert.ToDouble()` para conversão direta de valores decimais. Essa mudança é aplicada a células que contêm valores de impostos, totais líquidos, totais brutos e pagamentos. Além disso, ajusta a lógica de cálculo do imposto para garantir que o valor retornado seja um decimal.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR updates the conversion of cell values in the Excel generator, replacing string-based conversion with direct decimal-to-double conversion.
- Replaces ToString() calls with Convert.ToDouble() across multiple cell value assignments.
- Adjusts the tax calculation to directly return a decimal value as a double for Excel cell population.
Comment on lines
334
to
343
| decimal impostos = factura.Lines? | ||
| .FirstOrDefault(w => | ||
| w.Tax.Where(wh => wh.TaxPercentage != 0m).FirstOrDefault()?.TaxPercentage != 0m)? | ||
| .Tax.FirstOrDefault(w => w.TaxPercentage != 0m)?.TaxPercentage ?? 0m; | ||
|
|
||
| row.CreateCell(23).SetCellValue(factura.Lines? | ||
| row.CreateCell(23).SetCellValue(Convert.ToDouble(factura.Lines? | ||
| .FirstOrDefault(w => | ||
| w.Tax.Where(wh => wh.TaxPercentage != 0m).FirstOrDefault()?.TaxPercentage != 0m)? | ||
| .Tax.FirstOrDefault(w => w.TaxPercentage != 0m)?.TaxPercentage.ToString() ?? "0"); | ||
| .Tax.FirstOrDefault(w => w.TaxPercentage != 0m)?.TaxPercentage ?? 0m)); | ||
|
|
There was a problem hiding this comment.
The nested lambda expressions and conditional chaining make the tax percentage extraction hard to read. Consider refactoring by extracting the tax computation into a separate variable to improve clarity and ease future maintenance.
Contributor
Author
There was a problem hiding this comment.
Para mim, parece bem. Posso fazer isso mais tarde. Por agora, preciso de lançar esta correcção o mais rápido possível.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Modifica a forma como os valores são definidos nas células, substituindo o uso de
ToString()porConvert.ToDouble()para conversão direta de valores decimais. Essa mudança é aplicada a células que contêm valores de impostos, totais líquidos, totais brutos e pagamentos. Além disso, ajusta a lógica de cálculo do imposto para garantir que o valor retornado seja um decimal.