Commit c28f89332a45b08e672914ec5a41c431ff4fd271

Authored by Luigi
1 parent 44d96ee19c
Exists in master and in 1 other branch develop

Arreglo

Showing 1 changed file with 63 additions and 64 deletions   Show diff stats
src/js/controller.js
... ... @@ -155,76 +155,75 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
155 155 focaModalService.alert('Debe cargar al menos un articulo');
156 156 return;
157 157 }
158   - focaBotoneraLateralService.startGuardar();
159   - $scope.saveLoading = true;
160   - var notaPedido = {
161   - id: $scope.notaPedido.id,
162   - fechaCarga: new Date($scope.notaPedido.fechaCarga)
163   - .toISOString().slice(0, 19).replace('T', ' '),
164   - idVendedor: $scope.notaPedido.vendedor.id,
165   - idCliente: $scope.notaPedido.cliente.COD,
166   - nombreCliente: $scope.notaPedido.cliente.NOM,
167   - cuitCliente: $scope.notaPedido.cliente.CUIT,
168   - idProveedor: $scope.notaPedido.proveedor.COD,
169   - idDomicilio: $scope.notaPedido.domicilio.id,
170   - idCotizacion: $scope.notaPedido.cotizacion.ID,
171   - idPrecioCondicion: $scope.notaPedido.idPrecioCondicion,
172   - cotizacion: $scope.notaPedido.cotizacion.VENDEDOR,
173   - flete: $scope.notaPedido.flete,
174   - fob: $scope.notaPedido.fob,
175   - bomba: $scope.notaPedido.bomba,
176   - kilometros: $scope.notaPedido.kilometros,
177   - domicilioStamp: $scope.notaPedido.domicilioStamp,
178   - observaciones: $scope.notaPedido.observaciones,
179   - estado: 0,
180   - total: $scope.getTotal()
181   - };
182   - crearNotaPedidoService.crearNotaPedido(notaPedido).then(
183   - function(data) {
184   - // Al guardar los datos de la nota de pedido logueamos la
185   - // actividad para su seguimiento.
186   - //TODO: GUARDAR POSISIONAMIENTO AL EDITAR?
187   - focaSeguimientoService.guardarPosicion(
188   - 'Nota de pedido',
189   - data.data.id,
190   - ''
191   - );
192   - notaPedidoBusinessService.addArticulos(
193   - $scope.notaPedido.articulosNotaPedido,
194   - data.data.id, $scope.notaPedido.cotizacion.VENDEDOR);
195   -
196   - if ($scope.notaPedido.notaPedidoPuntoDescarga) {
197   - notaPedidoBusinessService.addPuntosDescarga(data.data.id,
198   - $scope.notaPedido.notaPedidoPuntoDescarga);
199   - }
  158 + focaBotoneraLateralService.startGuardar();
  159 + $scope.saveLoading = true;
  160 + var notaPedido = {
  161 + id: $scope.notaPedido.id,
  162 + fechaCarga: new Date($scope.notaPedido.fechaCarga)
  163 + .toISOString().slice(0, 19).replace('T', ' '),
  164 + idVendedor: $scope.notaPedido.vendedor.id,
  165 + idCliente: $scope.notaPedido.cliente.COD,
  166 + nombreCliente: $scope.notaPedido.cliente.NOM,
  167 + cuitCliente: $scope.notaPedido.cliente.CUIT,
  168 + idProveedor: $scope.notaPedido.proveedor.COD,
  169 + idDomicilio: $scope.notaPedido.domicilio.id,
  170 + idCotizacion: $scope.notaPedido.cotizacion.ID,
  171 + idPrecioCondicion: $scope.notaPedido.idPrecioCondicion,
  172 + cotizacion: $scope.notaPedido.cotizacion.VENDEDOR,
  173 + flete: $scope.notaPedido.flete,
  174 + fob: $scope.notaPedido.fob,
  175 + bomba: $scope.notaPedido.bomba,
  176 + kilometros: $scope.notaPedido.kilometros,
  177 + domicilioStamp: $scope.notaPedido.domicilioStamp,
  178 + observaciones: $scope.notaPedido.observaciones,
  179 + estado: 0,
  180 + total: $scope.getTotal()
  181 + };
  182 + crearNotaPedidoService.crearNotaPedido(notaPedido).then(
  183 + function(data) {
  184 + // Al guardar los datos de la nota de pedido logueamos la
  185 + // actividad para su seguimiento.
  186 + //TODO: GUARDAR POSISIONAMIENTO AL EDITAR?
  187 + focaSeguimientoService.guardarPosicion(
  188 + 'Nota de pedido',
  189 + data.data.id,
  190 + ''
  191 + );
  192 + notaPedidoBusinessService.addArticulos(
  193 + $scope.notaPedido.articulosNotaPedido,
  194 + data.data.id, $scope.notaPedido.cotizacion.VENDEDOR);
200 195  
201   - var plazos = $scope.notaPedido.notaPedidoPlazo;
202   - var plazosACrear = [];
203   - plazos.forEach(function(plazo) {
204   - plazosACrear.push({
205   - idNotaPedido: data.data.id,
206   - dias: plazo.dias
207   - });
  196 + if ($scope.notaPedido.notaPedidoPuntoDescarga) {
  197 + notaPedidoBusinessService.addPuntosDescarga(data.data.id,
  198 + $scope.notaPedido.notaPedidoPuntoDescarga);
  199 + }
  200 +
  201 + var plazos = $scope.notaPedido.notaPedidoPlazo;
  202 + var plazosACrear = [];
  203 + plazos.forEach(function(plazo) {
  204 + plazosACrear.push({
  205 + idNotaPedido: data.data.id,
  206 + dias: plazo.dias
208 207 });
  208 + });
209 209  
210   - if (plazosACrear.length) {
211   - crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear);
212   - }
  210 + if (plazosACrear.length) {
  211 + crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear);
  212 + }
213 213  
214   - notaPedidoBusinessService.addEstado(data.data.id,
215   - $scope.notaPedido.vendedor.id);
  214 + notaPedidoBusinessService.addEstado(data.data.id,
  215 + $scope.notaPedido.vendedor.id);
216 216  
217   - focaBotoneraLateralService.endGuardar(true);
218   - $scope.saveLoading = false;
  217 + focaBotoneraLateralService.endGuardar(true);
  218 + $scope.saveLoading = false;
219 219  
220   - init();
221   - }, function(error) {
222   - focaModalService.alert('Hubo un error al crear la nota de pedido');
223   - focaBotoneraLateralService.endGuardar();
224   - $scope.saveLoading = false;
225   - console.info(error);
226   - }
227   - );
  220 + init();
  221 + }, function(error) {
  222 + focaModalService.alert('Hubo un error al crear la nota de pedido');
  223 + focaBotoneraLateralService.endGuardar();
  224 + $scope.saveLoading = false;
  225 + console.info(error);
  226 + });
228 227 }
229 228 };
230 229