Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 17 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ItemGetMovementDateService | |
0.00% |
0 / 17 |
|
0.00% |
0 / 2 |
30 | |
0.00% |
0 / 1 |
| process | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
6 | |||
| query | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Domain\Item\Services; |
| 4 | |
| 5 | use App\Events\ServiceProcessed; |
| 6 | use App\Models\User; |
| 7 | use Carbon\Carbon; |
| 8 | use Domain\Item\DTOs\ItemGetMovementDateDTO; |
| 9 | use Domain\Shared\Integrations\Senior\Exceptions\IntegrationSoapSeniorException; |
| 10 | use Domain\Shared\Integrations\Senior\SeniorQueryExecute; |
| 11 | |
| 12 | readonly class ItemGetMovementDateService |
| 13 | { |
| 14 | /** |
| 15 | * @param ItemGetMovementDateDTO $itemGetMovementDateDTO |
| 16 | * @param User $user |
| 17 | * @return array |
| 18 | * @throws IntegrationSoapSeniorException |
| 19 | */ |
| 20 | public function process(ItemGetMovementDateDTO $itemGetMovementDateDTO, User $user): array |
| 21 | { |
| 22 | ServiceProcessed::dispatch(self::class, $user); |
| 23 | |
| 24 | if (config('integration.disable_movement_date')) { |
| 25 | return [ |
| 26 | [ |
| 27 | "E210MVP_DATMOV" => Carbon::now()->format('Y-m-d\TH:i:s'), |
| 28 | 'E210MVP_DATDD' => Carbon::now()->format('Y-m-d\TH:i:s'), |
| 29 | ] |
| 30 | ]; |
| 31 | } |
| 32 | |
| 33 | return (new SeniorQueryExecute())->execute( |
| 34 | $this->query($itemGetMovementDateDTO) |
| 35 | ); |
| 36 | } |
| 37 | |
| 38 | private function query(ItemGetMovementDateDTO $itemGetMovementDateDTO): string |
| 39 | { |
| 40 | $where = $itemGetMovementDateDTO->integrationProduct && $itemGetMovementDateDTO->integrationDerivation ? |
| 41 | "(E075DER.codpro = '$itemGetMovementDateDTO->integrationProduct' and E075DER.codder = '$itemGetMovementDateDTO->integrationDerivation')" : |
| 42 | "E075DER.codref = '$itemGetMovementDateDTO->integrationCode'"; |
| 43 | |
| 44 | return "select |
| 45 | min(e210mvp.datmov) as e210mvp_datmov, |
| 46 | max(e210mvp.datmov) as e210mvp_datdd |
| 47 | FROM e210mvp |
| 48 | INNER JOIN e210est |
| 49 | ON e210est.codemp = e210mvp.codemp |
| 50 | AND e210est.coddep = e210mvp.coddep |
| 51 | AND e210est.codpro = e210mvp.codpro |
| 52 | AND e210est.codder = e210mvp.codder |
| 53 | INNER JOIN E075DER |
| 54 | ON E075DER.CODDER = E210EST.CODDER |
| 55 | AND E075DER.CODEMP = E210EST.CODEMP |
| 56 | AND E075DER.CODPRO = E210EST.CODPRO |
| 57 | INNER JOIN E075PRO |
| 58 | ON E075PRO.CODEMP = E075DER.CODEMP |
| 59 | AND E075PRO.CODPRO = E075DER.CODPRO |
| 60 | INNER JOIN e205dep |
| 61 | ON e205dep.CODEMP = e210mvp.CODEMP |
| 62 | AND e205dep.CODdep = e210mvp.COddep |
| 63 | INNER JOIN e001tns |
| 64 | ON e001tns.codemp = e210mvp.codemp |
| 65 | AND e001tns.codtns = e210mvp.codtns |
| 66 | where e210mvp.codemp = 1 |
| 67 | and e210mvp.esteos = 'E' |
| 68 | and e210mvp.estmov = 'NO' |
| 69 | and e210mvp.codtns in ('90201') |
| 70 | and e205dep.depven = 'S' |
| 71 | and e210mvp.numdoc = '$itemGetMovementDateDTO->productionOrder' |
| 72 | and $where"; |
| 73 | } |
| 74 | } |