Commit 55f6418a6b124a8a569f4d46cab95fd1c1ac534d
1 parent
f9733a66b2
Exists in
master
code review
Showing
2 changed files
with
2 additions
and
2 deletions
Show diff stats
index.html
1 | <html ng-app="focaCrearRemito"> | 1 | <html ng-app="focaCrearRemito"> |
2 | <head> | 2 | <head> |
3 | <meta charset="UTF-8"/> | 3 | <meta charset="UTF-8"/> |
4 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | 4 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
5 | 5 | ||
6 | <!--CSS--> | 6 | <!--CSS--> |
7 | <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/> | 7 | <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/> |
8 | <link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet"/> | 8 | <link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet"/> |
9 | <link href="node_modules/ladda/dist/ladda-themeless.min.css" rel="stylesheet"> | 9 | <link href="node_modules/ladda/dist/ladda-themeless.min.css" rel="stylesheet"> |
10 | 10 | ||
11 | <!--VENDOR JS--> | 11 | <!--VENDOR JS--> |
12 | <script src="node_modules/jquery/dist/jquery.min.js"></script> | 12 | <script src="node_modules/jquery/dist/jquery.min.js"></script> |
13 | <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> | 13 | <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> |
14 | <script src="node_modules/angular/angular.min.js"></script> | 14 | <script src="node_modules/angular/angular.min.js"></script> |
15 | <script src="node_modules/angular-route/angular-route.min.js"></script> | 15 | <script src="node_modules/angular-route/angular-route.min.js"></script> |
16 | <script src="node_modules/angular-cookies/angular-cookies.min.js"></script> | 16 | <script src="node_modules/angular-cookies/angular-cookies.min.js"></script> |
17 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> | 17 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> |
18 | <script src="node_modules/ladda/dist/spin.min.js"></script> | 18 | <script src="node_modules/ladda/dist/spin.min.js"></script> |
19 | <script src="node_modules/ladda/dist/ladda.min.js"></script> | 19 | <script src="node_modules/ladda/dist/ladda.min.js"></script> |
20 | <script src="node_modules/angular-ladda/dist/angular-ladda.min.js"></script> | 20 | <script src="node_modules/angular-ladda/dist/angular-ladda.min.js"></script> |
21 | <script src="vendor/cordovaGeolocationModule.min.js"></script> | 21 | <script src="vendor/cordovaGeolocationModule.min.js"></script> |
22 | 22 | ||
23 | <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script> | 23 | <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script> |
24 | <script src="node_modules/foca-modal-vendedores/dist/foca-modal-vendedores.min.js"></script> | 24 | <script src="node_modules/foca-modal-vendedores/dist/foca-modal-vendedores.min.js"></script> |
25 | <script src="node_modules/foca-modal-busqueda-productos/dist/foca-busqueda-productos.min.js"></script> | 25 | <script src="node_modules/foca-modal-busqueda-productos/dist/foca-busqueda-productos.min.js"></script> |
26 | <script src="node_modules/foca-modal-proveedor/dist/foca-modal-proveedor.min.js"></script> | 26 | <script src="node_modules/foca-modal-proveedor/dist/foca-modal-proveedor.min.js"></script> |
27 | <script src="node_modules/foca-busqueda-cliente/dist/foca-busqueda-cliente.min.js"></script> | 27 | <script src="node_modules/foca-busqueda-cliente/dist/foca-busqueda-cliente.min.js"></script> |
28 | <script src="node_modules/foca-modal-precio-condiciones/dist/foca-modal-precio-condiciones.min.js"></script> | 28 | <script src="node_modules/foca-modal-precio-condiciones/dist/foca-modal-precio-condiciones.min.js"></script> |
29 | <script src="node_modules/foca-modal-flete/dist/foca-modal-flete.min.js"></script> | 29 | <script src="node_modules/foca-modal-flete/dist/foca-modal-flete.min.js"></script> |
30 | <script src="node_modules/foca-modal/dist/foca-modal.min.js"></script> | 30 | <script src="node_modules/foca-modal/dist/foca-modal.min.js"></script> |
31 | <script src="node_modules/foca-modal-domicilio/dist/foca-modal-domicilios.min.js"></script> | 31 | <script src="node_modules/foca-modal-domicilio/dist/foca-modal-domicilios.min.js"></script> |
32 | <script src="./node_modules/foca-configuracion/dist/foca-configuracion.min.js"></script> | 32 | <script src="./node_modules/foca-configuracion/dist/foca-configuracion.min.js"></script> |
33 | <script src="node_modules/foca-modal-moneda/dist/foca-modal-moneda.min.js"></script> | 33 | <script src="node_modules/foca-modal-moneda/dist/foca-modal-moneda.min.js"></script> |
34 | <script src="node_modules/foca-modal-cotizacion/dist/foca-modal-cotizacion.min.js"></script> | 34 | <script src="node_modules/foca-modal-cotizacion/dist/foca-modal-cotizacion.min.js"></script> |
35 | <script src="node_modules/foca-seguimiento/dist/foca-seguimiento.min.js"></script> | 35 | <script src="node_modules/foca-seguimiento/dist/foca-seguimiento.min.js"></script> |
36 | <script src="../foca-modal-nota-pedido/dist/foca-modal-nota-pedido.min.js"></script> | 36 | <script src="node_modules/foca-modal-nota-pedido/dist/foca-modal-nota-pedido.min.js"></script> |
37 | 37 | ||
38 | <script src="src/js/app.js"></script> | 38 | <script src="src/js/app.js"></script> |
39 | <script src="src/js/controller.js"></script> | 39 | <script src="src/js/controller.js"></script> |
40 | <script src="src/js/service.js"></script> | 40 | <script src="src/js/service.js"></script> |
41 | <script src="src/js/businessService.js"></script> | 41 | <script src="src/js/businessService.js"></script> |
42 | <script src="src/js/route.js"></script> | 42 | <script src="src/js/route.js"></script> |
43 | 43 | ||
44 | <script src="src/etc/develop.js"></script> | 44 | <script src="src/etc/develop.js"></script> |
45 | </head> | 45 | </head> |
46 | <body> | 46 | <body> |
47 | <div ng-view class="container-fluid"></div> | 47 | <div ng-view class="container-fluid"></div> |
48 | </body> | 48 | </body> |
49 | </html> | 49 | </html> |
50 | 50 |
src/js/controller.js
1 | angular.module('focaCrearRemito') .controller('remitoController', | 1 | angular.module('focaCrearRemito') .controller('remitoController', |
2 | [ | 2 | [ |
3 | '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', | 3 | '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', |
4 | 'focaModalService', 'remitoBusinessService', | 4 | 'focaModalService', 'remitoBusinessService', |
5 | function( | 5 | function( |
6 | $scope, $uibModal, $location, $filter, crearRemitoService, focaModalService, | 6 | $scope, $uibModal, $location, $filter, crearRemitoService, focaModalService, |
7 | remitoBusinessService | 7 | remitoBusinessService |
8 | ) { | 8 | ) { |
9 | $scope.botonera = [ | 9 | $scope.botonera = [ |
10 | {texto: 'Nota Pedido', accion: function() {$scope.seleccionarNotaPedido();}}, | 10 | {texto: 'Nota Pedido', accion: function() {$scope.seleccionarNotaPedido();}}, |
11 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, | 11 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, |
12 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, | 12 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, |
13 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, | 13 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, |
14 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, | 14 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, |
15 | { | 15 | { |
16 | texto: 'Precios y condiciones', | 16 | texto: 'Precios y condiciones', |
17 | accion: function() {$scope.abrirModalListaPrecio();}}, | 17 | accion: function() {$scope.abrirModalListaPrecio();}}, |
18 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, | 18 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, |
19 | {texto: '', accion: function() {}} | 19 | {texto: '', accion: function() {}} |
20 | ]; | 20 | ]; |
21 | $scope.datepickerAbierto = false; | 21 | $scope.datepickerAbierto = false; |
22 | 22 | ||
23 | $scope.show = false; | 23 | $scope.show = false; |
24 | $scope.cargando = true; | 24 | $scope.cargando = true; |
25 | $scope.dateOptions = { | 25 | $scope.dateOptions = { |
26 | maxDate: new Date(), | 26 | maxDate: new Date(), |
27 | minDate: new Date(2010, 0, 1) | 27 | minDate: new Date(2010, 0, 1) |
28 | }; | 28 | }; |
29 | 29 | ||
30 | $scope.remito = { | 30 | $scope.remito = { |
31 | vendedor: {}, | 31 | vendedor: {}, |
32 | cliente: {}, | 32 | cliente: {}, |
33 | proveedor: {}, | 33 | proveedor: {}, |
34 | domicilio: {dom: ''}, | 34 | domicilio: {dom: ''}, |
35 | moneda: {}, | 35 | moneda: {}, |
36 | cotizacion: {} | 36 | cotizacion: {} |
37 | }; | 37 | }; |
38 | var monedaPorDefecto; | 38 | var monedaPorDefecto; |
39 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 39 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
40 | crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) { | 40 | crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) { |
41 | monedaPorDefecto = { | 41 | monedaPorDefecto = { |
42 | id: res.data[0].ID, | 42 | id: res.data[0].ID, |
43 | detalle: res.data[0].DETALLE, | 43 | detalle: res.data[0].DETALLE, |
44 | simbolo: res.data[0].SIMBOLO, | 44 | simbolo: res.data[0].SIMBOLO, |
45 | cotizaciones: res.data[0].cotizaciones | 45 | cotizaciones: res.data[0].cotizaciones |
46 | }; | 46 | }; |
47 | addCabecera('Moneda:', monedaPorDefecto.detalle); | 47 | addCabecera('Moneda:', monedaPorDefecto.detalle); |
48 | addCabecera('Fecha cotizacion:', | 48 | addCabecera('Fecha cotizacion:', |
49 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); | 49 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); |
50 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); | 50 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); |
51 | $scope.remito.moneda = monedaPorDefecto; | 51 | $scope.remito.moneda = monedaPorDefecto; |
52 | $scope.remito.cotizacion = monedaPorDefecto.cotizaciones[0]; | 52 | $scope.remito.cotizacion = monedaPorDefecto.cotizaciones[0]; |
53 | }); | 53 | }); |
54 | 54 | ||
55 | $scope.cabecera = []; | 55 | $scope.cabecera = []; |
56 | $scope.showCabecera = true; | 56 | $scope.showCabecera = true; |
57 | 57 | ||
58 | $scope.now = new Date(); | 58 | $scope.now = new Date(); |
59 | $scope.puntoVenta = Math.round(Math.random() * 10000); | 59 | $scope.puntoVenta = Math.round(Math.random() * 10000); |
60 | $scope.comprobante = Math.round(Math.random() * 1000000); | 60 | $scope.comprobante = Math.round(Math.random() * 1000000); |
61 | 61 | ||
62 | $scope.articulosTabla = []; | 62 | $scope.articulosTabla = []; |
63 | $scope.idLista = undefined; | 63 | $scope.idLista = undefined; |
64 | //La pantalla solo se usa para cargar remitos | 64 | //La pantalla solo se usa para cargar remitos |
65 | //var remitoTemp = crearRemitoService.getRemito(); | 65 | //var remitoTemp = crearRemitoService.getRemito(); |
66 | 66 | ||
67 | crearRemitoService.getPrecioCondicion().then( | 67 | crearRemitoService.getPrecioCondicion().then( |
68 | function(res) { | 68 | function(res) { |
69 | $scope.precioCondiciones = res.data; | 69 | $scope.precioCondiciones = res.data; |
70 | } | 70 | } |
71 | ); | 71 | ); |
72 | 72 | ||
73 | crearRemitoService.getNumeroRemito().then( | 73 | crearRemitoService.getNumeroRemito().then( |
74 | function(res) { | 74 | function(res) { |
75 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 75 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
76 | $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); | 76 | $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); |
77 | }, | 77 | }, |
78 | function(err) { | 78 | function(err) { |
79 | focaModalService.alert('La terminal no esta configurada correctamente'); | 79 | focaModalService.alert('La terminal no esta configurada correctamente'); |
80 | console.info(err); | 80 | console.info(err); |
81 | } | 81 | } |
82 | ); | 82 | ); |
83 | 83 | ||
84 | $scope.seleccionarNotaPedido = function() { | 84 | $scope.seleccionarNotaPedido = function() { |
85 | var modalInstance = $uibModal.open( | 85 | var modalInstance = $uibModal.open( |
86 | { | 86 | { |
87 | ariaLabelledBy: 'Busqueda de Nota de Pedido', | 87 | ariaLabelledBy: 'Busqueda de Nota de Pedido', |
88 | templateUrl: 'foca-modal-nota-pedido.html', | 88 | templateUrl: 'foca-modal-nota-pedido.html', |
89 | controller: 'focaModalNotaPedidoController', | 89 | controller: 'focaModalNotaPedidoController', |
90 | size: 'lg' | 90 | size: 'lg' |
91 | } | 91 | } |
92 | ); | 92 | ); |
93 | modalInstance.result.then( | 93 | modalInstance.result.then( |
94 | function(notaPedido) { | 94 | function(notaPedido) { |
95 | //añado cabeceras | 95 | //añado cabeceras |
96 | removeCabecera('Moneda:'); | 96 | removeCabecera('Moneda:'); |
97 | removeCabecera('Fecha cotizacion:'); | 97 | removeCabecera('Fecha cotizacion:'); |
98 | removeCabecera('Cotizacion:'); | 98 | removeCabecera('Cotizacion:'); |
99 | var cabeceras = [ | 99 | var cabeceras = [ |
100 | { | 100 | { |
101 | label: 'Moneda', | 101 | label: 'Moneda', |
102 | valor: notaPedido.cotizacion[0].moneda[0].DETALLE | 102 | valor: notaPedido.cotizacion[0].moneda[0].DETALLE |
103 | }, | 103 | }, |
104 | { | 104 | { |
105 | label: 'Fecha cotizacion', | 105 | label: 'Fecha cotizacion', |
106 | valor: $filter('date')(notaPedido.cotizacion[0].FECHA, | 106 | valor: $filter('date')(notaPedido.cotizacion[0].FECHA, |
107 | 'dd/MM/yyyy') | 107 | 'dd/MM/yyyy') |
108 | }, | 108 | }, |
109 | { | 109 | { |
110 | label: 'Cotizacion', | 110 | label: 'Cotizacion', |
111 | valor: notaPedido.cotizacion[0].VENDEDOR | 111 | valor: notaPedido.cotizacion[0].VENDEDOR |
112 | }, | 112 | }, |
113 | { | 113 | { |
114 | label: 'Cliente:', | 114 | label: 'Cliente:', |
115 | valor: notaPedido.cliente[0].NOM | 115 | valor: notaPedido.cliente[0].NOM |
116 | }, | 116 | }, |
117 | { | 117 | { |
118 | label: 'Vendedor:', | 118 | label: 'Vendedor:', |
119 | valor: notaPedido.vendedor[0].NomVen | 119 | valor: notaPedido.vendedor[0].NomVen |
120 | }, | 120 | }, |
121 | { | 121 | { |
122 | label: 'Proveedor:', | 122 | label: 'Proveedor:', |
123 | valor: notaPedido.proveedor[0].NOM | 123 | valor: notaPedido.proveedor[0].NOM |
124 | }, | 124 | }, |
125 | { | 125 | { |
126 | label: 'Flete:', | 126 | label: 'Flete:', |
127 | valor: notaPedido.flete === 1 ? 'Si' : 'No' | 127 | valor: notaPedido.flete === 1 ? 'Si' : 'No' |
128 | }, | 128 | }, |
129 | { | 129 | { |
130 | label: 'FOB:', | 130 | label: 'FOB:', |
131 | valor: notaPedido.fob === 1 ? 'Si' : 'No' | 131 | valor: notaPedido.fob === 1 ? 'Si' : 'No' |
132 | }, | 132 | }, |
133 | { | 133 | { |
134 | label: 'Precio condicion:', | 134 | label: 'Precio condicion:', |
135 | valor: valorPrecioCondicion() | 135 | valor: valorPrecioCondicion() |
136 | } | 136 | } |
137 | ]; | 137 | ]; |
138 | //TO DO CUANDO MOSTRAR PLAZOS | 138 | //TO DO CUANDO MOSTRAR PLAZOS |
139 | function valorPrecioCondicion() { | 139 | function valorPrecioCondicion() { |
140 | if(notaPedido.idPrecioCondicion > 0) { | 140 | if(notaPedido.idPrecioCondicion > 0) { |
141 | return notaPedido.precioCondicion[0].nombre; | 141 | return notaPedido.precioCondicion[0].nombre; |
142 | } else { | 142 | } else { |
143 | return 'Ingreso Manual'; | 143 | return 'Ingreso Manual'; |
144 | } | 144 | } |
145 | 145 | ||
146 | } | 146 | } |
147 | 147 | ||
148 | if(notaPedido.flete === 1) { | 148 | if(notaPedido.flete === 1) { |
149 | var cabeceraBomba = { | 149 | var cabeceraBomba = { |
150 | label: 'Bomba', | 150 | label: 'Bomba', |
151 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' | 151 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' |
152 | }; | 152 | }; |
153 | if(notaPedido.kilometros){ | 153 | if(notaPedido.kilometros) { |
154 | var cabeceraKilometros = { | 154 | var cabeceraKilometros = { |
155 | label: 'Kilometros', | 155 | label: 'Kilometros', |
156 | valor: notaPedido.kilometros | 156 | valor: notaPedido.kilometros |
157 | }; | 157 | }; |
158 | cabeceras.push(cabeceraKilometros); | 158 | cabeceras.push(cabeceraKilometros); |
159 | } | 159 | } |
160 | cabeceras.push(cabeceraBomba); | 160 | cabeceras.push(cabeceraBomba); |
161 | } | 161 | } |
162 | $scope.articulosTabla = notaPedido.articulosNotaPedido; | 162 | $scope.articulosTabla = notaPedido.articulosNotaPedido; |
163 | $scope.remito = notaPedido; | 163 | $scope.remito = notaPedido; |
164 | addArrayCabecera(cabeceras); | 164 | addArrayCabecera(cabeceras); |
165 | 165 | ||
166 | }, function() { | 166 | }, function() { |
167 | // funcion ejecutada cuando se cancela el modal | 167 | // funcion ejecutada cuando se cancela el modal |
168 | } | 168 | } |
169 | ); | 169 | ); |
170 | }; | 170 | }; |
171 | 171 | ||
172 | $scope.seleccionarRemito = function() { | 172 | $scope.seleccionarRemito = function() { |
173 | var modalInstance = $uibModal.open( | 173 | var modalInstance = $uibModal.open( |
174 | { | 174 | { |
175 | ariaLabelledBy: 'Busqueda de Remito', | 175 | ariaLabelledBy: 'Busqueda de Remito', |
176 | templateUrl: 'foca-modal-remito.html', | 176 | templateUrl: 'foca-modal-remito.html', |
177 | controller: 'focaModalRemitoController', | 177 | controller: 'focaModalRemitoController', |
178 | size: 'lg' | 178 | size: 'lg' |
179 | } | 179 | } |
180 | ); | 180 | ); |
181 | modalInstance.result.then( | 181 | modalInstance.result.then( |
182 | function() { | 182 | function() { |
183 | // TODO: Implementar carga remito | 183 | // TODO: Implementar carga remito |
184 | }, function() { | 184 | }, function() { |
185 | // funcion ejecutada cuando se cancela el modal | 185 | // funcion ejecutada cuando se cancela el modal |
186 | } | 186 | } |
187 | ); | 187 | ); |
188 | }; | 188 | }; |
189 | 189 | ||
190 | //La pantalla solo se usa para cargar remitos | 190 | //La pantalla solo se usa para cargar remitos |
191 | // if (remitoTemp !== undefined) { | 191 | // if (remitoTemp !== undefined) { |
192 | // remitoTemp.fechaCarga = new Date(remitoTemp.fechaCarga); | 192 | // remitoTemp.fechaCarga = new Date(remitoTemp.fechaCarga); |
193 | // $scope.remito = remitoTemp; | 193 | // $scope.remito = remitoTemp; |
194 | // $scope.remito.flete = ($scope.remito.flete).toString(); | 194 | // $scope.remito.flete = ($scope.remito.flete).toString(); |
195 | // $scope.remito.bomba = ($scope.remito.bomba).toString(); | 195 | // $scope.remito.bomba = ($scope.remito.bomba).toString(); |
196 | // $scope.idLista = $scope.remito.precioCondicion; | 196 | // $scope.idLista = $scope.remito.precioCondicion; |
197 | // crearRemitoService | 197 | // crearRemitoService |
198 | // .getArticulosByIdRemito($scope.remito.id).then( | 198 | // .getArticulosByIdRemito($scope.remito.id).then( |
199 | // function(res) { | 199 | // function(res) { |
200 | // $scope.articulosTabla = res.data; | 200 | // $scope.articulosTabla = res.data; |
201 | // } | 201 | // } |
202 | // ); | 202 | // ); |
203 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR REMITO | 203 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR REMITO |
204 | //(NO REQUERIDO EN ESTA VERSION) | 204 | //(NO REQUERIDO EN ESTA VERSION) |
205 | // crearRemitoService.getDomiciliosByIdRemito($scope.remito.id).then( | 205 | // crearRemitoService.getDomiciliosByIdRemito($scope.remito.id).then( |
206 | // function(res) { | 206 | // function(res) { |
207 | // $scope.remito.domicilio = res.data; | 207 | // $scope.remito.domicilio = res.data; |
208 | // } | 208 | // } |
209 | // ); | 209 | // ); |
210 | // } else { | 210 | // } else { |
211 | // $scope.remito.fechaCarga = new Date(); | 211 | // $scope.remito.fechaCarga = new Date(); |
212 | // $scope.remito.bomba = '0'; | 212 | // $scope.remito.bomba = '0'; |
213 | // $scope.remito.flete = '0'; | 213 | // $scope.remito.flete = '0'; |
214 | // $scope.idLista = undefined; | 214 | // $scope.idLista = undefined; |
215 | // } | 215 | // } |
216 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | 216 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
217 | // $scope.addNewDom = function() { | 217 | // $scope.addNewDom = function() { |
218 | // $scope.remito.domicilio.push({ 'id': 0 }); | 218 | // $scope.remito.domicilio.push({ 'id': 0 }); |
219 | // }; | 219 | // }; |
220 | // $scope.removeNewChoice = function(choice) { | 220 | // $scope.removeNewChoice = function(choice) { |
221 | // if ($scope.remito.domicilio.length > 1) { | 221 | // if ($scope.remito.domicilio.length > 1) { |
222 | // $scope.remito.domicilio.splice($scope.remito.domicilio.findIndex( | 222 | // $scope.remito.domicilio.splice($scope.remito.domicilio.findIndex( |
223 | // function(c) { | 223 | // function(c) { |
224 | // return c.$$hashKey === choice.$$hashKey; | 224 | // return c.$$hashKey === choice.$$hashKey; |
225 | // } | 225 | // } |
226 | // ), 1); | 226 | // ), 1); |
227 | // } | 227 | // } |
228 | // }; | 228 | // }; |
229 | 229 | ||
230 | $scope.crearRemito = function() { | 230 | $scope.crearRemito = function() { |
231 | if(!$scope.remito.vendedor.codigo) { | 231 | if(!$scope.remito.vendedor.codigo) { |
232 | focaModalService.alert('Ingrese Vendedor'); | 232 | focaModalService.alert('Ingrese Vendedor'); |
233 | return; | 233 | return; |
234 | } else if(!$scope.remito.cliente.cod) { | 234 | } else if(!$scope.remito.cliente.cod) { |
235 | focaModalService.alert('Ingrese Cliente'); | 235 | focaModalService.alert('Ingrese Cliente'); |
236 | return; | 236 | return; |
237 | } else if(!$scope.remito.proveedor.codigo) { | 237 | } else if(!$scope.remito.proveedor.codigo) { |
238 | focaModalService.alert('Ingrese Proveedor'); | 238 | focaModalService.alert('Ingrese Proveedor'); |
239 | return; | 239 | return; |
240 | } else if(!$scope.remito.moneda.id) { | 240 | } else if(!$scope.remito.moneda.id) { |
241 | focaModalService.alert('Ingrese Moneda'); | 241 | focaModalService.alert('Ingrese Moneda'); |
242 | return; | 242 | return; |
243 | } else if(!$scope.remito.cotizacion.ID) { | 243 | } else if(!$scope.remito.cotizacion.ID) { |
244 | focaModalService.alert('Ingrese Cotización'); | 244 | focaModalService.alert('Ingrese Cotización'); |
245 | return; | 245 | return; |
246 | } else if(!$scope.plazosPagos) { | 246 | } else if(!$scope.plazosPagos) { |
247 | focaModalService.alert('Ingrese Precios y Condiciones'); | 247 | focaModalService.alert('Ingrese Precios y Condiciones'); |
248 | return; | 248 | return; |
249 | } else if( | 249 | } else if( |
250 | $scope.remito.flete === undefined || $scope.remito.flete === null) | 250 | $scope.remito.flete === undefined || $scope.remito.flete === null) |
251 | { | 251 | { |
252 | focaModalService.alert('Ingrese Flete'); | 252 | focaModalService.alert('Ingrese Flete'); |
253 | return; | 253 | return; |
254 | } else if(!$scope.remito.domicilio.id) { | 254 | } else if(!$scope.remito.domicilio.id) { |
255 | focaModalService.alert('Ingrese Domicilio'); | 255 | focaModalService.alert('Ingrese Domicilio'); |
256 | return; | 256 | return; |
257 | } else if($scope.articulosTabla.length === 0) { | 257 | } else if($scope.articulosTabla.length === 0) { |
258 | focaModalService.alert('Debe cargar al menos un articulo'); | 258 | focaModalService.alert('Debe cargar al menos un articulo'); |
259 | return; | 259 | return; |
260 | } | 260 | } |
261 | var date = new Date(); | 261 | var date = new Date(); |
262 | var remito = { | 262 | var remito = { |
263 | id: 0, | 263 | id: 0, |
264 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 264 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
265 | .toISOString().slice(0, 19).replace('T', ' '), | 265 | .toISOString().slice(0, 19).replace('T', ' '), |
266 | idVendedor: $scope.remito.vendedor.codigo, | 266 | idVendedor: $scope.remito.vendedor.codigo, |
267 | idCliente: $scope.remito.cliente.cod, | 267 | idCliente: $scope.remito.cliente.cod, |
268 | nombreCliente: $scope.remito.cliente.nom, | 268 | nombreCliente: $scope.remito.cliente.nom, |
269 | cuitCliente: $scope.remito.cliente.cuit, | 269 | cuitCliente: $scope.remito.cliente.cuit, |
270 | idProveedor: $scope.remito.proveedor.codigo, | 270 | idProveedor: $scope.remito.proveedor.codigo, |
271 | idDomicilio: $scope.remito.domicilio.id, | 271 | idDomicilio: $scope.remito.domicilio.id, |
272 | idCotizacion: $scope.remito.cotizacion.ID, | 272 | idCotizacion: $scope.remito.cotizacion.ID, |
273 | cotizacion: $scope.remito.cotizacion.COTIZACION, | 273 | cotizacion: $scope.remito.cotizacion.COTIZACION, |
274 | flete: $scope.remito.flete, | 274 | flete: $scope.remito.flete, |
275 | fob: $scope.remito.fob, | 275 | fob: $scope.remito.fob, |
276 | bomba: $scope.remito.bomba, | 276 | bomba: $scope.remito.bomba, |
277 | kilometros: $scope.remito.kilometros, | 277 | kilometros: $scope.remito.kilometros, |
278 | estado: 0, | 278 | estado: 0, |
279 | total: $scope.getTotal() | 279 | total: $scope.getTotal() |
280 | }; | 280 | }; |
281 | crearRemitoService.crearRemito(remito).then( | 281 | crearRemitoService.crearRemito(remito).then( |
282 | function(data) { | 282 | function(data) { |
283 | remitoBusinessService.addArticulos($scope.articulosTabla, | 283 | remitoBusinessService.addArticulos($scope.articulosTabla, |
284 | data.data.id, $scope.remito.cotizacion.COTIZACION); | 284 | data.data.id, $scope.remito.cotizacion.COTIZACION); |
285 | var plazos = $scope.plazosPagos; | 285 | var plazos = $scope.plazosPagos; |
286 | for(var j = 0; j < plazos.length; j++) { | 286 | for(var j = 0; j < plazos.length; j++) { |
287 | var json = { | 287 | var json = { |
288 | idRemito: data.data.id, | 288 | idRemito: data.data.id, |
289 | dias: plazos[j].dias | 289 | dias: plazos[j].dias |
290 | }; | 290 | }; |
291 | crearRemitoService.crearPlazosParaRemito(json); | 291 | crearRemitoService.crearPlazosParaRemito(json); |
292 | } | 292 | } |
293 | remitoBusinessService.addEstado(data.data.id, | 293 | remitoBusinessService.addEstado(data.data.id, |
294 | $scope.remito.vendedor.codigo); | 294 | $scope.remito.vendedor.codigo); |
295 | 295 | ||
296 | focaModalService.alert('Nota remito creada'); | 296 | focaModalService.alert('Nota remito creada'); |
297 | $scope.cabecera = []; | 297 | $scope.cabecera = []; |
298 | addCabecera('Moneda:', $scope.remito.moneda.detalle); | 298 | addCabecera('Moneda:', $scope.remito.moneda.detalle); |
299 | addCabecera( | 299 | addCabecera( |
300 | 'Fecha cotizacion:', | 300 | 'Fecha cotizacion:', |
301 | $filter('date')($scope.remito.cotizacion.FECHA, 'dd/MM/yyyy') | 301 | $filter('date')($scope.remito.cotizacion.FECHA, 'dd/MM/yyyy') |
302 | ); | 302 | ); |
303 | addCabecera('Cotizacion:', $scope.remito.cotizacion.COTIZACION); | 303 | addCabecera('Cotizacion:', $scope.remito.cotizacion.COTIZACION); |
304 | $scope.remito.vendedor = {}; | 304 | $scope.remito.vendedor = {}; |
305 | $scope.remito.cliente = {}; | 305 | $scope.remito.cliente = {}; |
306 | $scope.remito.proveedor = {}; | 306 | $scope.remito.proveedor = {}; |
307 | $scope.remito.domicilio = {}; | 307 | $scope.remito.domicilio = {}; |
308 | $scope.remito.flete = null; | 308 | $scope.remito.flete = null; |
309 | $scope.remito.fob = null; | 309 | $scope.remito.fob = null; |
310 | $scope.remito.bomba = null; | 310 | $scope.remito.bomba = null; |
311 | $scope.remito.kilometros = null; | 311 | $scope.remito.kilometros = null; |
312 | $scope.articulosTabla = []; | 312 | $scope.articulosTabla = []; |
313 | } | 313 | } |
314 | ); | 314 | ); |
315 | }; | 315 | }; |
316 | 316 | ||
317 | $scope.seleccionarArticulo = function() { | 317 | $scope.seleccionarArticulo = function() { |
318 | if ($scope.idLista === undefined) { | 318 | if ($scope.idLista === undefined) { |
319 | focaModalService.alert( | 319 | focaModalService.alert( |
320 | 'Primero seleccione una lista de precio y condicion'); | 320 | 'Primero seleccione una lista de precio y condicion'); |
321 | return; | 321 | return; |
322 | } | 322 | } |
323 | var modalInstance = $uibModal.open( | 323 | var modalInstance = $uibModal.open( |
324 | { | 324 | { |
325 | ariaLabelledBy: 'Busqueda de Productos', | 325 | ariaLabelledBy: 'Busqueda de Productos', |
326 | templateUrl: 'modal-busqueda-productos.html', | 326 | templateUrl: 'modal-busqueda-productos.html', |
327 | controller: 'modalBusquedaProductosCtrl', | 327 | controller: 'modalBusquedaProductosCtrl', |
328 | resolve: { | 328 | resolve: { |
329 | parametroProducto: { | 329 | parametroProducto: { |
330 | idLista: $scope.idLista, | 330 | idLista: $scope.idLista, |
331 | cotizacion: $scope.remito.cotizacion.COTIZACION, | 331 | cotizacion: $scope.remito.cotizacion.COTIZACION, |
332 | simbolo: $scope.remito.moneda.simbolo | 332 | simbolo: $scope.remito.moneda.simbolo |
333 | } | 333 | } |
334 | }, | 334 | }, |
335 | size: 'lg' | 335 | size: 'lg' |
336 | } | 336 | } |
337 | ); | 337 | ); |
338 | modalInstance.result.then( | 338 | modalInstance.result.then( |
339 | function(producto) { | 339 | function(producto) { |
340 | var newArt = | 340 | var newArt = |
341 | { | 341 | { |
342 | id: 0, | 342 | id: 0, |
343 | codigo: producto.codigo, | 343 | codigo: producto.codigo, |
344 | sector: producto.sector, | 344 | sector: producto.sector, |
345 | sectorCodigo: producto.sector + '-' + producto.codigo, | 345 | sectorCodigo: producto.sector + '-' + producto.codigo, |
346 | descripcion: producto.descripcion, | 346 | descripcion: producto.descripcion, |
347 | item: $scope.articulosTabla.length + 1, | 347 | item: $scope.articulosTabla.length + 1, |
348 | nombre: producto.descripcion, | 348 | nombre: producto.descripcion, |
349 | precio: parseFloat(producto.precio.toFixed(4)), | 349 | precio: parseFloat(producto.precio.toFixed(4)), |
350 | costoUnitario: producto.costo, | 350 | costoUnitario: producto.costo, |
351 | editCantidad: false, | 351 | editCantidad: false, |
352 | editPrecio: false | 352 | editPrecio: false |
353 | }; | 353 | }; |
354 | $scope.articuloACargar = newArt; | 354 | $scope.articuloACargar = newArt; |
355 | $scope.cargando = false; | 355 | $scope.cargando = false; |
356 | }, function() { | 356 | }, function() { |
357 | // funcion ejecutada cuando se cancela el modal | 357 | // funcion ejecutada cuando se cancela el modal |
358 | } | 358 | } |
359 | ); | 359 | ); |
360 | }; | 360 | }; |
361 | 361 | ||
362 | $scope.seleccionarVendedor = function() { | 362 | $scope.seleccionarVendedor = function() { |
363 | var modalInstance = $uibModal.open( | 363 | var modalInstance = $uibModal.open( |
364 | { | 364 | { |
365 | ariaLabelledBy: 'Busqueda de Vendedores', | 365 | ariaLabelledBy: 'Busqueda de Vendedores', |
366 | templateUrl: 'modal-vendedores.html', | 366 | templateUrl: 'modal-vendedores.html', |
367 | controller: 'modalVendedoresCtrl', | 367 | controller: 'modalVendedoresCtrl', |
368 | size: 'lg' | 368 | size: 'lg' |
369 | } | 369 | } |
370 | ); | 370 | ); |
371 | modalInstance.result.then( | 371 | modalInstance.result.then( |
372 | function(vendedor) { | 372 | function(vendedor) { |
373 | addCabecera('Vendedor:', vendedor.NomVen); | 373 | addCabecera('Vendedor:', vendedor.NomVen); |
374 | $scope.remito.vendedor.codigo = vendedor.CodVen; | 374 | $scope.remito.vendedor.codigo = vendedor.CodVen; |
375 | }, function() { | 375 | }, function() { |
376 | 376 | ||
377 | } | 377 | } |
378 | ); | 378 | ); |
379 | }; | 379 | }; |
380 | 380 | ||
381 | $scope.seleccionarProveedor = function() { | 381 | $scope.seleccionarProveedor = function() { |
382 | var modalInstance = $uibModal.open( | 382 | var modalInstance = $uibModal.open( |
383 | { | 383 | { |
384 | ariaLabelledBy: 'Busqueda de Proveedor', | 384 | ariaLabelledBy: 'Busqueda de Proveedor', |
385 | templateUrl: 'modal-proveedor.html', | 385 | templateUrl: 'modal-proveedor.html', |
386 | controller: 'focaModalProveedorCtrl', | 386 | controller: 'focaModalProveedorCtrl', |
387 | size: 'lg' | 387 | size: 'lg' |
388 | } | 388 | } |
389 | ); | 389 | ); |
390 | modalInstance.result.then( | 390 | modalInstance.result.then( |
391 | function(proveedor) { | 391 | function(proveedor) { |
392 | $scope.remito.proveedor.codigo = proveedor.COD; | 392 | $scope.remito.proveedor.codigo = proveedor.COD; |
393 | addCabecera('Proveedor:', proveedor.NOM); | 393 | addCabecera('Proveedor:', proveedor.NOM); |
394 | }, function() { | 394 | }, function() { |
395 | 395 | ||
396 | } | 396 | } |
397 | ); | 397 | ); |
398 | }; | 398 | }; |
399 | 399 | ||
400 | $scope.seleccionarCliente = function() { | 400 | $scope.seleccionarCliente = function() { |
401 | 401 | ||
402 | var modalInstance = $uibModal.open( | 402 | var modalInstance = $uibModal.open( |
403 | { | 403 | { |
404 | ariaLabelledBy: 'Busqueda de Cliente', | 404 | ariaLabelledBy: 'Busqueda de Cliente', |
405 | templateUrl: 'foca-busqueda-cliente-modal.html', | 405 | templateUrl: 'foca-busqueda-cliente-modal.html', |
406 | controller: 'focaBusquedaClienteModalController', | 406 | controller: 'focaBusquedaClienteModalController', |
407 | size: 'lg' | 407 | size: 'lg' |
408 | } | 408 | } |
409 | ); | 409 | ); |
410 | modalInstance.result.then( | 410 | modalInstance.result.then( |
411 | function(cliente) { | 411 | function(cliente) { |
412 | $scope.abrirModalDomicilios(cliente); | 412 | $scope.abrirModalDomicilios(cliente); |
413 | }, function() { | 413 | }, function() { |
414 | 414 | ||
415 | } | 415 | } |
416 | ); | 416 | ); |
417 | }; | 417 | }; |
418 | 418 | ||
419 | $scope.abrirModalDomicilios = function(cliente) { | 419 | $scope.abrirModalDomicilios = function(cliente) { |
420 | var modalInstanceDomicilio = $uibModal.open( | 420 | var modalInstanceDomicilio = $uibModal.open( |
421 | { | 421 | { |
422 | ariaLabelledBy: 'Busqueda de Domicilios', | 422 | ariaLabelledBy: 'Busqueda de Domicilios', |
423 | templateUrl: 'modal-domicilio.html', | 423 | templateUrl: 'modal-domicilio.html', |
424 | controller: 'focaModalDomicilioController', | 424 | controller: 'focaModalDomicilioController', |
425 | resolve: { idCliente: function() { return cliente.cod; }}, | 425 | resolve: { idCliente: function() { return cliente.cod; }}, |
426 | size: 'lg', | 426 | size: 'lg', |
427 | } | 427 | } |
428 | ); | 428 | ); |
429 | modalInstanceDomicilio.result.then( | 429 | modalInstanceDomicilio.result.then( |
430 | function(domicilio) { | 430 | function(domicilio) { |
431 | $scope.remito.domicilio.id = domicilio.nivel2; | 431 | $scope.remito.domicilio.id = domicilio.nivel2; |
432 | $scope.remito.cliente = cliente; | 432 | $scope.remito.cliente = cliente; |
433 | 433 | ||
434 | addCabecera('Cliente:', cliente.nom); | 434 | addCabecera('Cliente:', cliente.nom); |
435 | addCabecera('Domicilio:', domicilio.dom); | 435 | addCabecera('Domicilio:', domicilio.dom); |
436 | }, function() { | 436 | }, function() { |
437 | $scope.seleccionarCliente(); | 437 | $scope.seleccionarCliente(); |
438 | return; | 438 | return; |
439 | } | 439 | } |
440 | ); | 440 | ); |
441 | }; | 441 | }; |
442 | 442 | ||
443 | $scope.mostrarFichaCliente = function() { | 443 | $scope.mostrarFichaCliente = function() { |
444 | $uibModal.open( | 444 | $uibModal.open( |
445 | { | 445 | { |
446 | ariaLabelledBy: 'Datos del Cliente', | 446 | ariaLabelledBy: 'Datos del Cliente', |
447 | templateUrl: 'foca-crear-remito-ficha-cliente.html', | 447 | templateUrl: 'foca-crear-remito-ficha-cliente.html', |
448 | controller: 'focaCrearRemitoFichaClienteController', | 448 | controller: 'focaCrearRemitoFichaClienteController', |
449 | size: 'lg' | 449 | size: 'lg' |
450 | } | 450 | } |
451 | ); | 451 | ); |
452 | }; | 452 | }; |
453 | 453 | ||
454 | $scope.getTotal = function() { | 454 | $scope.getTotal = function() { |
455 | var total = 0; | 455 | var total = 0; |
456 | var arrayTempArticulos = $scope.articulosTabla; | 456 | var arrayTempArticulos = $scope.articulosTabla; |
457 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 457 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
458 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 458 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
459 | } | 459 | } |
460 | return parseFloat(total.toFixed(2)); | 460 | return parseFloat(total.toFixed(2)); |
461 | }; | 461 | }; |
462 | 462 | ||
463 | $scope.getSubTotal = function() { | 463 | $scope.getSubTotal = function() { |
464 | if($scope.articuloACargar) { | 464 | if($scope.articuloACargar) { |
465 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 465 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
466 | } | 466 | } |
467 | }; | 467 | }; |
468 | 468 | ||
469 | $scope.abrirModalListaPrecio = function() { | 469 | $scope.abrirModalListaPrecio = function() { |
470 | var modalInstance = $uibModal.open( | 470 | var modalInstance = $uibModal.open( |
471 | { | 471 | { |
472 | ariaLabelledBy: 'Busqueda de Precio Condición', | 472 | ariaLabelledBy: 'Busqueda de Precio Condición', |
473 | templateUrl: 'modal-precio-condicion.html', | 473 | templateUrl: 'modal-precio-condicion.html', |
474 | controller: 'focaModalPrecioCondicionController', | 474 | controller: 'focaModalPrecioCondicionController', |
475 | size: 'lg' | 475 | size: 'lg' |
476 | } | 476 | } |
477 | ); | 477 | ); |
478 | modalInstance.result.then( | 478 | modalInstance.result.then( |
479 | function(precioCondicion) { | 479 | function(precioCondicion) { |
480 | var cabecera = ''; | 480 | var cabecera = ''; |
481 | var plazosConcat = ''; | 481 | var plazosConcat = ''; |
482 | if(!Array.isArray(precioCondicion)) { | 482 | if(!Array.isArray(precioCondicion)) { |
483 | $scope.plazosPagos = precioCondicion.plazoPago; | 483 | $scope.plazosPagos = precioCondicion.plazoPago; |
484 | $scope.idLista = precioCondicion.idListaPrecio; | 484 | $scope.idLista = precioCondicion.idListaPrecio; |
485 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 485 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
486 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 486 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
487 | } | 487 | } |
488 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | 488 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); |
489 | } else { //Cuando se ingresan los plazos manualmente | 489 | } else { //Cuando se ingresan los plazos manualmente |
490 | $scope.idLista = -1; //-1, el modal productos busca todos los productos | 490 | $scope.idLista = -1; //-1, el modal productos busca todos los productos |
491 | $scope.plazosPagos = precioCondicion; | 491 | $scope.plazosPagos = precioCondicion; |
492 | for(var j = 0; j < precioCondicion.length; j++) { | 492 | for(var j = 0; j < precioCondicion.length; j++) { |
493 | plazosConcat += precioCondicion[j].dias + ' '; | 493 | plazosConcat += precioCondicion[j].dias + ' '; |
494 | } | 494 | } |
495 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 495 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
496 | } | 496 | } |
497 | $scope.articulosTabla = []; | 497 | $scope.articulosTabla = []; |
498 | addCabecera('Precios y condiciones:', cabecera); | 498 | addCabecera('Precios y condiciones:', cabecera); |
499 | }, function() { | 499 | }, function() { |
500 | 500 | ||
501 | } | 501 | } |
502 | ); | 502 | ); |
503 | }; | 503 | }; |
504 | 504 | ||
505 | $scope.abrirModalFlete = function() { | 505 | $scope.abrirModalFlete = function() { |
506 | var modalInstance = $uibModal.open( | 506 | var modalInstance = $uibModal.open( |
507 | { | 507 | { |
508 | ariaLabelledBy: 'Busqueda de Flete', | 508 | ariaLabelledBy: 'Busqueda de Flete', |
509 | templateUrl: 'modal-flete.html', | 509 | templateUrl: 'modal-flete.html', |
510 | controller: 'focaModalFleteController', | 510 | controller: 'focaModalFleteController', |
511 | size: 'lg', | 511 | size: 'lg', |
512 | resolve: { | 512 | resolve: { |
513 | parametrosFlete: | 513 | parametrosFlete: |
514 | function() { | 514 | function() { |
515 | return { | 515 | return { |
516 | flete: $scope.remito.flete ? '1' : | 516 | flete: $scope.remito.flete ? '1' : |
517 | ($scope.remito.fob ? 'FOB' : | 517 | ($scope.remito.fob ? 'FOB' : |
518 | ($scope.remito.flete === undefined ? null : '0')), | 518 | ($scope.remito.flete === undefined ? null : '0')), |
519 | bomba: $scope.remito.bomba ? '1' : | 519 | bomba: $scope.remito.bomba ? '1' : |
520 | ($scope.remito.bomba === undefined ? null : '0'), | 520 | ($scope.remito.bomba === undefined ? null : '0'), |
521 | kilometros: $scope.remito.kilometros | 521 | kilometros: $scope.remito.kilometros |
522 | }; | 522 | }; |
523 | } | 523 | } |
524 | } | 524 | } |
525 | } | 525 | } |
526 | ); | 526 | ); |
527 | modalInstance.result.then( | 527 | modalInstance.result.then( |
528 | function(datos) { | 528 | function(datos) { |
529 | $scope.remito.flete = datos.flete; | 529 | $scope.remito.flete = datos.flete; |
530 | $scope.remito.fob = datos.FOB; | 530 | $scope.remito.fob = datos.FOB; |
531 | $scope.remito.bomba = datos.bomba; | 531 | $scope.remito.bomba = datos.bomba; |
532 | $scope.remito.kilometros = datos.kilometros; | 532 | $scope.remito.kilometros = datos.kilometros; |
533 | 533 | ||
534 | addCabecera('Flete:', datos.flete ? 'Si' : | 534 | addCabecera('Flete:', datos.flete ? 'Si' : |
535 | ($scope.remito.fob ? 'FOB' : 'No')); | 535 | ($scope.remito.fob ? 'FOB' : 'No')); |
536 | if(datos.flete) { | 536 | if(datos.flete) { |
537 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); | 537 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); |
538 | addCabecera('Kilometros:', datos.kilometros); | 538 | addCabecera('Kilometros:', datos.kilometros); |
539 | } else { | 539 | } else { |
540 | removeCabecera('Bomba:'); | 540 | removeCabecera('Bomba:'); |
541 | removeCabecera('Kilometros:'); | 541 | removeCabecera('Kilometros:'); |
542 | $scope.remito.fob = false; | 542 | $scope.remito.fob = false; |
543 | $scope.remito.bomba = false; | 543 | $scope.remito.bomba = false; |
544 | $scope.remito.kilometros = null; | 544 | $scope.remito.kilometros = null; |
545 | } | 545 | } |
546 | }, function() { | 546 | }, function() { |
547 | 547 | ||
548 | } | 548 | } |
549 | ); | 549 | ); |
550 | }; | 550 | }; |
551 | 551 | ||
552 | $scope.abrirModalMoneda = function() { | 552 | $scope.abrirModalMoneda = function() { |
553 | var modalInstance = $uibModal.open( | 553 | var modalInstance = $uibModal.open( |
554 | { | 554 | { |
555 | ariaLabelledBy: 'Busqueda de Moneda', | 555 | ariaLabelledBy: 'Busqueda de Moneda', |
556 | templateUrl: 'modal-moneda.html', | 556 | templateUrl: 'modal-moneda.html', |
557 | controller: 'focaModalMonedaController', | 557 | controller: 'focaModalMonedaController', |
558 | size: 'lg' | 558 | size: 'lg' |
559 | } | 559 | } |
560 | ); | 560 | ); |
561 | modalInstance.result.then( | 561 | modalInstance.result.then( |
562 | function(moneda) { | 562 | function(moneda) { |
563 | $scope.abrirModalCotizacion(moneda); | 563 | $scope.abrirModalCotizacion(moneda); |
564 | }, function() { | 564 | }, function() { |
565 | 565 | ||
566 | } | 566 | } |
567 | ); | 567 | ); |
568 | }; | 568 | }; |
569 | 569 | ||
570 | $scope.abrirModalCotizacion = function(moneda) { | 570 | $scope.abrirModalCotizacion = function(moneda) { |
571 | var modalInstance = $uibModal.open( | 571 | var modalInstance = $uibModal.open( |
572 | { | 572 | { |
573 | ariaLabelledBy: 'Busqueda de Cotización', | 573 | ariaLabelledBy: 'Busqueda de Cotización', |
574 | templateUrl: 'modal-cotizacion.html', | 574 | templateUrl: 'modal-cotizacion.html', |
575 | controller: 'focaModalCotizacionController', | 575 | controller: 'focaModalCotizacionController', |
576 | size: 'lg', | 576 | size: 'lg', |
577 | resolve: {idMoneda: function() {return moneda.ID;}} | 577 | resolve: {idMoneda: function() {return moneda.ID;}} |
578 | } | 578 | } |
579 | ); | 579 | ); |
580 | modalInstance.result.then( | 580 | modalInstance.result.then( |
581 | function(cotizacion) { | 581 | function(cotizacion) { |
582 | var articulosTablaTemp = $scope.articulosTabla; | 582 | var articulosTablaTemp = $scope.articulosTabla; |
583 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 583 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
584 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 584 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
585 | $scope.remito.cotizacion.COTIZACION; | 585 | $scope.remito.cotizacion.COTIZACION; |
586 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 586 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
587 | cotizacion.COTIZACION; | 587 | cotizacion.COTIZACION; |
588 | } | 588 | } |
589 | $scope.articulosTabla = articulosTablaTemp; | 589 | $scope.articulosTabla = articulosTablaTemp; |
590 | $scope.remito.moneda = { | 590 | $scope.remito.moneda = { |
591 | id: moneda.ID, | 591 | id: moneda.ID, |
592 | detalle: moneda.DETALLE, | 592 | detalle: moneda.DETALLE, |
593 | simbolo: moneda.SIMBOLO | 593 | simbolo: moneda.SIMBOLO |
594 | }; | 594 | }; |
595 | $scope.remito.cotizacion = { | 595 | $scope.remito.cotizacion = { |
596 | ID: cotizacion.ID, | 596 | ID: cotizacion.ID, |
597 | COTIZACION: cotizacion.COTIZACION, | 597 | COTIZACION: cotizacion.COTIZACION, |
598 | FECHA: cotizacion.FECHA | 598 | FECHA: cotizacion.FECHA |
599 | }; | 599 | }; |
600 | addCabecera('Moneda:', moneda.DETALLE); | 600 | addCabecera('Moneda:', moneda.DETALLE); |
601 | addCabecera( | 601 | addCabecera( |
602 | 'Fecha cotizacion:', | 602 | 'Fecha cotizacion:', |
603 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 603 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
604 | ); | 604 | ); |
605 | addCabecera('Cotizacion:', cotizacion.COTIZACION); | 605 | addCabecera('Cotizacion:', cotizacion.COTIZACION); |
606 | }, function() { | 606 | }, function() { |
607 | 607 | ||
608 | } | 608 | } |
609 | ); | 609 | ); |
610 | }; | 610 | }; |
611 | 611 | ||
612 | $scope.agregarATabla = function(key) { | 612 | $scope.agregarATabla = function(key) { |
613 | if(key === 13) { | 613 | if(key === 13) { |
614 | if($scope.articuloACargar.cantidad === undefined || | 614 | if($scope.articuloACargar.cantidad === undefined || |
615 | $scope.articuloACargar.cantidad === 0 || | 615 | $scope.articuloACargar.cantidad === 0 || |
616 | $scope.articuloACargar.cantidad === null ) { | 616 | $scope.articuloACargar.cantidad === null ) { |
617 | focaModalService.alert('El valor debe ser al menos 1'); | 617 | focaModalService.alert('El valor debe ser al menos 1'); |
618 | return; | 618 | return; |
619 | } | 619 | } |
620 | delete $scope.articuloACargar.sectorCodigo; | 620 | delete $scope.articuloACargar.sectorCodigo; |
621 | $scope.articulosTabla.push($scope.articuloACargar); | 621 | $scope.articulosTabla.push($scope.articuloACargar); |
622 | $scope.cargando = true; | 622 | $scope.cargando = true; |
623 | } | 623 | } |
624 | }; | 624 | }; |
625 | 625 | ||
626 | $scope.quitarArticulo = function(key) { | 626 | $scope.quitarArticulo = function(key) { |
627 | $scope.articulosTabla.splice(key, 1); | 627 | $scope.articulosTabla.splice(key, 1); |
628 | }; | 628 | }; |
629 | 629 | ||
630 | $scope.editarArticulo = function(key, articulo) { | 630 | $scope.editarArticulo = function(key, articulo) { |
631 | if(key === 13) { | 631 | if(key === 13) { |
632 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 632 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
633 | articulo.cantidad === undefined) { | 633 | articulo.cantidad === undefined) { |
634 | focaModalService.alert('El valor debe ser al menos 1'); | 634 | focaModalService.alert('El valor debe ser al menos 1'); |
635 | return; | 635 | return; |
636 | } | 636 | } |
637 | articulo.editCantidad = false; | 637 | articulo.editCantidad = false; |
638 | articulo.editPrecio = false; | 638 | articulo.editPrecio = false; |
639 | } | 639 | } |
640 | }; | 640 | }; |
641 | 641 | ||
642 | $scope.cambioEdit = function(articulo, propiedad) { | 642 | $scope.cambioEdit = function(articulo, propiedad) { |
643 | if(propiedad === 'cantidad') { | 643 | if(propiedad === 'cantidad') { |
644 | articulo.editCantidad = true; | 644 | articulo.editCantidad = true; |
645 | } else if(propiedad === 'precio') { | 645 | } else if(propiedad === 'precio') { |
646 | articulo.editPrecio = true; | 646 | articulo.editPrecio = true; |
647 | } | 647 | } |
648 | }; | 648 | }; |
649 | 649 | ||
650 | $scope.limpiarFlete = function() { | 650 | $scope.limpiarFlete = function() { |
651 | $scope.remito.fleteNombre = ''; | 651 | $scope.remito.fleteNombre = ''; |
652 | $scope.remito.chofer = ''; | 652 | $scope.remito.chofer = ''; |
653 | $scope.remito.vehiculo = ''; | 653 | $scope.remito.vehiculo = ''; |
654 | $scope.remito.kilometros = ''; | 654 | $scope.remito.kilometros = ''; |
655 | $scope.remito.costoUnitarioKmFlete = ''; | 655 | $scope.remito.costoUnitarioKmFlete = ''; |
656 | $scope.choferes = ''; | 656 | $scope.choferes = ''; |
657 | $scope.vehiculos = ''; | 657 | $scope.vehiculos = ''; |
658 | }; | 658 | }; |
659 | 659 | ||
660 | $scope.limpiarPantalla = function() { | 660 | $scope.limpiarPantalla = function() { |
661 | $scope.limpiarFlete(); | 661 | $scope.limpiarFlete(); |
662 | $scope.remito.flete = '0'; | 662 | $scope.remito.flete = '0'; |
663 | $scope.remito.bomba = '0'; | 663 | $scope.remito.bomba = '0'; |
664 | $scope.remito.precioCondicion = ''; | 664 | $scope.remito.precioCondicion = ''; |
665 | $scope.articulosTabla = []; | 665 | $scope.articulosTabla = []; |
666 | $scope.remito.vendedor.nombre = ''; | 666 | $scope.remito.vendedor.nombre = ''; |
667 | $scope.remito.cliente = {nombre: ''}; | 667 | $scope.remito.cliente = {nombre: ''}; |
668 | $scope.remito.domicilio = {dom: ''}; | 668 | $scope.remito.domicilio = {dom: ''}; |
669 | $scope.domiciliosCliente = []; | 669 | $scope.domiciliosCliente = []; |
670 | }; | 670 | }; |
671 | 671 | ||
672 | $scope.resetFilter = function() { | 672 | $scope.resetFilter = function() { |
673 | $scope.articuloACargar = {}; | 673 | $scope.articuloACargar = {}; |
674 | $scope.cargando = true; | 674 | $scope.cargando = true; |
675 | }; | 675 | }; |
676 | 676 | ||
677 | $scope.selectFocus = function($event) { | 677 | $scope.selectFocus = function($event) { |
678 | $event.target.select(); | 678 | $event.target.select(); |
679 | }; | 679 | }; |
680 | 680 | ||
681 | $scope.salir = function() { | 681 | $scope.salir = function() { |
682 | $location.path('/'); | 682 | $location.path('/'); |
683 | }; | 683 | }; |
684 | function addArrayCabecera(array) { | 684 | function addArrayCabecera(array) { |
685 | for(var i = 0; i < array.length; i++) { | 685 | for(var i = 0; i < array.length; i++) { |
686 | addCabecera(array[i].label, array[i].valor); | 686 | addCabecera(array[i].label, array[i].valor); |
687 | } | 687 | } |
688 | } | 688 | } |
689 | 689 | ||
690 | function addCabecera(label, valor) { | 690 | function addCabecera(label, valor) { |
691 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 691 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
692 | if(propiedad.length === 1) { | 692 | if(propiedad.length === 1) { |
693 | propiedad[0].valor = valor; | 693 | propiedad[0].valor = valor; |
694 | } else { | 694 | } else { |
695 | $scope.cabecera.push({label: label, valor: valor}); | 695 | $scope.cabecera.push({label: label, valor: valor}); |
696 | } | 696 | } |
697 | } | 697 | } |
698 | 698 | ||
699 | function removeCabecera(label) { | 699 | function removeCabecera(label) { |
700 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 700 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
701 | if(propiedad.length === 1) { | 701 | if(propiedad.length === 1) { |
702 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | 702 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
703 | } | 703 | } |
704 | } | 704 | } |
705 | 705 | ||
706 | function rellenar(relleno, longitud) { | 706 | function rellenar(relleno, longitud) { |
707 | relleno = '' + relleno; | 707 | relleno = '' + relleno; |
708 | while (relleno.length < longitud) { | 708 | while (relleno.length < longitud) { |
709 | relleno = '0' + relleno; | 709 | relleno = '0' + relleno; |
710 | } | 710 | } |
711 | 711 | ||
712 | return relleno; | 712 | return relleno; |
713 | } | 713 | } |
714 | } | 714 | } |
715 | ] | 715 | ] |
716 | ) | 716 | ) |
717 | .controller('remitoListaCtrl', [ | 717 | .controller('remitoListaCtrl', [ |
718 | '$scope', | 718 | '$scope', |
719 | 'crearRemitoService', | 719 | 'crearRemitoService', |
720 | '$location', | 720 | '$location', |
721 | function($scope, crearRemitoService, $location) { | 721 | function($scope, crearRemitoService, $location) { |
722 | crearRemitoService.obtenerRemito().then(function(datos) { | 722 | crearRemitoService.obtenerRemito().then(function(datos) { |
723 | $scope.remitos = datos.data; | 723 | $scope.remitos = datos.data; |
724 | }); | 724 | }); |
725 | $scope.editar = function(remito) { | 725 | $scope.editar = function(remito) { |
726 | crearRemitoService.setRemito(remito); | 726 | crearRemitoService.setRemito(remito); |
727 | $location.path('/venta-nota-remito/abm/'); | 727 | $location.path('/venta-nota-remito/abm/'); |
728 | }; | 728 | }; |
729 | $scope.crearRemito = function() { | 729 | $scope.crearRemito = function() { |
730 | crearRemitoService.clearRemito(); | 730 | crearRemitoService.clearRemito(); |
731 | $location.path('/venta-nota-remito/abm/'); | 731 | $location.path('/venta-nota-remito/abm/'); |
732 | }; | 732 | }; |
733 | } | 733 | } |
734 | ]) | 734 | ]) |
735 | .controller('focaCrearRemitoFichaClienteController', [ | 735 | .controller('focaCrearRemitoFichaClienteController', [ |
736 | '$scope', | 736 | '$scope', |
737 | 'crearRemitoService', | 737 | 'crearRemitoService', |
738 | '$location', | 738 | '$location', |
739 | function($scope, crearRemitoService, $location) { | 739 | function($scope, crearRemitoService, $location) { |
740 | crearRemitoService.obtenerRemito().then(function(datos) { | 740 | crearRemitoService.obtenerRemito().then(function(datos) { |
741 | $scope.remitos = datos.data; | 741 | $scope.remitos = datos.data; |
742 | }); | 742 | }); |
743 | $scope.editar = function(remito) { | 743 | $scope.editar = function(remito) { |
744 | crearRemitoService.setRemito(remito); | 744 | crearRemitoService.setRemito(remito); |
745 | $location.path('/venta-nota-remito/abm/'); | 745 | $location.path('/venta-nota-remito/abm/'); |
746 | }; | 746 | }; |
747 | $scope.crearRemito = function() { | 747 | $scope.crearRemito = function() { |
748 | crearRemitoService.clearRemito(); | 748 | crearRemitoService.clearRemito(); |
749 | $location.path('/venta-nota-remito/abm/'); | 749 | $location.path('/venta-nota-remito/abm/'); |
750 | }; | 750 | }; |
751 | } | 751 | } |
752 | ]); | 752 | ]); |
753 | 753 |