SAT.Report.ISR (sat_mexico v0.2.0)

View Source

Get a summarized report for withholdings ISR taxes.

Summary

Functions

Round according to SAT: fractional part > 0.50 → up; else (≤ 0.50) → down.

Apply SAT rounding to each {tax_id, gross_amount, tax_withheld} tuple, returning {tax_id, rounded_gross, rounded_withheld} with integer values.

Apply SAT rounding to each {tax_id, gross_amount, tax_withheld} tuple, returning {tax_id, rounded_gross, rounded_withheld} with integer values. The output is a list of maps with the following keys

Expects a directory with the XML invoices to build the a grouped list. Supports both individual XML files and ZIP files containing XML files.

Expects the output obtained via withholdings/1 to return the summarized result.

Expects the output obtained via withholdings/1 to return the summarized result. This helps to get the right values to do the details for withheld tax by a moral person.

Functions

custom_round(decimal)

Round according to SAT: fractional part > 0.50 → up; else (≤ 0.50) → down.

round_withholdings(withholdings)

Apply SAT rounding to each {tax_id, gross_amount, tax_withheld} tuple, returning {tax_id, rounded_gross, rounded_withheld} with integer values.

round_withholdings_detailed(withholdings)

@spec round_withholdings_detailed(withholdings :: map()) :: []

Apply SAT rounding to each {tax_id, gross_amount, tax_withheld} tuple, returning {tax_id, rounded_gross, rounded_withheld} with integer values. The output is a list of maps with the following keys:

  • tax_id: The tax ID of the person who is withholding the tax.
  • incoming: The total amount of the invoice.
  • withheld: The total amount of the tax withheld.

withholdings(path_dir, nested_lookup \\ true)

@spec withholdings(path_dir :: String.t(), nested_lookup :: boolean()) ::
  withholdings :: map() | {:error, message :: String.t()}

Expects a directory with the XML invoices to build the a grouped list. Supports both individual XML files and ZIP files containing XML files.

withholdings_summarize(data)

@spec withholdings_summarize(data :: map()) :: withholdings :: []

Expects the output obtained via withholdings/1 to return the summarized result.

This helps to get the right values to do the details for withheld tax by a moral person.

withholdings_summarize_detailed(withholdings)

@spec withholdings_summarize_detailed(withholdings :: map() | list()) :: []

Expects the output obtained via withholdings/1 to return the summarized result. This helps to get the right values to do the details for withheld tax by a moral person.

The output is a list of maps with the following keys:

  • tax_id: The tax ID of the person who is withholding the tax.
  • incoming: The total amount of the invoice.
  • withheld: The total amount of the tax withheld.