Commit 44ab0493f07535ed5255fa27e09ef9ef4345325a
Exists in
master
Merge branch 'master' into 'master'
Master See merge request modulos-npm/foca-crear-remito!9
Showing
3 changed files
Show diff stats
src/js/businessService.js
1 | angular.module('focaCrearRemito') | 1 | angular.module('focaCrearRemito') |
2 | .factory('remitoBusinessService', [ | 2 | .factory('remitoBusinessService', [ |
3 | 'crearRemitoService', | 3 | 'crearRemitoService', |
4 | function(crearRemitoService) { | 4 | function(crearRemitoService) { |
5 | return { | 5 | return { |
6 | addArticulos: function(articulosRemito, idRemito, cotizacion) { | 6 | addArticulos: function(articulosRemito, idRemito, cotizacion) { |
7 | for(var i = 0; i < articulosRemito.length; i++) { | 7 | for(var i = 0; i < articulosRemito.length; i++) { |
8 | delete articulosRemito[i].editCantidad; | 8 | delete articulosRemito[i].editCantidad; |
9 | delete articulosRemito[i].editPrecio; | 9 | delete articulosRemito[i].editPrecio; |
10 | articulosRemito[i].idRemito = idRemito; | 10 | articulosRemito[i].idRemito = idRemito; |
11 | articulosRemito[i].precio = articulosRemito[i].precio * cotizacion; | 11 | articulosRemito[i].precio = articulosRemito[i].precio * cotizacion; |
12 | delete articulosRemito[i].idNotaPedido; | ||
12 | crearRemitoService.crearArticulosParaRemito(articulosRemito[i]); | 13 | crearRemitoService.crearArticulosParaRemito(articulosRemito[i]); |
13 | } | 14 | } |
14 | }, | 15 | }, |
15 | addEstado: function(idRemito, idVendedor) { | 16 | addEstado: function(idRemito, idVendedor) { |
16 | var date = new Date(); | 17 | var date = new Date(); |
17 | var estado = { | 18 | var estado = { |
18 | idRemito: idRemito, | 19 | idRemito: idRemito, |
19 | fecha: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 20 | fecha: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
20 | .toISOString().slice(0, 19).replace('T', ' '), | 21 | .toISOString().slice(0, 19).replace('T', ' '), |
21 | estado: 0, | 22 | estado: 0, |
22 | idVendedor: idVendedor | 23 | idVendedor: idVendedor |
23 | }; | 24 | }; |
24 | crearRemitoService.crearEstadoParaRemito(estado); | 25 | crearRemitoService.crearEstadoParaRemito(estado); |
25 | } | 26 | } |
26 | }; | 27 | }; |
27 | }]); | 28 | }]); |
28 | 29 |
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.idLista = notaPedido.precioCondicion[0].idListaPrecio; | ||
163 | $scope.remito = notaPedido; | 164 | $scope.remito = notaPedido; |
165 | $scope.remito.vendedor = notaPedido.vendedor[0]; | ||
166 | $scope.remito.cliente = notaPedido.cliente[0]; | ||
167 | $scope.remito.proveedor = notaPedido.proveedor[0]; | ||
168 | $scope.remito.moneda = notaPedido.cotizacion[0].moneda[0]; | ||
169 | $scope.remito.cotizacion = notaPedido.cotizacion[0]; | ||
164 | addArrayCabecera(cabeceras); | 170 | addArrayCabecera(cabeceras); |
165 | 171 | ||
166 | }, function() { | 172 | }, function() { |
167 | // funcion ejecutada cuando se cancela el modal | 173 | // funcion ejecutada cuando se cancela el modal |
168 | } | 174 | } |
169 | ); | 175 | ); |
170 | }; | 176 | }; |
171 | 177 | ||
172 | $scope.seleccionarRemito = function() { | 178 | $scope.seleccionarRemito = function() { |
173 | var modalInstance = $uibModal.open( | 179 | var modalInstance = $uibModal.open( |
174 | { | 180 | { |
175 | ariaLabelledBy: 'Busqueda de Remito', | 181 | ariaLabelledBy: 'Busqueda de Remito', |
176 | templateUrl: 'foca-modal-remito.html', | 182 | templateUrl: 'foca-modal-remito.html', |
177 | controller: 'focaModalRemitoController', | 183 | controller: 'focaModalRemitoController', |
178 | size: 'lg' | 184 | size: 'lg' |
179 | } | 185 | } |
180 | ); | 186 | ); |
181 | modalInstance.result.then( | 187 | modalInstance.result.then( |
182 | function() { | 188 | function() { |
183 | // TODO: Implementar carga remito | 189 | // TODO: Implementar carga remito |
184 | }, function() { | 190 | }, function() { |
185 | // funcion ejecutada cuando se cancela el modal | 191 | // funcion ejecutada cuando se cancela el modal |
186 | } | 192 | } |
187 | ); | 193 | ); |
188 | }; | 194 | }; |
189 | 195 | ||
190 | //La pantalla solo se usa para cargar remitos | 196 | //La pantalla solo se usa para cargar remitos |
191 | // if (remitoTemp !== undefined) { | 197 | // if (remitoTemp !== undefined) { |
192 | // remitoTemp.fechaCarga = new Date(remitoTemp.fechaCarga); | 198 | // remitoTemp.fechaCarga = new Date(remitoTemp.fechaCarga); |
193 | // $scope.remito = remitoTemp; | 199 | // $scope.remito = remitoTemp; |
194 | // $scope.remito.flete = ($scope.remito.flete).toString(); | 200 | // $scope.remito.flete = ($scope.remito.flete).toString(); |
195 | // $scope.remito.bomba = ($scope.remito.bomba).toString(); | 201 | // $scope.remito.bomba = ($scope.remito.bomba).toString(); |
196 | // $scope.idLista = $scope.remito.precioCondicion; | 202 | // $scope.idLista = $scope.remito.precioCondicion; |
197 | // crearRemitoService | 203 | // crearRemitoService |
198 | // .getArticulosByIdRemito($scope.remito.id).then( | 204 | // .getArticulosByIdRemito($scope.remito.id).then( |
199 | // function(res) { | 205 | // function(res) { |
200 | // $scope.articulosTabla = res.data; | 206 | // $scope.articulosTabla = res.data; |
201 | // } | 207 | // } |
202 | // ); | 208 | // ); |
203 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR REMITO | 209 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR REMITO |
204 | //(NO REQUERIDO EN ESTA VERSION) | 210 | //(NO REQUERIDO EN ESTA VERSION) |
205 | // crearRemitoService.getDomiciliosByIdRemito($scope.remito.id).then( | 211 | // crearRemitoService.getDomiciliosByIdRemito($scope.remito.id).then( |
206 | // function(res) { | 212 | // function(res) { |
207 | // $scope.remito.domicilio = res.data; | 213 | // $scope.remito.domicilio = res.data; |
208 | // } | 214 | // } |
209 | // ); | 215 | // ); |
210 | // } else { | 216 | // } else { |
211 | // $scope.remito.fechaCarga = new Date(); | 217 | // $scope.remito.fechaCarga = new Date(); |
212 | // $scope.remito.bomba = '0'; | 218 | // $scope.remito.bomba = '0'; |
213 | // $scope.remito.flete = '0'; | 219 | // $scope.remito.flete = '0'; |
214 | // $scope.idLista = undefined; | 220 | // $scope.idLista = undefined; |
215 | // } | 221 | // } |
216 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | 222 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
217 | // $scope.addNewDom = function() { | 223 | // $scope.addNewDom = function() { |
218 | // $scope.remito.domicilio.push({ 'id': 0 }); | 224 | // $scope.remito.domicilio.push({ 'id': 0 }); |
219 | // }; | 225 | // }; |
220 | // $scope.removeNewChoice = function(choice) { | 226 | // $scope.removeNewChoice = function(choice) { |
221 | // if ($scope.remito.domicilio.length > 1) { | 227 | // if ($scope.remito.domicilio.length > 1) { |
222 | // $scope.remito.domicilio.splice($scope.remito.domicilio.findIndex( | 228 | // $scope.remito.domicilio.splice($scope.remito.domicilio.findIndex( |
223 | // function(c) { | 229 | // function(c) { |
224 | // return c.$$hashKey === choice.$$hashKey; | 230 | // return c.$$hashKey === choice.$$hashKey; |
225 | // } | 231 | // } |
226 | // ), 1); | 232 | // ), 1); |
227 | // } | 233 | // } |
228 | // }; | 234 | // }; |
229 | 235 | //validacion por domicilio y por plazo pago | |
230 | $scope.crearRemito = function() { | 236 | $scope.crearRemito = function() { |
231 | if(!$scope.remito.vendedor.codigo) { | 237 | if(!$scope.remito.vendedor) { |
232 | focaModalService.alert('Ingrese Vendedor'); | 238 | focaModalService.alert('Ingrese Vendedor'); |
233 | return; | 239 | return; |
234 | } else if(!$scope.remito.cliente.cod) { | 240 | } else if(!$scope.remito.cliente) { |
235 | focaModalService.alert('Ingrese Cliente'); | 241 | focaModalService.alert('Ingrese Cliente'); |
236 | return; | 242 | return; |
237 | } else if(!$scope.remito.proveedor.codigo) { | 243 | } else if(!$scope.remito.proveedor) { |
238 | focaModalService.alert('Ingrese Proveedor'); | 244 | focaModalService.alert('Ingrese Proveedor'); |
239 | return; | 245 | return; |
240 | } else if(!$scope.remito.moneda.id) { | 246 | } else if(!$scope.remito.moneda.ID) { |
241 | focaModalService.alert('Ingrese Moneda'); | 247 | focaModalService.alert('Ingrese Moneda'); |
242 | return; | 248 | return; |
243 | } else if(!$scope.remito.cotizacion.ID) { | 249 | } else if(!$scope.remito.cotizacion.ID) { |
244 | focaModalService.alert('Ingrese Cotización'); | 250 | focaModalService.alert('Ingrese Cotización'); |
245 | return; | 251 | return; |
246 | } else if(!$scope.plazosPagos) { | ||
247 | focaModalService.alert('Ingrese Precios y Condiciones'); | ||
248 | return; | ||
249 | } else if( | 252 | } else if( |
250 | $scope.remito.flete === undefined || $scope.remito.flete === null) | 253 | $scope.remito.flete === undefined || $scope.remito.flete === null) |
251 | { | 254 | { |
252 | focaModalService.alert('Ingrese Flete'); | 255 | focaModalService.alert('Ingrese Flete'); |
253 | return; | 256 | return; |
254 | } else if(!$scope.remito.domicilio.id) { | ||
255 | focaModalService.alert('Ingrese Domicilio'); | ||
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 | fechaRemito: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
265 | .toISOString().slice(0, 19).replace('T', ' '), | 265 | .toISOString().slice(0, 19).replace('T', ' '),//TODO$filter |
266 | idVendedor: $scope.remito.vendedor.codigo, | 266 | idCliente: $scope.remito.idCliente, |
267 | idCliente: $scope.remito.cliente.cod, | 267 | nombreCliente: $scope.remito.nombreCliente, |
268 | nombreCliente: $scope.remito.cliente.nom, | 268 | cuitCliente: $scope.remito.cuitCliente, |
269 | cuitCliente: $scope.remito.cliente.cuit, | 269 | responsabilidadIvaCliente: 0,//TODO, |
270 | idProveedor: $scope.remito.proveedor.codigo, | 270 | descuento: 0,//TODO, |
271 | idDomicilio: $scope.remito.domicilio.id, | 271 | importeNeto: 0,//TODO |
272 | idCotizacion: $scope.remito.cotizacion.ID, | 272 | importeExento: 0,//TODO |
273 | cotizacion: $scope.remito.cotizacion.COTIZACION, | 273 | importeIva: 0,//TODO |
274 | importeIvaServicios: 0,//TODO | ||
275 | importeImpuestoInterno: 0,//TODO | ||
276 | importeImpuestoInterno1: 0,//TODO | ||
277 | importeImpuestoInterno2: 0,//TODO | ||
278 | percepcion: 0,//TODO | ||
279 | percepcionIva: 0,//TODO | ||
280 | redondeo: 0,//TODO | ||
281 | total: $scope.getTotal(), | ||
282 | numeroNotaPedido: $scope.remito.numeroNotaPedido, | ||
283 | anulado: false, | ||
284 | planilla: 0,//TODO | ||
285 | lugar: 0,//TODO | ||
286 | cuentaMadre: 0,// | ||
287 | cuentaContable: 0,//TODO | ||
288 | asiento: 0,//TODO | ||
289 | e_hd: '',//TODO | ||
290 | c_hd: '', | ||
291 | numeroLiquidoProducto: 0,//TODO | ||
292 | idVendedor: $scope.remito.idVendedor, | ||
293 | idProveedor: $scope.remito.idProveedor, | ||
294 | idDomicilio: 0,//TODO | ||
295 | idCotizacion: $scope.remito.idCotizacion, | ||
274 | flete: $scope.remito.flete, | 296 | flete: $scope.remito.flete, |
275 | fob: $scope.remito.fob, | 297 | fob: $scope.remito.fob, |
276 | bomba: $scope.remito.bomba, | 298 | bomba: $scope.remito.bomba, |
277 | kilometros: $scope.remito.kilometros, | 299 | kilometros: $scope.remito.kilometros, |
278 | estado: 0, | 300 | estado: 0,//TODO |
279 | total: $scope.getTotal() | 301 | destinoVenta: 0,//TODO |
302 | operacionTipo: 0//TODO | ||
280 | }; | 303 | }; |
281 | crearRemitoService.crearRemito(remito).then( | 304 | crearRemitoService.crearRemito(remito).then( |
282 | function(data) { | 305 | function(data) { |
283 | remitoBusinessService.addArticulos($scope.articulosTabla, | 306 | remitoBusinessService.addArticulos($scope.articulosTabla, |
284 | data.data.id, $scope.remito.cotizacion.COTIZACION); | 307 | data.data.id, $scope.remito.cotizacion.COTIZACION); |
285 | var plazos = $scope.plazosPagos; | ||
286 | for(var j = 0; j < plazos.length; j++) { | ||
287 | var json = { | ||
288 | idRemito: data.data.id, | ||
289 | dias: plazos[j].dias | ||
290 | }; | ||
291 | crearRemitoService.crearPlazosParaRemito(json); | ||
292 | } | ||
293 | remitoBusinessService.addEstado(data.data.id, | ||
294 | $scope.remito.vendedor.codigo); | ||
295 | 308 | ||
296 | focaModalService.alert('Nota remito creada'); | 309 | focaModalService.alert('Nota remito creada'); |
297 | $scope.cabecera = []; | 310 | $scope.cabecera = []; |
298 | addCabecera('Moneda:', $scope.remito.moneda.detalle); | 311 | addCabecera('Moneda:', $scope.remito.moneda.detalle); |
299 | addCabecera( | 312 | addCabecera( |
300 | 'Fecha cotizacion:', | 313 | 'Fecha cotizacion:', |
301 | $filter('date')($scope.remito.cotizacion.FECHA, 'dd/MM/yyyy') | 314 | $filter('date')($scope.remito.cotizacion.FECHA, 'dd/MM/yyyy') |
302 | ); | 315 | ); |
303 | addCabecera('Cotizacion:', $scope.remito.cotizacion.COTIZACION); | 316 | addCabecera('Cotizacion:', $scope.remito.cotizacion.COTIZACION); |
304 | $scope.remito.vendedor = {}; | 317 | $scope.remito.vendedor = {}; |
305 | $scope.remito.cliente = {}; | 318 | $scope.remito.cliente = {}; |
306 | $scope.remito.proveedor = {}; | 319 | $scope.remito.proveedor = {}; |
307 | $scope.remito.domicilio = {}; | 320 | $scope.remito.domicilio = {}; |
308 | $scope.remito.flete = null; | 321 | $scope.remito.flete = null; |
309 | $scope.remito.fob = null; | 322 | $scope.remito.fob = null; |
310 | $scope.remito.bomba = null; | 323 | $scope.remito.bomba = null; |
311 | $scope.remito.kilometros = null; | 324 | $scope.remito.kilometros = null; |
312 | $scope.articulosTabla = []; | 325 | $scope.articulosTabla = []; |
313 | } | 326 | } |
314 | ); | 327 | ); |
315 | }; | 328 | }; |
316 | 329 | ||
317 | $scope.seleccionarArticulo = function() { | 330 | $scope.seleccionarArticulo = function() { |
318 | if ($scope.idLista === undefined) { | 331 | if ($scope.idLista === undefined) { |
319 | focaModalService.alert( | 332 | focaModalService.alert( |
320 | 'Primero seleccione una lista de precio y condicion'); | 333 | 'Primero seleccione una lista de precio y condicion'); |
321 | return; | 334 | return; |
322 | } | 335 | } |
323 | var modalInstance = $uibModal.open( | 336 | var modalInstance = $uibModal.open( |
324 | { | 337 | { |
325 | ariaLabelledBy: 'Busqueda de Productos', | 338 | ariaLabelledBy: 'Busqueda de Productos', |
326 | templateUrl: 'modal-busqueda-productos.html', | 339 | templateUrl: 'modal-busqueda-productos.html', |
327 | controller: 'modalBusquedaProductosCtrl', | 340 | controller: 'modalBusquedaProductosCtrl', |
328 | resolve: { | 341 | resolve: { |
329 | parametroProducto: { | 342 | parametroProducto: { |
330 | idLista: $scope.idLista, | 343 | idLista: $scope.idLista, |
331 | cotizacion: $scope.remito.cotizacion.COTIZACION, | 344 | cotizacion: $scope.remito.cotizacion.COTIZACION, |
332 | simbolo: $scope.remito.moneda.simbolo | 345 | simbolo: $scope.remito.moneda.simbolo |
333 | } | 346 | } |
334 | }, | 347 | }, |
335 | size: 'lg' | 348 | size: 'lg' |
336 | } | 349 | } |
337 | ); | 350 | ); |
338 | modalInstance.result.then( | 351 | modalInstance.result.then( |
339 | function(producto) { | 352 | function(producto) { |
340 | var newArt = | 353 | var newArt = |
341 | { | 354 | { |
342 | id: 0, | 355 | id: 0, |
343 | codigo: producto.codigo, | 356 | codigo: producto.codigo, |
344 | sector: producto.sector, | 357 | sector: producto.sector, |
345 | sectorCodigo: producto.sector + '-' + producto.codigo, | 358 | sectorCodigo: producto.sector + '-' + producto.codigo, |
346 | descripcion: producto.descripcion, | 359 | descripcion: producto.descripcion, |
347 | item: $scope.articulosTabla.length + 1, | 360 | item: $scope.articulosTabla.length + 1, |
348 | nombre: producto.descripcion, | 361 | nombre: producto.descripcion, |
349 | precio: parseFloat(producto.precio.toFixed(4)), | 362 | precio: parseFloat(producto.precio.toFixed(4)), |
350 | costoUnitario: producto.costo, | 363 | costoUnitario: producto.costo, |
351 | editCantidad: false, | 364 | editCantidad: false, |
352 | editPrecio: false | 365 | editPrecio: false |
353 | }; | 366 | }; |
354 | $scope.articuloACargar = newArt; | 367 | $scope.articuloACargar = newArt; |
355 | $scope.cargando = false; | 368 | $scope.cargando = false; |
356 | }, function() { | 369 | }, function() { |
357 | // funcion ejecutada cuando se cancela el modal | 370 | // funcion ejecutada cuando se cancela el modal |
358 | } | 371 | } |
359 | ); | 372 | ); |
360 | }; | 373 | }; |
361 | 374 | ||
362 | $scope.seleccionarVendedor = function() { | 375 | $scope.seleccionarVendedor = function() { |
363 | var modalInstance = $uibModal.open( | 376 | var modalInstance = $uibModal.open( |
364 | { | 377 | { |
365 | ariaLabelledBy: 'Busqueda de Vendedores', | 378 | ariaLabelledBy: 'Busqueda de Vendedores', |
366 | templateUrl: 'modal-vendedores.html', | 379 | templateUrl: 'modal-vendedores.html', |
367 | controller: 'modalVendedoresCtrl', | 380 | controller: 'modalVendedoresCtrl', |
368 | size: 'lg' | 381 | size: 'lg' |
369 | } | 382 | } |
370 | ); | 383 | ); |
371 | modalInstance.result.then( | 384 | modalInstance.result.then( |
372 | function(vendedor) { | 385 | function(vendedor) { |
373 | addCabecera('Vendedor:', vendedor.NomVen); | 386 | addCabecera('Vendedor:', vendedor.NomVen); |
374 | $scope.remito.vendedor.codigo = vendedor.CodVen; | 387 | $scope.remito.vendedor.codigo = vendedor.CodVen; |
375 | }, function() { | 388 | }, function() { |
376 | 389 | ||
377 | } | 390 | } |
378 | ); | 391 | ); |
379 | }; | 392 | }; |
380 | 393 | ||
381 | $scope.seleccionarProveedor = function() { | 394 | $scope.seleccionarProveedor = function() { |
382 | var modalInstance = $uibModal.open( | 395 | var modalInstance = $uibModal.open( |
383 | { | 396 | { |
384 | ariaLabelledBy: 'Busqueda de Proveedor', | 397 | ariaLabelledBy: 'Busqueda de Proveedor', |
385 | templateUrl: 'modal-proveedor.html', | 398 | templateUrl: 'modal-proveedor.html', |
386 | controller: 'focaModalProveedorCtrl', | 399 | controller: 'focaModalProveedorCtrl', |
387 | size: 'lg', | 400 | size: 'lg', |
388 | resolve: { | 401 | resolve: { |
389 | transportista: function() { | 402 | transportista: function() { |
390 | return false; | 403 | return false; |
391 | } | 404 | } |
392 | } | 405 | } |
393 | } | 406 | } |
394 | ); | 407 | ); |
395 | modalInstance.result.then( | 408 | modalInstance.result.then( |
396 | function(proveedor) { | 409 | function(proveedor) { |
397 | $scope.remito.proveedor.codigo = proveedor.COD; | 410 | $scope.remito.proveedor.codigo = proveedor.COD; |
398 | addCabecera('Proveedor:', proveedor.NOM); | 411 | addCabecera('Proveedor:', proveedor.NOM); |
399 | }, function() { | 412 | }, function() { |
400 | 413 | ||
401 | } | 414 | } |
402 | ); | 415 | ); |
403 | }; | 416 | }; |
404 | 417 | ||
405 | $scope.seleccionarCliente = function() { | 418 | $scope.seleccionarCliente = function() { |
406 | 419 | ||
407 | var modalInstance = $uibModal.open( | 420 | var modalInstance = $uibModal.open( |
408 | { | 421 | { |
409 | ariaLabelledBy: 'Busqueda de Cliente', | 422 | ariaLabelledBy: 'Busqueda de Cliente', |
410 | templateUrl: 'foca-busqueda-cliente-modal.html', | 423 | templateUrl: 'foca-busqueda-cliente-modal.html', |
411 | controller: 'focaBusquedaClienteModalController', | 424 | controller: 'focaBusquedaClienteModalController', |
412 | size: 'lg' | 425 | size: 'lg' |
413 | } | 426 | } |
414 | ); | 427 | ); |
415 | modalInstance.result.then( | 428 | modalInstance.result.then( |
416 | function(cliente) { | 429 | function(cliente) { |
417 | $scope.abrirModalDomicilios(cliente); | 430 | $scope.abrirModalDomicilios(cliente); |
418 | }, function() { | 431 | }, function() { |
419 | 432 | ||
420 | } | 433 | } |
421 | ); | 434 | ); |
422 | }; | 435 | }; |
423 | 436 | ||
424 | $scope.abrirModalDomicilios = function(cliente) { | 437 | $scope.abrirModalDomicilios = function(cliente) { |
425 | var modalInstanceDomicilio = $uibModal.open( | 438 | var modalInstanceDomicilio = $uibModal.open( |
426 | { | 439 | { |
427 | ariaLabelledBy: 'Busqueda de Domicilios', | 440 | ariaLabelledBy: 'Busqueda de Domicilios', |
428 | templateUrl: 'modal-domicilio.html', | 441 | templateUrl: 'modal-domicilio.html', |
429 | controller: 'focaModalDomicilioController', | 442 | controller: 'focaModalDomicilioController', |
430 | resolve: { idCliente: function() { return cliente.cod; }}, | 443 | resolve: { idCliente: function() { return cliente.cod; }}, |
431 | size: 'lg', | 444 | size: 'lg', |
432 | } | 445 | } |
433 | ); | 446 | ); |
434 | modalInstanceDomicilio.result.then( | 447 | modalInstanceDomicilio.result.then( |
435 | function(domicilio) { | 448 | function(domicilio) { |
436 | $scope.remito.domicilio.id = domicilio.nivel2; | 449 | $scope.remito.domicilio.id = domicilio.nivel2; |
437 | $scope.remito.cliente = cliente; | 450 | $scope.remito.cliente = cliente; |
438 | 451 | ||
439 | addCabecera('Cliente:', cliente.nom); | 452 | addCabecera('Cliente:', cliente.nom); |
440 | addCabecera('Domicilio:', domicilio.dom); | 453 | addCabecera('Domicilio:', domicilio.dom); |
441 | }, function() { | 454 | }, function() { |
442 | $scope.seleccionarCliente(); | 455 | $scope.seleccionarCliente(); |
443 | return; | 456 | return; |
444 | } | 457 | } |
445 | ); | 458 | ); |
446 | }; | 459 | }; |
447 | 460 | ||
448 | $scope.mostrarFichaCliente = function() { | 461 | $scope.mostrarFichaCliente = function() { |
449 | $uibModal.open( | 462 | $uibModal.open( |
450 | { | 463 | { |
451 | ariaLabelledBy: 'Datos del Cliente', | 464 | ariaLabelledBy: 'Datos del Cliente', |
452 | templateUrl: 'foca-crear-remito-ficha-cliente.html', | 465 | templateUrl: 'foca-crear-remito-ficha-cliente.html', |
453 | controller: 'focaCrearRemitoFichaClienteController', | 466 | controller: 'focaCrearRemitoFichaClienteController', |
454 | size: 'lg' | 467 | size: 'lg' |
455 | } | 468 | } |
456 | ); | 469 | ); |
457 | }; | 470 | }; |
458 | 471 | ||
459 | $scope.getTotal = function() { | 472 | $scope.getTotal = function() { |
460 | var total = 0; | 473 | var total = 0; |
461 | var arrayTempArticulos = $scope.articulosTabla; | 474 | var arrayTempArticulos = $scope.articulosTabla; |
462 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 475 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
463 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 476 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
464 | } | 477 | } |
465 | return parseFloat(total.toFixed(2)); | 478 | return parseFloat(total.toFixed(2)); |
466 | }; | 479 | }; |
467 | 480 | ||
468 | $scope.getSubTotal = function() { | 481 | $scope.getSubTotal = function() { |
469 | if($scope.articuloACargar) { | 482 | if($scope.articuloACargar) { |
470 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 483 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
471 | } | 484 | } |
472 | }; | 485 | }; |
473 | 486 | ||
474 | $scope.abrirModalListaPrecio = function() { | 487 | $scope.abrirModalListaPrecio = function() { |
475 | var modalInstance = $uibModal.open( | 488 | var modalInstance = $uibModal.open( |
476 | { | 489 | { |
477 | ariaLabelledBy: 'Busqueda de Precio Condición', | 490 | ariaLabelledBy: 'Busqueda de Precio Condición', |
478 | templateUrl: 'modal-precio-condicion.html', | 491 | templateUrl: 'modal-precio-condicion.html', |
479 | controller: 'focaModalPrecioCondicionController', | 492 | controller: 'focaModalPrecioCondicionController', |
480 | size: 'lg' | 493 | size: 'lg' |
481 | } | 494 | } |
482 | ); | 495 | ); |
483 | modalInstance.result.then( | 496 | modalInstance.result.then( |
484 | function(precioCondicion) { | 497 | function(precioCondicion) { |
485 | var cabecera = ''; | 498 | var cabecera = ''; |
486 | var plazosConcat = ''; | 499 | var plazosConcat = ''; |
487 | if(!Array.isArray(precioCondicion)) { | 500 | if(!Array.isArray(precioCondicion)) { |
488 | $scope.plazosPagos = precioCondicion.plazoPago; | 501 | $scope.plazosPagos = precioCondicion.plazoPago; |
489 | $scope.idLista = precioCondicion.idListaPrecio; | 502 | $scope.idLista = precioCondicion.idListaPrecio; |
490 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 503 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
491 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 504 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
492 | } | 505 | } |
493 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | 506 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); |
494 | } else { //Cuando se ingresan los plazos manualmente | 507 | } else { //Cuando se ingresan los plazos manualmente |
495 | $scope.idLista = -1; //-1, el modal productos busca todos los productos | 508 | $scope.idLista = -1; //-1, el modal productos busca todos los productos |
496 | $scope.plazosPagos = precioCondicion; | 509 | $scope.plazosPagos = precioCondicion; |
497 | for(var j = 0; j < precioCondicion.length; j++) { | 510 | for(var j = 0; j < precioCondicion.length; j++) { |
498 | plazosConcat += precioCondicion[j].dias + ' '; | 511 | plazosConcat += precioCondicion[j].dias + ' '; |
499 | } | 512 | } |
500 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 513 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
501 | } | 514 | } |
502 | $scope.articulosTabla = []; | 515 | $scope.articulosTabla = []; |
503 | addCabecera('Precios y condiciones:', cabecera); | 516 | addCabecera('Precios y condiciones:', cabecera); |
504 | }, function() { | 517 | }, function() { |
505 | 518 | ||
506 | } | 519 | } |
507 | ); | 520 | ); |
508 | }; | 521 | }; |
509 | 522 | ||
510 | $scope.abrirModalFlete = function() { | 523 | $scope.abrirModalFlete = function() { |
511 | var modalInstance = $uibModal.open( | 524 | var modalInstance = $uibModal.open( |
512 | { | 525 | { |
513 | ariaLabelledBy: 'Busqueda de Flete', | 526 | ariaLabelledBy: 'Busqueda de Flete', |
514 | templateUrl: 'modal-flete.html', | 527 | templateUrl: 'modal-flete.html', |
515 | controller: 'focaModalFleteController', | 528 | controller: 'focaModalFleteController', |
516 | size: 'lg', | 529 | size: 'lg', |
517 | resolve: { | 530 | resolve: { |
518 | parametrosFlete: | 531 | parametrosFlete: |
519 | function() { | 532 | function() { |
520 | return { | 533 | return { |
521 | flete: $scope.remito.flete ? '1' : | 534 | flete: $scope.remito.flete ? '1' : |
522 | ($scope.remito.fob ? 'FOB' : | 535 | ($scope.remito.fob ? 'FOB' : |
523 | ($scope.remito.flete === undefined ? null : '0')), | 536 | ($scope.remito.flete === undefined ? null : '0')), |
524 | bomba: $scope.remito.bomba ? '1' : | 537 | bomba: $scope.remito.bomba ? '1' : |
525 | ($scope.remito.bomba === undefined ? null : '0'), | 538 | ($scope.remito.bomba === undefined ? null : '0'), |
526 | kilometros: $scope.remito.kilometros | 539 | kilometros: $scope.remito.kilometros |
527 | }; | 540 | }; |
528 | } | 541 | } |
529 | } | 542 | } |
530 | } | 543 | } |
531 | ); | 544 | ); |
532 | modalInstance.result.then( | 545 | modalInstance.result.then( |
533 | function(datos) { | 546 | function(datos) { |
534 | $scope.remito.flete = datos.flete; | 547 | $scope.remito.flete = datos.flete; |
535 | $scope.remito.fob = datos.FOB; | 548 | $scope.remito.fob = datos.FOB; |
536 | $scope.remito.bomba = datos.bomba; | 549 | $scope.remito.bomba = datos.bomba; |
537 | $scope.remito.kilometros = datos.kilometros; | 550 | $scope.remito.kilometros = datos.kilometros; |
538 | 551 | ||
539 | addCabecera('Flete:', datos.flete ? 'Si' : | 552 | addCabecera('Flete:', datos.flete ? 'Si' : |
540 | ($scope.remito.fob ? 'FOB' : 'No')); | 553 | ($scope.remito.fob ? 'FOB' : 'No')); |
541 | if(datos.flete) { | 554 | if(datos.flete) { |
542 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); | 555 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); |
543 | addCabecera('Kilometros:', datos.kilometros); | 556 | addCabecera('Kilometros:', datos.kilometros); |
544 | } else { | 557 | } else { |
545 | removeCabecera('Bomba:'); | 558 | removeCabecera('Bomba:'); |
546 | removeCabecera('Kilometros:'); | 559 | removeCabecera('Kilometros:'); |
547 | $scope.remito.fob = false; | 560 | $scope.remito.fob = false; |
548 | $scope.remito.bomba = false; | 561 | $scope.remito.bomba = false; |
549 | $scope.remito.kilometros = null; | 562 | $scope.remito.kilometros = null; |
550 | } | 563 | } |
551 | }, function() { | 564 | }, function() { |
552 | 565 | ||
553 | } | 566 | } |
554 | ); | 567 | ); |
555 | }; | 568 | }; |
556 | 569 | ||
557 | $scope.abrirModalMoneda = function() { | 570 | $scope.abrirModalMoneda = function() { |
558 | var modalInstance = $uibModal.open( | 571 | var modalInstance = $uibModal.open( |
559 | { | 572 | { |
560 | ariaLabelledBy: 'Busqueda de Moneda', | 573 | ariaLabelledBy: 'Busqueda de Moneda', |
561 | templateUrl: 'modal-moneda.html', | 574 | templateUrl: 'modal-moneda.html', |
562 | controller: 'focaModalMonedaController', | 575 | controller: 'focaModalMonedaController', |
563 | size: 'lg' | 576 | size: 'lg' |
564 | } | 577 | } |
565 | ); | 578 | ); |
566 | modalInstance.result.then( | 579 | modalInstance.result.then( |
567 | function(moneda) { | 580 | function(moneda) { |
568 | $scope.abrirModalCotizacion(moneda); | 581 | $scope.abrirModalCotizacion(moneda); |
569 | }, function() { | 582 | }, function() { |
570 | 583 | ||
571 | } | 584 | } |
572 | ); | 585 | ); |
573 | }; | 586 | }; |
574 | 587 | ||
575 | $scope.abrirModalCotizacion = function(moneda) { | 588 | $scope.abrirModalCotizacion = function(moneda) { |
576 | var modalInstance = $uibModal.open( | 589 | var modalInstance = $uibModal.open( |
577 | { | 590 | { |
578 | ariaLabelledBy: 'Busqueda de Cotización', | 591 | ariaLabelledBy: 'Busqueda de Cotización', |
579 | templateUrl: 'modal-cotizacion.html', | 592 | templateUrl: 'modal-cotizacion.html', |
580 | controller: 'focaModalCotizacionController', | 593 | controller: 'focaModalCotizacionController', |
581 | size: 'lg', | 594 | size: 'lg', |
582 | resolve: {idMoneda: function() {return moneda.ID;}} | 595 | resolve: {idMoneda: function() {return moneda.ID;}} |
583 | } | 596 | } |
584 | ); | 597 | ); |
585 | modalInstance.result.then( | 598 | modalInstance.result.then( |
586 | function(cotizacion) { | 599 | function(cotizacion) { |
587 | var articulosTablaTemp = $scope.articulosTabla; | 600 | var articulosTablaTemp = $scope.articulosTabla; |
588 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 601 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
589 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 602 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
590 | $scope.remito.cotizacion.COTIZACION; | 603 | $scope.remito.cotizacion.COTIZACION; |
591 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 604 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
592 | cotizacion.COTIZACION; | 605 | cotizacion.COTIZACION; |
593 | } | 606 | } |
594 | $scope.articulosTabla = articulosTablaTemp; | 607 | $scope.articulosTabla = articulosTablaTemp; |
595 | $scope.remito.moneda = { | 608 | $scope.remito.moneda = { |
596 | id: moneda.ID, | 609 | id: moneda.ID, |
597 | detalle: moneda.DETALLE, | 610 | detalle: moneda.DETALLE, |
598 | simbolo: moneda.SIMBOLO | 611 | simbolo: moneda.SIMBOLO |
599 | }; | 612 | }; |
600 | $scope.remito.cotizacion = { | 613 | $scope.remito.cotizacion = { |
601 | ID: cotizacion.ID, | 614 | ID: cotizacion.ID, |
602 | COTIZACION: cotizacion.COTIZACION, | 615 | COTIZACION: cotizacion.COTIZACION, |
603 | FECHA: cotizacion.FECHA | 616 | FECHA: cotizacion.FECHA |
604 | }; | 617 | }; |
605 | addCabecera('Moneda:', moneda.DETALLE); | 618 | addCabecera('Moneda:', moneda.DETALLE); |
606 | addCabecera( | 619 | addCabecera( |
607 | 'Fecha cotizacion:', | 620 | 'Fecha cotizacion:', |
608 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 621 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
609 | ); | 622 | ); |
610 | addCabecera('Cotizacion:', cotizacion.COTIZACION); | 623 | addCabecera('Cotizacion:', cotizacion.COTIZACION); |
611 | }, function() { | 624 | }, function() { |
612 | 625 | ||
613 | } | 626 | } |
614 | ); | 627 | ); |
615 | }; | 628 | }; |
616 | 629 | ||
617 | $scope.agregarATabla = function(key) { | 630 | $scope.agregarATabla = function(key) { |
618 | if(key === 13) { | 631 | if(key === 13) { |
619 | if($scope.articuloACargar.cantidad === undefined || | 632 | if($scope.articuloACargar.cantidad === undefined || |
620 | $scope.articuloACargar.cantidad === 0 || | 633 | $scope.articuloACargar.cantidad === 0 || |
621 | $scope.articuloACargar.cantidad === null ) { | 634 | $scope.articuloACargar.cantidad === null ) { |
622 | focaModalService.alert('El valor debe ser al menos 1'); | 635 | focaModalService.alert('El valor debe ser al menos 1'); |
623 | return; | 636 | return; |
624 | } | 637 | } |
625 | delete $scope.articuloACargar.sectorCodigo; | 638 | delete $scope.articuloACargar.sectorCodigo; |
626 | $scope.articulosTabla.push($scope.articuloACargar); | 639 | $scope.articulosTabla.push($scope.articuloACargar); |
627 | $scope.cargando = true; | 640 | $scope.cargando = true; |
628 | } | 641 | } |
629 | }; | 642 | }; |
630 | 643 | ||
631 | $scope.quitarArticulo = function(key) { | 644 | $scope.quitarArticulo = function(key) { |
632 | $scope.articulosTabla.splice(key, 1); | 645 | $scope.articulosTabla.splice(key, 1); |
633 | }; | 646 | }; |
634 | 647 | ||
635 | $scope.editarArticulo = function(key, articulo) { | 648 | $scope.editarArticulo = function(key, articulo) { |
636 | if(key === 13) { | 649 | if(key === 13) { |
637 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 650 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
638 | articulo.cantidad === undefined) { | 651 | articulo.cantidad === undefined) { |
639 | focaModalService.alert('El valor debe ser al menos 1'); | 652 | focaModalService.alert('El valor debe ser al menos 1'); |
640 | return; | 653 | return; |
641 | } | 654 | } |
642 | articulo.editCantidad = false; | 655 | articulo.editCantidad = false; |
643 | articulo.editPrecio = false; | 656 | articulo.editPrecio = false; |
644 | } | 657 | } |
645 | }; | 658 | }; |
646 | 659 | ||
647 | $scope.cambioEdit = function(articulo, propiedad) { | 660 | $scope.cambioEdit = function(articulo, propiedad) { |
648 | if(propiedad === 'cantidad') { | 661 | if(propiedad === 'cantidad') { |
649 | articulo.editCantidad = true; | 662 | articulo.editCantidad = true; |
650 | } else if(propiedad === 'precio') { | 663 | } else if(propiedad === 'precio') { |
651 | articulo.editPrecio = true; | 664 | articulo.editPrecio = true; |
652 | } | 665 | } |
653 | }; | 666 | }; |
654 | 667 | ||
655 | $scope.limpiarFlete = function() { | 668 | $scope.limpiarFlete = function() { |
656 | $scope.remito.fleteNombre = ''; | 669 | $scope.remito.fleteNombre = ''; |
657 | $scope.remito.chofer = ''; | 670 | $scope.remito.chofer = ''; |
658 | $scope.remito.vehiculo = ''; | 671 | $scope.remito.vehiculo = ''; |
659 | $scope.remito.kilometros = ''; | 672 | $scope.remito.kilometros = ''; |
660 | $scope.remito.costoUnitarioKmFlete = ''; | 673 | $scope.remito.costoUnitarioKmFlete = ''; |
661 | $scope.choferes = ''; | 674 | $scope.choferes = ''; |
662 | $scope.vehiculos = ''; | 675 | $scope.vehiculos = ''; |
663 | }; | 676 | }; |
664 | 677 | ||
665 | $scope.limpiarPantalla = function() { | 678 | $scope.limpiarPantalla = function() { |
666 | $scope.limpiarFlete(); | 679 | $scope.limpiarFlete(); |
667 | $scope.remito.flete = '0'; | 680 | $scope.remito.flete = '0'; |
668 | $scope.remito.bomba = '0'; | 681 | $scope.remito.bomba = '0'; |
669 | $scope.remito.precioCondicion = ''; | 682 | $scope.remito.precioCondicion = ''; |
670 | $scope.articulosTabla = []; | 683 | $scope.articulosTabla = []; |
671 | $scope.remito.vendedor.nombre = ''; | 684 | $scope.remito.vendedor.nombre = ''; |
672 | $scope.remito.cliente = {nombre: ''}; | 685 | $scope.remito.cliente = {nombre: ''}; |
673 | $scope.remito.domicilio = {dom: ''}; | 686 | $scope.remito.domicilio = {dom: ''}; |
674 | $scope.domiciliosCliente = []; | 687 | $scope.domiciliosCliente = []; |
675 | }; | 688 | }; |
676 | 689 | ||
677 | $scope.resetFilter = function() { | 690 | $scope.resetFilter = function() { |
678 | $scope.articuloACargar = {}; | 691 | $scope.articuloACargar = {}; |
679 | $scope.cargando = true; | 692 | $scope.cargando = true; |
680 | }; | 693 | }; |
681 | 694 | ||
682 | $scope.selectFocus = function($event) { | 695 | $scope.selectFocus = function($event) { |
683 | $event.target.select(); | 696 | $event.target.select(); |
684 | }; | 697 | }; |
685 | 698 | ||
686 | $scope.salir = function() { | 699 | $scope.salir = function() { |
687 | $location.path('/'); | 700 | $location.path('/'); |
688 | }; | 701 | }; |
689 | function addArrayCabecera(array) { | 702 | function addArrayCabecera(array) { |
690 | for(var i = 0; i < array.length; i++) { | 703 | for(var i = 0; i < array.length; i++) { |
691 | addCabecera(array[i].label, array[i].valor); | 704 | addCabecera(array[i].label, array[i].valor); |
692 | } | 705 | } |
693 | } | 706 | } |
694 | 707 | ||
695 | function addCabecera(label, valor) { | 708 | function addCabecera(label, valor) { |
696 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 709 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
697 | if(propiedad.length === 1) { | 710 | if(propiedad.length === 1) { |
698 | propiedad[0].valor = valor; | 711 | propiedad[0].valor = valor; |
699 | } else { | 712 | } else { |
700 | $scope.cabecera.push({label: label, valor: valor}); | 713 | $scope.cabecera.push({label: label, valor: valor}); |
701 | } | 714 | } |
702 | } | 715 | } |
703 | 716 | ||
704 | function removeCabecera(label) { | 717 | function removeCabecera(label) { |
705 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 718 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
706 | if(propiedad.length === 1) { | 719 | if(propiedad.length === 1) { |
707 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | 720 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
708 | } | 721 | } |
709 | } | 722 | } |
710 | 723 | ||
711 | function rellenar(relleno, longitud) { | 724 | function rellenar(relleno, longitud) { |
712 | relleno = '' + relleno; | 725 | relleno = '' + relleno; |
713 | while (relleno.length < longitud) { | 726 | while (relleno.length < longitud) { |
714 | relleno = '0' + relleno; | 727 | relleno = '0' + relleno; |
715 | } | 728 | } |
716 | 729 | ||
717 | return relleno; | 730 | return relleno; |
718 | } | 731 | } |
719 | } | 732 | } |
720 | ] | 733 | ] |
721 | ) | 734 | ) |
722 | .controller('remitoListaCtrl', [ | 735 | .controller('remitoListaCtrl', [ |
723 | '$scope', | 736 | '$scope', |
724 | 'crearRemitoService', | 737 | 'crearRemitoService', |
725 | '$location', | 738 | '$location', |
726 | function($scope, crearRemitoService, $location) { | 739 | function($scope, crearRemitoService, $location) { |
727 | crearRemitoService.obtenerRemito().then(function(datos) { | 740 | crearRemitoService.obtenerRemito().then(function(datos) { |
728 | $scope.remitos = datos.data; | 741 | $scope.remitos = datos.data; |
729 | }); | 742 | }); |
730 | $scope.editar = function(remito) { | 743 | $scope.editar = function(remito) { |
731 | crearRemitoService.setRemito(remito); | 744 | crearRemitoService.setRemito(remito); |
732 | $location.path('/venta-nota-remito/abm/'); | 745 | $location.path('/venta-nota-remito/abm/'); |
733 | }; | 746 | }; |
734 | $scope.crearRemito = function() { | 747 | $scope.crearRemito = function() { |
735 | crearRemitoService.clearRemito(); | 748 | crearRemitoService.clearRemito(); |
736 | $location.path('/venta-nota-remito/abm/'); | 749 | $location.path('/venta-nota-remito/abm/'); |
737 | }; | 750 | }; |
738 | } | 751 | } |
739 | ]) | 752 | ]) |
740 | .controller('focaCrearRemitoFichaClienteController', [ | 753 | .controller('focaCrearRemitoFichaClienteController', [ |
741 | '$scope', | 754 | '$scope', |
742 | 'crearRemitoService', | 755 | 'crearRemitoService', |
src/js/service.js
1 | angular.module('focaCrearRemito') | 1 | angular.module('focaCrearRemito') |
2 | .service('crearRemitoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | 2 | .service('crearRemitoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { |
3 | var route = API_ENDPOINT.URL; | 3 | var route = API_ENDPOINT.URL; |
4 | return { | 4 | return { |
5 | crearRemito: function(remito) { | 5 | crearRemito: function(remito) { |
6 | // TODO: Cambiar para usar el servicio /remito | 6 | // TODO: Cambiar para usar el servicio /remito |
7 | return $http.post(route + '/nota-pedido', {remito: remito}); | 7 | return $http.post(route + '/remito', {remito: remito}); |
8 | }, | 8 | }, |
9 | obtenerRemito: function() { | 9 | obtenerRemito: function() { |
10 | return $http.get(route +'/nota-pedido'); | 10 | return $http.get(route +'/nota-pedido'); |
11 | }, | 11 | }, |
12 | setRemito: function(remito) { | 12 | setRemito: function(remito) { |
13 | this.remito = remito; | 13 | this.remito = remito; |
14 | }, | 14 | }, |
15 | clearRemito: function() { | 15 | clearRemito: function() { |
16 | this.remito = undefined; | 16 | this.remito = undefined; |
17 | }, | 17 | }, |
18 | getRemito: function() { | 18 | getRemito: function() { |
19 | return this.remito; | 19 | return this.remito; |
20 | }, | 20 | }, |
21 | getArticulosByIdRemito: function(id) { | 21 | getArticulosByIdRemito: function(id) { |
22 | return $http.get(route+'/articulos/nota-pedido/'+id); | 22 | return $http.get(route+'/articulos/nota-pedido/'+id); |
23 | }, | 23 | }, |
24 | crearArticulosParaRemito: function(articuloRemito) { | 24 | crearArticulosParaRemito: function(articuloRemito) { |
25 | return $http.post(route + '/articulos/nota-pedido', | 25 | return $http.post(route + '/articulos/remito', |
26 | {articuloRemito: articuloRemito}); | 26 | {articuloRemito: articuloRemito}); |
27 | }, | 27 | }, |
28 | getDomiciliosByIdRemito: function(id) { | 28 | getDomiciliosByIdRemito: function(id) { |
29 | return $http.get(route +'/nota-pedido/'+id+'/domicilios'); | 29 | return $http.get(route +'/nota-pedido/'+id+'/domicilios'); |
30 | }, | 30 | }, |
31 | getDomiciliosByIdCliente: function(id) { | 31 | getDomiciliosByIdCliente: function(id) { |
32 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) | 32 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) |
33 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); | 33 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); |
34 | }, | 34 | }, |
35 | getPrecioCondicion: function() { | 35 | getPrecioCondicion: function() { |
36 | return $http.get(route + '/precio-condicion'); | 36 | return $http.get(route + '/precio-condicion'); |
37 | }, | 37 | }, |
38 | getPrecioCondicionById: function(id) { | 38 | getPrecioCondicionById: function(id) { |
39 | return $http.get(route + '/precio-condicion/' + id); | 39 | return $http.get(route + '/precio-condicion/' + id); |
40 | }, | 40 | }, |
41 | getPlazoPagoByPrecioCondicion: function(id) { | 41 | getPlazoPagoByPrecioCondicion: function(id) { |
42 | return $http.get(route + '/plazo-pago/precio-condicion/'+ id); | 42 | return $http.get(route + '/plazo-pago/precio-condicion/'+ id); |
43 | }, | 43 | }, |
44 | crearFlete: function(flete) { | 44 | crearFlete: function(flete) { |
45 | return $http.post(route + '/flete', {flete : flete}); | 45 | return $http.post(route + '/flete', {flete : flete}); |
46 | }, | 46 | }, |
47 | crearPlazosParaRemito: function(plazos) { | 47 | crearPlazosParaRemito: function(plazos) { |
48 | return $http.post(route + '/plazo-pago/nota-pedido', plazos); | 48 | return $http.post(route + '/plazo-pago/nota-pedido', plazos); |
49 | }, | 49 | }, |
50 | getCotizacionByIdMoneda: function(id) { | 50 | getCotizacionByIdMoneda: function(id) { |
51 | return $http.get(route + '/moneda/' + id); | 51 | return $http.get(route + '/moneda/' + id); |
52 | }, | 52 | }, |
53 | crearEstadoParaRemito: function(estado) { | 53 | crearEstadoParaRemito: function(estado) { |
54 | return $http.post(route + '/estado', {estado: estado}); | 54 | return $http.post(route + '/estado', {estado: estado}); |
55 | }, | 55 | }, |
56 | getNumeroRemito: function() { | 56 | getNumeroRemito: function() { |
57 | return $http.get(route + '/nota-pedido/numero-siguiente'); | 57 | return $http.get(route + '/nota-pedido/numero-siguiente'); |
58 | } | 58 | } |
59 | }; | 59 | }; |
60 | }]); | 60 | }]); |
61 | 61 |