Skip to Content
Saldo is currently in alpha - report any bugs here

Referência da API

APIs de trabalhador por conta de outrem para folha de pagamento portuguesa. Para cálculos de trabalhadores por conta própria, consulte a API de trabalhador independente.

Função Principal

simulateDependentWorker(options)

Calcula os impostos e o salário líquido de trabalhadores por conta de outrem portugueses usando as tabelas de retenção oficiais.

Parâmetros

interface SimulateDependentWorkerOptions { income: number; married?: boolean; disabled?: boolean; partnerDisabled?: boolean; location?: LocationT; numberOfHolders?: number | null; numberOfDependents?: number | null; numberOfDependentsDisabled?: number | null; period?: PeriodT; socialSecurityTaxRate?: number; twelfths?: Twelfths; lunchAllowanceDailyValue?: number; lunchAllowanceMode?: "cupon" | "salary"; lunchAllowanceDaysCount?: number; }
ParâmetroTipoPredefiniçãoDescrição
incomenumberObrigatórioRendimento bruto mensal em euros
marriedbooleanfalseSe a pessoa é casada
disabledbooleanfalseSe a pessoa tem deficiência
partnerDisabledbooleanfalseSe o cônjuge tem deficiência
locationLocationT'continent'Região fiscal: 'continent', 'azores', ou 'madeira'
numberOfHoldersnumber | nullnullNúmero de titulares de rendimentos no casamento (1 ou 2)
numberOfDependentsnumber | nullnullNúmero de dependentes
numberOfDependentsDisablednumber | nullnullNúmero de dependentes com deficiências
periodPeriodT"2025-01-01_2025-07-31"Período de cálculo fiscal no formato “YYYY-MM-DD_YYYY-MM-DD”
socialSecurityTaxRatenumber0.11Taxa de segurança social (11%)
twelfthsTwelfthsTwelfths.TWO_MONTHSDistribuição de subsídios de férias
lunchAllowanceDailyValuenumber10.2Valor diário do subsídio de refeição em euros
lunchAllowanceMode"cupon" | "salary""cupon"Tipo de subsídio de refeição
lunchAllowanceDaysCountnumber22Dias úteis por mês para subsídio de refeição

Valor de Retorno

interface DependentWorkerResult { taxableIncome: number; grossIncome: number; tax: number; socialSecurity: number; socialSecurityTax: number; netSalary: number; yearlyNetSalary: number; yearlyGrossSalary: number; lunchAllowance: LunchAllowance; bracket: { signal: "max" | "min"; limit: number; max_marginal_rate: number; deduction: number; var1_deduction: number; var2_deduction: number; dependent_aditional_deduction: number; effective_mensal_rate: number; }; taxRetentionTable: { situation: string; description: string; brackets: { signal: "max" | "min"; limit: number; max_marginal_rate: number; deduction: number; var1_deduction: number; var2_deduction: number; dependent_aditional_deduction: number; effective_mensal_rate: number; }[]; dependent_disabled_aditional_deduction?: number; }; }
PropriedadeTipoDescrição
taxableIncomenumberRendimento mensal sujeito a imposto
grossIncomenumberRendimento bruto mensal total incluindo subsídios
taxnumberValor mensal de imposto
socialSecuritynumberContribuição mensal de segurança social
socialSecurityTaxnumberTaxa de segurança social aplicada
netSalarynumberSalário líquido mensal após deduções
yearlyNetSalarynumberSalário líquido anual (14 meses)
yearlyGrossSalarynumberSalário bruto anual (14 meses)
lunchAllowanceLunchAllowanceDetalhamento do subsídio de refeição
bracketobjectInformação do escalão fiscal com taxas e deduções
taxRetentionTableobjectDados completos da tabela de retenção fiscal

Exemplo

Interactive Example

Tipos e Enums

LocationT

type LocationT = "continent" | "azores" | "madeira";

Twelfths

enum Twelfths { NONE = 0, // Sem subsídios de férias ONE_HALF_MONTH = 0.5, // 1x50% - Um subsídio a 50% (meio mês) ONE_MONTH = 1, // 2x50% - Dois subsídios a 50% cada (um mês total) TWO_MONTHS = 2 // 2x100% - Dois subsídios a 100% cada (dois meses total) }

LunchAllowance

class LunchAllowance { constructor( public dailyValue: number, public mode: "cupon" | "salary" | null, public daysCount: number ) {} get monthlyValue(): number; get taxableMonthlyValue(): number; get taxFreeMonthlyValue(): number; get yearlyValue(): number; }
PropriedadeTipoDescrição
dailyValuenumberValor diário do subsídio de refeição
mode"cupon" | "salary" | nullTipo de subsídio de refeição
daysCountnumberNúmero de dias úteis por mês
monthlyValuenumberSubsídio de refeição mensal total
taxableMonthlyValuenumberPorção sujeita a imposto
taxFreeMonthlyValuenumberPorção isenta de imposto
yearlyValuenumberSubsídio de refeição anual (11 meses)

Regras Fiscais:

  • Cartões de refeição ("cupon"): Isento até €10,20/dia
  • Subsídio em dinheiro ("salary"): Isento até €6,00/dia

SituationCodesT

type SituationCodesT = | "TABLE1_SINGLE_OR_MARRIED_2_HOLDERS" // Solteiro ou casado com 2 titulares | "TABLE2_SINGLE_ONE_OR_MORE_DEPENDENTS" // Solteiro com dependentes | "TABLE3_MARRIED_1_HOLDER" // Casado, um titular | "TABLE4_SINGLE_OR_MARRIED_2_HOLDERS_NO_DEPENDENTS_PERSON_WITH_DISABILITY" // Solteiro ou casado 2 titulares + deficiência | "TABLE5_SINGLE_ONE_OR_MORE_DEPENDENTS_PERSON_WITH_DISABILITY" // Solteiro com dependentes + deficiência | "TABLE6_MARRIED_2_HOLDERS_ONE_OR_MORE_DEPENDENTS_PERSON_WITH_DISABILITY" // Casado 2 titulares com dependentes + deficiência | "TABLE7_MARRIED_1_HOLDER_PERSON_WITH_DISABILITY"; // Casado um titular + deficiência

Situation

interface Situation { code: SituationCodesT; description: string; conditions: Condition[]; }

Condition

interface Condition { married: boolean; dependents: boolean; disabled: boolean; partnerDisabled: boolean; description: string; numberOfHolders?: number | null; }

Bracket

interface Bracket { signal: "max" | "min"; // Se este é um escalão máximo ou mínimo limit: number; // Limite de rendimento para este escalão max_marginal_rate: number; // Taxa marginal máxima de imposto deduction: number; // Valor de dedução padrão var1_deduction: number; // Dedução variável 1 var2_deduction: number; // Dedução variável 2 dependent_aditional_deduction: number; // Dedução adicional por dependente effective_mensal_rate: number; // Taxa efetiva mensal de imposto }

TaxRetentionTable

interface TaxRetentionTable { situation: string; // Código da situação description: string; // Descrição legível brackets: Bracket[]; // Array de todos os escalões fiscais dependent_disabled_aditional_deduction?: number; // Dedução adicional para dependentes com deficiência }

RetentionPathsSchema

class RetentionPathsSchema { public identifier: string; constructor( period: PeriodT, location: LocationT, situationCode: SituationCodesT, year: number | string ); get path(): string; // Retorna o identificador }

Constrói identificadores no formato "2025/continent/2025-01-01_2025-07-31/TABLE1_SINGLE_OR_MARRIED_2_HOLDERS".

Funções Utilitárias

SituationUtils.getSituation()

SituationUtils.getSituation( married: boolean, disabled: boolean, partnerDisabled: boolean, numberOfHolders?: number | null, numberOfDependents?: number ): Situation | undefined

Determina a situação fiscal apropriada com base nas circunstâncias pessoais.

SituationUtils.getSituationFromCode()

SituationUtils.getSituationFromCode(code: string): Situation | undefined

Recupera uma situação fiscal pelo seu código.

Funções de Validação

A biblioteca inclui funções de validação internas que são chamadas automaticamente:

  • validateNumberOfHolders(numberOfHolders)
  • validateMarriedAndNumberOfHolders(married, numberOfHolders)
  • validateDependents(numberOfDependents, numberOfDependentsDisabled)

Tratamento de Erros

Interactive Example

Uso Avançado

Cálculos Baseados em Períodos

Interactive Example

Taxas de Segurança Social Personalizadas

Interactive Example

Benefícios de Deficiência

Interactive Example
Last updated on