-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from giansalex/feature/ubl-21
Validator for UBL 2.1
- Loading branch information
Showing
18 changed files
with
685 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Greenter\Validator\Loader\v21; | ||
|
||
use Greenter\Validator\Metadata\LoaderMetadataInterface; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
use Symfony\Component\Validator\Mapping\ClassMetadata; | ||
|
||
class ChargeLoader implements LoaderMetadataInterface | ||
{ | ||
public function load(ClassMetadata $metadata) | ||
{ | ||
$metadata->addPropertyConstraints('factor', [ | ||
new Assert\NotBlank(), | ||
new Assert\Type(['type' => 'numeric']), | ||
]); | ||
$metadata->addPropertyConstraints('monto', [ | ||
new Assert\NotBlank(), | ||
new Assert\Type(['type' => 'numeric']), | ||
]); | ||
$metadata->addPropertyConstraints('montoBase', [ | ||
new Assert\NotBlank(), | ||
new Assert\Type(['type' => 'numeric']), | ||
]); | ||
$metadata->addPropertyConstraint('codTipo', new Assert\NotBlank()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
|
||
namespace Greenter\Validator\Loader\v21; | ||
|
||
use Greenter\Validator\Metadata\LoaderMetadataInterface; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
use Symfony\Component\Validator\Mapping\ClassMetadata; | ||
|
||
class DetailAttributeLoader implements LoaderMetadataInterface | ||
{ | ||
public function load(ClassMetadata $metadata) | ||
{ | ||
$metadata->addPropertyConstraint('name', new Assert\NotBlank()); | ||
$metadata->addPropertyConstraint('code', new Assert\NotBlank()); | ||
$metadata->addPropertyConstraint('fecInicio', new Assert\DateTime()); | ||
$metadata->addPropertyConstraint('fecFin', new Assert\DateTime()); | ||
$metadata->addPropertyConstraint('duracion', new Assert\Type(['type' => 'int'])); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Greenter\Validator\Loader\v21; | ||
|
||
use Greenter\Validator\Metadata\LoaderMetadataInterface; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
use Symfony\Component\Validator\Mapping\ClassMetadata; | ||
|
||
class DetractionLoader implements LoaderMetadataInterface | ||
{ | ||
public function load(ClassMetadata $metadata) | ||
{ | ||
$metadata->addPropertyConstraints('percent', [ | ||
new Assert\NotBlank(), | ||
new Assert\Type(['type' => 'numeric']), | ||
]); | ||
$metadata->addPropertyConstraints('mount', [ | ||
new Assert\NotBlank(), | ||
new Assert\Type(['type' => 'numeric']), | ||
]); | ||
$metadata->addPropertyConstraint('codMedioPago', new Assert\NotBlank()); | ||
$metadata->addPropertyConstraint('ctaBanco', new Assert\NotBlank()); | ||
$metadata->addPropertyConstraint('codBienDetraccion', new Assert\NotBlank()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?php | ||
|
||
namespace Greenter\Validator\Loader\v21; | ||
|
||
use Greenter\Validator\Metadata\LoaderMetadataInterface; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
use Greenter\Validator\Constraint as MyAssert; | ||
use Symfony\Component\Validator\Mapping\ClassMetadata; | ||
|
||
class InvoiceLoader implements LoaderMetadataInterface | ||
{ | ||
public function load(ClassMetadata $metadata) | ||
{ | ||
$metadata->addPropertyConstraints('tipoOperacion', [ | ||
new Assert\NotBlank(), | ||
]); | ||
$metadata->addPropertyConstraints('tipoDoc', [ | ||
new Assert\NotBlank(), | ||
]); | ||
$metadata->addPropertyConstraints('serie', [ | ||
new Assert\NotBlank(), | ||
new Assert\Length(['max' => 4]), | ||
]); | ||
$metadata->addPropertyConstraints('correlativo', [ | ||
new Assert\NotBlank(), | ||
new Assert\Length(['max' => 8]), | ||
]); | ||
$metadata->addPropertyConstraints('fechaEmision', [ | ||
new Assert\NotBlank(), | ||
new Assert\DateTime(), | ||
]); | ||
$metadata->addPropertyConstraint('fecVencimiento', new Assert\DateTime()); | ||
$metadata->addPropertyConstraints('tipoMoneda', [ | ||
new Assert\NotBlank(), | ||
new MyAssert\Currency(), | ||
]); | ||
$metadata->addPropertyConstraints('mtoOperGravadas', [ | ||
new Assert\Type(['type' => 'numeric']), | ||
]); | ||
$metadata->addPropertyConstraints('mtoOperInafectas', [ | ||
new Assert\Type(['type' => 'numeric']), | ||
]); | ||
$metadata->addPropertyConstraints('mtoOperExoneradas', [ | ||
new Assert\Type(['type' => 'numeric']), | ||
]); | ||
$metadata->addPropertyConstraints('mtoOperGratuitas', [ | ||
new Assert\Type(['type' => 'numeric']), | ||
]); | ||
$metadata->addPropertyConstraints('mtoOperExportacion', [ | ||
new Assert\Type(['type' => 'numeric']), | ||
]); | ||
$metadata->addPropertyConstraint('mtoIGV', new Assert\Type(['type' => 'numeric'])); | ||
$metadata->addPropertyConstraint('mtoISC', new Assert\Type(['type' => 'numeric'])); | ||
$metadata->addPropertyConstraint('mtoBaseIsc', new Assert\Type(['type' => 'numeric'])); | ||
$metadata->addPropertyConstraint('mtoOtrosTributos', new Assert\Type(['type' => 'numeric'])); | ||
$metadata->addPropertyConstraint('mtoBaseOth', new Assert\Type(['type' => 'numeric'])); | ||
$metadata->addPropertyConstraint('mtoDescuentos', new Assert\Type(['type' => 'numeric'])); | ||
$metadata->addPropertyConstraint('sumOtrosCargos', new Assert\Type(['type' => 'numeric'])); | ||
$metadata->addPropertyConstraint('totalAnticipos', new Assert\Type(['type' => 'numeric'])); | ||
$metadata->addPropertyConstraints('totalImpuestos', [ | ||
new Assert\NotBlank(), | ||
new Assert\Type(['type' => 'numeric']), | ||
]); | ||
$metadata->addPropertyConstraints('valorVenta', [ | ||
new Assert\NotBlank(), | ||
new Assert\Type(['type' => 'numeric']), | ||
]); | ||
$metadata->addPropertyConstraints('mtoImpVenta', [ | ||
new Assert\NotBlank(), | ||
new Assert\Type(['type' => 'numeric']), | ||
]); | ||
$metadata->addPropertyConstraints('client', [ | ||
new Assert\NotBlank(), | ||
new Assert\Valid(), | ||
]); | ||
$metadata->addPropertyConstraints('company', [ | ||
new Assert\NotBlank(), | ||
new Assert\Valid(), | ||
]); | ||
$metadata->addPropertyConstraint('seller', new Assert\Valid()); | ||
$metadata->addPropertyConstraint('details', new Assert\Valid()); | ||
$metadata->addPropertyConstraint('legends', new Assert\Valid()); | ||
$metadata->addPropertyConstraint('guias', new Assert\Valid()); | ||
$metadata->addPropertyConstraint('anticipos', new Assert\Valid()); | ||
$metadata->addPropertyConstraint('detraccion', new Assert\Valid()); | ||
$metadata->addPropertyConstraint('relDocs', new Assert\Valid()); | ||
$metadata->addPropertyConstraint('perception', new Assert\Valid()); | ||
$metadata->addPropertyConstraint('cargos', new Assert\Valid()); | ||
$metadata->addPropertyConstraint('descuentos', new Assert\Valid()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: Giansalex | ||
* Date: 18/07/2017 | ||
* Time: 22:27. | ||
*/ | ||
|
||
namespace Greenter\Validator\Loader\v21; | ||
|
||
use Greenter\Validator\Metadata\LoaderMetadataInterface; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
use Greenter\Validator\Constraint as MyAssert; | ||
use Symfony\Component\Validator\Mapping\ClassMetadata; | ||
|
||
class NoteLoader implements LoaderMetadataInterface | ||
{ | ||
public function load(ClassMetadata $metadata) | ||
{ | ||
$metadata->addPropertyConstraints('tipoDoc', [ | ||
new Assert\NotBlank(), | ||
]); | ||
$metadata->addPropertyConstraints('serie', [ | ||
new Assert\NotBlank(), | ||
new Assert\Length(['max' => 4]), | ||
]); | ||
$metadata->addPropertyConstraints('correlativo', [ | ||
new Assert\NotBlank(), | ||
new Assert\Length(['max' => 8]), | ||
]); | ||
$metadata->addPropertyConstraints('fechaEmision', [ | ||
new Assert\NotBlank(), | ||
new Assert\DateTime(), | ||
]); | ||
$metadata->addPropertyConstraints('tipoMoneda', [ | ||
new Assert\NotBlank(), | ||
new MyAssert\Currency(), | ||
]); | ||
$metadata->addPropertyConstraint('codMotivo', new Assert\NotBlank()); | ||
$metadata->addPropertyConstraint('tipDocAfectado', new Assert\NotBlank()); | ||
$metadata->addPropertyConstraint('numDocfectado', new Assert\NotBlank()); | ||
$metadata->addPropertyConstraints('desMotivo', [ | ||
new Assert\NotBlank(), | ||
new Assert\Length(['max' => 500]), | ||
]); | ||
$metadata->addPropertyConstraints('mtoOperGravadas', [ | ||
new Assert\Type(['type' => 'numeric']), | ||
]); | ||
$metadata->addPropertyConstraints('mtoOperInafectas', [ | ||
new Assert\Type(['type' => 'numeric']), | ||
]); | ||
$metadata->addPropertyConstraints('mtoOperExoneradas', [ | ||
new Assert\Type(['type' => 'numeric']), | ||
]); | ||
$metadata->addPropertyConstraints('mtoOperGratuitas', [ | ||
new Assert\Type(['type' => 'numeric']), | ||
]); | ||
$metadata->addPropertyConstraints('mtoOperExportacion', [ | ||
new Assert\Type(['type' => 'numeric']), | ||
]); | ||
$metadata->addPropertyConstraints('totalImpuestos', [ | ||
new Assert\NotBlank(), | ||
new Assert\Type(['type' => 'numeric']), | ||
]); | ||
$metadata->addPropertyConstraints('mtoImpVenta', [ | ||
new Assert\NotBlank(), | ||
new Assert\Type(['type' => 'numeric']), | ||
]); | ||
$metadata->addPropertyConstraints('client', [ | ||
new Assert\NotBlank(), | ||
new Assert\Valid(), | ||
]); | ||
$metadata->addPropertyConstraints('company', [ | ||
new Assert\NotBlank(), | ||
new Assert\Valid(), | ||
]); | ||
$metadata->addPropertyConstraint('mtoIGV', new Assert\Type(['type' => 'numeric'])); | ||
$metadata->addPropertyConstraint('mtoISC', new Assert\Type(['type' => 'numeric'])); | ||
$metadata->addPropertyConstraint('mtoBaseIsc', new Assert\Type(['type' => 'numeric'])); | ||
$metadata->addPropertyConstraint('mtoOtrosTributos', new Assert\Type(['type' => 'numeric'])); | ||
$metadata->addPropertyConstraint('mtoBaseOth', new Assert\Type(['type' => 'numeric'])); | ||
$metadata->addPropertyConstraint('sumOtrosCargos', new Assert\Type(['type' => 'numeric'])); | ||
$metadata->addPropertyConstraint('details', new Assert\Valid()); | ||
$metadata->addPropertyConstraint('legends', new Assert\Valid()); | ||
$metadata->addPropertyConstraint('guias', new Assert\Valid()); | ||
$metadata->addPropertyConstraint('relDocs', new Assert\Valid()); | ||
$metadata->addPropertyConstraint('perception', new Assert\Valid()); | ||
} | ||
} |
Oops, something went wrong.