CalculatorModSpain
in package
implements
CalculatorModInterface
This class implements the CalculatorModInterface for Spain.
Tags
Table of Contents
Interfaces
Methods
- apply() : bool
- calculate() : bool
- calculateLine() : bool
- clear() : bool
- getSubtotals() : bool
- applyUsedGoods() : bool
- checkLineConflicts() : bool
- Válida conflictos de exenciones a nivel de línea.
- suggestGlobalExemption() : void
- Sugiere el valor global de exención si todas las líneas son fiscalmente coherentes.
- validateGlobalExemption() : bool
- Válida coherencia entre operación global y líneas.
- validateLineExemptions() : bool
- Válida que cada línea tenga una exención fiscalmente coherente según el global y la propia línea.
Methods
apply()
public
apply(BusinessDocument &$doc, array<string|int, mixed> &$lines) : bool
Parameters
- $doc : BusinessDocument
- $lines : array<string|int, mixed>
Return values
boolcalculate()
public
calculate(BusinessDocument &$doc, array<string|int, mixed> &$lines) : bool
Parameters
- $doc : BusinessDocument
- $lines : array<string|int, mixed>
Return values
boolcalculateLine()
public
calculateLine(BusinessDocument $doc, BusinessDocumentLine &$line) : bool
Parameters
- $doc : BusinessDocument
- $line : BusinessDocumentLine
Return values
boolclear()
public
clear(BusinessDocument &$doc, array<string|int, mixed> &$lines) : bool
Parameters
- $doc : BusinessDocument
- $lines : array<string|int, mixed>
Return values
boolgetSubtotals()
public
getSubtotals(array<string|int, mixed> &$subtotals, BusinessDocument $doc, array<string|int, BusinessDocumentLine> $lines) : bool
Parameters
- $subtotals : array<string|int, mixed>
- $doc : BusinessDocument
- $lines : array<string|int, BusinessDocumentLine>
Return values
boolapplyUsedGoods()
private
static applyUsedGoods(array<string|int, mixed> &$subtotals, BusinessDocument $doc, BusinessDocumentLine $line, string $ivaKey, float $pvpTotal, float $totalCoste) : bool
Parameters
- $subtotals : array<string|int, mixed>
- $doc : BusinessDocument
- $line : BusinessDocumentLine
- $ivaKey : string
- $pvpTotal : float
- $totalCoste : float
Return values
boolcheckLineConflicts()
Válida conflictos de exenciones a nivel de línea.
private
checkLineConflicts(array<string|int, mixed> $exenciones, bool $hasIva) : bool
No permite mezclar exenciones incompatibles (ej: E1+IVA, E2+IVA, E1+E2, etc). Lanza advertencia o retorna false si hay conflicto.
Parameters
- $exenciones : array<string|int, mixed>
- $hasIva : bool
Return values
boolsuggestGlobalExemption()
Sugiere el valor global de exención si todas las líneas son fiscalmente coherentes.
private
suggestGlobalExemption(BusinessDocument $doc, array<string|int, mixed> $lines, bool $allLinesSaved, bool $allE3, bool $allE4, bool $allE2, bool $allE5) : void
Devuelve el tipo de operación global sugerido o null si no aplica.
Parameters
- $doc : BusinessDocument
- $lines : array<string|int, mixed>
- $allLinesSaved : bool
- $allE3 : bool
- $allE4 : bool
- $allE2 : bool
- $allE5 : bool
validateGlobalExemption()
Válida coherencia entre operación global y líneas.
private
validateGlobalExemption(string|null $globalEx, bool $allZeroIva, array<string|int, mixed> $exenciones) : bool
Si hay conflicto, anula el valor global y lanza advertencia.
Parameters
- $globalEx : string|null
- $allZeroIva : bool
- $exenciones : array<string|int, mixed>
Return values
boolvalidateLineExemptions()
Válida que cada línea tenga una exención fiscalmente coherente según el global y la propia línea.
private
validateLineExemptions(BusinessDocument $doc, BusinessDocumentLine $line, string|null $subjectFiscalID, Contacto $addressShipping, string|null $globalEx) : bool
Retorna false si alguna línea no cumple la lógica fiscal.
Parameters
- $doc : BusinessDocument
- $line : BusinessDocumentLine
- $subjectFiscalID : string|null
- $addressShipping : Contacto
- $globalEx : string|null