Commit 977cd9c32a104c1ef543cb44863b17a2d4be25d8
Exists in
master
Merge branch 'develop' of http://git.focasoftware.com/npm/foca-crear-remito
Showing
3 changed files
Show diff stats
src/js/controller.js
| 1 | angular.module('focaCrearRemito').controller('remitoController', | 1 | angular.module('focaCrearRemito').controller('remitoController', |
| 2 | [ | 2 | [ |
| 3 | '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', '$timeout', | 3 | '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', '$timeout', |
| 4 | 'focaModalService', 'remitoBusinessService', '$rootScope', 'focaBotoneraLateralService', | 4 | 'focaModalService', 'remitoBusinessService', '$rootScope', 'focaBotoneraLateralService', |
| 5 | '$localStorage', | 5 | '$localStorage', |
| 6 | function ( | 6 | function ( |
| 7 | $scope, $uibModal, $location, $filter, crearRemitoService, $timeout, focaModalService, | 7 | $scope, $uibModal, $location, $filter, crearRemitoService, $timeout, focaModalService, |
| 8 | remitoBusinessService, $rootScope, focaBotoneraLateralService, $localStorage) { | 8 | remitoBusinessService, $rootScope, focaBotoneraLateralService, $localStorage) { |
| 9 | config(); | 9 | config(); |
| 10 | 10 | ||
| 11 | var cotizacionPArgentino = {}; | 11 | var cotizacionPArgentino = {}; |
| 12 | 12 | ||
| 13 | function config() { | 13 | function config() { |
| 14 | $scope.tmpCantidad = Number; | 14 | $scope.tmpCantidad = Number; |
| 15 | $scope.tmpPrecio = Number; | 15 | $scope.tmpPrecio = Number; |
| 16 | $scope.botonera = crearRemitoService.getBotonera(); | 16 | $scope.botonera = crearRemitoService.getBotonera(); |
| 17 | $scope.isNumber = angular.isNumber; | 17 | $scope.isNumber = angular.isNumber; |
| 18 | $scope.datepickerAbierto = false; | 18 | $scope.datepickerAbierto = false; |
| 19 | $scope.show = false; | 19 | $scope.show = false; |
| 20 | $scope.cargando = true; | 20 | $scope.cargando = true; |
| 21 | $scope.now = new Date(); | 21 | $scope.now = new Date(); |
| 22 | $scope.puntoVenta = rellenar(0, 4); | 22 | $scope.puntoVenta = rellenar(0, 4); |
| 23 | $scope.comprobante = rellenar(0, 8); | 23 | $scope.comprobante = rellenar(0, 8); |
| 24 | $scope.dateOptions = { | 24 | $scope.dateOptions = { |
| 25 | maxDate: new Date(), | 25 | maxDate: new Date(), |
| 26 | minDate: new Date(2010, 0, 1) | 26 | minDate: new Date(2010, 0, 1) |
| 27 | }; | 27 | }; |
| 28 | $scope.cabeceras = []; | 28 | $scope.cabeceras = []; |
| 29 | crearRemitoService.getParametros().then(function (res) { | 29 | crearRemitoService.getParametros().then(function (res) { |
| 30 | var parametros = JSON.parse(res.data[0].jsonText); | 30 | var parametros = JSON.parse(res.data[0].jsonText); |
| 31 | if ($localStorage.remito) { | 31 | if ($localStorage.remito) { |
| 32 | $timeout(function () { getLSRemito(); }); | 32 | $timeout(function () { getLSRemito(); }); |
| 33 | } else { | 33 | } else { |
| 34 | for (var property in parametros) { | 34 | for (var property in parametros) { |
| 35 | $scope.remito[property] = parametros[property]; | 35 | $scope.remito[property] = parametros[property]; |
| 36 | $scope.inicial[property] = parametros[property]; | 36 | $scope.inicial[property] = parametros[property]; |
| 37 | } | 37 | } |
| 38 | setearRemito($scope.remito); | 38 | setearRemito($scope.remito); |
| 39 | } | 39 | } |
| 40 | }); | 40 | }); |
| 41 | 41 | ||
| 42 | //SETEO BOTONERA LATERAL | 42 | //SETEO BOTONERA LATERAL |
| 43 | $timeout(function () { | 43 | $timeout(function () { |
| 44 | focaBotoneraLateralService.showSalir(false); | 44 | focaBotoneraLateralService.showSalir(false); |
| 45 | focaBotoneraLateralService.showPausar(true); | 45 | focaBotoneraLateralService.showPausar(true); |
| 46 | focaBotoneraLateralService.showGuardar(true, $scope.crearRemito); | 46 | focaBotoneraLateralService.showGuardar(true, $scope.crearRemito); |
| 47 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 47 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
| 48 | }); | 48 | }); |
| 49 | 49 | ||
| 50 | init(); | 50 | init(); |
| 51 | 51 | ||
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | function init() { | 54 | function init() { |
| 55 | $scope.$broadcast('cleanCabecera'); | 55 | $scope.$broadcast('cleanCabecera'); |
| 56 | $scope.remito = { | 56 | $scope.remito = { |
| 57 | id: 0, | 57 | id: 0, |
| 58 | estado: 0, | 58 | estado: 0, |
| 59 | vendedor: {}, | 59 | vendedor: {}, |
| 60 | cliente: {}, | 60 | cliente: {}, |
| 61 | proveedor: {}, | 61 | proveedor: {}, |
| 62 | domicilio: { dom: '' }, | 62 | domicilio: { dom: '' }, |
| 63 | moneda: {}, | 63 | moneda: {}, |
| 64 | cotizacion: $scope.cotizacionPorDefecto || {}, | 64 | cotizacion: $scope.cotizacionPorDefecto || {}, |
| 65 | articulosRemito: [], | 65 | articulosRemito: [], |
| 66 | remitoPuntoDescarga: [] | 66 | remitoPuntoDescarga: [] |
| 67 | }; | 67 | }; |
| 68 | $scope.notaPedido = { | 68 | $scope.notaPedido = { |
| 69 | id: 0 | 69 | id: 0 |
| 70 | }; | 70 | }; |
| 71 | 71 | ||
| 72 | $scope.remito.articulosRemito = []; | 72 | $scope.remito.articulosRemito = []; |
| 73 | $scope.idLista = undefined; | 73 | $scope.idLista = undefined; |
| 74 | 74 | ||
| 75 | crearRemitoService.getNumeroRemito().then( | 75 | crearRemitoService.getNumeroRemito().then( |
| 76 | function (res) { | 76 | function (res) { |
| 77 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 77 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
| 78 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); | 78 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); |
| 79 | }, | 79 | }, |
| 80 | function (err) { | 80 | function (err) { |
| 81 | focaModalService.alert('La terminal no esta configurada correctamente'); | 81 | focaModalService.alert('La terminal no esta configurada correctamente'); |
| 82 | console.info(err); | 82 | console.info(err); |
| 83 | } | 83 | } |
| 84 | ); | 84 | ); |
| 85 | 85 | ||
| 86 | $scope.inicial = angular.copy($scope.remito); | 86 | $scope.inicial = angular.copy($scope.remito); |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | $scope.$watch('remito', function (newValue) { | 89 | $scope.$watch('remito', function (newValue) { |
| 90 | focaBotoneraLateralService.setPausarData({ | 90 | focaBotoneraLateralService.setPausarData({ |
| 91 | label: 'remito', | 91 | label: 'remito', |
| 92 | val: newValue | 92 | val: newValue |
| 93 | }); | 93 | }); |
| 94 | }, true); | 94 | }, true); |
| 95 | 95 | ||
| 96 | $scope.seleccionarNotaPedido = function () { | 96 | $scope.seleccionarNotaPedido = function () { |
| 97 | if ($scope.remitoIsDirty) { | 97 | if ($scope.remitoIsDirty) { |
| 98 | focaModalService.confirm('¿Desea continuar? Se perderan los cambios') | 98 | focaModalService.confirm('¿Desea continuar? Se perderan los cambios') |
| 99 | .then(function () { | 99 | .then(function () { |
| 100 | $scope.getNotaPedidoModal(); | 100 | $scope.getNotaPedidoModal(); |
| 101 | }); | 101 | }); |
| 102 | } else { | 102 | } else { |
| 103 | $scope.getNotaPedidoModal(); | 103 | $scope.getNotaPedidoModal(); |
| 104 | } | 104 | } |
| 105 | }; | 105 | }; |
| 106 | 106 | ||
| 107 | $scope.getNotaPedidoModal = function () { | 107 | $scope.getNotaPedidoModal = function () { |
| 108 | if (!varlidarRemitoFacturado()) return; | 108 | if (!varlidarRemitoFacturado()) return; |
| 109 | if (!varlidarRemitoAbierto()) return; | 109 | if (!varlidarRemitoAbierto()) return; |
| 110 | var modalInstance = $uibModal.open( | 110 | var modalInstance = $uibModal.open( |
| 111 | { | 111 | { |
| 112 | ariaLabelledBy: 'Busqueda de Nota de Pedido', | 112 | ariaLabelledBy: 'Busqueda de Nota de Pedido', |
| 113 | templateUrl: 'foca-modal-nota-pedido.html', | 113 | templateUrl: 'foca-modal-nota-pedido.html', |
| 114 | controller: 'focaModalNotaPedidoController', | 114 | controller: 'focaModalNotaPedidoController', |
| 115 | size: 'lg', | 115 | size: 'lg', |
| 116 | resolve: { | 116 | resolve: { |
| 117 | usadoPor: function () { return 'remito'; }, | 117 | usadoPor: function () { return 'remito'; }, |
| 118 | idVendedor: function () { return null; } | 118 | idVendedor: function () { return null; } |
| 119 | } | 119 | } |
| 120 | } | 120 | } |
| 121 | ); | 121 | ); |
| 122 | modalInstance.result.then( | 122 | modalInstance.result.then( |
| 123 | function (notaPedido) { | 123 | function (notaPedido) { |
| 124 | //añado cabeceras | 124 | //añado cabeceras |
| 125 | $scope.remitoIsDirty = true; | 125 | $scope.remitoIsDirty = true; |
| 126 | $scope.notaPedido = notaPedido; | 126 | $scope.notaPedido = notaPedido; |
| 127 | $scope.remito.cliente = notaPedido.cliente; | 127 | $scope.remito.cliente = notaPedido.cliente; |
| 128 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 128 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
| 129 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 129 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
| 130 | var puntosDescarga = []; | 130 | var puntosDescarga = []; |
| 131 | notaPedido.notaPedidoPuntoDescarga.forEach(function (notaPedido) { | 131 | notaPedido.notaPedidoPuntoDescarga.forEach(function (notaPedido) { |
| 132 | puntosDescarga.push(notaPedido.puntoDescarga); | 132 | puntosDescarga.push(notaPedido.puntoDescarga); |
| 133 | }); | 133 | }); |
| 134 | $scope.cabeceras = [ | 134 | $scope.cabeceras = [ |
| 135 | { | 135 | { |
| 136 | label: 'Cliente:', | 136 | label: 'Cliente:', |
| 137 | valor: $filter('rellenarDigitos')(notaPedido.cliente.COD, 3) + | 137 | valor: $filter('rellenarDigitos')(notaPedido.cliente.COD, 3) + |
| 138 | ' - ' + notaPedido.cliente.NOM | 138 | ' - ' + notaPedido.cliente.NOM |
| 139 | }, | 139 | }, |
| 140 | { | 140 | { |
| 141 | label: 'Domicilio:', | 141 | label: 'Domicilio:', |
| 142 | valor: notaPedido.domicilioStamp | 142 | valor: notaPedido.domicilioStamp |
| 143 | }, | 143 | }, |
| 144 | { | 144 | { |
| 145 | label: 'Vendedor:', | 145 | label: 'Vendedor:', |
| 146 | valor: $filter('rellenarDigitos')( | 146 | valor: $filter('rellenarDigitos')( |
| 147 | notaPedido.vendedor.NUM, 3 | 147 | notaPedido.vendedor.NUM, 3 |
| 148 | ) + ' - ' + notaPedido.vendedor.NOM | 148 | ) + ' - ' + notaPedido.vendedor.NOM |
| 149 | }, | 149 | }, |
| 150 | 150 | ||
| 151 | { | 151 | { |
| 152 | label: 'Proveedor:', | 152 | label: 'Proveedor:', |
| 153 | valor: $filter('rellenarDigitos') | 153 | valor: $filter('rellenarDigitos') |
| 154 | (notaPedido.proveedor.COD, 5) + ' - ' + | 154 | (notaPedido.proveedor.COD, 5) + ' - ' + |
| 155 | notaPedido.proveedor.NOM | 155 | notaPedido.proveedor.NOM |
| 156 | }, | 156 | }, |
| 157 | 157 | ||
| 158 | { | 158 | { |
| 159 | label: 'Flete:', | 159 | label: 'Flete:', |
| 160 | valor: notaPedido.fob === 1 ? 'FOB' : ( | 160 | valor: notaPedido.fob === 1 ? 'FOB' : ( |
| 161 | notaPedido.flete === 1 ? 'Si' : 'No') | 161 | notaPedido.flete === 1 ? 'Si' : 'No') |
| 162 | }, | 162 | }, |
| 163 | { | 163 | { |
| 164 | label: 'Puntos de descarga: ', | 164 | label: 'Puntos de descarga: ', |
| 165 | valor: $filter('rellenarDigitos')( | 165 | valor: $filter('rellenarDigitos')( |
| 166 | getCabeceraPuntoDescarga(puntosDescarga)) | 166 | getCabeceraPuntoDescarga(puntosDescarga)) |
| 167 | } | 167 | } |
| 168 | ]; | 168 | ]; |
| 169 | actualizarCabeceraMoneda(notaPedido.cotizacion); | 169 | actualizarCabeceraMoneda(notaPedido.cotizacion); |
| 170 | valorPrecioCondicion(); | 170 | valorPrecioCondicion(); |
| 171 | // Seteo checked en cabeceras | 171 | // Seteo checked en cabeceras |
| 172 | $filter('filter')($scope.botonera, | 172 | $filter('filter')($scope.botonera, |
| 173 | { label: 'Cliente' })[0].checked = true; | 173 | { label: 'Cliente' })[0].checked = true; |
| 174 | $filter('filter')($scope.botonera, | 174 | $filter('filter')($scope.botonera, |
| 175 | { label: 'Proveedor' })[0].checked = true; | 175 | { label: 'Proveedor' })[0].checked = true; |
| 176 | $filter('filter')($scope.botonera, | 176 | $filter('filter')($scope.botonera, |
| 177 | { label: 'Moneda' })[0].checked = true; | 177 | { label: 'Moneda' })[0].checked = true; |
| 178 | $filter('filter')($scope.botonera, | 178 | $filter('filter')($scope.botonera, |
| 179 | { label: 'Nota pedido' })[0].checked = true; | 179 | { label: 'Nota pedido' })[0].checked = true; |
| 180 | $filter('filter')($scope.botonera, | 180 | $filter('filter')($scope.botonera, |
| 181 | { label: 'Precios y condiciones' })[0].checked = true; | 181 | { label: 'Precios y condiciones' })[0].checked = true; |
| 182 | $filter('filter')($scope.botonera, | 182 | $filter('filter')($scope.botonera, |
| 183 | { label: 'Domicilio de Entrega' })[0].checked = true; | 183 | { label: 'Domicilio de Entrega' })[0].checked = true; |
| 184 | 184 | ||
| 185 | if (notaPedido.observaciones) { | 185 | if (notaPedido.observaciones) { |
| 186 | $filter('filter')($scope.botonera, | 186 | $filter('filter')($scope.botonera, |
| 187 | { label: 'Observaciones' })[0].checked = true; | 187 | { label: 'Observaciones' })[0].checked = true; |
| 188 | } | 188 | } |
| 189 | 189 | ||
| 190 | function valorPrecioCondicion() { | 190 | function valorPrecioCondicion() { |
| 191 | if (parseInt(notaPedido.idListaPrecio) > 0) { | 191 | if (parseInt(notaPedido.idListaPrecio) > 0) { |
| 192 | crearRemitoService | 192 | crearRemitoService |
| 193 | .getListaPrecioById(parseInt(notaPedido.idListaPrecio)) | 193 | .getListaPrecioById(parseInt(notaPedido.idListaPrecio)) |
| 194 | .then(function (res) { | 194 | .then(function (res) { |
| 195 | $scope.cabeceras.push({ | 195 | $scope.cabeceras.push({ |
| 196 | label: 'Precios y Condiciones:', | 196 | label: 'Precios y Condiciones:', |
| 197 | valor: | 197 | valor: |
| 198 | parseInt(res.data[0].ID) + ' - ' + | 198 | parseInt(res.data[0].ID) + ' - ' + |
| 199 | res.data[0].DES + ' ' + | 199 | res.data[0].DES + ' ' + |
| 200 | remitoBusinessService | 200 | remitoBusinessService |
| 201 | .plazoToString(notaPedido.notaPedidoPlazo) | 201 | .plazoToString(notaPedido.notaPedidoPlazo) |
| 202 | }); | 202 | }); |
| 203 | addArrayCabecera($scope.cabeceras); | 203 | addArrayCabecera($scope.cabeceras); |
| 204 | }); | 204 | }); |
| 205 | } | 205 | } |
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | if (notaPedido.flete === 1) { | 208 | if (notaPedido.flete === 1) { |
| 209 | var cabeceraBomba = { | 209 | var cabeceraBomba = { |
| 210 | label: 'Bomba:', | 210 | label: 'Bomba:', |
| 211 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' | 211 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' |
| 212 | }; | 212 | }; |
| 213 | if (notaPedido.kilometros) { | 213 | if (notaPedido.kilometros) { |
| 214 | var cabeceraKilometros = { | 214 | var cabeceraKilometros = { |
| 215 | label: 'Kilometros:', | 215 | label: 'Kilometros:', |
| 216 | valor: notaPedido.kilometros | 216 | valor: notaPedido.kilometros |
| 217 | }; | 217 | }; |
| 218 | $scope.cabeceras.push(cabeceraKilometros); | 218 | $scope.cabeceras.push(cabeceraKilometros); |
| 219 | } | 219 | } |
| 220 | $scope.cabeceras.push(cabeceraBomba); | 220 | $scope.cabeceras.push(cabeceraBomba); |
| 221 | } | 221 | } |
| 222 | 222 | ||
| 223 | $scope.remito = angular.copy(notaPedido); | 223 | $scope.remito = angular.copy(notaPedido); |
| 224 | $scope.remito.id = 0; | 224 | $scope.remito.id = 0; |
| 225 | $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo; | 225 | $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo; |
| 226 | $scope.remito.remitoPuntoDescarga = notaPedido.notaPedidoPuntoDescarga; | 226 | $scope.remito.remitoPuntoDescarga = notaPedido.notaPedidoPuntoDescarga; |
| 227 | 227 | ||
| 228 | notaPedido.articulosNotaPedido.forEach(function (articulo) { | 228 | notaPedido.articulosNotaPedido.forEach(function (articulo) { |
| 229 | articulo.id = 0; | 229 | articulo.id = 0; |
| 230 | articulo.idRemito = 0; | 230 | articulo.idRemito = 0; |
| 231 | articulo.precio = | 231 | articulo.precio = |
| 232 | (articulo.precio / notaPedido.cotizacion.VENDEDOR).toFixed(4); | 232 | (articulo.precio / notaPedido.cotizacion.VENDEDOR).toFixed(4); |
| 233 | }); | 233 | }); |
| 234 | 234 | ||
| 235 | $scope.remito.articulosRemito = notaPedido.articulosNotaPedido; | 235 | $scope.remito.articulosRemito = notaPedido.articulosNotaPedido; |
| 236 | 236 | ||
| 237 | if (notaPedido.idPrecioCondicion > 0) { | 237 | if (notaPedido.idPrecioCondicion > 0) { |
| 238 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; | 238 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; |
| 239 | } else { | 239 | } else { |
| 240 | $scope.idLista = -1; | 240 | $scope.idLista = -1; |
| 241 | } | 241 | } |
| 242 | 242 | ||
| 243 | enableObservaciones(notaPedido.observaciones ? true : false); | 243 | enableObservaciones(notaPedido.observaciones ? true : false); |
| 244 | addArrayCabecera($scope.cabeceras); | 244 | addArrayCabecera($scope.cabeceras); |
| 245 | 245 | ||
| 246 | }, function () { | 246 | }, function () { |
| 247 | // funcion ejecutada cuando se cancela el modal | 247 | // funcion ejecutada cuando se cancela el modal |
| 248 | } | 248 | } |
| 249 | ); | 249 | ); |
| 250 | }; | 250 | }; |
| 251 | 251 | ||
| 252 | $scope.seleccionarRemito = function () { | 252 | $scope.seleccionarRemito = function () { |
| 253 | if ($scope.remitoIsDirty) { | 253 | if ($scope.remitoIsDirty) { |
| 254 | focaModalService.confirm('¿Desea continuar? Se perderan los cambios') | 254 | focaModalService.confirm('¿Desea continuar? Se perderan los cambios') |
| 255 | .then(function () { | 255 | .then(function () { |
| 256 | $scope.getRemitoModal(); | 256 | $scope.getRemitoModal(); |
| 257 | }); | 257 | }); |
| 258 | } else { | 258 | } else { |
| 259 | $scope.getRemitoModal(); | 259 | $scope.getRemitoModal(); |
| 260 | } | 260 | } |
| 261 | }; | 261 | }; |
| 262 | $scope.getRemitoModal = function () { | 262 | $scope.getRemitoModal = function () { |
| 263 | var modalInstance = $uibModal.open( | 263 | var modalInstance = $uibModal.open( |
| 264 | { | 264 | { |
| 265 | ariaLabelledBy: 'Busqueda de Remito', | 265 | ariaLabelledBy: 'Busqueda de Remito', |
| 266 | templateUrl: 'foca-modal-remito.html', | 266 | templateUrl: 'foca-modal-remito.html', |
| 267 | controller: 'focaModalRemitoController', | 267 | controller: 'focaModalRemitoController', |
| 268 | size: 'lg', | 268 | size: 'lg', |
| 269 | resolve: { usadoPor: function () { return 'remito'; } } | 269 | resolve: { usadoPor: function () { return 'remito'; } } |
| 270 | } | 270 | } |
| 271 | ); | 271 | ); |
| 272 | modalInstance.result.then(function (remito) { | 272 | modalInstance.result.then(function (remito) { |
| 273 | 273 | ||
| 274 | remito.articulosRemito.forEach(function (articulo) { | 274 | remito.articulosRemito.forEach(function (articulo) { |
| 275 | articulo.precio = | 275 | articulo.precio = |
| 276 | (articulo.precio / remito.cotizacion.VENDEDOR).toFixed(4); | 276 | (articulo.precio / remito.cotizacion.VENDEDOR).toFixed(4); |
| 277 | }); | 277 | }); |
| 278 | 278 | ||
| 279 | setearRemito(remito); | 279 | setearRemito(remito); |
| 280 | 280 | ||
| 281 | }, function () { | 281 | }, function () { |
| 282 | // funcion ejecutada cuando se cancela el modal | 282 | // funcion ejecutada cuando se cancela el modal |
| 283 | } | 283 | } |
| 284 | ); | 284 | ); |
| 285 | }; | 285 | }; |
| 286 | //validacion por domicilio y por plazo pago | 286 | //validacion por domicilio y por plazo pago |
| 287 | $scope.crearRemito = function () { | 287 | $scope.crearRemito = function () { |
| 288 | if (!$scope.remito.vendedor.NUM) { | 288 | if (!$scope.remito.vendedor.NUM) { |
| 289 | focaModalService.alert('Ingrese Vendedor'); | 289 | focaModalService.alert('Ingrese Vendedor'); |
| 290 | return; | 290 | return; |
| 291 | } else if (!$scope.remito.cliente.COD) { | 291 | } else if (!$scope.remito.cliente.COD) { |
| 292 | focaModalService.alert('Ingrese Cliente'); | 292 | focaModalService.alert('Ingrese Cliente'); |
| 293 | return; | 293 | return; |
| 294 | } else if (!$scope.remito.proveedor.COD) { | 294 | } else if (!$scope.remito.proveedor.COD) { |
| 295 | focaModalService.alert('Ingrese Proveedor'); | 295 | focaModalService.alert('Ingrese Proveedor'); |
| 296 | return; | 296 | return; |
| 297 | } else if (!$scope.remito.cotizacion.moneda.id && | 297 | } else if (!$scope.remito.cotizacion.moneda.id && |
| 298 | !$scope.remito.cotizacion.moneda.ID) { | 298 | !$scope.remito.cotizacion.moneda.ID) { |
| 299 | focaModalService.alert('Ingrese Moneda'); | 299 | focaModalService.alert('Ingrese Moneda'); |
| 300 | return; | 300 | return; |
| 301 | } else if (!$scope.remito.cotizacion.ID) { | 301 | } else if (!$scope.remito.cotizacion.ID) { |
| 302 | focaModalService.alert('Ingrese Cotización'); | 302 | focaModalService.alert('Ingrese Cotización'); |
| 303 | return; | 303 | return; |
| 304 | } else if ($scope.remito.flete === undefined || $scope.remito.flete === null) { | 304 | } else if ($scope.remito.flete === undefined || $scope.remito.flete === null) { |
| 305 | focaModalService.alert('Ingrese Flete'); | 305 | focaModalService.alert('Ingrese Flete'); |
| 306 | return; | 306 | return; |
| 307 | } else if ($scope.articulosFiltro().length === 0) { | 307 | } else if ($scope.articulosFiltro().length === 0) { |
| 308 | focaModalService.alert('Debe cargar al menos un articulo'); | 308 | focaModalService.alert('Debe cargar al menos un articulo'); |
| 309 | return; | 309 | return; |
| 310 | } | 310 | } |
| 311 | 311 | ||
| 312 | focaBotoneraLateralService.startGuardar(); | 312 | focaBotoneraLateralService.startGuardar(); |
| 313 | $scope.saveLoading = true; | 313 | $scope.saveLoading = true; |
| 314 | var save = { | 314 | var save = { |
| 315 | remito: { | 315 | remito: { |
| 316 | id: $scope.remito.id, | 316 | id: $scope.remito.id, |
| 317 | fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '), | 317 | fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '), |
| 318 | idCliente: $scope.remito.cliente.COD, | 318 | idCliente: $scope.remito.cliente.COD, |
| 319 | nombreCliente: $scope.remito.cliente.NOM, | 319 | nombreCliente: $scope.remito.cliente.NOM, |
| 320 | cuitCliente: $scope.remito.cliente.CUIT, | 320 | cuitCliente: $scope.remito.cliente.CUIT, |
| 321 | total: $scope.getTotal() * $scope.remito.cotizacion.VENDEDOR, | 321 | total: $scope.getTotal() * $scope.remito.cotizacion.VENDEDOR, |
| 322 | numeroNotaPedido: $scope.remito.numeroNotaPedido, | 322 | numeroNotaPedido: $scope.remito.numeroNotaPedido, |
| 323 | idVendedor: parseInt($scope.remito.cliente.VEN), | 323 | idVendedor: parseInt($scope.remito.cliente.VEN), |
| 324 | idProveedor: $scope.remito.proveedor.COD, | 324 | idProveedor: $scope.remito.proveedor.COD, |
| 325 | idDomicilio: $scope.remito.idDomicilio || $scope.remito.domicilio.id, | 325 | idDomicilio: $scope.remito.idDomicilio || $scope.remito.domicilio.id, |
| 326 | idCotizacion: $scope.remito.cotizacion.ID, | 326 | idCotizacion: $scope.remito.cotizacion.ID, |
| 327 | idListaPrecio: $scope.idLista, | 327 | idListaPrecio: $scope.idLista, |
| 328 | flete: $scope.remito.flete, | 328 | flete: $scope.remito.flete, |
| 329 | fob: $scope.remito.fob, | 329 | fob: $scope.remito.fob, |
| 330 | bomba: $scope.remito.bomba, | 330 | bomba: $scope.remito.bomba, |
| 331 | kilometros: $scope.remito.kilometros, | 331 | kilometros: $scope.remito.kilometros, |
| 332 | domicilioStamp: $scope.remito.domicilioStamp, | 332 | domicilioStamp: $scope.remito.domicilioStamp, |
| 333 | observaciones: $scope.remito.observaciones, | 333 | observaciones: $scope.remito.observaciones, |
| 334 | numeroRemito: parseInt($scope.comprobante), | 334 | numeroRemito: parseInt($scope.comprobante), |
| 335 | sucursal: parseInt($scope.puntoVenta), | 335 | sucursal: parseInt($scope.puntoVenta), |
| 336 | responsabilidadIvaCliente: $scope.remito.cliente.IVA, | 336 | responsabilidadIvaCliente: $scope.remito.cliente.IVA, |
| 337 | descuento: 0,//TODO, | 337 | descuento: 0,//TODO, |
| 338 | importeNeto: getImporte('netoUnitario'), | 338 | importeNeto: getImporte('netoUnitario'), |
| 339 | importeExento: getImporte('exentoUnitario'), | 339 | importeExento: getImporte('exentoUnitario'), |
| 340 | importeIva: getImporte('ivaUnitario'), | 340 | importeIva: getImporte('ivaUnitario'), |
| 341 | importeIvaServicios: 0,//TODO | 341 | importeIvaServicios: 0,//TODO |
| 342 | importeImpuestoInterno: getImporte('impuestoInternoUnitario'), | 342 | importeImpuestoInterno: getImporte('impuestoInternoUnitario'), |
| 343 | importeImpuestoInterno1: getImporte('impuestoInterno1Unitario'), | 343 | importeImpuestoInterno1: getImporte('impuestoInterno1Unitario'), |
| 344 | importeImpuestoInterno2: getImporte('impuestoInterno2Unitario'), | 344 | importeImpuestoInterno2: getImporte('impuestoInterno2Unitario'), |
| 345 | percepcion: 0,//TODO | 345 | percepcion: 0,//TODO |
| 346 | percepcionIva: 0,//TODO | 346 | percepcionIva: 0,//TODO |
| 347 | redondeo: 0,//TODO | 347 | redondeo: 0,//TODO |
| 348 | anulado: false, | 348 | anulado: false, |
| 349 | planilla: $filter('date')($scope.now, 'ddMMyyyy'), | 349 | planilla: $filter('date')($scope.now, 'ddMMyyyy'), |
| 350 | lugar: parseInt($scope.puntoVenta), | 350 | lugar: parseInt($scope.puntoVenta), |
| 351 | cuentaMadre: 0,//TODO | 351 | cuentaMadre: 0,//TODO |
| 352 | cuentaContable: 0,//TODO | 352 | cuentaContable: 0,//TODO |
| 353 | asiento: 0,//TODO | 353 | asiento: 0,//TODO |
| 354 | e_hd: '',//TODO | 354 | e_hd: '',//TODO |
| 355 | c_hd: '', | 355 | c_hd: '', |
| 356 | numeroLiquidoProducto: 0,//TODO | 356 | numeroLiquidoProducto: 0,//TODO |
| 357 | estado: $scope.remito.estado, | 357 | estado: $scope.remito.estado, |
| 358 | destinoVenta: 0,//TODO | 358 | destinoVenta: 0,//TODO |
| 359 | operacionTipo: 0, //TODO | 359 | operacionTipo: 0, //TODO |
| 360 | }, | 360 | }, |
| 361 | notaPedido: $scope.notaPedido | 361 | notaPedido: $scope.notaPedido |
| 362 | }; | 362 | }; |
| 363 | crearRemitoService.crearRemito(save).then( | 363 | crearRemitoService.crearRemito(save).then( |
| 364 | function (data) { | 364 | function (data) { |
| 365 | 365 | ||
| 366 | focaBotoneraLateralService.endGuardar(true); | 366 | focaBotoneraLateralService.endGuardar(true); |
| 367 | $scope.saveLoading = false; | 367 | $scope.saveLoading = false; |
| 368 | 368 | ||
| 369 | $scope.remito.numeroRemito = data.data.numero; | 369 | $scope.remito.numeroRemito = data.data.numero; |
| 370 | 370 | ||
| 371 | if ($scope.remito.remitoPuntoDescarga.length > 0) { | 371 | if ($scope.remito.remitoPuntoDescarga.length > 0) { |
| 372 | remitoBusinessService.addPuntosDescarga(data.data.id, | 372 | remitoBusinessService.addPuntosDescarga(data.data.id, |
| 373 | $scope.remito.remitoPuntoDescarga); | 373 | $scope.remito.remitoPuntoDescarga); |
| 374 | } | 374 | } |
| 375 | 375 | ||
| 376 | if (data.status === 500) { | 376 | if (data.status === 500) { |
| 377 | focaModalService.alert(data.data); | 377 | focaModalService.alert(data.data); |
| 378 | return; | 378 | return; |
| 379 | } | 379 | } |
| 380 | 380 | ||
| 381 | // TODO: updatear plazos | 381 | // TODO: updatear plazos |
| 382 | if ($scope.remito.id === 0) { | 382 | if ($scope.remito.id === 0) { |
| 383 | 383 | ||
| 384 | remitoBusinessService.addArticulos($scope.remito.articulosRemito, | 384 | remitoBusinessService.addArticulos($scope.remito.articulosRemito, |
| 385 | data.data.id, $scope.remito.cotizacion.VENDEDOR); | 385 | data.data.id, $scope.remito.cotizacion.VENDEDOR); |
| 386 | 386 | ||
| 387 | var plazos = $scope.remito.remitoPlazo; | 387 | var plazos = $scope.remito.remitoPlazo; |
| 388 | 388 | ||
| 389 | for (var j = 0; j < plazos.length; j++) { | 389 | for (var j = 0; j < plazos.length; j++) { |
| 390 | var json = { | 390 | var json = { |
| 391 | idRemito: data.data.id, | 391 | idRemito: data.data.id, |
| 392 | dias: plazos[j].dias | 392 | dias: plazos[j].dias |
| 393 | }; | 393 | }; |
| 394 | crearRemitoService.crearPlazosParaRemito(json); | 394 | crearRemitoService.crearPlazosParaRemito(json); |
| 395 | } | 395 | } |
| 396 | } | 396 | } |
| 397 | abrirModalMail(data.data.id, | 397 | abrirModalMail(data.data.id, |
| 398 | $scope.remito.cliente, | 398 | $scope.remito.cliente, |
| 399 | $filter('comprobante')([ | 399 | $filter('comprobante')([ |
| 400 | $scope.puntoVenta, | 400 | $scope.puntoVenta, |
| 401 | $scope.remito.numeroRemito | 401 | $scope.remito.numeroRemito |
| 402 | ]) | 402 | ]) |
| 403 | ); | 403 | ); |
| 404 | 404 | ||
| 405 | config(); | 405 | config(); |
| 406 | 406 | ||
| 407 | }, function (error) { | 407 | }, function (error) { |
| 408 | focaModalService.alert(error.data || 'Hubo un error al crear el remito'); | 408 | focaModalService.alert(error.data || 'Hubo un error al crear el remito'); |
| 409 | focaBotoneraLateralService.endGuardar(); | 409 | focaBotoneraLateralService.endGuardar(); |
| 410 | $scope.saveLoading = false; | 410 | $scope.saveLoading = false; |
| 411 | console.info(error); | 411 | console.info(error); |
| 412 | } | 412 | } |
| 413 | ); | 413 | ); |
| 414 | }; | 414 | }; |
| 415 | 415 | ||
| 416 | $scope.seleccionarProductos = function () { | 416 | $scope.seleccionarProductos = function () { |
| 417 | if (!varlidarRemitoFacturado()) return; | 417 | if (!varlidarRemitoFacturado()) return; |
| 418 | if (!varlidarRemitoAbierto()) return; | 418 | if (!varlidarRemitoAbierto()) return; |
| 419 | if ($scope.notaPedido.id !== 0) { | 419 | if ($scope.notaPedido.id !== 0) { |
| 420 | $scope.idLista = parseInt($scope.notaPedido.idListaPrecio); | 420 | $scope.idLista = parseInt($scope.notaPedido.idListaPrecio); |
| 421 | } | 421 | } |
| 422 | if ($scope.idLista === undefined) { | 422 | if ($scope.idLista === undefined) { |
| 423 | focaModalService.alert( | 423 | focaModalService.alert( |
| 424 | 'Primero seleccione una lista de precio y condicion'); | 424 | 'Primero seleccione una lista de precio y condicion'); |
| 425 | return; | 425 | return; |
| 426 | } | 426 | } |
| 427 | var modalInstance = $uibModal.open( | 427 | var modalInstance = $uibModal.open( |
| 428 | { | 428 | { |
| 429 | ariaLabelledBy: 'Busqueda de Productos', | 429 | ariaLabelledBy: 'Busqueda de Productos', |
| 430 | templateUrl: 'modal-busqueda-productos.html', | 430 | templateUrl: 'modal-busqueda-productos.html', |
| 431 | controller: 'modalBusquedaProductosCtrl', | 431 | controller: 'modalBusquedaProductosCtrl', |
| 432 | resolve: { | 432 | resolve: { |
| 433 | parametroProducto: { | 433 | parametroProducto: { |
| 434 | idLista: $scope.idLista, | 434 | idLista: $scope.idLista, |
| 435 | cotizacion: $scope.remito.cotizacion.VENDEDOR, | 435 | cotizacion: $scope.remito.cotizacion.VENDEDOR, |
| 436 | simbolo: $scope.remito.cotizacion.moneda.SIMBOLO | 436 | simbolo: $scope.remito.cotizacion.moneda.SIMBOLO |
| 437 | } | 437 | } |
| 438 | }, | 438 | }, |
| 439 | size: 'lg' | 439 | size: 'lg' |
| 440 | } | 440 | } |
| 441 | ); | 441 | ); |
| 442 | modalInstance.result.then( | 442 | modalInstance.result.then( |
| 443 | function (producto) { | 443 | function (producto) { |
| 444 | var newArt = | 444 | var newArt = |
| 445 | { | 445 | { |
| 446 | id: 0, | 446 | id: 0, |
| 447 | idRemito: 0, | 447 | idRemito: 0, |
| 448 | codigo: producto.codigo, | 448 | codigo: producto.codigo, |
| 449 | sector: producto.sector, | 449 | sector: producto.sector, |
| 450 | sectorCodigo: producto.sector + '-' + producto.codigo, | 450 | sectorCodigo: producto.sector + '-' + producto.codigo, |
| 451 | descripcion: producto.descripcionLarga, | 451 | descripcion: producto.descripcionLarga, |
| 452 | item: $scope.remito.articulosRemito.length + 1, | 452 | item: $scope.remito.articulosRemito.length + 1, |
| 453 | nombre: producto.descripcion, | 453 | nombre: producto.descripcion, |
| 454 | precio: parseFloat(producto.precio.toFixed(4)), | 454 | precio: parseFloat(producto.precio.toFixed(4)), |
| 455 | costoUnitario: producto.costo, | 455 | costoUnitario: producto.costo, |
| 456 | editCantidad: false, | 456 | editCantidad: false, |
| 457 | editPrecio: false, | 457 | editPrecio: false, |
| 458 | rubro: producto.CodRub, | 458 | rubro: producto.CodRub, |
| 459 | ivaUnitario: producto.IMPIVA, | 459 | ivaUnitario: producto.IMPIVA, |
| 460 | impuestoInternoUnitario: producto.ImpInt, | 460 | impuestoInternoUnitario: producto.ImpInt, |
| 461 | impuestoInterno1Unitario: producto.ImpInt2, | 461 | impuestoInterno1Unitario: producto.ImpInt2, |
| 462 | impuestoInterno2Unitario: producto.ImpInt3, | 462 | impuestoInterno2Unitario: producto.ImpInt3, |
| 463 | precioLista: producto.precio, | 463 | precioLista: producto.precio, |
| 464 | combustible: 1, | 464 | combustible: 1, |
| 465 | facturado: 0, | 465 | facturado: 0, |
| 466 | idArticulo: producto.id, | 466 | idArticulo: producto.id, |
| 467 | tasaIva: producto.tasaIVA | 467 | tasaIva: producto.tasaIVA |
| 468 | }; | 468 | }; |
| 469 | 469 | ||
| 470 | newArt.exentoUnitario = newArt.ivaUnitario ? 0 : producto.neto; | 470 | newArt.exentoUnitario = newArt.ivaUnitario ? 0 : producto.neto; |
| 471 | newArt.netoUnitario = newArt.ivaUnitario ? producto.neto : 0; | 471 | newArt.netoUnitario = newArt.ivaUnitario ? producto.neto : 0; |
| 472 | 472 | ||
| 473 | $scope.articuloACargar = newArt; | 473 | $scope.articuloACargar = newArt; |
| 474 | $scope.cargando = false; | 474 | $scope.cargando = false; |
| 475 | }, function () { | 475 | }, function () { |
| 476 | // funcion ejecutada cuando se cancela el modal | 476 | // funcion ejecutada cuando se cancela el modal |
| 477 | } | 477 | } |
| 478 | ); | 478 | ); |
| 479 | }; | 479 | }; |
| 480 | 480 | ||
| 481 | $scope.seleccionarPuntosDeDescarga = function () { | 481 | $scope.seleccionarPuntosDeDescarga = function () { |
| 482 | if (!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) { | 482 | if (!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) { |
| 483 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); | 483 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); |
| 484 | return; | 484 | return; |
| 485 | } else { | 485 | } else { |
| 486 | var modalInstance = $uibModal.open( | 486 | var modalInstance = $uibModal.open( |
| 487 | { | 487 | { |
| 488 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', | 488 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', |
| 489 | templateUrl: 'modal-punto-descarga.html', | 489 | templateUrl: 'modal-punto-descarga.html', |
| 490 | controller: 'focaModalPuntoDescargaController', | 490 | controller: 'focaModalPuntoDescargaController', |
| 491 | size: 'lg', | 491 | size: 'lg', |
| 492 | resolve: { | 492 | resolve: { |
| 493 | filters: { | 493 | filters: { |
| 494 | idDomicilio: $scope.remito.domicilio.id, | 494 | idDomicilio: $scope.remito.domicilio.id, |
| 495 | idCliente: $scope.remito.cliente.COD, | 495 | idCliente: $scope.remito.cliente.COD, |
| 496 | articulos: $scope.remito.articulosRemito, | 496 | articulos: $scope.remito.articulosRemito, |
| 497 | puntosDescarga: $scope.remito.remitoPuntoDescarga, | 497 | puntosDescarga: $scope.remito.remitoPuntoDescarga, |
| 498 | domicilio: $scope.remito.domicilio | 498 | domicilio: $scope.remito.domicilio |
| 499 | } | 499 | } |
| 500 | } | 500 | } |
| 501 | } | 501 | } |
| 502 | ); | 502 | ); |
| 503 | modalInstance.result.then( | 503 | modalInstance.result.then( |
| 504 | function (puntosDescarga) { | 504 | function (puntosDescarga) { |
| 505 | 505 | ||
| 506 | puntosDescarga.forEach(function (punto) { | 506 | puntosDescarga.forEach(function (punto) { |
| 507 | $scope.remito.remitoPuntoDescarga.push( | 507 | $scope.remito.remitoPuntoDescarga.push( |
| 508 | { | 508 | { |
| 509 | puntoDescarga: punto | 509 | puntoDescarga: punto |
| 510 | } | 510 | } |
| 511 | ); | 511 | ); |
| 512 | }); | 512 | }); |
| 513 | 513 | ||
| 514 | $scope.$broadcast('addCabecera', { | 514 | $scope.$broadcast('addCabecera', { |
| 515 | label: 'Puntos de descarga:', | 515 | label: 'Puntos de descarga:', |
| 516 | valor: getCabeceraPuntoDescarga(puntosDescarga) | 516 | valor: getCabeceraPuntoDescarga(puntosDescarga) |
| 517 | }); | 517 | }); |
| 518 | }, function () { | 518 | }, function () { |
| 519 | $scope.abrirModalDomicilios($scope.cliente); | 519 | $scope.abrirModalDomicilios($scope.cliente); |
| 520 | } | 520 | } |
| 521 | ); | 521 | ); |
| 522 | } | 522 | } |
| 523 | }; | 523 | }; |
| 524 | 524 | ||
| 525 | $scope.seleccionarCliente = function () { | 525 | $scope.seleccionarCliente = function () { |
| 526 | if (!varlidarRemitoFacturado()) return; | 526 | if (!varlidarRemitoFacturado()) return; |
| 527 | if (!varlidarRemitoAbierto()) return; | 527 | if (!varlidarRemitoAbierto()) return; |
| 528 | var modalInstance = $uibModal.open( | 528 | var modalInstance = $uibModal.open( |
| 529 | { | 529 | { |
| 530 | ariaLabelledBy: 'Busqueda de Cliente', | 530 | ariaLabelledBy: 'Busqueda de Cliente', |
| 531 | templateUrl: 'foca-busqueda-cliente-modal.html', | 531 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 532 | controller: 'focaBusquedaClienteModalController', | 532 | controller: 'focaBusquedaClienteModalController', |
| 533 | resolve: { | 533 | resolve: { |
| 534 | vendedor: function () { return null; }, | 534 | parametros: function () { |
| 535 | cobrador: function () { return null; } | 535 | return { |
| 536 | vendedor: $scope.idVendedor, | ||
| 537 | cobrador: null, | ||
| 538 | searchText: $scope.cliente ? $scope.cliente.nom : '' | ||
| 539 | }; | ||
| 540 | }, | ||
| 536 | }, | 541 | }, |
| 537 | size: 'lg' | 542 | size: 'lg' |
| 538 | } | 543 | } |
| 539 | ); | 544 | ); |
| 540 | modalInstance.result.then( | 545 | modalInstance.result.then( |
| 541 | function (cliente) { | 546 | function (cliente) { |
| 547 | |||
| 548 | if (angular.equals({}, cliente.vendedor)) { | ||
| 549 | |||
| 550 | focaModalService | ||
| 551 | .alert('El cliente seleccionado no tiene tiene ' + | ||
| 552 | 'vendedor asignado.') | ||
| 553 | .then($scope.seleccionarCliente); | ||
| 554 | |||
| 555 | return; | ||
| 556 | } | ||
| 557 | |||
| 542 | $scope.cliente = cliente; | 558 | $scope.cliente = cliente; |
| 543 | $scope.abrirModalDomicilios(cliente); | 559 | $scope.abrirModalDomicilios(cliente); |
| 544 | }, function () { | 560 | }, function () { |
| 545 | } | 561 | } |
| 546 | ); | 562 | ); |
| 547 | }; | 563 | }; |
| 548 | 564 | ||
| 549 | $scope.seleccionarEliminarRemito = function () { | 565 | $scope.seleccionarEliminarRemito = function () { |
| 550 | focaModalService.confirm('¿Desea eliminar este remito?').then(function (data) { | 566 | focaModalService.confirm('¿Desea eliminar este remito?').then(function (data) { |
| 551 | if (data) { | 567 | if (data) { |
| 552 | $scope.remito.anulado = true; | 568 | $scope.remito.anulado = true; |
| 553 | delete $scope.remito.remitoPlazo; | 569 | delete $scope.remito.remitoPlazo; |
| 554 | delete $scope.remito.vendedor; | 570 | delete $scope.remito.vendedor; |
| 555 | delete $scope.remito.proveedor; | 571 | delete $scope.remito.proveedor; |
| 556 | delete $scope.remito.cliente; | 572 | delete $scope.remito.cliente; |
| 557 | delete $scope.remito.cotizacion; | 573 | delete $scope.remito.cotizacion; |
| 558 | delete $scope.remito.remitoPuntoDescarga; | 574 | delete $scope.remito.remitoPuntoDescarga; |
| 559 | delete $scope.remito.articulosRemito; | 575 | delete $scope.remito.articulosRemito; |
| 560 | delete $scope.remito.fechaRemito; | 576 | delete $scope.remito.fechaRemito; |
| 561 | crearRemitoService.eliminarRemito($scope.remito); | 577 | crearRemitoService.eliminarRemito($scope.remito); |
| 562 | } | 578 | } |
| 563 | config(); | 579 | config(); |
| 564 | }); | 580 | }); |
| 565 | }; | 581 | }; |
| 566 | 582 | ||
| 567 | $scope.seleccionarProveedor = function () { | 583 | $scope.seleccionarProveedor = function () { |
| 568 | if (!varlidarRemitoFacturado()) return; | 584 | if (!varlidarRemitoFacturado()) return; |
| 569 | if (!varlidarRemitoAbierto()) return; | 585 | if (!varlidarRemitoAbierto()) return; |
| 570 | var parametrosModal = { | 586 | var parametrosModal = { |
| 571 | titulo: 'Búsqueda de Proveedor', | 587 | titulo: 'Búsqueda de Proveedor', |
| 572 | query: '/proveedor', | 588 | query: '/proveedor', |
| 573 | columnas: [ | 589 | columnas: [ |
| 574 | { | 590 | { |
| 575 | nombre: 'Código', | 591 | nombre: 'Código', |
| 576 | propiedad: 'COD', | 592 | propiedad: 'COD', |
| 577 | filtro: { | 593 | filtro: { |
| 578 | nombre: 'rellenarDigitos', | 594 | nombre: 'rellenarDigitos', |
| 579 | parametro: 5 | 595 | parametro: 5 |
| 580 | } | 596 | } |
| 581 | }, | 597 | }, |
| 582 | { | 598 | { |
| 583 | nombre: 'Nombre', | 599 | nombre: 'Nombre', |
| 584 | propiedad: 'NOM' | 600 | propiedad: 'NOM' |
| 585 | }, | 601 | }, |
| 586 | { | 602 | { |
| 587 | nombre: 'CUIT', | 603 | nombre: 'CUIT', |
| 588 | propiedad: 'CUIT' | 604 | propiedad: 'CUIT' |
| 589 | } | 605 | } |
| 590 | ], | 606 | ], |
| 591 | tipo: 'POST', | 607 | tipo: 'POST', |
| 592 | json: { razonCuitCod: '' } | 608 | json: { razonCuitCod: '' } |
| 593 | }; | 609 | }; |
| 594 | focaModalService.modal(parametrosModal).then( | 610 | focaModalService.modal(parametrosModal).then( |
| 595 | function (proveedor) { | 611 | function (proveedor) { |
| 596 | $scope.seleccionarFlete(proveedor); | 612 | $scope.seleccionarFlete(proveedor); |
| 597 | }, function () { } | 613 | }, function () { } |
| 598 | ); | 614 | ); |
| 599 | }; | 615 | }; |
| 600 | 616 | ||
| 601 | $scope.seleccionarDomicilioDeEntrega = function () { | 617 | $scope.seleccionarDomicilioDeEntrega = function () { |
| 602 | if (!varlidarRemitoFacturado()) return; | 618 | if (!varlidarRemitoFacturado()) return; |
| 603 | if (!varlidarRemitoAbierto()) return; | 619 | if (!varlidarRemitoAbierto()) return; |
| 604 | if (!$scope.remito.cliente.COD && !$scope.cliente) { | 620 | if (!$scope.remito.cliente.COD && !$scope.cliente) { |
| 605 | focaModalService.alert('Seleccione un Cliente'); | 621 | focaModalService.alert('Seleccione un Cliente'); |
| 606 | return; | 622 | return; |
| 607 | } else { | 623 | } else { |
| 608 | $scope.abrirModalDomicilios($scope.remito.cliente.COD ? | 624 | $scope.abrirModalDomicilios($scope.remito.cliente.COD ? |
| 609 | $scope.remito.cliente.COD : $scope.cliente); | 625 | $scope.remito.cliente.COD : $scope.cliente); |
| 610 | } | 626 | } |
| 611 | }; | 627 | }; |
| 612 | 628 | ||
| 613 | $scope.abrirModalDomicilios = function (cliente) { | 629 | $scope.abrirModalDomicilios = function (cliente) { |
| 614 | var modalInstanceDomicilio = $uibModal.open( | 630 | var modalInstanceDomicilio = $uibModal.open( |
| 615 | { | 631 | { |
| 616 | ariaLabelledBy: 'Busqueda de Domicilios', | 632 | ariaLabelledBy: 'Busqueda de Domicilios', |
| 617 | templateUrl: 'modal-domicilio.html', | 633 | templateUrl: 'modal-domicilio.html', |
| 618 | controller: 'focaModalDomicilioController', | 634 | controller: 'focaModalDomicilioController', |
| 619 | size: 'lg', | 635 | size: 'lg', |
| 620 | resolve: { | 636 | resolve: { |
| 621 | idCliente: function () { | 637 | idCliente: function () { |
| 622 | return $scope.remito.cliente.COD ? $scope.remito.cliente.COD : | 638 | return $scope.remito.cliente.COD ? $scope.remito.cliente.COD : |
| 623 | cliente.cod; | 639 | cliente.COD; |
| 624 | }, | 640 | }, |
| 625 | esNuevo: function () { | 641 | esNuevo: function () { |
| 626 | return ($scope.remito.cliente.COD ? false : cliente.esNuevo); | 642 | return ($scope.remito.cliente.COD ? false : cliente.esNuevo); |
| 627 | } | 643 | } |
| 628 | } | 644 | } |
| 629 | } | 645 | } |
| 630 | ); | 646 | ); |
| 631 | modalInstanceDomicilio.result | 647 | modalInstanceDomicilio.result |
| 632 | .then(function (domicilio) { | 648 | .then(function (domicilio) { |
| 633 | $scope.remito.domicilio = domicilio; | 649 | $scope.remito.domicilio = domicilio; |
| 634 | if (!$scope.remito.cliente.COD) { | 650 | $scope.remito.cliente = cliente; |
| 635 | $scope.remito.cliente = { | 651 | $scope.remito.vendedor = cliente.vendedor; |
| 636 | COD: cliente.cod, | 652 | |
| 637 | CUIT: cliente.cuit, | 653 | var domicilioStamp = |
| 638 | NOM: cliente.nom, | 654 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + |
| 639 | MAIL: cliente.mail, | 655 | domicilio.Localidad + ', ' + domicilio.Provincia; |
| 640 | MOD: cliente.mod, | 656 | |
| 641 | IVA: cliente.iva, | 657 | $scope.remito.domicilioStamp = domicilioStamp; |
| 642 | VEN: cliente.ven | 658 | |
| 643 | }; | 659 | $scope.$broadcast('addCabecera', { |
| 644 | } | 660 | label: 'Vendedor:', |
| 645 | crearRemitoService.getVendedorById($scope.remito.cliente.VEN) | 661 | valor: $filter('rellenarDigitos')($scope.remito.vendedor |
| 646 | .then(function (res) { | 662 | .NUM, 3) + ' - ' + $scope.remito.vendedor.NOM |
| 647 | if (res.data !== '') { | 663 | }); |
| 648 | $scope.remito.vendedor = res.data; | 664 | $scope.$broadcast('addCabecera', { |
| 649 | $scope.$broadcast('addCabecera', { | 665 | label: 'Cliente:', |
| 650 | label: 'Vendedor:', | 666 | valor: $filter('rellenarDigitos') |
| 651 | valor: $filter('rellenarDigitos')($scope.remito.vendedor | 667 | ($scope.remito.cliente.COD, 3) + |
| 652 | .NUM, 3) + ' - ' + $scope.remito.vendedor.NOM | 668 | ' - ' + $scope.remito.cliente.NOM |
| 653 | }); | 669 | }); |
| 654 | } | 670 | $scope.$broadcast('addCabecera', { |
| 655 | var domicilioStamp = | 671 | label: 'Domicilio:', |
| 656 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | 672 | valor: domicilioStamp |
| 657 | domicilio.Localidad + ', ' + domicilio.Provincia; | 673 | }); |
| 658 | $scope.remito.domicilioStamp = domicilioStamp; | 674 | |
| 659 | $scope.$broadcast('addCabecera', { | 675 | if (domicilio.verPuntos) { |
| 660 | label: 'Cliente:', | 676 | delete $scope.remito.domicilio.verPuntos; |
| 661 | valor: $filter('rellenarDigitos') | 677 | $scope.seleccionarPuntosDeDescarga(); |
| 662 | ($scope.remito.cliente.COD, 3) + | 678 | } else { |
| 663 | ' - ' + $scope.remito.cliente.NOM | 679 | crearRemitoService |
| 664 | }); | 680 | .getPuntosDescargaByClienDom(domicilio.id, |
| 665 | $scope.$broadcast('addCabecera', { | 681 | $scope.remito.cliente.COD) |
| 666 | label: 'Domicilio:', | 682 | .then(function (res) { |
| 667 | valor: domicilioStamp | 683 | if (res.data.length) { |
| 684 | $scope.seleccionarPuntosDeDescarga(); | ||
| 685 | } | ||
| 668 | }); | 686 | }); |
| 687 | } | ||
| 669 | 688 | ||
| 670 | if (domicilio.verPuntos) { | 689 | $filter('filter')($scope.botonera, |
| 671 | delete $scope.remito.domicilio.verPuntos; | 690 | { label: 'Cliente' })[0].checked = true; |
| 672 | $scope.seleccionarPuntosDeDescarga(); | 691 | $filter('filter')($scope.botonera, |
| 673 | } else { | 692 | { label: 'Domicilio de Entrega' })[0].checked = true; |
| 674 | crearRemitoService | ||
| 675 | .getPuntosDescargaByClienDom(domicilio.id, | ||
| 676 | $scope.remito.cliente.COD) | ||
| 677 | .then(function (res) { | ||
| 678 | if (res.data.length) { | ||
| 679 | $scope.seleccionarPuntosDeDescarga(); | ||
| 680 | } | ||
| 681 | }); | ||
| 682 | } | ||
| 683 | 693 | ||
| 684 | $filter('filter')($scope.botonera, | ||
| 685 | { label: 'Cliente' })[0].checked = true; | ||
| 686 | $filter('filter')($scope.botonera, | ||
| 687 | { label: 'Domicilio de Entrega' })[0].checked = true; | ||
| 688 | }) | ||
| 689 | .catch(function (e) { console.info(e); }); | ||
| 690 | }) | 694 | }) |
| 691 | .catch(function (e) { | 695 | .catch(function (e) { |
| 692 | console.info(e); | 696 | console.info(e); |
| 693 | $scope.seleccionarCliente(true); | 697 | $scope.seleccionarCliente(true); |
| 694 | return; | 698 | return; |
| 695 | }); | 699 | }); |
| 696 | }; | 700 | }; |
| 697 | 701 | ||
| 698 | $scope.getTotal = function () { | 702 | $scope.getTotal = function () { |
| 699 | var total = 0; | 703 | var total = 0; |
| 700 | var arrayTempArticulos = $scope.articulosFiltro(); | 704 | var arrayTempArticulos = $scope.articulosFiltro(); |
| 701 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 705 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
| 702 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 706 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
| 703 | } | 707 | } |
| 704 | return parseFloat(total.toFixed(2)); | 708 | return parseFloat(total.toFixed(2)); |
| 705 | }; | 709 | }; |
| 706 | 710 | ||
| 707 | $scope.getSubTotal = function () { | 711 | $scope.getSubTotal = function () { |
| 708 | if ($scope.articuloACargar) { | 712 | if ($scope.articuloACargar) { |
| 709 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 713 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
| 710 | } | 714 | } |
| 711 | }; | 715 | }; |
| 712 | 716 | ||
| 713 | $scope.seleccionarPreciosYCondiciones = function () { | 717 | $scope.seleccionarPreciosYCondiciones = function () { |
| 714 | if (!$scope.remito.cliente.COD) { | 718 | if (!$scope.remito.cliente.COD) { |
| 715 | focaModalService.alert('Primero seleccione un cliente'); | 719 | focaModalService.alert('Primero seleccione un cliente'); |
| 716 | return; | 720 | return; |
| 717 | } | 721 | } |
| 718 | if ($scope.remito.articulosRemito.length !== 0) { | 722 | if ($scope.remito.articulosRemito.length !== 0) { |
| 719 | if (varlidarRemitoFacturado() && varlidarRemitoAbierto()) { | 723 | if (varlidarRemitoFacturado() && varlidarRemitoAbierto()) { |
| 720 | abrirModal(); | 724 | abrirModal(); |
| 721 | } | 725 | } |
| 722 | } else { | 726 | } else { |
| 723 | abrirModal(); | 727 | abrirModal(); |
| 724 | } | 728 | } |
| 725 | 729 | ||
| 726 | function abrirModal() { | 730 | function abrirModal() { |
| 727 | var parametros = { | 731 | var parametros = { |
| 728 | idCliente: $scope.remito.cliente.COD, | 732 | idCliente: $scope.remito.cliente.COD, |
| 729 | idListaPrecio: $scope.remito.cliente.MOD | 733 | idListaPrecio: $scope.remito.cliente.MOD |
| 730 | }; | 734 | }; |
| 731 | var modalInstance = $uibModal.open( | 735 | var modalInstance = $uibModal.open( |
| 732 | { | 736 | { |
| 733 | ariaLabelledBy: 'Busqueda de Precio Condición', | 737 | ariaLabelledBy: 'Busqueda de Precio Condición', |
| 734 | templateUrl: 'modal-precio-condicion.html', | 738 | templateUrl: 'modal-precio-condicion.html', |
| 735 | controller: 'focaModalPrecioCondicionController', | 739 | controller: 'focaModalPrecioCondicionController', |
| 736 | size: 'lg', | 740 | size: 'lg', |
| 737 | resolve: { | 741 | resolve: { |
| 738 | parametros: function () { return parametros; } | 742 | parametros: function () { return parametros; } |
| 739 | } | 743 | } |
| 740 | } | 744 | } |
| 741 | ); | 745 | ); |
| 742 | modalInstance.result.then( | 746 | modalInstance.result.then( |
| 743 | function (precioCondicion) { | 747 | function (precioCondicion) { |
| 744 | var cabecera = ''; | 748 | var cabecera = ''; |
| 745 | var plazosConcat = ''; | 749 | var plazosConcat = ''; |
| 746 | if (!Array.isArray(precioCondicion)) { | 750 | if (!Array.isArray(precioCondicion)) { |
| 747 | $scope.remito.idPrecioCondicion = precioCondicion.listaPrecio.ID; | 751 | $scope.remito.idPrecioCondicion = precioCondicion.listaPrecio.ID; |
| 748 | $scope.remito.remitoPlazo = precioCondicion.plazoPago; | 752 | $scope.remito.remitoPlazo = precioCondicion.plazoPago; |
| 749 | $scope.idLista = parseInt(precioCondicion.listaPrecio.ID) ? | 753 | $scope.idLista = parseInt(precioCondicion.listaPrecio.ID) ? |
| 750 | parseInt(precioCondicion.listaPrecio.ID) : -1; | 754 | parseInt(precioCondicion.listaPrecio.ID) : -1; |
| 751 | $scope.remito.cliente.MOD = precioCondicion.listaPrecio.ID; | 755 | $scope.remito.cliente.MOD = precioCondicion.listaPrecio.ID; |
| 752 | for (var i = 0; i < precioCondicion.plazoPago.length; i++) { | 756 | for (var i = 0; i < precioCondicion.plazoPago.length; i++) { |
| 753 | plazosConcat += precioCondicion.plazoPago[i].dias + ', '; | 757 | plazosConcat += precioCondicion.plazoPago[i].dias + ', '; |
| 754 | } | 758 | } |
| 755 | plazosConcat = plazosConcat.substring(0, plazosConcat.length - 2); | 759 | plazosConcat = plazosConcat.substring(0, plazosConcat.length - 2); |
| 756 | cabecera = $filter('rellenarDigitos') | 760 | cabecera = $filter('rellenarDigitos') |
| 757 | (parseInt(precioCondicion.listaPrecio.ID), 4) + | 761 | (parseInt(precioCondicion.listaPrecio.ID), 4) + |
| 758 | ' - ' + precioCondicion.listaPrecio.DES + ' ' + | 762 | ' - ' + precioCondicion.listaPrecio.DES + ' ' + |
| 759 | plazosConcat.trim(); | 763 | plazosConcat.trim(); |
| 760 | } else { //Cuando se ingresan los plazos manualmente | 764 | } else { //Cuando se ingresan los plazos manualmente |
| 761 | $scope.remito.idPrecioCondicion = 0; | 765 | $scope.remito.idPrecioCondicion = 0; |
| 762 | //-1, el modal productos busca todos los productos | 766 | //-1, el modal productos busca todos los productos |
| 763 | $scope.idLista = -1; | 767 | $scope.idLista = -1; |
| 764 | $scope.remito.remitoPlazo = precioCondicion; | 768 | $scope.remito.remitoPlazo = precioCondicion; |
| 765 | for (var j = 0; j < precioCondicion.length; j++) { | 769 | for (var j = 0; j < precioCondicion.length; j++) { |
| 766 | plazosConcat += precioCondicion[j].dias + ' '; | 770 | plazosConcat += precioCondicion[j].dias + ' '; |
| 767 | } | 771 | } |
| 768 | cabecera = plazosConcat.trim(); | 772 | cabecera = plazosConcat.trim(); |
| 769 | } | 773 | } |
| 770 | var cabecerasFilter = !$filter('filter')($scope.cabeceras, | 774 | var cabecerasFilter = !$filter('filter')($scope.cabeceras, |
| 771 | { label: 'Precios y Condiciones' }); | 775 | { label: 'Precios y Condiciones' }); |
| 772 | if (!cabecerasFilter) { | 776 | if (!cabecerasFilter) { |
| 773 | $scope.cabeceras.push({ | 777 | $scope.cabeceras.push({ |
| 774 | label: 'Precios y Condiciones:', | 778 | label: 'Precios y Condiciones:', |
| 775 | valor: parseInt(precioCondicion.listaPrecio.ID) + ' - ' + | 779 | valor: parseInt(precioCondicion.listaPrecio.ID) + ' - ' + |
| 776 | precioCondicion.listaPrecio.DES + ' ' + | 780 | precioCondicion.listaPrecio.DES + ' ' + |
| 777 | remitoBusinessService | 781 | remitoBusinessService |
| 778 | .plazoToString(precioCondicion.plazoPago) | 782 | .plazoToString(precioCondicion.plazoPago) |
| 779 | }); | 783 | }); |
| 780 | $scope.remito.idListaPrecio = parseInt(precioCondicion.listaPrecio.ID); | 784 | |
| 785 | $scope.remito.idListaPrecio = parseInt( | ||
| 786 | precioCondicion.listaPrecio.ID); | ||
| 781 | } | 787 | } |
| 782 | $filter('filter')($scope.cabeceras, | 788 | $filter('filter')($scope.cabeceras, |
| 783 | { label: 'Precios y Condiciones' })[0].valor = cabecera; | 789 | { label: 'Precios y Condiciones' })[0].valor = cabecera; |
| 784 | 790 | ||
| 785 | $scope.remito.precioCondicion = precioCondicion; | 791 | $scope.remito.precioCondicion = precioCondicion; |
| 786 | $filter('filter')($scope.botonera, | 792 | $filter('filter')($scope.botonera, |
| 787 | { label: 'Precios y Condiciones' })[0].checked = true; | 793 | { label: 'Precios y Condiciones' })[0].checked = true; |
| 788 | addArrayCabecera($scope.cabeceras); | 794 | addArrayCabecera($scope.cabeceras); |
| 789 | }, function () { | 795 | }, function () { |
| 790 | 796 | ||
| 791 | } | 797 | } |
| 792 | ); | 798 | ); |
| 793 | } | 799 | } |
| 794 | }; | 800 | }; |
| 795 | 801 | ||
| 796 | $scope.seleccionarFlete = function (proveedor) { | 802 | $scope.seleccionarFlete = function (proveedor) { |
| 797 | if (!varlidarRemitoFacturado()) return; | 803 | if (!varlidarRemitoFacturado()) return; |
| 798 | if (!varlidarRemitoAbierto()) return; | 804 | if (!varlidarRemitoAbierto()) return; |
| 799 | var modalInstance = $uibModal.open( | 805 | var modalInstance = $uibModal.open( |
| 800 | { | 806 | { |
| 801 | ariaLabelledBy: 'Busqueda de Flete', | 807 | ariaLabelledBy: 'Busqueda de Flete', |
| 802 | templateUrl: 'modal-flete.html', | 808 | templateUrl: 'modal-flete.html', |
| 803 | controller: 'focaModalFleteController', | 809 | controller: 'focaModalFleteController', |
| 804 | size: 'lg', | 810 | size: 'lg', |
| 805 | resolve: { | 811 | resolve: { |
| 806 | parametrosFlete: | 812 | parametrosFlete: |
| 807 | function () { | 813 | function () { |
| 808 | return { | 814 | return { |
| 809 | flete: $scope.remito.flete ? '1' : | 815 | flete: $scope.remito.flete ? '1' : |
| 810 | ($scope.remito.fob ? 'FOB' : | 816 | ($scope.remito.fob ? 'FOB' : |
| 811 | ($scope.remito.flete === undefined ? | 817 | ($scope.remito.flete === undefined ? |
| 812 | null : '0')), | 818 | null : '0')), |
| 813 | bomba: $scope.remito.bomba ? '1' : | 819 | bomba: $scope.remito.bomba ? '1' : |
| 814 | ($scope.remito.bomba === undefined ? | 820 | ($scope.remito.bomba === undefined ? |
| 815 | null : '0'), | 821 | null : '0'), |
| 816 | kilometros: $scope.remito.kilometros | 822 | kilometros: $scope.remito.kilometros |
| 817 | }; | 823 | }; |
| 818 | } | 824 | } |
| 819 | } | 825 | } |
| 820 | } | 826 | } |
| 821 | ); | 827 | ); |
| 822 | modalInstance.result.then( | 828 | modalInstance.result.then( |
| 823 | function (datos) { | 829 | function (datos) { |
| 824 | $scope.remitoIsDirty = true; | 830 | $scope.remitoIsDirty = true; |
| 825 | $scope.remito.proveedor = proveedor; | 831 | $scope.remito.proveedor = proveedor; |
| 826 | $scope.remito.idProveedor = proveedor.COD; | 832 | $scope.remito.idProveedor = proveedor.COD; |
| 827 | $scope.$broadcast('addCabecera', { | 833 | $scope.$broadcast('addCabecera', { |
| 828 | label: 'Proveedor:', | 834 | label: 'Proveedor:', |
| 829 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | 835 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
| 830 | proveedor.NOM | 836 | proveedor.NOM |
| 831 | }); | 837 | }); |
| 832 | 838 | ||
| 833 | $scope.remito.flete = datos.flete; | 839 | $scope.remito.flete = datos.flete; |
| 834 | $scope.remito.fob = datos.FOB; | 840 | $scope.remito.fob = datos.FOB; |
| 835 | $scope.remito.bomba = datos.bomba; | 841 | $scope.remito.bomba = datos.bomba; |
| 836 | $scope.remito.kilometros = datos.kilometros; | 842 | $scope.remito.kilometros = datos.kilometros; |
| 837 | 843 | ||
| 838 | $scope.$broadcast('addCabecera', { | 844 | $scope.$broadcast('addCabecera', { |
| 839 | label: 'Flete:', | 845 | label: 'Flete:', |
| 840 | valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No') | 846 | valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No') |
| 841 | }); | 847 | }); |
| 842 | if (datos.flete) { | 848 | if (datos.flete) { |
| 843 | $scope.$broadcast('addCabecera', { | 849 | $scope.$broadcast('addCabecera', { |
| 844 | label: 'Bomba:', | 850 | label: 'Bomba:', |
| 845 | valor: datos.bomba ? 'Si' : 'No' | 851 | valor: datos.bomba ? 'Si' : 'No' |
| 846 | }); | 852 | }); |
| 847 | $scope.$broadcast('addCabecera', { | 853 | $scope.$broadcast('addCabecera', { |
| 848 | label: 'Kilometros:', | 854 | label: 'Kilometros:', |
| 849 | valor: datos.kilometros | 855 | valor: datos.kilometros |
| 850 | }); | 856 | }); |
| 851 | } else { | 857 | } else { |
| 852 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 858 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
| 853 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 859 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
| 854 | $scope.remito.bomba = false; | 860 | $scope.remito.bomba = false; |
| 855 | $scope.remito.kilometros = null; | 861 | $scope.remito.kilometros = null; |
| 856 | } | 862 | } |
| 857 | 863 | ||
| 858 | $filter('filter')($scope.botonera, | 864 | $filter('filter')($scope.botonera, |
| 859 | { label: 'Proveedor' })[0].checked = true; | 865 | { label: 'Proveedor' })[0].checked = true; |
| 860 | }, function () { | 866 | }, function () { |
| 861 | $scope.seleccionarTransportista(); | 867 | $scope.seleccionarTransportista(); |
| 862 | } | 868 | } |
| 863 | ); | 869 | ); |
| 864 | }; | 870 | }; |
| 865 | 871 | ||
| 866 | $scope.seleccionarMoneda = function () { | 872 | $scope.seleccionarMoneda = function () { |
| 867 | if (!varlidarRemitoFacturado()) return; | 873 | if (!varlidarRemitoFacturado()) return; |
| 868 | if (!varlidarRemitoAbierto()) return; | 874 | if (!varlidarRemitoAbierto()) return; |
| 869 | var parametrosModal = { | 875 | var parametrosModal = { |
| 870 | titulo: 'Búsqueda de monedas', | 876 | titulo: 'Búsqueda de monedas', |
| 871 | query: '/moneda', | 877 | query: '/moneda', |
| 872 | columnas: [ | 878 | columnas: [ |
| 873 | { | 879 | { |
| 874 | propiedad: 'DETALLE', | 880 | propiedad: 'DETALLE', |
| 875 | nombre: 'Nombre' | 881 | nombre: 'Nombre' |
| 876 | }, | 882 | }, |
| 877 | { | 883 | { |
| 878 | propiedad: 'SIMBOLO', | 884 | propiedad: 'SIMBOLO', |
| 879 | nombre: 'Símbolo' | 885 | nombre: 'Símbolo' |
| 880 | } | 886 | } |
| 881 | ], | 887 | ], |
| 882 | size: 'md' | 888 | size: 'md' |
| 883 | }; | 889 | }; |
| 884 | focaModalService.modal(parametrosModal).then( | 890 | focaModalService.modal(parametrosModal).then( |
| 885 | function (moneda) { | 891 | function (moneda) { |
| 886 | 892 | ||
| 887 | if (moneda.ID !== 1) { | 893 | if (moneda.ID !== 1) { |
| 888 | $scope.abrirModalCotizacion(moneda); | 894 | $scope.abrirModalCotizacion(moneda); |
| 889 | return; | 895 | return; |
| 890 | } | 896 | } |
| 891 | 897 | ||
| 892 | crearRemitoService.getCotizacionByIdMoneda(1) | 898 | crearRemitoService.getCotizacionByIdMoneda(1) |
| 893 | .then(function (res) { | 899 | .then(function (res) { |
| 894 | 900 | ||
| 895 | cotizacionPArgentino = res.data[0].cotizaciones[0]; | 901 | cotizacionPArgentino = res.data[0].cotizaciones[0]; |
| 896 | cotizacionPArgentino.moneda = moneda; | 902 | cotizacionPArgentino.moneda = moneda; |
| 897 | 903 | ||
| 898 | actualizarCabeceraMoneda(cotizacionPArgentino); | 904 | actualizarCabeceraMoneda(cotizacionPArgentino); |
| 899 | 905 | ||
| 900 | $scope.remito.cotizacion = cotizacionPArgentino; | 906 | $scope.remito.cotizacion = cotizacionPArgentino; |
| 901 | }); | 907 | }); |
| 902 | }, function () { | 908 | }, function () { |
| 903 | 909 | ||
| 904 | } | 910 | } |
| 905 | ); | 911 | ); |
| 906 | }; | 912 | }; |
| 907 | 913 | ||
| 908 | $scope.seleccionarObservaciones = function () { | 914 | $scope.seleccionarObservaciones = function () { |
| 909 | focaModalService | 915 | focaModalService |
| 910 | .prompt({ | 916 | .prompt({ |
| 911 | titulo: 'Observaciones', | 917 | titulo: 'Observaciones', |
| 912 | value: $scope.remito.observaciones, | 918 | value: $scope.remito.observaciones, |
| 913 | textarea: true, | 919 | textarea: true, |
| 914 | readonly: true | 920 | readonly: true |
| 915 | }) | 921 | }) |
| 916 | .then(function (observaciones) { | 922 | .then(function (observaciones) { |
| 917 | $scope.remito.observaciones = observaciones; | 923 | $scope.remito.observaciones = observaciones; |
| 918 | }); | 924 | }); |
| 919 | }; | 925 | }; |
| 920 | 926 | ||
| 921 | $scope.abrirModalCotizacion = function (moneda) { | 927 | $scope.abrirModalCotizacion = function (moneda) { |
| 922 | var modalInstance = $uibModal.open( | 928 | var modalInstance = $uibModal.open( |
| 923 | { | 929 | { |
| 924 | ariaLabelledBy: 'Busqueda de Cotización', | 930 | ariaLabelledBy: 'Busqueda de Cotización', |
| 925 | templateUrl: 'modal-cotizacion.html', | 931 | templateUrl: 'modal-cotizacion.html', |
| 926 | controller: 'focaModalCotizacionController', | 932 | controller: 'focaModalCotizacionController', |
| 927 | size: 'lg', | 933 | size: 'lg', |
| 928 | resolve: { idMoneda: function () { return moneda.ID; } } | 934 | resolve: { idMoneda: function () { return moneda.ID; } } |
| 929 | } | 935 | } |
| 930 | ); | 936 | ); |
| 931 | modalInstance.result.then( | 937 | modalInstance.result.then( |
| 932 | function (cotizacion) { | 938 | function (cotizacion) { |
| 933 | cotizacion.moneda = moneda; | 939 | cotizacion.moneda = moneda; |
| 934 | $scope.remitoIsDirty = true; | 940 | $scope.remitoIsDirty = true; |
| 935 | actualizarCabeceraMoneda(cotizacion); | 941 | actualizarCabeceraMoneda(cotizacion); |
| 936 | $scope.remito.cotizacion = cotizacion; | 942 | $scope.remito.cotizacion = cotizacion; |
| 937 | }, function () { | 943 | }, function () { |
| 938 | 944 | ||
| 939 | } | 945 | } |
| 940 | ); | 946 | ); |
| 941 | }; | 947 | }; |
| 942 | 948 | ||
| 943 | function actualizarCabeceraMoneda(cotizacion) { | 949 | function actualizarCabeceraMoneda(cotizacion) { |
| 944 | 950 | ||
| 945 | $scope.remito.articulosRemito.forEach(function (art) { | 951 | $scope.remito.articulosRemito.forEach(function (art) { |
| 946 | art.precio = (art.precio * $scope.remito.cotizacion.VENDEDOR).toFixed(4); | 952 | art.precio = (art.precio * $scope.remito.cotizacion.VENDEDOR).toFixed(4); |
| 947 | art.precio = (art.precio / cotizacion.VENDEDOR).toFixed(4); | 953 | art.precio = (art.precio / cotizacion.VENDEDOR).toFixed(4); |
| 948 | }); | 954 | }); |
| 949 | 955 | ||
| 950 | if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { | 956 | if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { |
| 951 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 957 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
| 952 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 958 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
| 953 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 959 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
| 954 | } else { | 960 | } else { |
| 955 | $scope.$broadcast('addCabecera', { | 961 | $scope.$broadcast('addCabecera', { |
| 956 | label: 'Moneda:', | 962 | label: 'Moneda:', |
| 957 | valor: cotizacion.moneda.DETALLE | 963 | valor: cotizacion.moneda.DETALLE |
| 958 | }); | 964 | }); |
| 959 | $scope.$broadcast('addCabecera', { | 965 | $scope.$broadcast('addCabecera', { |
| 960 | label: 'Fecha cotizacion:', | 966 | label: 'Fecha cotizacion:', |
| 961 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 967 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
| 962 | }); | 968 | }); |
| 963 | $scope.$broadcast('addCabecera', { | 969 | $scope.$broadcast('addCabecera', { |
| 964 | label: 'Cotizacion:', | 970 | label: 'Cotizacion:', |
| 965 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | 971 | valor: $filter('number')(cotizacion.VENDEDOR, '2') |
| 966 | }); | 972 | }); |
| 967 | } | 973 | } |
| 968 | } | 974 | } |
| 969 | 975 | ||
| 970 | $scope.agregarATabla = function (key) { | 976 | $scope.agregarATabla = function (key) { |
| 971 | if (key === 13) { | 977 | if (key === 13) { |
| 972 | if (!$scope.articuloACargar.cantidad || !$scope.articuloACargar.precio) { | 978 | if (!$scope.articuloACargar.cantidad || !$scope.articuloACargar.precio) { |
| 973 | focaModalService.alert('El valor debe ser al menos 1'); | 979 | focaModalService.alert('El valor debe ser al menos 1'); |
| 974 | return; | 980 | return; |
| 975 | } | 981 | } |
| 976 | delete $scope.articuloACargar.sectorCodigo; | 982 | delete $scope.articuloACargar.sectorCodigo; |
| 977 | $scope.remito.articulosRemito.push($scope.articuloACargar); | 983 | $scope.remito.articulosRemito.push($scope.articuloACargar); |
| 978 | $scope.cargando = true; | 984 | $scope.cargando = true; |
| 979 | } | 985 | } |
| 980 | }; | 986 | }; |
| 981 | 987 | ||
| 982 | $scope.quitarArticulo = function (articulo) { | 988 | $scope.quitarArticulo = function (articulo) { |
| 983 | articulo.idRemito = -1; | 989 | articulo.idRemito = -1; |
| 984 | }; | 990 | }; |
| 985 | 991 | ||
| 986 | $scope.articulosFiltro = function () { | 992 | $scope.articulosFiltro = function () { |
| 987 | 993 | ||
| 988 | var result = $scope.remito.articulosRemito.filter(function (articulo) { | 994 | var result = $scope.remito.articulosRemito.filter(function (articulo) { |
| 989 | return articulo.idRemito >= 0; | 995 | return articulo.idRemito >= 0; |
| 990 | }); | 996 | }); |
| 991 | 997 | ||
| 992 | // Agrego checked en cabecera si hay datos | 998 | // Agrego checked en cabecera si hay datos |
| 993 | if (result.length) { | 999 | if (result.length) { |
| 994 | $filter('filter')($scope.botonera, { label: 'Productos' })[0].checked = true; | 1000 | $filter('filter')($scope.botonera, { label: 'Productos' })[0].checked = true; |
| 995 | } else { | 1001 | } else { |
| 996 | $filter('filter')($scope.botonera, { label: 'Productos' })[0].checked = false; | 1002 | $filter('filter')($scope.botonera, { label: 'Productos' })[0].checked = false; |
| 997 | } | 1003 | } |
| 998 | return result; | 1004 | return result; |
| 999 | }; | 1005 | }; |
| 1000 | 1006 | ||
| 1001 | $scope.editarArticulo = function (key, articulo, tmpCantidad, tmpPrecio) { | 1007 | $scope.editarArticulo = function (key, articulo, tmpCantidad, tmpPrecio) { |
| 1002 | if (key === 13) { | 1008 | if (key === 13) { |
| 1003 | if (!articulo.cantidad || !articulo.precio || !tmpCantidad || !tmpPrecio) { | 1009 | if (!articulo.cantidad || !articulo.precio || !tmpCantidad || !tmpPrecio) { |
| 1004 | focaModalService.alert('Los valores deben ser al menos 1'); | 1010 | focaModalService.alert('Los valores deben ser al menos 1'); |
| 1005 | return; | 1011 | return; |
| 1006 | } else if (tmpCantidad === '0' || tmpPrecio === '0') { | 1012 | } else if (tmpCantidad === '0' || tmpPrecio === '0') { |
| 1007 | focaModalService.alert('Esta ingresando un producto con valor 0'); | 1013 | focaModalService.alert('Esta ingresando un producto con valor 0'); |
| 1008 | } else if (articulo.cantidad < 0 || articulo.precio < 0) { | 1014 | } else if (articulo.cantidad < 0 || articulo.precio < 0) { |
| 1009 | focaModalService.alert('Los valores no pueden ser negativos'); | 1015 | focaModalService.alert('Los valores no pueden ser negativos'); |
| 1010 | return; | 1016 | return; |
| 1011 | } | 1017 | } |
| 1012 | articulo.cantidad = tmpCantidad; | 1018 | articulo.cantidad = tmpCantidad; |
| 1013 | articulo.precio = tmpPrecio; | 1019 | articulo.precio = tmpPrecio; |
| 1014 | $scope.getTotal(); | 1020 | $scope.getTotal(); |
| 1015 | articulo.editCantidad = articulo.editPrecio = false; | 1021 | articulo.editCantidad = articulo.editPrecio = false; |
| 1016 | } | 1022 | } |
| 1017 | }; | 1023 | }; |
| 1018 | 1024 | ||
| 1019 | $scope.cancelarEditar = function (articulo) { | 1025 | $scope.cancelarEditar = function (articulo) { |
| 1020 | $scope.tmpCantidad = articulo.cantidad; | 1026 | $scope.tmpCantidad = articulo.cantidad; |
| 1021 | $scope.tmpPrecio = articulo.precio; | 1027 | $scope.tmpPrecio = articulo.precio; |
| 1022 | articulo.editCantidad = articulo.editPrecio = false; | 1028 | articulo.editCantidad = articulo.editPrecio = false; |
| 1023 | }; | 1029 | }; |
| 1024 | 1030 | ||
| 1025 | $scope.cambioEdit = function (articulo, propiedad) { | 1031 | $scope.cambioEdit = function (articulo, propiedad) { |
| 1026 | if (propiedad === 'cantidad') { | 1032 | if (propiedad === 'cantidad') { |
| 1027 | articulo.editCantidad = true; | 1033 | articulo.editCantidad = true; |
| 1028 | } else if (propiedad === 'precio') { | 1034 | } else if (propiedad === 'precio') { |
| 1029 | articulo.editPrecio = true; | 1035 | articulo.editPrecio = true; |
| 1030 | } | 1036 | } |
| 1031 | }; | 1037 | }; |
| 1032 | 1038 | ||
| 1033 | $scope.resetFilter = function () { | 1039 | $scope.resetFilter = function () { |
| 1034 | $scope.articuloACargar = {}; | 1040 | $scope.articuloACargar = {}; |
| 1035 | $scope.cargando = true; | 1041 | $scope.cargando = true; |
| 1036 | }; | 1042 | }; |
| 1037 | //Recibe aviso si el teclado está en uso | 1043 | //Recibe aviso si el teclado está en uso |
| 1038 | $rootScope.$on('usarTeclado', function (event, data) { | 1044 | $rootScope.$on('usarTeclado', function (event, data) { |
| 1039 | if (data) { | 1045 | if (data) { |
| 1040 | $scope.mostrarTeclado = true; | 1046 | $scope.mostrarTeclado = true; |
| 1041 | return; | 1047 | return; |
| 1042 | } | 1048 | } |
| 1043 | $scope.mostrarTeclado = false; | 1049 | $scope.mostrarTeclado = false; |
| 1044 | }); | 1050 | }); |
| 1045 | 1051 | ||
| 1046 | $scope.selectFocus = function ($event) { | 1052 | $scope.selectFocus = function ($event) { |
| 1047 | // Si el teclado esta en uso no selecciona el valor | 1053 | // Si el teclado esta en uso no selecciona el valor |
| 1048 | if ($scope.mostrarTeclado) { | 1054 | if ($scope.mostrarTeclado) { |
| 1049 | return; | 1055 | return; |
| 1050 | } | 1056 | } |
| 1051 | $event.target.select(); | 1057 | $event.target.select(); |
| 1052 | }; | 1058 | }; |
| 1053 | 1059 | ||
| 1054 | function addArrayCabecera(array) { | 1060 | function addArrayCabecera(array) { |
| 1055 | for (var i = 0; i < array.length; i++) { | 1061 | for (var i = 0; i < array.length; i++) { |
| 1056 | $scope.$broadcast('addCabecera', { | 1062 | $scope.$broadcast('addCabecera', { |
| 1057 | label: array[i].label, | 1063 | label: array[i].label, |
| 1058 | valor: array[i].valor | 1064 | valor: array[i].valor |
| 1059 | }); | 1065 | }); |
| 1060 | } | 1066 | } |
| 1061 | } | 1067 | } |
| 1062 | 1068 | ||
| 1063 | function rellenar(relleno, longitud) { | 1069 | function rellenar(relleno, longitud) { |
| 1064 | relleno = '' + relleno; | 1070 | relleno = '' + relleno; |
| 1065 | while (relleno.length < longitud) { | 1071 | while (relleno.length < longitud) { |
| 1066 | relleno = '0' + relleno; | 1072 | relleno = '0' + relleno; |
| 1067 | } | 1073 | } |
| 1068 | return relleno; | 1074 | return relleno; |
| 1069 | } | 1075 | } |
| 1070 | 1076 | ||
| 1071 | function varlidarRemitoFacturado() { | 1077 | function varlidarRemitoFacturado() { |
| 1072 | if ($scope.remito.estado !== 5) { | 1078 | if ($scope.remito.estado !== 5) { |
| 1073 | return true; | 1079 | return true; |
| 1074 | } else { | 1080 | } else { |
| 1075 | focaModalService.alert('No se puede editar un remito facturado'); | 1081 | focaModalService.alert('No se puede editar un remito facturado'); |
| 1076 | return false; | 1082 | return false; |
| 1077 | } | 1083 | } |
| 1078 | } | 1084 | } |
| 1079 | 1085 | ||
| 1080 | function varlidarRemitoAbierto() { | 1086 | function varlidarRemitoAbierto() { |
| 1081 | if (!$scope.remito.hojaRuta) return true; | 1087 | if (!$scope.remito.hojaRuta) return true; |
| 1082 | if ($scope.remito.hojaRuta.abierta !== '1') { | 1088 | if ($scope.remito.hojaRuta.abierta !== '1') { |
| 1083 | return true; | 1089 | return true; |
| 1084 | } else { | 1090 | } else { |
| 1085 | focaModalService.alert('No se puede editar un remito abierto'); | 1091 | focaModalService.alert('No se puede editar un remito abierto'); |
| 1086 | return false; | 1092 | return false; |
| 1087 | } | 1093 | } |
| 1088 | } | 1094 | } |
| 1089 | 1095 | ||
| 1090 | function salir() { | 1096 | function salir() { |
| 1091 | var confirmacion = false; | 1097 | var confirmacion = false; |
| 1092 | 1098 | ||
| 1093 | if (!angular.equals($scope.remito, $scope.inicial)) { | 1099 | if (!angular.equals($scope.remito, $scope.inicial)) { |
| 1094 | confirmacion = true; | 1100 | confirmacion = true; |
| 1095 | } | 1101 | } |
| 1096 | 1102 | ||
| 1097 | if (confirmacion) { | 1103 | if (confirmacion) { |
| 1098 | focaModalService.confirm( | 1104 | focaModalService.confirm( |
| 1099 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' | 1105 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' |
| 1100 | ).then(function (data) { | 1106 | ).then(function (data) { |
| 1101 | if (data) { | 1107 | if (data) { |
| 1102 | $location.path('/'); | 1108 | $location.path('/'); |
| 1103 | } | 1109 | } |
| 1104 | }); | 1110 | }); |
| 1105 | } else { | 1111 | } else { |
| 1106 | $location.path('/'); | 1112 | $location.path('/'); |
| 1107 | } | 1113 | } |
| 1108 | } | 1114 | } |
| 1109 | 1115 | ||
| 1110 | function enableObservaciones(val) { | 1116 | function enableObservaciones(val) { |
| 1111 | var boton = $scope.botonera.filter(function (botonObs) { | 1117 | var boton = $scope.botonera.filter(function (botonObs) { |
| 1112 | return botonObs.label === 'Observaciones'; | 1118 | return botonObs.label === 'Observaciones'; |
| 1113 | }); | 1119 | }); |
| 1114 | boton[0].disable = !val; | 1120 | boton[0].disable = !val; |
| 1115 | } | 1121 | } |
| 1116 | 1122 | ||
| 1117 | function setearRemito(remito) { | 1123 | function setearRemito(remito) { |
| 1118 | //añado cabeceras | 1124 | //añado cabeceras |
| 1119 | console.log(remito); | 1125 | console.log(remito); |
| 1120 | var esAbierto = remito.hojaRuta ? | 1126 | var esAbierto = remito.hojaRuta ? |
| 1121 | (remito.hojaRuta.abierta === '1') : false; | 1127 | (remito.hojaRuta.abierta === '1') : false; |
| 1122 | if (remito.estado !== 5 && remito.id && !esAbierto) { | 1128 | if (remito.estado !== 5 && remito.id && !esAbierto) { |
| 1123 | 1129 | ||
| 1124 | $scope.botonera.forEach(function (boton) { | 1130 | $scope.botonera.forEach(function (boton) { |
| 1125 | 1131 | ||
| 1126 | if (boton.label === 'Eliminar Remito') { | 1132 | if (boton.label === 'Eliminar Remito') { |
| 1127 | boton.disable = false; | 1133 | boton.disable = false; |
| 1128 | } | 1134 | } |
| 1129 | }); | 1135 | }); |
| 1130 | } | 1136 | } |
| 1131 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 1137 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
| 1132 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 1138 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
| 1133 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 1139 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
| 1134 | $scope.$broadcast('removeCabecera', 'Vendedor:'); | 1140 | $scope.$broadcast('removeCabecera', 'Vendedor:'); |
| 1135 | 1141 | ||
| 1136 | $scope.cabeceras = []; | 1142 | $scope.cabeceras = []; |
| 1137 | 1143 | ||
| 1138 | if (remito.cotizacion && remito.cotizacion.moneda.CODIGO_AFIP !== 'PES') { | 1144 | if (remito.cotizacion && remito.cotizacion.moneda.CODIGO_AFIP !== 'PES') { |
| 1139 | $scope.cabeceras.push({ | 1145 | $scope.cabeceras.push({ |
| 1140 | label: 'Moneda:', | 1146 | label: 'Moneda:', |
| 1141 | valor: remito.cotizacion.moneda.DETALLE | 1147 | valor: remito.cotizacion.moneda.DETALLE |
| 1142 | }); | 1148 | }); |
| 1143 | $scope.cabeceras.push({ | 1149 | $scope.cabeceras.push({ |
| 1144 | label: 'Fecha cotizacion:', | 1150 | label: 'Fecha cotizacion:', |
| 1145 | valor: $filter('date')(remito.cotizacion.FECHA, | 1151 | valor: $filter('date')(remito.cotizacion.FECHA, |
| 1146 | 'dd/MM/yyyy') | 1152 | 'dd/MM/yyyy') |
| 1147 | }); | 1153 | }); |
| 1148 | $scope.cabeceras.push({ | 1154 | $scope.cabeceras.push({ |
| 1149 | label: 'Cotizacion:', | 1155 | label: 'Cotizacion:', |
| 1150 | valor: $filter('number')(remito.cotizacion.VENDEDOR, | 1156 | valor: $filter('number')(remito.cotizacion.VENDEDOR, |
| 1151 | '2') | 1157 | '2') |
| 1152 | }); | 1158 | }); |
| 1153 | } | 1159 | } |
| 1154 | 1160 | ||
| 1155 | if (remito.cotizacion && remito.cotizacion.moneda) { | 1161 | if (remito.cotizacion && remito.cotizacion.moneda) { |
| 1156 | $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true; | 1162 | $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true; |
| 1157 | } | 1163 | } |
| 1158 | 1164 | ||
| 1159 | if (remito.cliente && remito.cliente.COD) { | 1165 | if (remito.cliente && remito.cliente.COD) { |
| 1160 | $scope.cabeceras.push({ | 1166 | $scope.cabeceras.push({ |
| 1161 | label: 'Cliente:', | 1167 | label: 'Cliente:', |
| 1162 | valor: $filter('rellenarDigitos')(remito.cliente.COD, 3) + ' - ' + | 1168 | valor: $filter('rellenarDigitos')(remito.cliente.COD, 3) + ' - ' + |
| 1163 | remito.cliente.NOM | 1169 | remito.cliente.NOM |
| 1164 | }); | 1170 | }); |
| 1165 | $scope.cabeceras.push({ | 1171 | $scope.cabeceras.push({ |
| 1166 | label: 'Domicilio:', | 1172 | label: 'Domicilio:', |
| 1167 | valor: remito.domicilioStamp | 1173 | valor: remito.domicilioStamp |
| 1168 | }); | 1174 | }); |
| 1169 | 1175 | ||
| 1170 | $filter('filter')($scope.botonera, | 1176 | $filter('filter')($scope.botonera, |
| 1171 | { label: 'Domicilio de Entrega' })[0].checked = true; | 1177 | { label: 'Domicilio de Entrega' })[0].checked = true; |
| 1172 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; | 1178 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; |
| 1173 | } | 1179 | } |
| 1174 | if (remito.vendedor && remito.vendedor.NUM) { | 1180 | if (remito.vendedor && remito.vendedor.NUM) { |
| 1175 | $scope.cabeceras.push({ | 1181 | $scope.cabeceras.push({ |
| 1176 | label: 'Vendedor:', | 1182 | label: 'Vendedor:', |
| 1177 | valor: $filter('rellenarDigitos')(remito.vendedor.NUM, 3) + | 1183 | valor: $filter('rellenarDigitos')(remito.vendedor.NUM, 3) + |
| 1178 | ' - ' + remito.vendedor.NOM | 1184 | ' - ' + remito.vendedor.NOM |
| 1179 | }); | 1185 | }); |
| 1180 | } | 1186 | } |
| 1181 | if (remito.proveedor && remito.proveedor.COD) { | 1187 | if (remito.proveedor && remito.proveedor.COD) { |
| 1182 | $scope.cabeceras.push({ | 1188 | $scope.cabeceras.push({ |
| 1183 | label: 'Proveedor:', | 1189 | label: 'Proveedor:', |
| 1184 | valor: $filter('rellenarDigitos')(remito.proveedor.COD, 5) + | 1190 | valor: $filter('rellenarDigitos')(remito.proveedor.COD, 5) + |
| 1185 | ' - ' + remito.proveedor.NOM | 1191 | ' - ' + remito.proveedor.NOM |
| 1186 | }); | 1192 | }); |
| 1187 | 1193 | ||
| 1188 | $filter('filter')($scope.botonera, { label: 'Proveedor' })[0].checked = true; | 1194 | $filter('filter')($scope.botonera, { label: 'Proveedor' })[0].checked = true; |
| 1189 | } | 1195 | } |
| 1190 | if (remito.flete !== undefined && remito.fob !== undefined) { | 1196 | if (remito.flete !== undefined && remito.fob !== undefined) { |
| 1191 | $scope.cabeceras.push({ | 1197 | $scope.cabeceras.push({ |
| 1192 | label: 'Flete:', | 1198 | label: 'Flete:', |
| 1193 | valor: remito.fob ? 'FOB' : ( | 1199 | valor: remito.fob ? 'FOB' : ( |
| 1194 | remito.flete ? 'Si' : 'No') | 1200 | remito.flete ? 'Si' : 'No') |
| 1195 | }); | 1201 | }); |
| 1196 | } | 1202 | } |
| 1197 | if (remito.remitoPlazo) { | 1203 | if (remito.remitoPlazo) { |
| 1198 | valorPrecioCondicion(); | 1204 | valorPrecioCondicion(); |
| 1199 | $filter('filter')($scope.botonera, | 1205 | $filter('filter')($scope.botonera, |
| 1200 | { label: 'Precios y condiciones' })[0].checked = true; | 1206 | { label: 'Precios y condiciones' })[0].checked = true; |
| 1201 | } | 1207 | } |
| 1202 | 1208 | ||
| 1203 | function valorPrecioCondicion() { | 1209 | function valorPrecioCondicion() { |
| 1204 | if (parseInt(remito.idListaPrecio)) { | 1210 | if (parseInt(remito.idListaPrecio)) { |
| 1205 | crearRemitoService.getListaPrecioById(parseInt(remito.idListaPrecio)) | 1211 | crearRemitoService.getListaPrecioById(parseInt(remito.idListaPrecio)) |
| 1206 | .then(function (res) { | 1212 | .then(function (res) { |
| 1207 | $timeout(function () { | 1213 | $timeout(function () { |
| 1208 | $scope.cabeceras.push({ | 1214 | $scope.cabeceras.push({ |
| 1209 | label: 'Precios y Condiciones:', | 1215 | label: 'Precios y Condiciones:', |
| 1210 | valor: parseInt(res.data[0].ID) + ' - ' + | 1216 | valor: parseInt(res.data[0].ID) + ' - ' + |
| 1211 | res.data[0].DES + ' ' + | 1217 | res.data[0].DES + ' ' + |
| 1212 | remitoBusinessService | 1218 | remitoBusinessService |
| 1213 | .plazoToString(remito.remitoPlazo) | 1219 | .plazoToString(remito.remitoPlazo) |
| 1214 | }); | 1220 | }); |
| 1215 | addArrayCabecera($scope.cabeceras); | 1221 | addArrayCabecera($scope.cabeceras); |
| 1216 | }, true); | 1222 | }, true); |
| 1217 | 1223 | ||
| 1218 | }); | 1224 | }); |
| 1219 | $scope.idLista = parseInt(remito.idListaPrecio); | 1225 | $scope.idLista = parseInt(remito.idListaPrecio); |
| 1220 | } | 1226 | } |
| 1221 | } | 1227 | } |
| 1222 | 1228 | ||
| 1223 | if (remito.flete === 1) { | 1229 | if (remito.flete === 1) { |
| 1224 | var cabeceraBomba = { | 1230 | var cabeceraBomba = { |
| 1225 | label: 'Bomba', | 1231 | label: 'Bomba', |
| 1226 | valor: remito.bomba === 1 ? 'Si' : 'No' | 1232 | valor: remito.bomba === 1 ? 'Si' : 'No' |
| 1227 | }; | 1233 | }; |
| 1228 | if (remito.kilometros) { | 1234 | if (remito.kilometros) { |
| 1229 | var cabeceraKilometros = { | 1235 | var cabeceraKilometros = { |
| 1230 | label: 'Kilometros', | 1236 | label: 'Kilometros', |
| 1231 | valor: remito.kilometros | 1237 | valor: remito.kilometros |
| 1232 | }; | 1238 | }; |
| 1233 | $scope.cabeceras.push(cabeceraKilometros); | 1239 | $scope.cabeceras.push(cabeceraKilometros); |
| 1234 | } | 1240 | } |
| 1235 | $scope.cabeceras.push(cabeceraBomba); | 1241 | $scope.cabeceras.push(cabeceraBomba); |
| 1236 | } | 1242 | } |
| 1237 | 1243 | ||
| 1238 | if (remito.idPrecioCondicion > 0) { | 1244 | if (remito.idPrecioCondicion > 0) { |
| 1239 | $scope.idLista = remito.precioCondicion.idListaPrecio; | 1245 | $scope.idLista = remito.precioCondicion.idListaPrecio; |
| 1240 | } else if (remito.idPrecioCondicion) { | 1246 | } else if (remito.idPrecioCondicion) { |
| 1241 | $scope.idLista = -1; | 1247 | $scope.idLista = -1; |
| 1242 | } | 1248 | } |
| 1243 | $scope.puntoVenta = rellenar(remito.sucursal, 4); | 1249 | $scope.puntoVenta = rellenar(remito.sucursal, 4); |
| 1244 | $scope.comprobante = rellenar(remito.numeroRemito, 8); | 1250 | $scope.comprobante = rellenar(remito.numeroRemito, 8); |
| 1245 | $scope.remito = remito; | 1251 | $scope.remito = remito; |
| 1246 | if ($scope.remito.remitoPuntoDescarga.length) { | 1252 | if ($scope.remito.remitoPuntoDescarga.length) { |
| 1247 | var puntoDescarga = []; | 1253 | var puntoDescarga = []; |
| 1248 | 1254 | ||
| 1249 | $scope.remito.remitoPuntoDescarga.forEach(function (remitoPuntoDescarga) { | 1255 | $scope.remito.remitoPuntoDescarga.forEach(function (remitoPuntoDescarga) { |
| 1250 | puntoDescarga.push(remitoPuntoDescarga.puntoDescarga); | 1256 | puntoDescarga.push(remitoPuntoDescarga.puntoDescarga); |
| 1251 | }); | 1257 | }); |
| 1252 | 1258 | ||
| 1253 | $scope.cabeceras.push({ | 1259 | $scope.cabeceras.push({ |
| 1254 | label: 'Puntos de descarga: ', | 1260 | label: 'Puntos de descarga: ', |
| 1255 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntoDescarga)) | 1261 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntoDescarga)) |
| 1256 | }); | 1262 | }); |
| 1257 | } | 1263 | } |
| 1258 | $scope.remitoIsDirty = false; | 1264 | $scope.remitoIsDirty = false; |
| 1259 | 1265 | ||
| 1260 | 1266 | ||
| 1261 | addArrayCabecera($scope.cabeceras); | 1267 | addArrayCabecera($scope.cabeceras); |
| 1262 | } | 1268 | } |
| 1263 | 1269 | ||
| 1264 | function getLSRemito() { | 1270 | function getLSRemito() { |
| 1265 | var remito = JSON.parse($localStorage.remito || null); | 1271 | var remito = JSON.parse($localStorage.remito || null); |
| 1266 | if (remito) { | 1272 | if (remito) { |
| 1267 | setearRemito(remito); | 1273 | setearRemito(remito); |
| 1268 | delete $localStorage.remito; | 1274 | delete $localStorage.remito; |
| 1269 | } | 1275 | } |
| 1270 | } | 1276 | } |
| 1271 | 1277 | ||
| 1272 | function getCabeceraPuntoDescarga(puntosDescarga) { | 1278 | function getCabeceraPuntoDescarga(puntosDescarga) { |
| 1273 | var puntosStamp = ''; | 1279 | var puntosStamp = ''; |
| 1274 | puntosDescarga.forEach(function (punto, idx, arr) { | 1280 | puntosDescarga.forEach(function (punto, idx, arr) { |
| 1275 | puntosStamp += punto.descripcion; | 1281 | puntosStamp += punto.descripcion; |
| 1276 | if ((idx + 1) !== arr.length) puntosStamp += ', '; | 1282 | if ((idx + 1) !== arr.length) puntosStamp += ', '; |
| 1277 | }); | 1283 | }); |
| 1278 | return puntosStamp; | 1284 | return puntosStamp; |
| 1279 | } | 1285 | } |
| 1280 | 1286 | ||
| 1281 | function abrirModalMail(id, cliente, numeroRemito) { | 1287 | function abrirModalMail(id, cliente, numeroRemito) { |
| 1282 | focaModalService.mail( | 1288 | focaModalService.mail( |
| 1283 | { | 1289 | { |
| 1284 | titulo: 'Comprobante de remito Nº ' + numeroRemito, | 1290 | titulo: 'Comprobante de remito Nº ' + numeroRemito, |
| 1285 | descarga: { | 1291 | descarga: { |
| 1286 | nombre: numeroRemito + '.pdf', | 1292 | nombre: numeroRemito + '.pdf', |
| 1287 | url: '/remito/comprobante', | 1293 | url: '/remito/comprobante', |
| 1288 | }, | 1294 | }, |
| 1289 | envio: { | 1295 | envio: { |
| 1290 | mailCliente: cliente.MAIL, | 1296 | mailCliente: cliente.MAIL, |
| 1291 | url: '/remito/mail', | 1297 | url: '/remito/mail', |
| 1292 | }, | 1298 | }, |
| 1293 | options: { | 1299 | options: { |
| 1294 | idRemito: id | 1300 | idRemito: id |
| 1295 | } | 1301 | } |
| 1296 | } | 1302 | } |
| 1297 | ) | 1303 | ) |
| 1298 | .then(function (res) { | 1304 | .then(function (res) { |
| 1299 | if (res === false) { | 1305 | if (res === false) { |
| 1300 | abrirModalMail(id); | 1306 | abrirModalMail(id); |
| 1301 | focaModalService.alert('Descarga o envíe su remito ' + | 1307 | focaModalService.alert('Descarga o envíe su remito ' + |
| 1302 | 'antes de cerrar esta ventana'); | 1308 | 'antes de cerrar esta ventana'); |
| 1303 | } | 1309 | } |
| 1304 | }); | 1310 | }); |
| 1305 | } | 1311 | } |
| 1306 | //recibo la propiedad por la cual quiero obtener el valor | 1312 | //recibo la propiedad por la cual quiero obtener el valor |
| 1307 | function getImporte(propiedad) { | 1313 | function getImporte(propiedad) { |
| 1308 | var importe = 0; | 1314 | var importe = 0; |
src/js/service.js
| 1 | angular.module('focaCrearRemito') | 1 | angular.module('focaCrearRemito') |
| 2 | .service('crearRemitoService', ['$http', 'API_ENDPOINT', | 2 | .service('crearRemitoService', ['$http', 'API_ENDPOINT', |
| 3 | function($http, API_ENDPOINT) { | 3 | function($http, API_ENDPOINT) { |
| 4 | var route = API_ENDPOINT.URL; | 4 | var route = API_ENDPOINT.URL; |
| 5 | return { | 5 | return { |
| 6 | getVendedorById: function (idVendedor) { | 6 | getVendedorById: function (idVendedor) { |
| 7 | return $http.get(route + '/vendedor-cobrador/' + idVendedor); | 7 | return $http.get(route + '/vendedor-cobrador/' + idVendedor); |
| 8 | }, | 8 | }, |
| 9 | crearRemito: function(remito) { | 9 | crearRemito: function(remito) { |
| 10 | // TODO: Cambiar para usar el servicio /remito | 10 | // TODO: Cambiar para usar el servicio /remito |
| 11 | return $http.post(route + '/remito/guardar', remito); | 11 | return $http.post(route + '/remito/guardar', remito); |
| 12 | }, | 12 | }, |
| 13 | getRemitoById: function(id) { | 13 | getRemitoById: function(id) { |
| 14 | return $http.get(route + '/remito/obtener/' + id); | 14 | return $http.get(route + '/remito/obtener/' + id); |
| 15 | }, | 15 | }, |
| 16 | obtenerRemito: function() { | 16 | obtenerRemito: function() { |
| 17 | return $http.get(route +'/nota-pedido'); | 17 | return $http.get(route +'/nota-pedido'); |
| 18 | }, | 18 | }, |
| 19 | setRemito: function(remito) { | 19 | setRemito: function(remito) { |
| 20 | this.remito = remito; | 20 | this.remito = remito; |
| 21 | }, | 21 | }, |
| 22 | clearRemito: function() { | 22 | clearRemito: function() { |
| 23 | this.remito = undefined; | 23 | this.remito = undefined; |
| 24 | }, | 24 | }, |
| 25 | getRemito: function() { | 25 | getRemito: function() { |
| 26 | return this.remito; | 26 | return this.remito; |
| 27 | }, | 27 | }, |
| 28 | getArticulosByIdRemito: function(id) { | 28 | getArticulosByIdRemito: function(id) { |
| 29 | return $http.get(route+'/articulos/nota-pedido/'+id); | 29 | return $http.get(route+'/articulos/nota-pedido/'+id); |
| 30 | }, | 30 | }, |
| 31 | crearArticulosParaRemito: function(articuloRemito) { | 31 | crearArticulosParaRemito: function(articuloRemito) { |
| 32 | return $http.post(route + '/articulos/remito', | 32 | return $http.post(route + '/articulos/remito', |
| 33 | {articuloRemito: articuloRemito}); | 33 | {articuloRemito: articuloRemito}); |
| 34 | }, | 34 | }, |
| 35 | getProveedorById: function(id) { | 35 | getProveedorById: function(id) { |
| 36 | return $http.get(API_ENDPOINT.URL + '/proveedor/' + id); | 36 | return $http.get(API_ENDPOINT.URL + '/proveedor/' + id); |
| 37 | }, | 37 | }, |
| 38 | getDomiciliosByIdRemito: function(id) { | 38 | getDomiciliosByIdRemito: function(id) { |
| 39 | return $http.get(route +'/nota-pedido/'+id+'/domicilios'); | 39 | return $http.get(route +'/nota-pedido/'+id+'/domicilios'); |
| 40 | }, | 40 | }, |
| 41 | getDomiciliosByIdCliente: function(id) { | 41 | getDomiciliosByIdCliente: function(id) { |
| 42 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) | 42 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) |
| 43 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); | 43 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); |
| 44 | }, | 44 | }, |
| 45 | getPrecioCondicion: function() { | 45 | getPrecioCondicion: function() { |
| 46 | return $http.get(route + '/precio-condicion'); | 46 | return $http.get(route + '/precio-condicion'); |
| 47 | }, | 47 | }, |
| 48 | getPrecioCondicionById: function(id) { | 48 | getPrecioCondicionById: function(id) { |
| 49 | return $http.get(route + '/precio-condicion/' + id); | 49 | return $http.get(route + '/precio-condicion/' + id); |
| 50 | }, | 50 | }, |
| 51 | getListaPrecioById: function (id) { | 51 | getListaPrecioById: function (id) { |
| 52 | return $http.get(route + '/lista-precio/' + id); | 52 | return $http.get(route + '/lista-precio/' + id); |
| 53 | }, | 53 | }, |
| 54 | getPlazoPagoByPrecioCondicion: function(id) { | 54 | getPlazoPagoByPrecioCondicion: function(id) { |
| 55 | return $http.get(route + '/plazo-pago/precio-condicion/'+ id); | 55 | return $http.get(route + '/plazo-pago/precio-condicion/'+ id); |
| 56 | }, | 56 | }, |
| 57 | crearFlete: function(flete) { | 57 | crearFlete: function(flete) { |
| 58 | return $http.post(route + '/flete', {flete : flete}); | 58 | return $http.post(route + '/flete', {flete : flete}); |
| 59 | }, | 59 | }, |
| 60 | crearPlazosParaRemito: function(plazos) { | 60 | crearPlazosParaRemito: function(plazos) { |
| 61 | return $http.post(route + '/plazo-pago/remito', plazos); | 61 | return $http.post(route + '/plazo-pago/remito', plazos); |
| 62 | }, | 62 | }, |
| 63 | getCotizacionByIdMoneda: function(id) { | 63 | getCotizacionByIdMoneda: function(id) { |
| 64 | return $http.get(route + '/moneda/' + id); | 64 | return $http.get(route + '/moneda/' + id); |
| 65 | }, | 65 | }, |
| 66 | crearEstadoParaRemito: function(estado) { | 66 | crearEstadoParaRemito: function(estado) { |
| 67 | return $http.post(route + '/estado', {estado: estado}); | 67 | return $http.post(route + '/estado', {estado: estado}); |
| 68 | }, | 68 | }, |
| 69 | getNumeroRemito: function() { | 69 | getNumeroRemito: function(tipoComprobante) { |
| 70 | return $http.get(route + '/remito/numero-siguiente'); | 70 | |
| 71 | var tipo = tipoComprobante ? '/' + tipoComprobante : ''; | ||
| 72 | |||
| 73 | return $http.get(route + '/remito/numero-siguiente' + tipo); | ||
| 71 | }, | 74 | }, |
| 72 | imprimirRemitoByIdRemito: function(idRemito) { | 75 | imprimirRemitoByIdRemito: function(idRemito) { |
| 73 | return $http.get(route + '/remito/comprobante/' + idRemito , { | 76 | return $http.get(route + '/remito/comprobante/' + idRemito , { |
| 74 | responseType: 'arraybuffer' | 77 | responseType: 'arraybuffer' |
| 75 | }); | 78 | }); |
| 76 | }, | 79 | }, |
| 77 | getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { | 80 | getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { |
| 78 | return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + | 81 | return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + |
| 79 | idDomicilio + '/' + idCliente); | 82 | idDomicilio + '/' + idCliente); |
| 80 | }, | 83 | }, |
| 81 | enviarCorreo: function(options) { | 84 | enviarCorreo: function(options) { |
| 82 | return $http.post(API_ENDPOINT.URL + '/remito/mail', options); | 85 | return $http.post(API_ENDPOINT.URL + '/remito/mail', options); |
| 83 | }, | 86 | }, |
| 84 | getParametros: function() { | 87 | getParametros: function() { |
| 85 | return $http.get(API_ENDPOINT.URL + '/parametros/remito'); | 88 | return $http.get(API_ENDPOINT.URL + '/parametros/remito'); |
| 86 | }, | 89 | }, |
| 87 | crearPuntosDescarga: function(puntosDescarga) { | 90 | crearPuntosDescarga: function(puntosDescarga) { |
| 88 | return $http.post(route + '/puntos-descarga/remito', | 91 | return $http.post(route + '/puntos-descarga/remito', |
| 89 | {puntosDescarga: puntosDescarga}); | 92 | {puntosDescarga: puntosDescarga}); |
| 90 | }, | 93 | }, |
| 91 | getBotonera: function() { | 94 | getBotonera: function() { |
| 92 | return [ | 95 | return [ |
| 93 | { | 96 | { |
| 94 | label: 'Nota pedido', | 97 | label: 'Nota pedido', |
| 95 | image: 'notaDePedido.png' | 98 | image: 'notaDePedido.png' |
| 96 | }, | 99 | }, |
| 97 | { | 100 | { |
| 98 | label: 'Cliente', | 101 | label: 'Cliente', |
| 99 | image: 'cliente.png' | 102 | image: 'cliente.png' |
| 100 | }, | 103 | }, |
| 101 | { | 104 | { |
| 102 | label: 'Proveedor', | 105 | label: 'Proveedor', |
| 103 | image: 'proveedor.png' | 106 | image: 'proveedor.png' |
| 104 | }, | 107 | }, |
| 105 | { | 108 | { |
| 106 | label: 'Moneda', | 109 | label: 'Moneda', |
| 107 | image: 'moneda.png' | 110 | image: 'moneda.png' |
| 108 | }, | 111 | }, |
| 109 | { | 112 | { |
| 110 | label: 'Precios y condiciones', | 113 | label: 'Precios y condiciones', |
| 111 | image: 'precios-condiciones.png' | 114 | image: 'precios-condiciones.png' |
| 112 | }, | 115 | }, |
| 113 | { | 116 | { |
| 114 | label: 'Productos', | 117 | label: 'Productos', |
| 115 | image: 'productos.png' | 118 | image: 'productos.png' |
| 116 | }, | 119 | }, |
| 117 | { | 120 | { |
| 118 | label: 'Domicilio de Entrega', | 121 | label: 'Domicilio de Entrega', |
| 119 | image: 'domicilioDeEntrega.png' | 122 | image: 'domicilioDeEntrega.png' |
| 120 | }, | 123 | }, |
| 121 | { | 124 | { |
| 122 | label: 'Observaciones', | 125 | label: 'Observaciones', |
| 123 | image: 'botonObservaciones.png', | 126 | image: 'botonObservaciones.png', |
| 124 | disable: true | 127 | disable: true |
| 125 | }, | 128 | }, |
| 126 | { | 129 | { |
| 127 | label: 'Eliminar Remito', | 130 | label: 'Eliminar Remito', |
| 128 | image: 'eliminarRemito.png', | 131 | image: 'eliminarRemito.png', |
| 129 | disable: true | 132 | disable: true |
| 130 | } | 133 | } |
| 131 | ]; | 134 | ]; |
| 132 | }, | 135 | }, |
| 133 | eliminarRemito: function (remito) { | 136 | eliminarRemito: function (remito) { |
| 134 | return $http.delete(API_ENDPOINT.URL + '/remito/anular/' + remito.id); | 137 | return $http.delete(API_ENDPOINT.URL + '/remito/anular/' + remito.id); |
| 135 | } | 138 | } |
| 136 | }; | 139 | }; |
| 137 | }]); | 140 | }]); |
| 138 | 141 |
src/views/remito.html
| 1 | <div class="crear-nota-remito foca-crear row"> | 1 | <div class="crear-nota-remito foca-crear row"> |
| 2 | <foca-cabecera-facturador | 2 | <foca-cabecera-facturador |
| 3 | titulo="'Remito'" | 3 | titulo="'Remito'" |
| 4 | numero="puntoVenta + '-' + comprobante" | 4 | numero="puntoVenta + '-' + comprobante" |
| 5 | fecha="now" | 5 | fecha="now" |
| 6 | class="mb-0 col-lg-12" | 6 | class="mb-0 col-lg-12" |
| 7 | busqueda="seleccionarRemito" | 7 | busqueda="seleccionarRemito" |
| 8 | ></foca-cabecera-facturador> | 8 | ></foca-cabecera-facturador> |
| 9 | <marquee | 9 | <marquee |
| 10 | bgcolor="#FF9900" | 10 | bgcolor="#FF9900" |
| 11 | behavior="scroll" | 11 | behavior="scroll" |
| 12 | direction="left" | 12 | direction="left" |
| 13 | ng-bind="remito.observaciones" | 13 | ng-bind="remito.observaciones" |
| 14 | ></marquee> | 14 | ></marquee> |
| 15 | <div class="col-lg-12"> | 15 | <div class="col-lg-12"> |
| 16 | <div class="row mt-4"> | 16 | <div class="row mt-4"> |
| 17 | <div class="col-12 col-md-10 col-lg-10 border border-light rounded"> | 17 | <div class="col-12 col-md-10 col-lg-10 border border-light rounded"> |
| 18 | <div class="row p-1 botonera-secundaria px-5 py-2"> | 18 | <div class="row p-1 botonera-secundaria px-5 py-2"> |
| 19 | <div class="col-12"> | 19 | <div class="col-12"> |
| 20 | <foca-botonera-facturador botones="botonera" extra="4" class="row"></foca-botonera-facturador> | 20 | <foca-botonera-facturador botones="botonera" extra="4" class="row"></foca-botonera-facturador> |
| 21 | </div> | 21 | </div> |
| 22 | </div> | 22 | </div> |
| 23 | <!-- PC --> | 23 | <!-- PC --> |
| 24 | <div class="row grilla-articulo align-items-end d-none d-sm-flex"> | 24 | <div class="row grilla-articulo align-items-end d-none d-sm-flex"> |
| 25 | <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> | 25 | <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> |
| 26 | <thead> | 26 | <thead> |
| 27 | <tr class="d-flex"> | 27 | <tr class="d-flex"> |
| 28 | <th class="">#</th> | 28 | <th class="">#</th> |
| 29 | <th class="col">Código</th> | 29 | <th class="col">Código</th> |
| 30 | <th class="col-4">Descripción</th> | 30 | <th class="col-4">Descripción</th> |
| 31 | <th class="col text-right">Cantidad</th> | 31 | <th class="col text-right">Cantidad</th> |
| 32 | <th class="col text-right">Precio Unitario</th> | 32 | <th class="col text-right">Precio Unitario</th> |
| 33 | <th class="col text-right">SubTotal</th> | 33 | <th class="col text-right">SubTotal</th> |
| 34 | <th class="text-right"> | 34 | <th class="text-right"> |
| 35 | <button | 35 | <button |
| 36 | class="btn btn-outline-light selectable" | 36 | class="btn btn-outline-light selectable" |
| 37 | ng-click="show = !show; masMenos()" | 37 | ng-click="show = !show; masMenos()" |
| 38 | > | 38 | > |
| 39 | <i | 39 | <i |
| 40 | class="fa fa-chevron-down" | 40 | class="fa fa-chevron-down" |
| 41 | ng-show="show" | 41 | ng-show="show" |
| 42 | aria-hidden="true" | 42 | aria-hidden="true" |
| 43 | > | 43 | > |
| 44 | </i> | 44 | </i> |
| 45 | <i | 45 | <i |
| 46 | class="fa fa-chevron-up" | 46 | class="fa fa-chevron-up" |
| 47 | ng-hide="show" | 47 | ng-hide="show" |
| 48 | aria-hidden="true"> | 48 | aria-hidden="true"> |
| 49 | </i> | 49 | </i> |
| 50 | </button> | 50 | </button> |
| 51 | </th> | 51 | </th> |
| 52 | </tr> | 52 | </tr> |
| 53 | </thead> | 53 | </thead> |
| 54 | <tbody class="tabla-articulo-body"> | 54 | <tbody class="tabla-articulo-body"> |
| 55 | <tr | 55 | <tr |
| 56 | ng-repeat="(key, articulo) in articulosFiltro()" | 56 | ng-repeat="(key, articulo) in articulosFiltro()" |
| 57 | ng-show="show || key == (articulosFiltro().length - 1)" | 57 | ng-show="show || key == (articulosFiltro().length - 1)" |
| 58 | class="d-flex" | 58 | class="d-flex" |
| 59 | > | 59 | > |
| 60 | <td ng-bind="key + 1"></td> | 60 | <td ng-bind="key + 1"></td> |
| 61 | <td | 61 | <td |
| 62 | class="col" | 62 | class="col" |
| 63 | ng-bind="articulo.sector + '-' + articulo.codigo" | 63 | ng-bind="articulo.sector + '-' + articulo.codigo" |
| 64 | ></td> | 64 | ></td> |
| 65 | <td | 65 | <td |
| 66 | class="col-4" | 66 | class="col-4" |
| 67 | ng-bind="articulo.descripcion" | 67 | ng-bind="articulo.descripcion" |
| 68 | ></td> | 68 | ></td> |
| 69 | <td class="col text-right"> | 69 | <td class="col text-right"> |
| 70 | <input | 70 | <input |
| 71 | ng-show="articulo.editCantidad && remito.estado !== 5 && remito.hojaRuta.abierta !== '1'" | 71 | ng-show="articulo.editCantidad && remito.estado !== 5 && remito.hojaRuta.abierta !== '1'" |
| 72 | ng-model="tmpCantidad" | 72 | ng-model="tmpCantidad" |
| 73 | class="form-control" | 73 | class="form-control" |
| 74 | foca-tipo-input | 74 | foca-tipo-input |
| 75 | min="1" | 75 | min="1" |
| 76 | foca-focus="articulo.editCantidad" | 76 | foca-focus="articulo.editCantidad" |
| 77 | ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" | 77 | ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" |
| 78 | esc-key="cancelarEditar(articulo)" | 78 | esc-key="cancelarEditar(articulo)" |
| 79 | ng-focus="selectFocus($event); tmpCantidad = articulo.cantidad; tmpPrecio = articulo.precio" | 79 | ng-focus="selectFocus($event); tmpCantidad = articulo.cantidad; tmpPrecio = articulo.precio" |
| 80 | teclado-virtual | 80 | teclado-virtual |
| 81 | > | 81 | > |
| 82 | <i | 82 | <i |
| 83 | class="selectable" | 83 | class="selectable" |
| 84 | ng-click="cambioEdit(articulo, 'cantidad')" | 84 | ng-click="cambioEdit(articulo, 'cantidad')" |
| 85 | ng-hide="articulo.editCantidad && remito.estado !== 5 && remito.hojaRuta.abierta !== '1'" | 85 | ng-hide="articulo.editCantidad && remito.estado !== 5 && remito.hojaRuta.abierta !== '1'" |
| 86 | ng-bind="articulo.cantidad"> | 86 | ng-bind="articulo.cantidad"> |
| 87 | </i> | 87 | </i> |
| 88 | </td> | 88 | </td> |
| 89 | <td class="col text-right"> | 89 | <td class="col text-right"> |
| 90 | <input | 90 | <input |
| 91 | ng-show="articulo.editPrecio && remito.estado !== 5 && remito.hojaRuta.abierta !== '1'" | 91 | ng-show="articulo.editPrecio && remito.estado !== 5 && remito.hojaRuta.abierta !== '1'" |
| 92 | ng-model="tmpPrecio" | 92 | ng-model="tmpPrecio" |
| 93 | class="form-control" | 93 | class="form-control" |
| 94 | foca-tipo-input | 94 | foca-tipo-input |
| 95 | min="1" | 95 | min="1" |
| 96 | step="0.0001" | 96 | step="0.0001" |
| 97 | foca-focus="articulo.editPrecio" | 97 | foca-focus="articulo.editPrecio" |
| 98 | ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" | 98 | ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" |
| 99 | esc-key="cancelarEditar(articulo)" | 99 | esc-key="cancelarEditar(articulo)" |
| 100 | ng-focus="selectFocus($event); | 100 | ng-focus="selectFocus($event); |
| 101 | tmpCantidad = articulo.cantidad; | 101 | tmpCantidad = articulo.cantidad; |
| 102 | tmpPrecio = articulo.precio" | 102 | tmpPrecio = articulo.precio" |
| 103 | teclado-virtual | 103 | teclado-virtual |
| 104 | > | 104 | > |
| 105 | <i | 105 | <i |
| 106 | class="selectable" | 106 | class="selectable" |
| 107 | ng-click="cambioEdit(articulo, 'precio')" | 107 | ng-click="cambioEdit(articulo, 'precio')" |
| 108 | ng-hide="articulo.editPrecio && remito.estado !== 5 && remito.hojaRuta.abierta !== '1'" | 108 | ng-hide="articulo.editPrecio && remito.estado !== 5 && remito.hojaRuta.abierta !== '1'" |
| 109 | ng-bind="articulo.precio | number: 4"> | 109 | ng-bind="articulo.precio | number: 4"> |
| 110 | </i> | 110 | </i> |
| 111 | </td> | 111 | </td> |
| 112 | <td | 112 | <td |
| 113 | class="col text-right" | 113 | class="col text-right" |
| 114 | ng-bind="(articulo.precio * articulo.cantidad) | number: 2"> | 114 | ng-bind="(articulo.precio * articulo.cantidad) | number: 2"> |
| 115 | </td> | 115 | </td> |
| 116 | <td class="text-center"> | 116 | <td class="text-center"> |
| 117 | <button | 117 | <button |
| 118 | ng-show="remito.estado !== 5 && remito.hojaRuta.abierta !== '1'" | 118 | ng-show="remito.estado !== 5 && remito.hojaRuta.abierta !== '1'" |
| 119 | class="btn btn-outline-light" | 119 | class="btn btn-outline-light" |
| 120 | ng-click="quitarArticulo(articulo)" | 120 | ng-click="quitarArticulo(articulo)" |
| 121 | > | 121 | > |
| 122 | <i class="fa fa-trash"></i> | 122 | <i class="fa fa-trash"></i> |
| 123 | </button> | 123 | </button> |
| 124 | <button | 124 | <button |
| 125 | ng-show="remito.estado !== 5 && remito.hojaRuta.abierta !== '1'" | 125 | ng-show="(articulo.editCantidad || articulo.editPrecio) && |
| 126 | (remito.estado !== 5 && remito.hojaRuta.abierta !== '1')" | ||
| 126 | class="btn btn-outline-light" | 127 | class="btn btn-outline-light" |
| 127 | ng-click="editarArticulo(13, articulo, tmpCantidad, tmpPrecio);" | 128 | ng-click="editarArticulo(13, articulo, tmpCantidad, tmpPrecio);" |
| 128 | ng-show="articulo.editCantidad || articulo.editPrecio" | ||
| 129 | > | 129 | > |
| 130 | <i class="fa fa-save"></i> | 130 | <i class="fa fa-save"></i> |
| 131 | </button> | 131 | </button> |
| 132 | </td> | 132 | </td> |
| 133 | </tr> | 133 | </tr> |
| 134 | </tbody> | 134 | </tbody> |
| 135 | <tfoot> | 135 | <tfoot> |
| 136 | <tr ng-show="!cargando" class="d-flex"> | 136 | <tr ng-show="!cargando" class="d-flex"> |
| 137 | <td | 137 | <td |
| 138 | class="align-middle" | 138 | class="align-middle" |
| 139 | ng-bind="articulosFiltro().length + 1" | 139 | ng-bind="articulosFiltro().length + 1" |
| 140 | ></td> | 140 | ></td> |
| 141 | <td class="col"> | 141 | <td class="col"> |
| 142 | <input | 142 | <input |
| 143 | class="form-control" | 143 | class="form-control" |
| 144 | ng-model="articuloACargar.sectorCodigo" | 144 | ng-model="articuloACargar.sectorCodigo" |
| 145 | readonly | 145 | readonly |
| 146 | > | 146 | > |
| 147 | </td> | 147 | </td> |
| 148 | <td class="col-4 tabla-articulo-descripcion"> | 148 | <td class="col-4 tabla-articulo-descripcion"> |
| 149 | <input | 149 | <input |
| 150 | class="form-control" | 150 | class="form-control" |
| 151 | ng-model="articuloACargar.descripcion" | 151 | ng-model="articuloACargar.descripcion" |
| 152 | readonly | 152 | readonly |
| 153 | > | 153 | > |
| 154 | </td> | 154 | </td> |
| 155 | <td class="col text-right"> | 155 | <td class="col text-right"> |
| 156 | <input | 156 | <input |
| 157 | class="form-control" | 157 | class="form-control" |
| 158 | foca-tipo-input | 158 | foca-tipo-input |
| 159 | min="1" | 159 | min="1" |
| 160 | ng-model="articuloACargar.cantidad" | 160 | ng-model="articuloACargar.cantidad" |
| 161 | foca-focus="!cargando" | 161 | foca-focus="!cargando" |
| 162 | esc-key="resetFilter()" | 162 | esc-key="resetFilter()" |
| 163 | ng-keypress="agregarATabla($event.keyCode)" | 163 | ng-keypress="agregarATabla($event.keyCode)" |
| 164 | teclado-virtual | 164 | teclado-virtual |
| 165 | > | 165 | > |
| 166 | </td> | 166 | </td> |
| 167 | <td class="col text-right"> | 167 | <td class="col text-right"> |
| 168 | <input | 168 | <input |
| 169 | class="form-control" | 169 | class="form-control" |
| 170 | ng-model="articuloACargar.precio" | 170 | ng-model="articuloACargar.precio" |
| 171 | ng-show="idLista != -1" | 171 | ng-show="idLista != -1" |
| 172 | ng-keypress="agregarATabla($event.keyCode)" | 172 | ng-keypress="agregarATabla($event.keyCode)" |
| 173 | > | 173 | > |
| 174 | <input | 174 | <input |
| 175 | class="form-control" | 175 | class="form-control" |
| 176 | foca-tipo-input | 176 | foca-tipo-input |
| 177 | step="0.0001" | 177 | step="0.0001" |
| 178 | ng-model="articuloACargar.precio" | 178 | ng-model="articuloACargar.precio" |
| 179 | esc-key="resetFilter()" | 179 | esc-key="resetFilter()" |
| 180 | ng-keypress="agregarATabla($event.keyCode)" | 180 | ng-keypress="agregarATabla($event.keyCode)" |
| 181 | ng-show="idLista == -1" | 181 | ng-show="idLista == -1" |
| 182 | teclado-virtual | 182 | teclado-virtual |
| 183 | > | 183 | > |
| 184 | </td> | 184 | </td> |
| 185 | <td class="col text-right"> | 185 | <td class="col text-right"> |
| 186 | <input | 186 | <input |
| 187 | class="form-control" | 187 | class="form-control" |
| 188 | ng-value="getSubTotal() | number: 2" | 188 | ng-value="getSubTotal() | number: 2" |
| 189 | readonly | 189 | readonly |
| 190 | ></td> | 190 | ></td> |
| 191 | <td class="text-center align-middle"> | 191 | <td class="text-center align-middle"> |
| 192 | <button | 192 | <button |
| 193 | class="btn btn-outline-light" | 193 | class="btn btn-outline-light" |
| 194 | ng-click="agregarATabla(13)" | 194 | ng-click="agregarATabla(13)" |
| 195 | > | 195 | > |
| 196 | <i class="fa fa-save"></i> | 196 | <i class="fa fa-save"></i> |
| 197 | </button> | 197 | </button> |
| 198 | </td> | 198 | </td> |
| 199 | </tr> | 199 | </tr> |
| 200 | 200 | ||
| 201 | <tr class="d-flex"> | 201 | <tr class="d-flex"> |
| 202 | <td colspan="4" class="no-border-top"> | 202 | <td colspan="4" class="no-border-top"> |
| 203 | <strong>Items:</strong> | 203 | <strong>Items:</strong> |
| 204 | <a ng-bind="articulosFiltro().length"></a> | 204 | <a ng-bind="articulosFiltro().length"></a> |
| 205 | </td> | 205 | </td> |
| 206 | <td class="text-right ml-auto table-celda-total no-border-top"> | 206 | <td class="text-right ml-auto table-celda-total no-border-top"> |
| 207 | <h3>Total:</h3> | 207 | <h3>Total:</h3> |
| 208 | </td> | 208 | </td> |
| 209 | <td class="table-celda-total text-right no-border-top" colspan="1"> | 209 | <td class="table-celda-total text-right no-border-top" colspan="1"> |
| 210 | <h3>{{getTotal() | currency: remito.cotizacion.moneda.SIMBOLO}}</h3> | 210 | <h3>{{getTotal() | currency: remito.cotizacion.moneda.SIMBOLO}}</h3> |
| 211 | </td> | 211 | </td> |
| 212 | <td class="text-right text-dark no-border-top"> | 212 | <td class="text-right text-dark no-border-top"> |
| 213 | <span>Totales</span> | 213 | <span>Totales</span> |
| 214 | </td> | 214 | </td> |
| 215 | </tr> | 215 | </tr> |
| 216 | </tfoot> | 216 | </tfoot> |
| 217 | </table> | 217 | </table> |
| 218 | </div> | 218 | </div> |
| 219 | </div> | 219 | </div> |
| 220 | </div> | 220 | </div> |
| 221 | </div> | 221 | </div> |
| 222 | <div class="row d-md-none fixed-bottom"> | 222 | <div class="row d-md-none fixed-bottom"> |
| 223 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> | 223 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> |
| 224 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> | 224 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> |
| 225 | <span | 225 | <span |
| 226 | class="mr-3 ml-auto" | 226 | class="mr-3 ml-auto" |
| 227 | ng-class="saveLoading ? 'text-muted' : ''" | 227 | ng-class="saveLoading ? 'text-muted' : ''" |
| 228 | ng-click="crearRemito()" | 228 | ng-click="crearRemito()" |
| 229 | ladda="saveLoading" | 229 | ladda="saveLoading" |
| 230 | data-style="expand-left" | 230 | data-style="expand-left" |
| 231 | >Guardar</span> | 231 | >Guardar</span> |
| 232 | </div> | 232 | </div> |
| 233 | </div> | 233 | </div> |
| 234 | </div> | 234 | </div> |