LibreDTE

AbstractLibroComprasVentasBuilderStrategy extends AbstractStrategy
in package

AbstractYes

Estrategia base de construcción para Libro de Compras/Ventas.

Recibe el bag con detalles ya normalizados por el LoaderWorker, calcula los totales del período y genera el XML según LibroCV_v10.xsd.

Table of Contents

Constants

CARATULA_REQUERIDA  : array<string, string> = ['ESPECIAL' => 'FolioNotificacion', 'RECTIFICA'...
Dato de la carátula que exige cada tipo de libro.
TIPOS_RESUMEN_MANUAL  : array<int, int> = [35, 38, 48]
Tipos de documento que se pueden informar solo con su resumen: boletas, boletas exentas y pagos electrónicos.

Properties

$totalDefault  : array<string, mixed>
Valores por defecto de los totales del período por tipo de documento.
$xmlEncoder  : XmlEncoderInterface

Methods

__construct()  : mixed
build()  : LibroComprasVentasInterface
Construye el Libro de Compras/Ventas a partir del bag normalizado.
filterDetalle()  : array<int, array<string, mixed>>
Entrega las filas del detalle que van en el XML del libro.
addResumen()  : array<int, array<string, mixed>>
Agrega al resumen del período el resumen manual: los totales de documentos que no están en el detalle.
calculateTotalesPeriodo()  : array<int, array<string, mixed>>
Calcula los totales del período agrupados por TpoDoc.
newGroup()  : array{documents: int, annulled: int|null, exempt: int, net: int, vat: int, total: int, fixedAsset: int|null, fixedAssetVat: int|null, notRecoverable: array, commonVat: int|null, proportion: int|float|null, commonCredit: int|null, latePayment: int|null, otherTaxes: array, withoutCredit: int|null, withheldTotal: int|null, withheldPartial: int|null, notWithheld: int|null, vehicle: int|null}
Entrega los acumuladores de un tipo de documento, vacíos. Un total que es `null` es uno que ningún documento aportó: no aparece en el XML.

Constants

CARATULA_REQUERIDA

Dato de la carátula que exige cada tipo de libro.

public array<string, string> CARATULA_REQUERIDA = ['ESPECIAL' => 'FolioNotificacion', 'RECTIFICA' => 'CodAutRec']

El esquema deja estos campos como opcionales: que sean obligatorios para estos tipos de libro no lo valida el esquema, por eso se valida al construir el libro.

TIPOS_RESUMEN_MANUAL

Tipos de documento que se pueden informar solo con su resumen: boletas, boletas exentas y pagos electrónicos.

public array<int, int> TIPOS_RESUMEN_MANUAL = [35, 38, 48]

Properties

$totalDefault

Valores por defecto de los totales del período por tipo de documento.

private array<string, mixed> $totalDefault = ['TpoDoc' => null, 'TotDoc' => 0, 'TotAnulado' => null, 'TotOpExe' => null, 'TotMntExe' => 0, 'TotMntNeto' => 0, 'TotMntIVA' => 0, 'TotIVAPropio' => null, 'TotIVATerceros' => null, 'TotLey18211' => null, 'TotMntActivoFijo' => null, 'TotMntIVAActivoFijo' => null, 'TotIVANoRec' => null, 'TotIVAUsoComun' => null, 'FctProp' => null, 'TotCredIVAUsoComun' => null, 'TotIVAFueraPlazo' => null, 'TotOtrosImp' => null, 'TotIVARetTotal' => null, 'TotIVARetParcial' => null, 'TotImpSinCredito' => null, 'TotMntTotal' => 0, 'TotIVANoRetenido' => null, 'TotMntNoFact' => null, 'TotMntPeriodo' => null, 'TotPsjNac' => null, 'TotPsjInt' => null, 'TotTabPuros' => null, 'TotTabCigarrillos' => null, 'TotTabElaborado' => null, 'TotImpVehiculo' => null]

El orden de las claves determina el orden de los elementos en el XML.

Methods

filterDetalle()

Entrega las filas del detalle que van en el XML del libro.

protected filterDetalle(array<int, array<string, mixed>> $detalles) : array<int, array<string, mixed>>

Por defecto son todas. Una estrategia puede dejar fuera algunas: sus totales igual se cuentan en el resumen del período.

Parameters
$detalles : array<int, array<string, mixed>>
Return values
array<int, array<string, mixed>>

addResumen()

Agrega al resumen del período el resumen manual: los totales de documentos que no están en el detalle.

private addResumen(array<int, array<string, mixed>> $totales, array<int, array<string, mixed>> $resumen) : array<int, array<string, mixed>>
Parameters
$totales : array<int, array<string, mixed>>

Totales calculados desde el detalle, por tipo de documento.

$resumen : array<int, array<string, mixed>>

Resumen manual.

Tags
throws
BookException

Si un elemento no tiene TpoDoc y TotDoc, si su tipo de documento no es uno de TIPOS_RESUMEN_MANUAL, si el tipo se repite en el resumen o si el tipo ya está en el detalle.

Return values
array<int, array<string, mixed>>

calculateTotalesPeriodo()

Calcula los totales del período agrupados por TpoDoc.

private calculateTotalesPeriodo(array<int, array<string, mixed>> &$detalles) : array<int, array<string, mixed>>

Se quita el factor de proporcionalidad (FctProp) de los detalles, que no es parte del XML de un detalle.

Parameters
$detalles : array<int, array<string, mixed>>
Return values
array<int, array<string, mixed>>

newGroup()

Entrega los acumuladores de un tipo de documento, vacíos. Un total que es `null` es uno que ningún documento aportó: no aparece en el XML.

private newGroup() : array{documents: int, annulled: int|null, exempt: int, net: int, vat: int, total: int, fixedAsset: int|null, fixedAssetVat: int|null, notRecoverable: array, commonVat: int|null, proportion: int|float|null, commonCredit: int|null, latePayment: int|null, otherTaxes: array, withoutCredit: int|null, withheldTotal: int|null, withheldPartial: int|null, notWithheld: int|null, vehicle: int|null}
Return values
array{documents: int, annulled: int|null, exempt: int, net: int, vat: int, total: int, fixedAsset: int|null, fixedAssetVat: int|null, notRecoverable: array, commonVat: int|null, proportion: int|float|null, commonCredit: int|null, latePayment: int|null, otherTaxes: array, withoutCredit: int|null, withheldTotal: int|null, withheldPartial: int|null, notWithheld: int|null, vehicle: int|null}
On this page

Search results