Commit 54e0e1b8a9cec1300070f4d02eb3bd802ea26122

Authored by Nicolás Guarnieri
1 parent de330bd447
Exists in master and in 2 other branches develop, lab

guardado hoja ruta

... ... @@ -18,6 +18,7 @@
18 18 "angular-route": "^1.7.5",
19 19 "bootstrap": "^4.1.3",
20 20 "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git",
  21 + "foca-modal-chofer": "git+https://debo.suite.repo/modulos-npm/foca-modal-chofer.git",
21 22 "foca-modal-remito": "git+https://debo.suite.repo/modulos-npm/foca-modal-remito.git",
22 23 "font-awesome": "^4.7.0",
23 24 "gulp": "^3.9.1",
src/js/controller.js
... ... @@ -100,90 +100,80 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
100 100 // };
101 101  
102 102 $scope.crearHojaRuta = function() {
103   - if(!$scope.hojaRuta.vendedor.codigo) {
104   - focaModalService.alert('Ingrese Vendedor');
  103 + if($scope.hojaRuta.litros <= 0) {
  104 + focaModalService.alert('Ingrese Remitos');
105 105 return;
106   - } else if(!$scope.hojaRuta.cliente.cod) {
107   - focaModalService.alert('Ingrese Cliente');
108   - return;
109   - } else if(!$scope.hojaRuta.transportista.codigo) {
110   - focaModalService.alert('Ingrese Transportista');
111   - return;
112   - } else if(!$scope.hojaRuta.moneda.id) {
113   - focaModalService.alert('Ingrese Moneda');
114   - return;
115   - } else if(!$scope.hojaRuta.cotizacion.ID) {
116   - focaModalService.alert('Ingrese Cotización');
  106 + }
  107 +
  108 + if(!$scope.hojaRuta.chofer.id) {
  109 + focaModalService.alert('Ingrese Chofer');
117 110 return;
118   - } else if(!$scope.plazosPagos) {
119   - focaModalService.alert('Ingrese Precios y Condiciones');
  111 + }
  112 +
  113 + if(!$scope.hojaRuta.vehiculo.id) {
  114 + focaModalService.alert('Ingrese Vehiculo');
120 115 return;
121   - } else if(
122   - $scope.hojaRuta.flete === undefined || $scope.hojaRuta.flete === null)
123   - {
124   - focaModalService.alert('Ingrese Flete');
  116 + }
  117 +
  118 + if(!$scope.hojaRuta.transportista.codigo) {
  119 + focaModalService.alert('Ingrese Transportista');
125 120 return;
126   - } else if(!$scope.hojaRuta.domicilio.id) {
127   - focaModalService.alert('Ingrese Domicilio');
  121 + }
  122 +
  123 + if($scope.hojaRuta.vehiculo.capacidad < $scope.hojaRuta.litros) {
  124 + focaModalService.alert(
  125 + 'La capacidad del Vehiculo es menor a lo ingresado en Remitos'
  126 + );
128 127 return;
129   - } else if($scope.remitosTabla.length === 0) {
130   - focaModalService.alert('Debe cargar al menos un articulo');
  128 + }
  129 +
  130 + if(!$scope.hojaRuta.tarifario.costo) {
  131 + focaModalService.alert('Ingrese Tarifario');
131 132 return;
132   - }
  133 + }
  134 +
133 135 var date = new Date();
134   - var hojaRuta = {
135   - id: 0,
136   - fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000))
137   - .toISOString().slice(0, 19).replace('T', ' '),
138   - idVendedor: $scope.hojaRuta.vendedor.codigo,
139   - idCliente: $scope.hojaRuta.cliente.cod,
140   - nombreCliente: $scope.hojaRuta.cliente.nom,
141   - cuitCliente: $scope.hojaRuta.cliente.cuit,
142   - idDomicilio: $scope.hojaRuta.domicilio.id,
143   - idProveedor: $scope.hojaRuta.transportista.codigo,
144   - idCotizacion: $scope.hojaRuta.cotizacion.ID,
145   - cotizacion: $scope.hojaRuta.cotizacion.COTIZACION,
146   - flete: $scope.hojaRuta.flete,
147   - fob: $scope.hojaRuta.fob,
148   - bomba: $scope.hojaRuta.bomba,
149   - kilometros: $scope.hojaRuta.kilometros,
150   - estado: 0,
151   - total: $scope.getTotal()
  136 + var save = {
  137 + hojaRuta: {
  138 + id: 0,
  139 + fechaCreacion:
  140 + new Date(date.getTime() - (date.getTimezoneOffset() * 60000))
  141 + .toISOString().slice(0, 19) .replace('T', ' '),
  142 + idTransportista: $scope.hojaRuta.transportista.codigo,
  143 + idChofer: $scope.hojaRuta.chofer.id,
  144 + idVehiculo: $scope.hojaRuta.vehiculo.id,
  145 + tarifaFlete: $scope.hojaRuta.tarifario.costo
  146 + },
  147 + remitos: $scope.remitosTabla
152 148 };
153   - crearHojaRutaService.crearHojaRuta(hojaRuta).then(
154   - function(data) {
155   - hojaRutaBusinessService.addArticulos($scope.remitosTabla,
156   - data.data.id, $scope.hojaRuta.cotizacion.COTIZACION);
157   - focaSeguimientoService.guardarPosicion('crear nota pedido', '');
158   - var plazos = $scope.plazosPagos;
159   -
160   - for(var j = 0; j < plazos.length; j++) {
161   - var json = {
162   - idPedido: data.data.id,
163   - dias: plazos[j].dias
164   - };
165   - crearHojaRutaService.crearPlazosParaHojaRuta(json);
166   - }
167   - hojaRutaBusinessService.addEstado(data.data.id,
168   - $scope.hojaRuta.vendedor.codigo);
169 149  
170   - focaModalService.alert('Nota pedido creada');
171   - $scope.cabecera = [];
172   - addCabecera('Moneda:', $scope.hojaRuta.moneda.detalle);
173   - addCabecera(
174   - 'Fecha cotizacion:',
175   - $filter('date')($scope.hojaRuta.cotizacion.FECHA, 'dd/MM/yyyy')
  150 + crearHojaRutaService.crearHojaRuta(save).then(
  151 + function(data) {
  152 + focaModalService.alert(
  153 + 'Hoja ruta creada Nº: ' +
  154 + rellenar(data.sucursal, 4) +
  155 + '-' +
  156 + rellenar(data.numeroHojaRuta, 8)
176 157 );
177   - addCabecera('Cotizacion:', $scope.hojaRuta.cotizacion.COTIZACION);
178   - $scope.hojaRuta.vendedor = {};
179   - $scope.hojaRuta.cliente = {};
180   - $scope.hojaRuta.domicilio = {};
181   - $scope.hojaRuta.transportista = {};
182   - $scope.hojaRuta.flete = null;
183   - $scope.hojaRuta.fob = null;
184   - $scope.hojaRuta.bomba = null;
185   - $scope.hojaRuta.kilometros = null;
  158 + $scope.hojaRuta = {
  159 + fecha: new Date(),
  160 + litros: 0,
  161 + chofer: {},
  162 + vehiculo: {
  163 + capacidad: 0
  164 + },
  165 + transportista: {},
  166 + tarifario: {
  167 + costo: null
  168 + }
  169 + };
  170 +
186 171 $scope.remitosTabla = [];
  172 + $scope.cabecera = [];
  173 +
  174 + crearHojaRutaService.getNumeroHojaRuta().then(function(res) {
  175 + $scope.comprobante = $scope.rellenar(res.data.numeroHojaRuta, 8);
  176 + })
187 177 },
188 178 function(error) {
189 179 focaModalService.alert('Hubo un error al crear la nota de pedido');
... ... @@ -3,7 +3,7 @@ angular.module(&#39;focaCrearHojaRuta&#39;)
3 3 var route = API_ENDPOINT.URL;
4 4 return {
5 5 crearHojaRuta: function(hojaRuta) {
6   - return $http.post(route + '/hoja-ruta', {hojaRuta: hojaRuta});
  6 + return $http.post(route + '/hoja-ruta', hojaRuta);
7 7 },
8 8 obtenerHojaRuta: function() {
9 9 return $http.get(route +'/hoja-ruta');
src/views/hoja-ruta.html
... ... @@ -325,7 +325,7 @@
325 325 <div class="row align-items-end">
326 326 <div class="col-12">
327 327 <button
328   - ng-click="crearNotaPedido()"
  328 + ng-click="crearHojaRuta()"
329 329 type="submit"
330 330 title="Crear nota pedido"
331 331 class="btn btn-default btn-block mb-2">
... ... @@ -345,7 +345,7 @@
345 345 <div class="row d-md-none fixed-bottom">
346 346 <div class="w-100 bg-dark d-flex px-3 acciones-mobile">
347 347 <span class="ml-3 text-muted" ng-click="salir()">Salir</span>
348   - <span class="mr-3 ml-auto" ng-click="crearNotaPedido()">Guardar</span>
  348 + <span class="mr-3 ml-auto" ng-click="crearHojaRuta()">Guardar</span>
349 349 </div>
350 350 </div>
351 351 </div>