Commit bac93f028f3fe9ad535d88cc3a7df310ad072a4f
1 parent
81f17d1b0c
Exists in
master
fix item
Showing
2 changed files
with
5 additions
and
5 deletions
Show diff stats
src/js/controllerDetalles.js
1 | angular.module('focaCrearHojaRuta') | 1 | angular.module('focaCrearHojaRuta') |
2 | .controller('focaModalDetalleController', [ | 2 | .controller('focaModalDetalleController', [ |
3 | '$scope', '$timeout', '$uibModalInstance', 'focaModalService', | 3 | '$scope', '$timeout', '$uibModalInstance', 'focaModalService', |
4 | 'focaCrearHojaRutaService', 'hojasRutas', '$uibModal', '$filter', | 4 | 'focaCrearHojaRutaService', 'hojasRutas', '$uibModal', '$filter', |
5 | function ($scope, $timeout, $uibModalInstance, focaModalService, | 5 | function ($scope, $timeout, $uibModalInstance, focaModalService, |
6 | focaCrearHojaRutaService, hojasRutas, $uibModal, $filter) { | 6 | focaCrearHojaRutaService, hojasRutas, $uibModal, $filter) { |
7 | 7 | ||
8 | $scope.mostrar = false; | 8 | $scope.mostrar = false; |
9 | $scope.articulos = []; | 9 | $scope.articulos = []; |
10 | $scope.cisternaMovimientos = []; | 10 | $scope.cisternaMovimientos = []; |
11 | 11 | ||
12 | init(); | 12 | init(); |
13 | function init() { | 13 | function init() { |
14 | $scope.hojasRutas = hojasRutas; | 14 | $scope.hojasRutas = hojasRutas; |
15 | 15 | ||
16 | $scope.hojasRutas.vehiculo.cisternas = $scope.hojasRutas.vehiculo.cisternas.filter( | 16 | $scope.hojasRutas.vehiculo.cisternas = $scope.hojasRutas.vehiculo.cisternas.filter( |
17 | function (cisterna) { | 17 | function (cisterna) { |
18 | return !cisterna.desactivado; | 18 | return !cisterna.desactivado; |
19 | } | 19 | } |
20 | ); | 20 | ); |
21 | focaCrearHojaRutaService.getArticulos() | 21 | focaCrearHojaRutaService.getArticulos() |
22 | .then(function (articulos) { | 22 | .then(function (articulos) { |
23 | $scope.articulos = articulos.data; | 23 | $scope.articulos = articulos.data; |
24 | }); | 24 | }); |
25 | } | 25 | } |
26 | 26 | ||
27 | $scope.validarCisternaDisponible = function (cisterna) { | 27 | $scope.validarCisternaDisponible = function (cisterna) { |
28 | if (parseInt(cisterna.disponible) > cisterna.capacidad) { | 28 | if (parseInt(cisterna.disponible) > cisterna.capacidad) { |
29 | focaModalService.alert('No se puede ingresar una capacidad disponible ' + | 29 | focaModalService.alert('No se puede ingresar una capacidad disponible ' + |
30 | 'superior a la ' + 'capacidad del vehiculo '); | 30 | 'superior a la ' + 'capacidad del vehiculo '); |
31 | cisterna.disponible = cisterna.capacidad; | 31 | cisterna.disponible = cisterna.capacidad; |
32 | return; | 32 | return; |
33 | } | 33 | } |
34 | }; | 34 | }; |
35 | 35 | ||
36 | $scope.seleccionarProductos = function (cisterna) { | 36 | $scope.seleccionarProductos = function (key, cisterna) { |
37 | focaModalService.modal({ | 37 | focaModalService.modal({ |
38 | titulo: 'Productos', | 38 | titulo: 'Productos', |
39 | data: $scope.articulos, | 39 | data: $scope.articulos, |
40 | size: 'md', | 40 | size: 'md', |
41 | columnas: [ | 41 | columnas: [ |
42 | { | 42 | { |
43 | propiedad: 'CodRub', | 43 | propiedad: 'CodRub', |
44 | nombre: 'Codigo' | 44 | nombre: 'Codigo' |
45 | }, | 45 | }, |
46 | { | 46 | { |
47 | propiedad: 'descripcion', | 47 | propiedad: 'descripcion', |
48 | nombre: 'Nombre' | 48 | nombre: 'Nombre' |
49 | }, | 49 | }, |
50 | ], | 50 | ], |
51 | }).then(function (res) { | 51 | }).then(function (res) { |
52 | cisterna.disponible = cisterna.capacidad; | 52 | cisterna.disponible = cisterna.capacidad; |
53 | var newArt = | 53 | var newArt = |
54 | { | 54 | { |
55 | id: 0, | 55 | id: 0, |
56 | idRemito: 0, | 56 | idRemito: 0, |
57 | codigo: res.codigo, | 57 | codigo: res.codigo, |
58 | sector: res.sector, | 58 | sector: res.sector, |
59 | sectorCodigo: res.sector + '-' + res.codigo, | 59 | sectorCodigo: res.sector + '-' + res.codigo, |
60 | descripcion: res.descripcion, | 60 | descripcion: res.descripcion, |
61 | item: 1, | 61 | item: key + 1, |
62 | nombre: res.descripcion, | 62 | nombre: res.descripcion, |
63 | precio: parseFloat(res.precio).toFixed(4), | 63 | precio: parseFloat(res.precio).toFixed(4), |
64 | costoUnitario: res.costo, | 64 | costoUnitario: res.costo, |
65 | editCantidad: false, | 65 | editCantidad: false, |
66 | editPrecio: false, | 66 | editPrecio: false, |
67 | rubro: res.CodRub, | 67 | rubro: res.CodRub, |
68 | ivaUnitario: res.IMPIVA, | 68 | ivaUnitario: res.IMPIVA, |
69 | impuestoInternoUnitario: res.ImpInt, | 69 | impuestoInternoUnitario: res.ImpInt, |
70 | impuestoInterno1Unitario: res.ImpInt2, | 70 | impuestoInterno1Unitario: res.ImpInt2, |
71 | impuestoInterno2Unitario: res.ImpInt3, | 71 | impuestoInterno2Unitario: res.ImpInt3, |
72 | precioLista: res.precio, | 72 | precioLista: res.precio, |
73 | combustible: 1, | 73 | combustible: 1, |
74 | facturado: 0, | 74 | facturado: 0, |
75 | idArticulo: res.id, | 75 | idArticulo: res.id, |
76 | tasaIva: res.tasaIVA | 76 | tasaIva: res.tasaIVA |
77 | }; | 77 | }; |
78 | 78 | ||
79 | newArt.exentoUnitario = newArt.ivaUnitario ? 0 : res.neto; | 79 | newArt.exentoUnitario = newArt.ivaUnitario ? 0 : res.neto; |
80 | newArt.netoUnitario = newArt.ivaUnitario ? res.neto : 0; | 80 | newArt.netoUnitario = newArt.ivaUnitario ? res.neto : 0; |
81 | 81 | ||
82 | cisterna.articuloSeleccionado = newArt; | 82 | cisterna.articuloSeleccionado = newArt; |
83 | cisterna.nombreArticulo = res.descripcion; | 83 | cisterna.nombreArticulo = res.descripcion; |
84 | }).catch(function (e) { | 84 | }).catch(function (e) { |
85 | console.log(e); | 85 | console.log(e); |
86 | }); | 86 | }); |
87 | }; | 87 | }; |
88 | 88 | ||
89 | $scope.guardar = function () { | 89 | $scope.guardar = function () { |
90 | 90 | ||
91 | var cisternasFilter = validarArticulos(); | 91 | var cisternasFilter = validarArticulos(); |
92 | 92 | ||
93 | var articulos = []; | 93 | var articulos = []; |
94 | if (cisternasFilter === undefined) { | 94 | if (cisternasFilter === undefined) { |
95 | return; | 95 | return; |
96 | } | 96 | } |
97 | cisternasFilter.forEach(function (cisterna) { | 97 | cisternasFilter.forEach(function (cisterna) { |
98 | 98 | ||
99 | var fechaReparto = $scope.hojasRutas.fechaReparto; | 99 | var fechaReparto = $scope.hojasRutas.fechaReparto; |
100 | 100 | ||
101 | var filtroCisternaCarga = cisterna.cisternasCarga.filter(function(carga) { | 101 | var filtroCisternaCarga = cisterna.cisternasCarga.filter(function(carga) { |
102 | return carga.fechaReparto === fechaReparto; | 102 | return carga.fechaReparto === fechaReparto; |
103 | }); | 103 | }); |
104 | 104 | ||
105 | if (filtroCisternaCarga.length) { | 105 | if (filtroCisternaCarga.length) { |
106 | cisterna.cisternaCarga = filtroCisternaCarga[0]; | 106 | cisterna.cisternaCarga = filtroCisternaCarga[0]; |
107 | } else { | 107 | } else { |
108 | cisterna.cisternaCarga = { | 108 | cisterna.cisternaCarga = { |
109 | confirmado: null, | 109 | confirmado: null, |
110 | fechaReparto: fechaReparto, | 110 | fechaReparto: fechaReparto, |
111 | idCisterna: cisterna.id, | 111 | idCisterna: cisterna.id, |
112 | }; | 112 | }; |
113 | } | 113 | } |
114 | 114 | ||
115 | //cargar | 115 | //cargar |
116 | if (cisterna.cisternaCarga.cantidad) { | 116 | if (cisterna.cisternaCarga.cantidad) { |
117 | cisterna.cisternaCarga.cantidad += cisterna.disponible; | 117 | cisterna.cisternaCarga.cantidad += cisterna.disponible; |
118 | } else { | 118 | } else { |
119 | cisterna.cisternaCarga.cantidad = cisterna.disponible; | 119 | cisterna.cisternaCarga.cantidad = cisterna.disponible; |
120 | cisterna.cisternaCarga.idProducto = | 120 | cisterna.cisternaCarga.idProducto = |
121 | cisterna.articuloSeleccionado.idArticulo; | 121 | cisterna.articuloSeleccionado.idArticulo; |
122 | } | 122 | } |
123 | 123 | ||
124 | //Guardar | 124 | //Guardar |
125 | var now = new Date(); | 125 | var now = new Date(); |
126 | var cisternaMovimiento = { | 126 | var cisternaMovimiento = { |
127 | fecha: now.toISOString().slice(0, 19).replace('T', ' '), | 127 | fecha: now.toISOString().slice(0, 19).replace('T', ' '), |
128 | cantidad: cisterna.disponible, | 128 | cantidad: cisterna.disponible, |
129 | metodo: 'carga', | 129 | metodo: 'carga', |
130 | idCisternaCarga: cisterna.cisternaCarga.id, | 130 | idCisternaCarga: cisterna.cisternaCarga.id, |
131 | }; | 131 | }; |
132 | 132 | ||
133 | cisterna.cisternaCarga.fechaReparto = fechaReparto; | 133 | cisterna.cisternaCarga.fechaReparto = fechaReparto; |
134 | cisterna.articuloSeleccionado.cantidad = cisterna.disponible; | 134 | cisterna.articuloSeleccionado.cantidad = cisterna.disponible; |
135 | articulos.push(cisterna.articuloSeleccionado); | 135 | articulos.push(cisterna.articuloSeleccionado); |
136 | $scope.cisternaMovimientos.push(cisternaMovimiento); | 136 | $scope.cisternaMovimientos.push(cisternaMovimiento); |
137 | }); | 137 | }); |
138 | 138 | ||
139 | $uibModalInstance.close({ | 139 | $uibModalInstance.close({ |
140 | cisternas: cisternasFilter, | 140 | cisternas: cisternasFilter, |
141 | movimientos: $scope.cisternaMovimientos, | 141 | movimientos: $scope.cisternaMovimientos, |
142 | articulos: articulos | 142 | articulos: articulos |
143 | }); | 143 | }); |
144 | }; | 144 | }; |
145 | 145 | ||
146 | $scope.cancel = function () { | 146 | $scope.cancel = function () { |
147 | var validarCisternas = validarArticulos(); | 147 | var validarCisternas = validarArticulos(); |
148 | if (validarCisternas !== undefined) { | 148 | if (validarCisternas !== undefined) { |
149 | $uibModalInstance.dismiss(null); | 149 | $uibModalInstance.dismiss(null); |
150 | } | 150 | } |
151 | }; | 151 | }; |
152 | 152 | ||
153 | function validarArticulos () { | 153 | function validarArticulos () { |
154 | var cisternasFilter = $scope.hojasRutas.vehiculo.cisternas.filter(function (cisterna) { | 154 | var cisternasFilter = $scope.hojasRutas.vehiculo.cisternas.filter(function (cisterna) { |
155 | return parseInt(cisterna.disponible) > 0 || cisterna.articuloSeleccionado; | 155 | return parseInt(cisterna.disponible) > 0 || cisterna.articuloSeleccionado; |
156 | }); | 156 | }); |
157 | 157 | ||
158 | var cisternasIncompletas = cisternasFilter.filter(function(cisterna) { | 158 | var cisternasIncompletas = cisternasFilter.filter(function(cisterna) { |
159 | return (cisterna.articuloSeleccionado && !cisterna.disponible) || | 159 | return (cisterna.articuloSeleccionado && !cisterna.disponible) || |
160 | (!cisterna.articuloSeleccionado && cisterna.disponible); | 160 | (!cisterna.articuloSeleccionado && cisterna.disponible); |
161 | }); | 161 | }); |
162 | 162 | ||
163 | if (cisternasIncompletas.length || !cisternasFilter.length) { | 163 | if (cisternasIncompletas.length || !cisternasFilter.length) { |
164 | focaModalService.alert('Ingrese todos los campos para completar el remito'); | 164 | focaModalService.alert('Ingrese todos los campos para completar el remito'); |
165 | cisternasFilter = undefined; | 165 | cisternasFilter = undefined; |
166 | } | 166 | } |
167 | return cisternasFilter; | 167 | return cisternasFilter; |
168 | } | 168 | } |
169 | } | 169 | } |
170 | ]); | 170 | ]); |
171 | 171 |
src/views/modal-detalle-carga.html
1 | <div class="modal-header py-1"> | 1 | <div class="modal-header py-1"> |
2 | <div class="row w-100"> | 2 | <div class="row w-100"> |
3 | <div class="col-lg-6"> | 3 | <div class="col-lg-6"> |
4 | <h5 class="modal-title my-1">Detalle de Carga</h5> | 4 | <h5 class="modal-title my-1">Detalle de Carga</h5> |
5 | </div> | 5 | </div> |
6 | </div> | 6 | </div> |
7 | </div> | 7 | </div> |
8 | <div class="row"> | 8 | <div class="row"> |
9 | <div class="col ml-3 mt-2"> | 9 | <div class="col ml-3 mt-2"> |
10 | <span class=" text-left"> | 10 | <span class=" text-left"> |
11 | Transportista <b>{{hojasRutas.idTransportista}} {{hojasRutas.transportista.NOM}}</b> | 11 | Transportista <b>{{hojasRutas.idTransportista}} {{hojasRutas.transportista.NOM}}</b> |
12 | Unidad <b>{{hojasRutas.vehiculo.codigo}}</b> Tractor <b>{{hojasRutas.vehiculo.tractor}}</b> | 12 | Unidad <b>{{hojasRutas.vehiculo.codigo}}</b> Tractor <b>{{hojasRutas.vehiculo.tractor}}</b> |
13 | </span> | 13 | </span> |
14 | 14 | ||
15 | </div> | 15 | </div> |
16 | </div> | 16 | </div> |
17 | <div class="row"> | 17 | <div class="row"> |
18 | <div class="col ml-3"> | 18 | <div class="col ml-3"> |
19 | <span class=" text-left">Fecha <b>{{hojasRutas.fecha | date:'yyyy-MM-dd':'-0300'}}</b></span> | 19 | <span class=" text-left">Fecha <b>{{hojasRutas.fecha | date:'yyyy-MM-dd':'-0300'}}</b></span> |
20 | </div> | 20 | </div> |
21 | </div> | 21 | </div> |
22 | <div class="modal-body" id="modal-body"> | 22 | <div class="modal-body" id="modal-body"> |
23 | <table class="table table-hover table-sm table-striped"> | 23 | <table class="table table-hover table-sm table-striped"> |
24 | <thead> | 24 | <thead> |
25 | <tr> | 25 | <tr> |
26 | <th>Cisterna</th> | 26 | <th>Cisterna</th> |
27 | <th>Capacidad</th> | 27 | <th>Capacidad</th> |
28 | <th>Disponibles</th> | 28 | <th>Disponibles</th> |
29 | <th>Articulo Cargado</th> | 29 | <th>Articulo Cargado</th> |
30 | </tr> | 30 | </tr> |
31 | </thead> | 31 | </thead> |
32 | <tbody> | 32 | <tbody> |
33 | <tr | 33 | <tr |
34 | ng-repeat="cisterna in hojasRutas.vehiculo.cisternas" | 34 | ng-repeat="(key, cisterna) in hojasRutas.vehiculo.cisternas" |
35 | > | 35 | > |
36 | <td ng-bind="cisterna.id"></td> | 36 | <td ng-bind="cisterna.id"></td> |
37 | <td ng-bind="cisterna.capacidad"></td> | 37 | <td ng-bind="cisterna.capacidad"></td> |
38 | <td class="w-50"> | 38 | <td class="w-50"> |
39 | <input | 39 | <input |
40 | ng-model="cisterna.disponible" | 40 | ng-model="cisterna.disponible" |
41 | ng-keyup="validarCisternaDisponible(cisterna)" | 41 | ng-keyup="validarCisternaDisponible(cisterna)" |
42 | class="form-control" | 42 | class="form-control" |
43 | solo-positivos | 43 | solo-positivos |
44 | foca-tipo-input | 44 | foca-tipo-input |
45 | /> | 45 | /> |
46 | </td> | 46 | </td> |
47 | <td class="w-25"> | 47 | <td class="w-25"> |
48 | <div class="input-group "> | 48 | <div class="input-group "> |
49 | <input | 49 | <input |
50 | ng-model="cisterna.nombreArticulo" | 50 | ng-model="cisterna.nombreArticulo" |
51 | class="form-control" | 51 | class="form-control" |
52 | ng-click="seleccionarProductos(cisterna)" | 52 | ng-click="seleccionarProductos(key, cisterna)" |
53 | readonly | 53 | readonly |
54 | /> | 54 | /> |
55 | <div class="input-group-append"> | 55 | <div class="input-group-append"> |
56 | <button | 56 | <button |
57 | ladda="searchLoading" | 57 | ladda="searchLoading" |
58 | class="btn btn-outline-secondary form-control" | 58 | class="btn btn-outline-secondary form-control" |
59 | type="button" | 59 | type="button" |
60 | ng-click="seleccionarProductos(cisterna)" | 60 | ng-click="seleccionarProductos(key, cisterna)" |
61 | > | 61 | > |
62 | <i class="fa fa-search" aria-hidden="true"></i> | 62 | <i class="fa fa-search" aria-hidden="true"></i> |
63 | </button> | 63 | </button> |
64 | </div> | 64 | </div> |
65 | </div> | 65 | </div> |
66 | </td> | 66 | </td> |
67 | </tr> | 67 | </tr> |
68 | </tbody> | 68 | </tbody> |
69 | </table> | 69 | </table> |
70 | </div> | 70 | </div> |
71 | <div class="modal-footer py-1"> | 71 | <div class="modal-footer py-1"> |
72 | <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | 72 | <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> |
73 | <button class="btn btn-sm btn-primary" type="button" ng-click="guardar()">Guardar</button> | 73 | <button class="btn btn-sm btn-primary" type="button" ng-click="guardar()">Guardar</button> |
74 | </div> | 74 | </div> |
75 | </div> | 75 | </div> |