1919
2020namespace FacturaScripts \Plugins \Servicios \Model ;
2121
22- use FacturaScripts \Core \Model \Agente ;
2322use FacturaScripts \Core \Template \ModelClass ;
2423use FacturaScripts \Core \Template \ModelTrait ;
2524use FacturaScripts \Core \Tools ;
2625use FacturaScripts \Core \Where ;
27- use FacturaScripts \Dinamic \Model \GrupoClientes ;
26+ use FacturaScripts \Dinamic \Agente ;
27+ use FacturaScripts \Dinamic \Model \PresupuestoCliente ;
2828use FacturaScripts \Dinamic \Model \ServicioAT as DinServicioAT ;
2929use FacturaScripts \Dinamic \Model \Stock ;
30- use FacturaScripts \Dinamic \Model \Tarifa ;
3130use FacturaScripts \Dinamic \Model \Variante ;
3231
3332/**
@@ -160,10 +159,10 @@ public function test(): bool
160159 }
161160
162161 if ($ this ->referencia ) {
163- $ variant = $ this -> getVariante ();
164- $ product = $ variant -> getProducto ();
165- $ this -> descripcion = empty ($ this ->descripcion ) ? $ variant -> description () : $ this -> descripcion ;
166- $ this ->precio = empty ( $ this -> precio ) ? $ this ->getRate ( )->applyTo ( $ variant , $ product ) : $ this -> precio ;
162+ // guardamos el precio que le asignaríamos si le hacemos un presupuesto al cliente
163+ $ doc = new PresupuestoCliente ();
164+ $ doc -> setSubject ($ this ->getServicio ()-> getSubject ()) ;
165+ $ this ->precio = $ doc -> getNewProductLine ( $ this ->referencia )->pvpunitario ;
167166 }
168167
169168 return parent ::test ();
@@ -174,22 +173,6 @@ public function url(string $type = 'auto', string $list = 'ListServicioAT'): str
174173 return empty ($ this ->idservicio ) ? parent ::url ($ type , $ list ) : $ this ->getServicio ()->url ();
175174 }
176175
177- protected function getRate (): Tarifa
178- {
179- $ rate = new Tarifa ();
180- $ customer = $ this ->getServicio ()->getCustomer ();
181- if ($ customer ->codtarifa && $ rate ->load ($ customer ->codtarifa )) {
182- return $ rate ;
183- }
184-
185- $ group = new GrupoClientes ();
186- if ($ customer ->codgrupo && $ group ->load ($ customer ->codgrupo ) && $ group ->codtarifa ) {
187- $ rate ->load ($ group ->codtarifa );
188- }
189-
190- return $ rate ;
191- }
192-
193176 protected function onChange (string $ field ): bool
194177 {
195178 switch ($ field ) {
0 commit comments