Skip to content

Atualiza conversão de valores em células da planilha#43

Merged
albertomandlate merged 1 commit intomainfrom
hotfix-preenchimento-campo-numero-excel
Jun 20, 2025
Merged

Atualiza conversão de valores em células da planilha#43
albertomandlate merged 1 commit intomainfrom
hotfix-preenchimento-campo-numero-excel

Conversation

@albertomandlate
Copy link
Copy Markdown
Contributor

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.

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.
@albertomandlate albertomandlate requested a review from Copilot June 20, 2025 07:16
@albertomandlate albertomandlate self-assigned this Jun 20, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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));

Copy link

Copilot AI Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Para mim, parece bem. Posso fazer isso mais tarde. Por agora, preciso de lançar esta correcção o mais rápido possível.

@albertomandlate albertomandlate merged commit eca89ed into main Jun 20, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants