Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions Lib/Modelo130.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,16 @@ public static function calcAfterDeduct(float $taxbase, float $gastosJustificacio
return round(($baseDeducible * $todeduct) / 100, 2);
}

/**
* Calcula el resultado final del modelo (casilla 07) restando retenciones e
* ingresos de trimestres anteriores. Si el resultado es negativo, la casilla
* no puede ser negativa
*/
public static function calcResult(float $afterdeduct, float $taxbaseRetenciones, float $positivosTrimestres): float
{
return max(0.0, round($afterdeduct - $taxbaseRetenciones - $positivosTrimestres, 2));
}

protected static function loadResults(bool $applyGastosJustificacion, float $todeduct, float $gastosJustificacionPct = 7.0): array
{
$taxbaseIngresos = 0.0;
Expand Down Expand Up @@ -369,10 +379,7 @@ protected static function loadResults(bool $applyGastosJustificacion, float $tod

$afterdeduct = static::calcAfterDeduct($taxbase, $gastosJustificacion, $todeduct);

$result = round($afterdeduct - $taxbaseRetenciones - $positivosTrimestres, 2);
if ($result < 0) {
$result = 0.0;
}
$result = static::calcResult($afterdeduct, $taxbaseRetenciones, $positivosTrimestres);

return [
'taxbaseIngresos' => $taxbaseIngresos,
Expand Down
19 changes: 19 additions & 0 deletions Test/main/Modelo130Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,25 @@ public function testCalcAfterDeduct(): void
$this->assertSame(1860.0, Modelo130::calcAfterDeduct(10000.0, 700.0, 20.0));
}

/**
* Verifica que el resultado final nunca es negativo tras descontar
* retenciones e ingresos de trimestres anteriores.
*/
public function testCalcResult(): void
{
// caso normal: 2.000 - 500 - 300 = 1.200
$this->assertSame(1200.0, Modelo130::calcResult(2000.0, 500.0, 300.0));

// resultado negativo: la casilla no baja de 0
$this->assertSame(0.0, Modelo130::calcResult(500.0, 400.0, 300.0));

// resultado exactamente 0
$this->assertSame(0.0, Modelo130::calcResult(100.0, 50.0, 50.0));

// redondeo a 2 decimales
$this->assertSame(33.33, Modelo130::calcResult(100.005, 33.33, 33.345));
}

protected function tearDown(): void
{
$this->logErrors();
Expand Down
3 changes: 2 additions & 1 deletion Translation/ca_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"after-deduct": "sobre casella 04",
"deductible-subaccounts": "Comptes deduïbles",
"exists-accounting-130": "Ja existeix un seient en l'exercici %codejercicio% amb el concepte: %concepte%",
"gastos-justificacion": "Despeses de difícil justificació (5%)",
"gastos-justificacion": "Despeses de difícil justificació",
"gastos-justificacion-limit": "Atenció: l'import supera el límit anual de 2.000 €",
"gastos-justificacion-pct": "% Despeses de difícil justificació",
"income-subaccounts": "Comptes d'ingressos",
"model-130": "Model 130",
"model-130-desc": "Es calcula sumant i acumulant cada trimestre, per exemple, si visualitzem el 3r trimestre veurem la suma dels trimestres 1, 2 i 3.",
Expand Down
3 changes: 2 additions & 1 deletion Translation/cs_CZ.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"after-deduct": "sobre casilla 04",
"deductible-subaccounts": "Odečitatelné účty",
"exists-accounting-130": "V účetním období %codejercicio% již existuje účetní zápis s popisem: %concepto%",
"gastos-justificacion": "Výdaje obtížně ospravedlnitelné (5%)",
"gastos-justificacion": "Výdaje obtížně ospravedlnitelné",
"gastos-justificacion-limit": "Pozor: částka překračuje roční limit 2 000 €",
"gastos-justificacion-pct": "% Výdaje obtížně ospravedlnitelné",
"income-subaccounts": "Podúčty příjmů",
"model-130": "Modelo 130",
"model-130-desc": "Vypočítává se sčítáním a akumulací každého čtvrtletí, například pokud zobrazíme 3. čtvrtletí, uvidíme součet prvních tří čtvrtletí.",
Expand Down
5 changes: 3 additions & 2 deletions Translation/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"after-deduct": "nach Feld 04",
"deductible-subaccounts": "Abziehbare Unterkonten",
"exists-accounting-130": "Es existiert bereits ein Buchungssatz im Geschäftsjahr %codejercicio% mit dem Verwendungszweck: %concepto%",
"gastos-justificacion": "Schwer belegbare Ausgaben (5%)",
"gastos-justificacion": "Schwer belegbare Ausgaben",
"gastos-justificacion-limit": "Achtung: Der Betrag überschreitet das jährliche Limit von 2.000 €",
"gastos-justificacion-pct": "% Schwer belegbare Ausgaben",
"income-subaccounts": "Unterkonten für Einnahmen",
"model-130": "Modell 130",
"model-130-desc": "Es wird berechnet, indem jeder Quartal summiert und akkumuliert wird. Zum Beispiel, wenn wir das 3. Quartal betrachten, sehen wir die Summe der Quartale 1, 2 und 3.",
"model-130-p": "Model 130 is a quarterly declaration of personal income tax (PIT) in which the installment payment of this tax is settled, on account of the annual declaration that is made the following year.",
"model-130-p": "Model 130 ist eine quartalsweise Erklärung der Einkommensteuer (IRPF), in der die Ratenzahlung dieser Steuer beglichen wird, aufgrund der jährlichen Erklärung, die im folgenden Jahr erstellt wird.",
"model-130-r": "Kumulierte Daten für den Zeitraum zwischen dem ersten Tag des Jahres und dem letzten Tag des ausgewählten Quartals.",
"net-total": "Nettoertrag",
"pct-to-deduct": "% abzuziehen",
Expand Down
5 changes: 3 additions & 2 deletions Translation/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"after-deduct": "about box 04",
"deductible-subaccounts": "Deductible Accounts",
"exists-accounting-130": "An accounting entry already exists in fiscal year %codejercicio% with the concept: %concepto%",
"gastos-justificacion": "Difficult-to-justify expenses (5%)",
"gastos-justificacion": "Difficult-to-justify expenses",
"gastos-justificacion-limit": "Warning: the amount exceeds the annual limit of €2,000",
"gastos-justificacion-pct": "% Hard-to-justify expenses",
"income-subaccounts": "Income accounts",
"model-130": "Model 130",
"model-130-desc": "It is calculated by adding and accumulating each quarter, for example, if we visualize the 3rd quarter we will see the sum of quarters 1, 2 and 3.",
"model-130-p": "Model 130 is a quarterly declaration of personal income tax (PIT) in which the installment payment of this tax is settled, on account of the annual declaration that is made the following year.",
"model-130-p": "Model 130 is a quarterly declaration of personal income tax (IRPF) in which the installment payment of this tax is settled, on account of the annual declaration that is made the following year.",
"model-130-r": "Accumulated data for the period between the first day of the year and the last day of the selected quarter.",
"net-total": "Net return",
"pct-to-deduct": "% to deduct",
Expand Down
3 changes: 2 additions & 1 deletion Translation/es_AR.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"after-deduct": "sobre casilla 03",
"deductible-subaccounts": "Cuentas deducibles",
"exists-accounting-130": "Ya existe un asiento en el ejercicio %codejercicio% con el concepto: %concepto%",
"gastos-justificacion": "Gastos de difícil justificación (7%)",
"gastos-justificacion": "Gastos de difícil justificación",
"gastos-justificacion-limit": "Atención: el importe supera el límite anual de 2.000 €",
"gastos-justificacion-pct": "% Gastos de difícil justificación",
"income-subaccounts": "Cuentas de ingresos",
"model-130": "Modelo 130",
"model-130-desc": "Se calcula sumando y acumulando cada trimestre, por ejemplo, si visualizamos el 3º trimestre veremos la suma de los trimestres 1, 2 y 3.",
Expand Down
3 changes: 2 additions & 1 deletion Translation/es_CL.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"after-deduct": "sobre casilla 03",
"deductible-subaccounts": "Cuentas deducibles",
"exists-accounting-130": "Ya existe un asiento en el ejercicio %codejercicio% con el concepto: %concepto%",
"gastos-justificacion": "Gastos de difícil justificación (7%)",
"gastos-justificacion": "Gastos de difícil justificación",
"gastos-justificacion-limit": "Atención: el importe supera el límite anual de 2.000 €",
"gastos-justificacion-pct": "% Gastos de difícil justificación",
"income-subaccounts": "Cuentas de ingresos",
"model-130": "Modelo 130",
"model-130-desc": "Se calcula sumando y acumulando cada trimestre, por ejemplo, si visualizamos el 3º trimestre veremos la suma de los trimestres 1, 2 y 3.",
Expand Down
3 changes: 2 additions & 1 deletion Translation/es_CO.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"after-deduct": "sobre casilla 03",
"deductible-subaccounts": "Cuentas deducibles",
"exists-accounting-130": "Ya existe un asiento en el ejercicio %codejercicio% con el concepto: %concepto%",
"gastos-justificacion": "Gastos de difícil justificación (7%)",
"gastos-justificacion": "Gastos de difícil justificación",
"gastos-justificacion-limit": "Atención: el importe supera el límite anual de 2.000 €",
"gastos-justificacion-pct": "% Gastos de difícil justificación",
"income-subaccounts": "Cuentas de ingresos",
"model-130": "Modelo 130",
"model-130-desc": "Se calcula sumando y acumulando cada trimestre, por ejemplo, si visualizamos el 3º trimestre veremos la suma de los trimestres 1, 2 y 3.",
Expand Down
3 changes: 2 additions & 1 deletion Translation/es_CR.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"after-deduct": "sobre casilla 03",
"deductible-subaccounts": "Cuentas deducibles",
"exists-accounting-130": "Ya existe un asiento en el ejercicio %codejercicio% con el concepto: %concepto%",
"gastos-justificacion": "Gastos de difícil justificación (7%)",
"gastos-justificacion": "Gastos de difícil justificación",
"gastos-justificacion-limit": "Atención: el importe supera el límite anual de 2.000 €",
"gastos-justificacion-pct": "% Gastos de difícil justificación",
"income-subaccounts": "Cuentas de ingresos",
"model-130": "Modelo 130",
"model-130-desc": "Se calcula sumando y acumulando cada trimestre, por ejemplo, si visualizamos el 3º trimestre veremos la suma de los trimestres 1, 2 y 3.",
Expand Down
3 changes: 2 additions & 1 deletion Translation/es_DO.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"after-deduct": "sobre casilla 03",
"deductible-subaccounts": "Cuentas deducibles",
"exists-accounting-130": "Ya existe un asiento en el ejercicio %codejercicio% con el concepto: %concepto%",
"gastos-justificacion": "Gastos de difícil justificación (7%)",
"gastos-justificacion": "Gastos de difícil justificación",
"gastos-justificacion-limit": "Atención: el importe supera el límite anual de 2.000 €",
"gastos-justificacion-pct": "% Gastos de difícil justificación",
"income-subaccounts": "Cuentas de ingresos",
"model-130": "Modelo 130",
"model-130-desc": "Se calcula sumando y acumulando cada trimestre, por ejemplo, si visualizamos el 3º trimestre veremos la suma de los trimestres 1, 2 y 3.",
Expand Down
3 changes: 2 additions & 1 deletion Translation/es_EC.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"after-deduct": "sobre casilla 03",
"deductible-subaccounts": "Cuentas deducibles",
"exists-accounting-130": "Ya existe un asiento en el ejercicio %codejercicio% con el concepto: %concepto%",
"gastos-justificacion": "Gastos de difícil justificación (7%)",
"gastos-justificacion": "Gastos de difícil justificación",
"gastos-justificacion-limit": "Atención: el importe supera el límite anual de 2.000 €",
"gastos-justificacion-pct": "% Gastos de difícil justificación",
"income-subaccounts": "Cuentas de ingresos",
"model-130": "Modelo 130",
"model-130-desc": "Se calcula sumando y acumulando cada trimestre, por ejemplo, si visualizamos el 3º trimestre veremos la suma de los trimestres 1, 2 y 3.",
Expand Down
3 changes: 2 additions & 1 deletion Translation/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"after-deduct": "sobre casilla 03",
"deductible-subaccounts": "Cuentas deducibles",
"exists-accounting-130": "Ya existe un asiento en el ejercicio %codejercicio% con el concepto: %concepto%",
"gastos-justificacion": "Gastos de difícil justificación (7%)",
"gastos-justificacion": "Gastos de difícil justificación",
"gastos-justificacion-limit": "Atención: el importe supera el límite anual de 2.000 €",
"gastos-justificacion-pct": "% Gastos de difícil justificación",
"income-subaccounts": "Cuentas de ingresos",
"model-130": "Modelo 130",
"model-130-desc": "Se calcula sumando y acumulando cada trimestre, por ejemplo, si visualizamos el 3º trimestre veremos la suma de los trimestres 1, 2 y 3.",
Expand Down
3 changes: 2 additions & 1 deletion Translation/es_GT.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"after-deduct": "sobre casilla 03",
"deductible-subaccounts": "Cuentas deducibles",
"exists-accounting-130": "Ya existe un asiento en el ejercicio %codejercicio% con el concepto: %concepto%",
"gastos-justificacion": "Gastos de difícil justificación (7%)",
"gastos-justificacion": "Gastos de difícil justificación",
"gastos-justificacion-limit": "Atención: el importe supera el límite anual de 2.000 €",
"gastos-justificacion-pct": "% Gastos de difícil justificación",
"income-subaccounts": "Cuentas de ingresos",
"model-130": "Modelo 130",
"model-130-desc": "Se calcula sumando y acumulando cada trimestre, por ejemplo, si visualizamos el 3º trimestre veremos la suma de los trimestres 1, 2 y 3.",
Expand Down
3 changes: 2 additions & 1 deletion Translation/es_MX.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"after-deduct": "sobre casilla 03",
"deductible-subaccounts": "Cuentas deducibles",
"exists-accounting-130": "Ya existe un asiento en el ejercicio %codejercicio% con el concepto: %concepto%",
"gastos-justificacion": "Gastos de difícil justificación (7%)",
"gastos-justificacion": "Gastos de difícil justificación",
"gastos-justificacion-limit": "Atención: el importe supera el límite anual de 2.000 €",
"gastos-justificacion-pct": "% Gastos de difícil justificación",
"income-subaccounts": "Cuentas de ingresos",
"model-130": "Modelo 130",
"model-130-desc": "Se calcula sumando y acumulando cada trimestre, por ejemplo, si visualizamos el 3º trimestre veremos la suma de los trimestres 1, 2 y 3.",
Expand Down
3 changes: 2 additions & 1 deletion Translation/es_PA.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"after-deduct": "sobre casilla 03",
"deductible-subaccounts": "Cuentas deducibles",
"exists-accounting-130": "Ya existe un asiento en el ejercicio %codejercicio% con el concepto: %concepto%",
"gastos-justificacion": "Gastos de difícil justificación (7%)",
"gastos-justificacion": "Gastos de difícil justificación",
"gastos-justificacion-limit": "Atención: el importe supera el límite anual de 2.000 €",
"gastos-justificacion-pct": "% Gastos de difícil justificación",
"income-subaccounts": "Cuentas de ingresos",
"model-130": "Modelo 130",
"model-130-desc": "Se calcula sumando y acumulando cada trimestre, por ejemplo, si visualizamos el 3º trimestre veremos la suma de los trimestres 1, 2 y 3.",
Expand Down
3 changes: 2 additions & 1 deletion Translation/es_PE.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"after-deduct": "sobre casilla 03",
"deductible-subaccounts": "Cuentas deducibles",
"exists-accounting-130": "Ya existe un asiento en el ejercicio %codejercicio% con el concepto: %concepto%",
"gastos-justificacion": "Gastos de difícil justificación (7%)",
"gastos-justificacion": "Gastos de difícil justificación",
"gastos-justificacion-limit": "Atención: el importe supera el límite anual de 2.000 €",
"gastos-justificacion-pct": "% Gastos de difícil justificación",
"income-subaccounts": "Cuentas de ingresos",
"model-130": "Modelo 130",
"model-130-desc": "Se calcula sumando y acumulando cada trimestre, por ejemplo, si visualizamos el 3º trimestre veremos la suma de los trimestres 1, 2 y 3.",
Expand Down
3 changes: 2 additions & 1 deletion Translation/es_UY.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"after-deduct": "sobre casilla 03",
"deductible-subaccounts": "Cuentas deducibles",
"exists-accounting-130": "Ya existe un asiento en el ejercicio %codejercicio% con el concepto: %concepto%",
"gastos-justificacion": "Gastos de difícil justificación (7%)",
"gastos-justificacion": "Gastos de difícil justificación",
"gastos-justificacion-limit": "Atención: el importe supera el límite anual de 2.000 €",
"gastos-justificacion-pct": "% Gastos de difícil justificación",
"income-subaccounts": "Cuentas de ingresos",
"model-130": "Modelo 130",
"model-130-desc": "Se calcula sumando y acumulando cada trimestre, por ejemplo, si visualizamos el 3º trimestre veremos la suma de los trimestres 1, 2 y 3.",
Expand Down
3 changes: 2 additions & 1 deletion Translation/eu_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"after-deduct": "04 koadroari buruz",
"deductible-subaccounts": "Deduzi daitezkeen azpis kontuak",
"exists-accounting-130": "Dagoeneko badago idazpen bat %codejercicio% ekitaldian %concepto% kontzeptuarekin",
"gastos-justificacion": "Zail justifikatzen diren gastuak (5%)",
"gastos-justificacion": "Zail justifikatzen diren gastuak",
"gastos-justificacion-limit": "Kontuz: zenbatekoa urteko 2.000 €-ko muga gainditzen du",
"gastos-justificacion-pct": "% Zail justifikatzen diren gastuak",
"income-subaccounts": "Sarreren kontuak",
"model-130": "130 Eredua",
"model-130-desc": "Hiruhileko bakoitzean gehienetan batu eta akumulatu egiten da, adibidez, hirugarren hiruhilekoko informazioa ikusten dugunean, 1., 2. eta 3. hiruhilekoak batu eta akumulatu ikusiko dugu.",
Expand Down
7 changes: 4 additions & 3 deletions Translation/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"after-deduct": "sur case 04",
"deductible-subaccounts": "Comptes déductibles",
"exists-accounting-130": "Il existe déjà une écriture pour l'exercice %codejercicio% avec le libellé : %concepto%",
"gastos-justificacion": "Dépenses difficiles à justifier (5%)",
"gastos-justificacion-limit": "Attention : le montant dépasse la limite annuelle de 2 000 €",
"gastos-justificacion": "Dépenses difficiles à justifier",
"gastos-justificacion-limit": "Attention: le montant dépasse la limite annuelle de 2.000 €",
"gastos-justificacion-pct": "% Dépenses difficiles à justifier",
"income-subaccounts": "Comptes de revenus",
"model-130": "Formulaire 130",
"model-130-desc": "Il est calculé en ajoutant et cumulant chaque trimestre, par exemple, si nous visualisons le 3ème trimestre, nous verrons la somme des trimestres 1, 2 et 3.",
"model-130-p": "Le formulaire 130 est une déclaration trimestrielle de l'impôt sur le revenu des personnes physiques (IRPP) dans laquelle le paiement de cet impôt est réglé par acomptes, compte tenu de la déclaration annuelle à effectuer l'année suivante.",
"model-130-p": "Le formulaire 130 est une déclaration trimestrielle de l'impôt sur le revenu des personnes physiques (IRPF) dans laquelle le paiement de cet impôt est réglé par acomptes, compte tenu de la déclaration annuelle à effectuer l'année suivante.",
"model-130-r": "Données cumulées pour la période comprise entre le premier jour de l'année et le dernier jour du trimestre sélectionné.",
"net-total": "Rendement net",
"pct-to-deduct": "% déduire",
Expand Down
3 changes: 2 additions & 1 deletion Translation/gl_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"after-deduct": "sobre casa 04",
"deductible-subaccounts": "Contas deducibles",
"exists-accounting-130": "Xa existe un asento no exercicio %codejercicio% co concepto: %concepto%",
"gastos-justificacion": "Gastos de difícil xustificación (5%)",
"gastos-justificacion": "Gastos de difícil xustificación",
"gastos-justificacion-limit": "Atención: o importe supera o límite anual de 2.000 €",
"gastos-justificacion-pct": "% Gastos de difícil xustificación",
"income-subaccounts": "Contas de ingresos",
"model-130": "Modelo 130",
"model-130-desc": "Calcúlase sumando e acumulando cada trimestre, por exemplo, se visualizamos o 3º trimestre veremos a suma dos trimestres 1, 2 e 3.",
Expand Down
3 changes: 2 additions & 1 deletion Translation/it_IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"after-deduct": "sulla casella 04",
"deductible-subaccounts": "Conti deducibili",
"exists-accounting-130": "Esiste già una registrazione nell'esercizio %codejercicio% con la causale: %concepto%",
"gastos-justificacion": "Spese di difficile giustificazione (5%)",
"gastos-justificacion": "Spese di difficile giustificazione",
"gastos-justificacion-limit": "Attenzione: l'importo supera il limite annuo di 2.000 €",
"gastos-justificacion-pct": "% Spese di difficile giustificazione",
"income-subaccounts": "Conti dei ricavi",
"model-130": "Modello 130",
"model-130-desc": "Si calcola sommando e accumulando ogni trimestre, ad esempio, se visualizziamo il 3° trimestre vedremo la somma dei trimestri 1, 2 e 3.",
Expand Down
Loading
Loading