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