Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
onestartup-shop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Angel Martin
onestartup-shop
Commits
a61dbfed
Commit
a61dbfed
authored
Jul 03, 2018
by
Angel MAS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implementado facturacion
parent
2e37c729
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
145 additions
and
3 deletions
+145
-3
AdminProductController.php
src/controllers/AdminProductController.php
+96
-0
OrderDataTable.php
src/lib/OrderDataTable.php
+21
-1
routes.php
src/routes.php
+4
-0
orden.blade.php
src/views/clients/orden.blade.php
+24
-2
No files found.
src/controllers/AdminProductController.php
View file @
a61dbfed
...
...
@@ -458,4 +458,100 @@ class AdminProductController extends Controller
}
public
function
facturar
(
Request
$request
,
$sale_id
)
{
$sale
=
Sale
::
find
(
$sale_id
);
$billing
=
$sale
->
billing
;
$products
=
$sale
->
products
;
$conceptos
=
[];
//return $products;
$emisor
=
\FacturaDigital
::
emisor
()
->
setRegimenFiscal
(
'612'
)
->
getData
();
$receptor
=
\FacturaDigital
::
receptor
()
->
setRfc
(
$billing
->
rfc
)
->
setNombre
(
$billing
->
razon
)
->
setUsoCFDI
(
$billing
->
uso_cfdi
)
->
setCalle
(
$billing
->
calle
)
->
setNoExt
(
$billing
->
numero
)
->
setColonia
(
$billing
->
colonia
)
->
setMunicipio
(
$billing
->
ciudad
)
->
setEstado
(
$billing
->
estado
)
->
setPais
(
'Mexico'
)
->
setCodigoPostal
(
$billing
->
cp
)
->
getData
();
foreach
(
$products
as
$product
)
{
$concepto
=
\FacturaDigital
::
concepto
()
->
setClaveProdServ
(
$product
->
categoria_sat
->
clave_producto
)
->
setNoIdentificacion
(
$product
->
id
)
->
setCantidad
(
$product
->
pivot
->
quantity
)
->
setClaveUnidad
(
$product
->
categoria_sat
->
clave_unidad
)
->
setUnidad
(
$product
->
categoria_sat
->
unidad
)
->
setDescripcion
(
$product
->
name
)
->
setValorUnitario
(
$product
->
infoSale
->
sale_price
)
->
getData
();
array_push
(
$conceptos
,
$concepto
);
}
$lista
=
\FacturaDigital
::
listaConceptos
();
$lista
->
setConceptos
(
$conceptos
);
$totales
=
$lista
->
getTotalConceptos
();
$factura
=
\FacturaDigital
::
setSerie
(
'F'
)
->
setFolio
(
'71278'
)
->
setFecha
(
'AUTO'
)
->
setFormaPago
(
'01'
)
->
setCondicionesDePago
(
'Pago de contado'
)
->
setMoneda
(
'MXN'
)
->
setTipoCambio
(
'1'
)
->
setTipoDeComprobante
(
'I'
)
->
setMetodoPago
(
'PUE'
)
->
setLugarExpedicion
(
'67150'
)
//C.P.
->
setLeyendaFolio
(
'Factura'
)
->
setSubTotal
(
$totales
[
'totalConceptos'
])
//->setDescuento('30.00')
->
setTotal
(
$totales
[
'totalConceptos'
]
+
$totales
[
'totalImpuestos'
]
);
$impuesto
=
\FacturaDigital
::
impuesto
()
->
getData
(
$totales
[
'totalImpuestos'
]);
$factura
->
setEmisor
(
$emisor
);
$factura
->
setReceptor
(
$receptor
);
$factura
->
setConceptos
(
$lista
->
getData
());
$factura
->
setImpuestos
(
$impuesto
);
$factura_final
=
$factura
->
enviar
();
if
(
$factura_final
[
'codigo'
]
==
200
)
{
$billing
->
uuid
=
$factura_final
[
'cfdi'
][
'UUID'
];
$billing
->
pdf
=
$factura_final
[
'cfdi'
][
'PDF'
];
$billing
->
xml
=
$factura_final
[
'cfdi'
][
'XML'
];
$billing
->
status
=
1
;
$billing
->
save
();
$enviar
=
$factura
->
enviarCorreo
(
$factura_final
[
'cfdi'
][
'UUID'
],
$billing
->
correo
,
''
);
if
(
$enviar
)
{
return
redirect
()
->
back
()
->
with
(
'message_success'
,
"Factura enviada por correo"
);
}
else
{
return
redirect
()
->
back
()
->
with
(
'message_warning'
,
"No se pudo enviar la factura"
);
}
}
else
{
return
redirect
()
->
back
()
->
with
(
'message_danger'
,
$factura_final
[
'mensaje'
]);
}
}
}
src/lib/OrderDataTable.php
View file @
a61dbfed
...
...
@@ -24,6 +24,8 @@ class OrderDataTable extends DataTable
->
addColumn
(
'orden'
,
function
(
Sale
$sale
)
{
$estado
=
""
;
$html
=
""
;
$facturacion
=
$sale
->
facturacion
!=
null
?
$sale
->
facturacion
:
'N/A'
;
$enviar_factura
=
"<br><b><span class='label warning'>Datos no proporcionados aún</span></b>"
;
if
(
$sale
->
status
==
0
)
{
$estado
=
"<span class='label danger'>Cancelado</span>"
;
}
...
...
@@ -47,6 +49,24 @@ class OrderDataTable extends DataTable
}
else
{
$html
=
"Estado: <b>
$estado
</b><br>Tipo: <b>
$sale->payment_type
</b> <br>Transaccion:<br><b>
$sale->transaction_id
</b><br>Envio: <b>Recojer en la tienda</b>"
;
}
$html
=
$html
.
"<br>Requiere factura: <b><span class='label info'>"
.
$facturacion
.
"</span></b>"
;
if
(
$facturacion
==
"Si"
)
{
if
(
$sale
->
billing
()
->
count
()
>
0
)
{
$billing
=
$sale
->
billing
;
$enviar_factura
=
"<br><b><span class='label warning'>Factura pendiente</span></b>"
;
if
(
$billing
->
status
==
1
)
{
$enviar_factura
=
"<br><b><span class='label success'>Factura enviada</span></b>"
;
}
if
(
$billing
->
status
==
2
)
{
$enviar_factura
=
"<br><b><span class='label danger'>Factura cancelada</span></b>"
;
}
}
$html
=
$html
.
$enviar_factura
;
}
return
$html
;
})
...
...
@@ -65,7 +85,7 @@ class OrderDataTable extends DataTable
*/
public
function
query
(
Sale
$model
)
{
return
$model
->
select
([
'id'
,
'client_id'
,
'status'
,
'payment_type'
,
'transaction_id'
,
'total'
,
'created_at'
])
->
where
(
'status'
,
'!='
,
0
)
->
orderBy
(
'id'
,
'desc'
);
return
$model
->
select
([
'id'
,
'client_id'
,
'status'
,
'payment_type'
,
'transaction_id'
,
'total'
,
'
facturacion'
,
'
created_at'
])
->
where
(
'status'
,
'!='
,
0
)
->
orderBy
(
'id'
,
'desc'
);
}
/**
...
...
src/routes.php
View file @
a61dbfed
...
...
@@ -11,6 +11,10 @@ Route::group(['middleware' => ['web', 'auth', 'is_admin']], function(){
Route
::
resource
(
'admin/shop/shipping'
,
'Onestartup\Shop\Controller\ShippingPriceController'
,
[
'as'
=>
'admin.shop'
]);
Route
::
put
(
'admin/shop/facturar/{sale_id}'
,
'Onestartup\Shop\Controller\AdminProductController@facturar'
)
->
name
(
'admin.shop.facturar'
);
Route
::
delete
(
'admin-shop-category/delete/cover{id}'
,
'Onestartup\Shop\Controller\CategoryController@deleteCover'
)
->
name
(
'admin-shop-category.delete.cover'
);
...
...
src/views/clients/orden.blade.php
View file @
a61dbfed
...
...
@@ -237,12 +237,34 @@ setlocale(LC_MONETARY, 'en_US');
</div>
<div class="
col
-
md
-
6
">
<h4>Datos de facturación</h4>
<p>
¿Requiere factura? <b>
{
{$sale->facturacion}
}
</b>
</p>
@if(
$sale->billing
()->count() > 0)
<h4>Datos de facturación</h4>
Dirección: <br>
@if(
$sale->billing
->status == 0)
<b>Factura Pendiente</b><br>
{!! Form::model(
$sale
,['route'=> ['admin.shop.facturar',
$sale->id
],"
method
"=>"
PUT
"]) !!}
{!! Form::submit('Crear y enviar factura', ['class'=>'btn-xs primary']) !!}
{!! Form::close() !!}
<br>
@endif
@if(
$sale->billing
->status == 1)
<b>Factura Enviada</b><br>
<a href="
#" class="btn btn-xs primary">Reenviar factura por correo</a>
<
br
>
UUID
:
<
b
>
{{
$sale
->
billing
->
uuid
}}
</
b
><
br
>
PDF
:
<
a
href
=
"
{
{$sale->billing->pdf}
}
"
target
=
"blank"
>
{{
$sale
->
billing
->
pdf
}}
</
a
><
br
>
XML
:
<
a
href
=
"
{
{$sale->billing->xml}
}
"
target
=
"blank"
>
{{
$sale
->
billing
->
xml
}}
</
a
><
br
>
@
endif
@
if
(
$sale
->
billing
->
status
==
2
)
Factura
Cancelada
@
endif
<
br
>
Dirección
:
<
br
>
Calle
{{
$sale
->
billing
->
calle
}}
numero
{{
$sale
->
billing
->
numero
}},
Col
.
{{
$sale
->
billing
->
colonia
}}
<
br
>
{{
$sale
->
billing
->
ciudad
}},
{{
$sale
->
billing
->
estado
}}
.
C
.
P
.
{{
$sale
->
billing
->
cp
}}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment