-
Notifications
You must be signed in to change notification settings - Fork 8
/
boleta.php
81 lines (67 loc) · 1.95 KB
/
boleta.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
declare(strict_types=1);
use Greenter\Model\Client\Client;
use Greenter\Model\Company\Company;
use Greenter\Model\Company\Address;
use Greenter\Model\Sale\Invoice;
use Greenter\Model\Sale\SaleDetail;
use Greenter\Model\Sale\Legend;
require __DIR__.'/vendor/autoload.php';
$see = require __DIR__.'/config.php';
// Cliente
$client = new Client();
$client->setTipoDoc('1')
->setNumDoc('46712369')
->setRznSocial('MARIA RAMOS ARTEAGA');
// Emisor
$address = new Address();
$address->setUbigueo('150101')
->setDepartamento('LIMA')
->setProvincia('LIMA')
->setDistrito('LIMA')
->setUrbanizacion('-')
->setDireccion('AV LOS GERUNDIOS');
$company = new Company();
$company->setRuc('20000000001')
->setRazonSocial('EMPRESA SAC')
->setNombreComercial('EMPRESA')
->setAddress($address);
// Venta
$invoice = (new Invoice())
->setUblVersion('2.1')
->setTipoOperacion('0101') // Catalog. 51
->setTipoDoc('01')
->setSerie('B001')
->setCorrelativo('1')
->setFechaEmision(new DateTime())
->setTipoMoneda('PEN')
->setClient($client)
->setMtoOperGravadas(100.00)
->setMtoIGV(18.00)
->setTotalImpuestos(18.00)
->setValorVenta(100.00)
->setMtoImpVenta(118.00)
->setCompany($company);
$item = (new SaleDetail())
->setCodProducto('P001')
->setUnidad('NIU')
->setCantidad(2)
->setDescripcion('PRODUCTO 1')
->setMtoBaseIgv(100)
->setPorcentajeIgv(18.00) // 18%
->setIgv(18.00)
->setTipAfeIgv('10')
->setTotalImpuestos(18.00)
->setMtoValorVenta(100.00)
->setMtoValorUnitario(50.00)
->setMtoPrecioUnitario(59.00);
$legend = (new Legend())
->setCode('1000')
->setValue('SON DOSCIENTOS TREINTA Y SEIS CON 00/100 SOLES');
$invoice->setDetails([$item])
->setLegends([$legend]);
$xml = $see->getXmlSigned($invoice);
// Guardar XML
$filename = $invoice->getName().'.xml';
file_put_contents($filename, $xml);
echo 'File created: '.$filename.PHP_EOL;