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