Commit 94d9c4f9563c06b235fff5e1c24ccf95b8faa697
1 parent
55f6418a6b
Exists in
master
guardo remito
desactivo camel case porque una propiedad de remito altera pre-commit
Showing
3 changed files
with
48 additions
and
34 deletions
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', ' '), |
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 | } | 401 | } |
389 | ); | 402 | ); |
390 | modalInstance.result.then( | 403 | modalInstance.result.then( |
391 | function(proveedor) { | 404 | function(proveedor) { |
392 | $scope.remito.proveedor.codigo = proveedor.COD; | 405 | $scope.remito.proveedor.codigo = proveedor.COD; |
393 | addCabecera('Proveedor:', proveedor.NOM); | 406 | addCabecera('Proveedor:', proveedor.NOM); |
394 | }, function() { | 407 | }, function() { |
395 | 408 | ||
396 | } | 409 | } |
397 | ); | 410 | ); |
398 | }; | 411 | }; |
399 | 412 | ||
400 | $scope.seleccionarCliente = function() { | 413 | $scope.seleccionarCliente = function() { |
401 | 414 | ||
402 | var modalInstance = $uibModal.open( | 415 | var modalInstance = $uibModal.open( |
403 | { | 416 | { |
404 | ariaLabelledBy: 'Busqueda de Cliente', | 417 | ariaLabelledBy: 'Busqueda de Cliente', |
405 | templateUrl: 'foca-busqueda-cliente-modal.html', | 418 | templateUrl: 'foca-busqueda-cliente-modal.html', |
406 | controller: 'focaBusquedaClienteModalController', | 419 | controller: 'focaBusquedaClienteModalController', |
407 | size: 'lg' | 420 | size: 'lg' |
408 | } | 421 | } |
409 | ); | 422 | ); |
410 | modalInstance.result.then( | 423 | modalInstance.result.then( |
411 | function(cliente) { | 424 | function(cliente) { |
412 | $scope.abrirModalDomicilios(cliente); | 425 | $scope.abrirModalDomicilios(cliente); |
413 | }, function() { | 426 | }, function() { |
414 | 427 | ||
415 | } | 428 | } |
416 | ); | 429 | ); |
417 | }; | 430 | }; |
418 | 431 | ||
419 | $scope.abrirModalDomicilios = function(cliente) { | 432 | $scope.abrirModalDomicilios = function(cliente) { |
420 | var modalInstanceDomicilio = $uibModal.open( | 433 | var modalInstanceDomicilio = $uibModal.open( |
421 | { | 434 | { |
422 | ariaLabelledBy: 'Busqueda de Domicilios', | 435 | ariaLabelledBy: 'Busqueda de Domicilios', |
423 | templateUrl: 'modal-domicilio.html', | 436 | templateUrl: 'modal-domicilio.html', |
424 | controller: 'focaModalDomicilioController', | 437 | controller: 'focaModalDomicilioController', |
425 | resolve: { idCliente: function() { return cliente.cod; }}, | 438 | resolve: { idCliente: function() { return cliente.cod; }}, |
426 | size: 'lg', | 439 | size: 'lg', |
427 | } | 440 | } |
428 | ); | 441 | ); |
429 | modalInstanceDomicilio.result.then( | 442 | modalInstanceDomicilio.result.then( |
430 | function(domicilio) { | 443 | function(domicilio) { |
431 | $scope.remito.domicilio.id = domicilio.nivel2; | 444 | $scope.remito.domicilio.id = domicilio.nivel2; |
432 | $scope.remito.cliente = cliente; | 445 | $scope.remito.cliente = cliente; |
433 | 446 | ||
434 | addCabecera('Cliente:', cliente.nom); | 447 | addCabecera('Cliente:', cliente.nom); |
435 | addCabecera('Domicilio:', domicilio.dom); | 448 | addCabecera('Domicilio:', domicilio.dom); |
436 | }, function() { | 449 | }, function() { |
437 | $scope.seleccionarCliente(); | 450 | $scope.seleccionarCliente(); |
438 | return; | 451 | return; |
439 | } | 452 | } |
440 | ); | 453 | ); |
441 | }; | 454 | }; |
442 | 455 | ||
443 | $scope.mostrarFichaCliente = function() { | 456 | $scope.mostrarFichaCliente = function() { |
444 | $uibModal.open( | 457 | $uibModal.open( |
445 | { | 458 | { |
446 | ariaLabelledBy: 'Datos del Cliente', | 459 | ariaLabelledBy: 'Datos del Cliente', |
447 | templateUrl: 'foca-crear-remito-ficha-cliente.html', | 460 | templateUrl: 'foca-crear-remito-ficha-cliente.html', |
448 | controller: 'focaCrearRemitoFichaClienteController', | 461 | controller: 'focaCrearRemitoFichaClienteController', |
449 | size: 'lg' | 462 | size: 'lg' |
450 | } | 463 | } |
451 | ); | 464 | ); |
452 | }; | 465 | }; |
453 | 466 | ||
454 | $scope.getTotal = function() { | 467 | $scope.getTotal = function() { |
455 | var total = 0; | 468 | var total = 0; |
456 | var arrayTempArticulos = $scope.articulosTabla; | 469 | var arrayTempArticulos = $scope.articulosTabla; |
457 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 470 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
458 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 471 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
459 | } | 472 | } |
460 | return parseFloat(total.toFixed(2)); | 473 | return parseFloat(total.toFixed(2)); |
461 | }; | 474 | }; |
462 | 475 | ||
463 | $scope.getSubTotal = function() { | 476 | $scope.getSubTotal = function() { |
464 | if($scope.articuloACargar) { | 477 | if($scope.articuloACargar) { |
465 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 478 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
466 | } | 479 | } |
467 | }; | 480 | }; |
468 | 481 | ||
469 | $scope.abrirModalListaPrecio = function() { | 482 | $scope.abrirModalListaPrecio = function() { |
470 | var modalInstance = $uibModal.open( | 483 | var modalInstance = $uibModal.open( |
471 | { | 484 | { |
472 | ariaLabelledBy: 'Busqueda de Precio Condición', | 485 | ariaLabelledBy: 'Busqueda de Precio Condición', |
473 | templateUrl: 'modal-precio-condicion.html', | 486 | templateUrl: 'modal-precio-condicion.html', |
474 | controller: 'focaModalPrecioCondicionController', | 487 | controller: 'focaModalPrecioCondicionController', |
475 | size: 'lg' | 488 | size: 'lg' |
476 | } | 489 | } |
477 | ); | 490 | ); |
478 | modalInstance.result.then( | 491 | modalInstance.result.then( |
479 | function(precioCondicion) { | 492 | function(precioCondicion) { |
480 | var cabecera = ''; | 493 | var cabecera = ''; |
481 | var plazosConcat = ''; | 494 | var plazosConcat = ''; |
482 | if(!Array.isArray(precioCondicion)) { | 495 | if(!Array.isArray(precioCondicion)) { |
483 | $scope.plazosPagos = precioCondicion.plazoPago; | 496 | $scope.plazosPagos = precioCondicion.plazoPago; |
484 | $scope.idLista = precioCondicion.idListaPrecio; | 497 | $scope.idLista = precioCondicion.idListaPrecio; |
485 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 498 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
486 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 499 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
487 | } | 500 | } |
488 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | 501 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); |
489 | } else { //Cuando se ingresan los plazos manualmente | 502 | } else { //Cuando se ingresan los plazos manualmente |
490 | $scope.idLista = -1; //-1, el modal productos busca todos los productos | 503 | $scope.idLista = -1; //-1, el modal productos busca todos los productos |
491 | $scope.plazosPagos = precioCondicion; | 504 | $scope.plazosPagos = precioCondicion; |
492 | for(var j = 0; j < precioCondicion.length; j++) { | 505 | for(var j = 0; j < precioCondicion.length; j++) { |
493 | plazosConcat += precioCondicion[j].dias + ' '; | 506 | plazosConcat += precioCondicion[j].dias + ' '; |
494 | } | 507 | } |
495 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 508 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
496 | } | 509 | } |
497 | $scope.articulosTabla = []; | 510 | $scope.articulosTabla = []; |
498 | addCabecera('Precios y condiciones:', cabecera); | 511 | addCabecera('Precios y condiciones:', cabecera); |
499 | }, function() { | 512 | }, function() { |
500 | 513 | ||
501 | } | 514 | } |
502 | ); | 515 | ); |
503 | }; | 516 | }; |
504 | 517 | ||
505 | $scope.abrirModalFlete = function() { | 518 | $scope.abrirModalFlete = function() { |
506 | var modalInstance = $uibModal.open( | 519 | var modalInstance = $uibModal.open( |
507 | { | 520 | { |
508 | ariaLabelledBy: 'Busqueda de Flete', | 521 | ariaLabelledBy: 'Busqueda de Flete', |
509 | templateUrl: 'modal-flete.html', | 522 | templateUrl: 'modal-flete.html', |
510 | controller: 'focaModalFleteController', | 523 | controller: 'focaModalFleteController', |
511 | size: 'lg', | 524 | size: 'lg', |
512 | resolve: { | 525 | resolve: { |
513 | parametrosFlete: | 526 | parametrosFlete: |
514 | function() { | 527 | function() { |
515 | return { | 528 | return { |
516 | flete: $scope.remito.flete ? '1' : | 529 | flete: $scope.remito.flete ? '1' : |
517 | ($scope.remito.fob ? 'FOB' : | 530 | ($scope.remito.fob ? 'FOB' : |
518 | ($scope.remito.flete === undefined ? null : '0')), | 531 | ($scope.remito.flete === undefined ? null : '0')), |
519 | bomba: $scope.remito.bomba ? '1' : | 532 | bomba: $scope.remito.bomba ? '1' : |
520 | ($scope.remito.bomba === undefined ? null : '0'), | 533 | ($scope.remito.bomba === undefined ? null : '0'), |
521 | kilometros: $scope.remito.kilometros | 534 | kilometros: $scope.remito.kilometros |
522 | }; | 535 | }; |
523 | } | 536 | } |
524 | } | 537 | } |
525 | } | 538 | } |
526 | ); | 539 | ); |
527 | modalInstance.result.then( | 540 | modalInstance.result.then( |
528 | function(datos) { | 541 | function(datos) { |
529 | $scope.remito.flete = datos.flete; | 542 | $scope.remito.flete = datos.flete; |
530 | $scope.remito.fob = datos.FOB; | 543 | $scope.remito.fob = datos.FOB; |
531 | $scope.remito.bomba = datos.bomba; | 544 | $scope.remito.bomba = datos.bomba; |
532 | $scope.remito.kilometros = datos.kilometros; | 545 | $scope.remito.kilometros = datos.kilometros; |
533 | 546 | ||
534 | addCabecera('Flete:', datos.flete ? 'Si' : | 547 | addCabecera('Flete:', datos.flete ? 'Si' : |
535 | ($scope.remito.fob ? 'FOB' : 'No')); | 548 | ($scope.remito.fob ? 'FOB' : 'No')); |
536 | if(datos.flete) { | 549 | if(datos.flete) { |
537 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); | 550 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); |
538 | addCabecera('Kilometros:', datos.kilometros); | 551 | addCabecera('Kilometros:', datos.kilometros); |
539 | } else { | 552 | } else { |
540 | removeCabecera('Bomba:'); | 553 | removeCabecera('Bomba:'); |
541 | removeCabecera('Kilometros:'); | 554 | removeCabecera('Kilometros:'); |
542 | $scope.remito.fob = false; | 555 | $scope.remito.fob = false; |
543 | $scope.remito.bomba = false; | 556 | $scope.remito.bomba = false; |
544 | $scope.remito.kilometros = null; | 557 | $scope.remito.kilometros = null; |
545 | } | 558 | } |
546 | }, function() { | 559 | }, function() { |
547 | 560 | ||
548 | } | 561 | } |
549 | ); | 562 | ); |
550 | }; | 563 | }; |
551 | 564 | ||
552 | $scope.abrirModalMoneda = function() { | 565 | $scope.abrirModalMoneda = function() { |
553 | var modalInstance = $uibModal.open( | 566 | var modalInstance = $uibModal.open( |
554 | { | 567 | { |
555 | ariaLabelledBy: 'Busqueda de Moneda', | 568 | ariaLabelledBy: 'Busqueda de Moneda', |
556 | templateUrl: 'modal-moneda.html', | 569 | templateUrl: 'modal-moneda.html', |
557 | controller: 'focaModalMonedaController', | 570 | controller: 'focaModalMonedaController', |
558 | size: 'lg' | 571 | size: 'lg' |
559 | } | 572 | } |
560 | ); | 573 | ); |
561 | modalInstance.result.then( | 574 | modalInstance.result.then( |
562 | function(moneda) { | 575 | function(moneda) { |
563 | $scope.abrirModalCotizacion(moneda); | 576 | $scope.abrirModalCotizacion(moneda); |
564 | }, function() { | 577 | }, function() { |
565 | 578 | ||
566 | } | 579 | } |
567 | ); | 580 | ); |
568 | }; | 581 | }; |
569 | 582 | ||
570 | $scope.abrirModalCotizacion = function(moneda) { | 583 | $scope.abrirModalCotizacion = function(moneda) { |
571 | var modalInstance = $uibModal.open( | 584 | var modalInstance = $uibModal.open( |
572 | { | 585 | { |
573 | ariaLabelledBy: 'Busqueda de Cotización', | 586 | ariaLabelledBy: 'Busqueda de Cotización', |
574 | templateUrl: 'modal-cotizacion.html', | 587 | templateUrl: 'modal-cotizacion.html', |
575 | controller: 'focaModalCotizacionController', | 588 | controller: 'focaModalCotizacionController', |
576 | size: 'lg', | 589 | size: 'lg', |
577 | resolve: {idMoneda: function() {return moneda.ID;}} | 590 | resolve: {idMoneda: function() {return moneda.ID;}} |
578 | } | 591 | } |
579 | ); | 592 | ); |
580 | modalInstance.result.then( | 593 | modalInstance.result.then( |
581 | function(cotizacion) { | 594 | function(cotizacion) { |
582 | var articulosTablaTemp = $scope.articulosTabla; | 595 | var articulosTablaTemp = $scope.articulosTabla; |
583 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 596 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
584 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 597 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
585 | $scope.remito.cotizacion.COTIZACION; | 598 | $scope.remito.cotizacion.COTIZACION; |
586 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 599 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
587 | cotizacion.COTIZACION; | 600 | cotizacion.COTIZACION; |
588 | } | 601 | } |
589 | $scope.articulosTabla = articulosTablaTemp; | 602 | $scope.articulosTabla = articulosTablaTemp; |
590 | $scope.remito.moneda = { | 603 | $scope.remito.moneda = { |
591 | id: moneda.ID, | 604 | id: moneda.ID, |
592 | detalle: moneda.DETALLE, | 605 | detalle: moneda.DETALLE, |
593 | simbolo: moneda.SIMBOLO | 606 | simbolo: moneda.SIMBOLO |
594 | }; | 607 | }; |
595 | $scope.remito.cotizacion = { | 608 | $scope.remito.cotizacion = { |
596 | ID: cotizacion.ID, | 609 | ID: cotizacion.ID, |
597 | COTIZACION: cotizacion.COTIZACION, | 610 | COTIZACION: cotizacion.COTIZACION, |
598 | FECHA: cotizacion.FECHA | 611 | FECHA: cotizacion.FECHA |
599 | }; | 612 | }; |
600 | addCabecera('Moneda:', moneda.DETALLE); | 613 | addCabecera('Moneda:', moneda.DETALLE); |
601 | addCabecera( | 614 | addCabecera( |
602 | 'Fecha cotizacion:', | 615 | 'Fecha cotizacion:', |
603 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 616 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
604 | ); | 617 | ); |
605 | addCabecera('Cotizacion:', cotizacion.COTIZACION); | 618 | addCabecera('Cotizacion:', cotizacion.COTIZACION); |
606 | }, function() { | 619 | }, function() { |
607 | 620 | ||
608 | } | 621 | } |
609 | ); | 622 | ); |
610 | }; | 623 | }; |
611 | 624 | ||
612 | $scope.agregarATabla = function(key) { | 625 | $scope.agregarATabla = function(key) { |
613 | if(key === 13) { | 626 | if(key === 13) { |
614 | if($scope.articuloACargar.cantidad === undefined || | 627 | if($scope.articuloACargar.cantidad === undefined || |
615 | $scope.articuloACargar.cantidad === 0 || | 628 | $scope.articuloACargar.cantidad === 0 || |
616 | $scope.articuloACargar.cantidad === null ) { | 629 | $scope.articuloACargar.cantidad === null ) { |
617 | focaModalService.alert('El valor debe ser al menos 1'); | 630 | focaModalService.alert('El valor debe ser al menos 1'); |
618 | return; | 631 | return; |
619 | } | 632 | } |
620 | delete $scope.articuloACargar.sectorCodigo; | 633 | delete $scope.articuloACargar.sectorCodigo; |
621 | $scope.articulosTabla.push($scope.articuloACargar); | 634 | $scope.articulosTabla.push($scope.articuloACargar); |
622 | $scope.cargando = true; | 635 | $scope.cargando = true; |
623 | } | 636 | } |
624 | }; | 637 | }; |
625 | 638 | ||
626 | $scope.quitarArticulo = function(key) { | 639 | $scope.quitarArticulo = function(key) { |
627 | $scope.articulosTabla.splice(key, 1); | 640 | $scope.articulosTabla.splice(key, 1); |
628 | }; | 641 | }; |
629 | 642 | ||
630 | $scope.editarArticulo = function(key, articulo) { | 643 | $scope.editarArticulo = function(key, articulo) { |
631 | if(key === 13) { | 644 | if(key === 13) { |
632 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 645 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
633 | articulo.cantidad === undefined) { | 646 | articulo.cantidad === undefined) { |
634 | focaModalService.alert('El valor debe ser al menos 1'); | 647 | focaModalService.alert('El valor debe ser al menos 1'); |
635 | return; | 648 | return; |
636 | } | 649 | } |
637 | articulo.editCantidad = false; | 650 | articulo.editCantidad = false; |
638 | articulo.editPrecio = false; | 651 | articulo.editPrecio = false; |
639 | } | 652 | } |
640 | }; | 653 | }; |
641 | 654 | ||
642 | $scope.cambioEdit = function(articulo, propiedad) { | 655 | $scope.cambioEdit = function(articulo, propiedad) { |
643 | if(propiedad === 'cantidad') { | 656 | if(propiedad === 'cantidad') { |
644 | articulo.editCantidad = true; | 657 | articulo.editCantidad = true; |
645 | } else if(propiedad === 'precio') { | 658 | } else if(propiedad === 'precio') { |
646 | articulo.editPrecio = true; | 659 | articulo.editPrecio = true; |
647 | } | 660 | } |
648 | }; | 661 | }; |
649 | 662 | ||
650 | $scope.limpiarFlete = function() { | 663 | $scope.limpiarFlete = function() { |
651 | $scope.remito.fleteNombre = ''; | 664 | $scope.remito.fleteNombre = ''; |
652 | $scope.remito.chofer = ''; | 665 | $scope.remito.chofer = ''; |
653 | $scope.remito.vehiculo = ''; | 666 | $scope.remito.vehiculo = ''; |
654 | $scope.remito.kilometros = ''; | 667 | $scope.remito.kilometros = ''; |
655 | $scope.remito.costoUnitarioKmFlete = ''; | 668 | $scope.remito.costoUnitarioKmFlete = ''; |
656 | $scope.choferes = ''; | 669 | $scope.choferes = ''; |
657 | $scope.vehiculos = ''; | 670 | $scope.vehiculos = ''; |
658 | }; | 671 | }; |
659 | 672 | ||
660 | $scope.limpiarPantalla = function() { | 673 | $scope.limpiarPantalla = function() { |
661 | $scope.limpiarFlete(); | 674 | $scope.limpiarFlete(); |
662 | $scope.remito.flete = '0'; | 675 | $scope.remito.flete = '0'; |
663 | $scope.remito.bomba = '0'; | 676 | $scope.remito.bomba = '0'; |
664 | $scope.remito.precioCondicion = ''; | 677 | $scope.remito.precioCondicion = ''; |
665 | $scope.articulosTabla = []; | 678 | $scope.articulosTabla = []; |
666 | $scope.remito.vendedor.nombre = ''; | 679 | $scope.remito.vendedor.nombre = ''; |
667 | $scope.remito.cliente = {nombre: ''}; | 680 | $scope.remito.cliente = {nombre: ''}; |
668 | $scope.remito.domicilio = {dom: ''}; | 681 | $scope.remito.domicilio = {dom: ''}; |
669 | $scope.domiciliosCliente = []; | 682 | $scope.domiciliosCliente = []; |
670 | }; | 683 | }; |
671 | 684 | ||
672 | $scope.resetFilter = function() { | 685 | $scope.resetFilter = function() { |
673 | $scope.articuloACargar = {}; | 686 | $scope.articuloACargar = {}; |
674 | $scope.cargando = true; | 687 | $scope.cargando = true; |
675 | }; | 688 | }; |
676 | 689 | ||
677 | $scope.selectFocus = function($event) { | 690 | $scope.selectFocus = function($event) { |
678 | $event.target.select(); | 691 | $event.target.select(); |
679 | }; | 692 | }; |
680 | 693 | ||
681 | $scope.salir = function() { | 694 | $scope.salir = function() { |
682 | $location.path('/'); | 695 | $location.path('/'); |
683 | }; | 696 | }; |
684 | function addArrayCabecera(array) { | 697 | function addArrayCabecera(array) { |
685 | for(var i = 0; i < array.length; i++) { | 698 | for(var i = 0; i < array.length; i++) { |
686 | addCabecera(array[i].label, array[i].valor); | 699 | addCabecera(array[i].label, array[i].valor); |
687 | } | 700 | } |
688 | } | 701 | } |
689 | 702 | ||
690 | function addCabecera(label, valor) { | 703 | function addCabecera(label, valor) { |
691 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 704 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
692 | if(propiedad.length === 1) { | 705 | if(propiedad.length === 1) { |
693 | propiedad[0].valor = valor; | 706 | propiedad[0].valor = valor; |
694 | } else { | 707 | } else { |
695 | $scope.cabecera.push({label: label, valor: valor}); | 708 | $scope.cabecera.push({label: label, valor: valor}); |
696 | } | 709 | } |
697 | } | 710 | } |
698 | 711 | ||
699 | function removeCabecera(label) { | 712 | function removeCabecera(label) { |
700 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 713 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
701 | if(propiedad.length === 1) { | 714 | if(propiedad.length === 1) { |
702 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | 715 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
703 | } | 716 | } |
704 | } | 717 | } |
705 | 718 | ||
706 | function rellenar(relleno, longitud) { | 719 | function rellenar(relleno, longitud) { |
707 | relleno = '' + relleno; | 720 | relleno = '' + relleno; |
708 | while (relleno.length < longitud) { | 721 | while (relleno.length < longitud) { |
709 | relleno = '0' + relleno; | 722 | relleno = '0' + relleno; |
710 | } | 723 | } |
711 | 724 | ||
712 | return relleno; | 725 | return relleno; |
713 | } | 726 | } |
714 | } | 727 | } |
715 | ] | 728 | ] |
716 | ) | 729 | ) |
717 | .controller('remitoListaCtrl', [ | 730 | .controller('remitoListaCtrl', [ |
718 | '$scope', | 731 | '$scope', |
719 | 'crearRemitoService', | 732 | 'crearRemitoService', |
720 | '$location', | 733 | '$location', |
721 | function($scope, crearRemitoService, $location) { | 734 | function($scope, crearRemitoService, $location) { |
722 | crearRemitoService.obtenerRemito().then(function(datos) { | 735 | crearRemitoService.obtenerRemito().then(function(datos) { |
723 | $scope.remitos = datos.data; | 736 | $scope.remitos = datos.data; |
724 | }); | 737 | }); |
725 | $scope.editar = function(remito) { | 738 | $scope.editar = function(remito) { |
726 | crearRemitoService.setRemito(remito); | 739 | crearRemitoService.setRemito(remito); |
727 | $location.path('/venta-nota-remito/abm/'); | 740 | $location.path('/venta-nota-remito/abm/'); |
728 | }; | 741 | }; |
729 | $scope.crearRemito = function() { | 742 | $scope.crearRemito = function() { |
730 | crearRemitoService.clearRemito(); | 743 | crearRemitoService.clearRemito(); |
731 | $location.path('/venta-nota-remito/abm/'); | 744 | $location.path('/venta-nota-remito/abm/'); |
732 | }; | 745 | }; |
733 | } | 746 | } |
734 | ]) | 747 | ]) |
735 | .controller('focaCrearRemitoFichaClienteController', [ | 748 | .controller('focaCrearRemitoFichaClienteController', [ |
736 | '$scope', | 749 | '$scope', |
737 | 'crearRemitoService', | 750 | '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 |