Skip to content

Instantly share code, notes, and snippets.

@cesjam7
Created September 30, 2020 23:09
Show Gist options
  • Save cesjam7/d9c76249477de2fe96688df37904f80e to your computer and use it in GitHub Desktop.
Save cesjam7/d9c76249477de2fe96688df37904f80e to your computer and use it in GitHub Desktop.
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
<DespatchAdvice xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" xmlns:ccts="urn:un:unece:uncefact:documentation:2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:sac="urn:sunat:names:specification:ubl:peru:schema:xsd:SunatAggregateComponents-1" xmlns="urn:oasis:names:specification:ubl:schema:xsd:DespatchAdvice-2">
<ext:UBLExtensions>
<ext:UBLExtension>
<ext:ExtensionContent></ext:ExtensionContent>
</ext:UBLExtension>
</ext:UBLExtensions>
<cbc:UBLVersionID>2.1</cbc:UBLVersionID>
<cbc:CustomizationID schemeAgencyName="PE:SUNAT">1.0</cbc:CustomizationID>
<cbc:ID>{{ $serie.'-'.$numero }}</cbc:ID>
<cbc:IssueDate>{{ date('Y-m-d', strtotime($documento->fecha_registro)) }}</cbc:IssueDate>
<cbc:DespatchAdviceTypeCode>{{ $documento->id_tipodoc_electronico }}</cbc:DespatchAdviceTypeCode>
<cac:Signature>
<cbc:ID>{{ $remitente['num_doc'] }}</cbc:ID>
<cac:SignatoryParty>
<cac:PartyIdentification>
<cbc:ID>{{ $remitente['num_doc'] }}</cbc:ID>
</cac:PartyIdentification>
<cac:PartyName>
<cbc:Name>{{ $remitente['nombre'] }}</cbc:Name>
</cac:PartyName>
</cac:SignatoryParty>
<cac:DigitalSignatureAttachment>
<cac:ExternalReference>
<cbc:URI>{{ $remitente['num_doc'] }}</cbc:URI>
</cac:ExternalReference>
</cac:DigitalSignatureAttachment>
</cac:Signature>
<cac:DespatchSupplierParty>
@php
$name = explode('-', $documento->name_xml);
@endphp
<cbc:CustomerAssignedAccountID schemeID="{{ $remitente['tipo_doc'] }}">{{ $remitente['num_doc'] }}</cbc:CustomerAssignedAccountID>
<cac:Party>
<cac:PartyLegalEntity>
<cbc:RegistrationName>{{ $remitente['nombre'] }}</cbc:RegistrationName>
</cac:PartyLegalEntity>
</cac:Party>
</cac:DespatchSupplierParty>
<cac:DeliveryCustomerParty>
<cbc:CustomerAssignedAccountID schemeID="{{ $cliente->id_tipodocidentidad }}">{{ $cliente->num_doc }}</cbc:CustomerAssignedAccountID>
<cac:Party>
<cac:PartyLegalEntity>
<cbc:RegistrationName>{{ $cliente->razon_social }}</cbc:RegistrationName>
</cac:PartyLegalEntity>
</cac:Party>
</cac:DeliveryCustomerParty>
<cac:Shipment>
<cbc:ID>1</cbc:ID>
<cbc:HandlingCode>{{ $documento->id_motivotraslado }}</cbc:HandlingCode>
<cbc:Information>{{ strtoupper($documento->motivo_traslado) }}</cbc:Information>
<cbc:GrossWeightMeasure unitCode="KGM">{{ number_format($documento->peso, 3, '.', ' ') }}</cbc:GrossWeightMeasure>
<cbc:TotalTransportHandlingUnitQuantity>{{ $documento->numero_paquetes }}</cbc:TotalTransportHandlingUnitQuantity>
<cac:ShipmentStage>
<cbc:TransportModeCode>{{ $documento->id_modalidadtraslado }}</cbc:TransportModeCode>
<cac:TransitPeriod>
<cbc:StartDate>{{ $documento->fecha_comprobante }}</cbc:StartDate>
</cac:TransitPeriod>
<cac:TransportMeans>
<cac:RoadTransport>
<cbc:LicensePlateID>{{ $documento->transporte_nro_placa }}</cbc:LicensePlateID>
</cac:RoadTransport>
</cac:TransportMeans>
<cac:DriverPerson>
<cbc:ID schemeID="{{ $documento->id_tipo_documento_transporte }}">{{ $documento->nro_documento_transporte }}</cbc:ID>
<cbc:FirstName>{{ $documento->razon_social_transporte }}</cbc:FirstName>
</cac:DriverPerson>
</cac:ShipmentStage>
<cac:Delivery>
<cac:DeliveryAddress>
<cbc:ID>{{ $documento->id_ubigeo_destino }}</cbc:ID>
<cbc:StreetName>{{ $documento->dir_destino }}</cbc:StreetName>
</cac:DeliveryAddress>
</cac:Delivery>
<cac:TransportHandlingUnit>
<cbc:ID>{{ $documento->transporte_nro_placa }}</cbc:ID>
<cac:TransportEquipment>
<cbc:ID> A7A-873 </cbc:ID>
</cac:TransportEquipment>
<cac:TransportEquipment>
<cbc:ID> F6C-866</cbc:ID>
</cac:TransportEquipment>
</cac:TransportHandlingUnit>
<cac:OriginAddress>
<cbc:ID>{{ $documento->id_ubigeo_partida }}</cbc:ID>
<cbc:StreetName>{{ $documento->dir_partida }}</cbc:StreetName>
</cac:OriginAddress>
</cac:Shipment>
@if ($items)
@foreach ($items as $key => $item)
<cac:DespatchLine>
<cbc:ID>{{ $key + 1 }}</cbc:ID>
<cbc:DeliveredQuantity unitCode="{{ $item['unidad_medida'] }}">{{ $item['cantidad'] }}</cbc:DeliveredQuantity>
<cac:OrderLineReference>
<cbc:LineID>{{ $key + 1 }}</cbc:LineID>
</cac:OrderLineReference>
<cac:Item>
<cbc:Name>{{ $item['nombre'] }} </cbc:Name>
<cac:SellersItemIdentification>
<cbc:ID>1028</cbc:ID>
</cac:SellersItemIdentification>
</cac:Item>
</cac:DespatchLine>
@endforeach
@endif
</DespatchAdvice>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment