src/Repository/Idempiere/CCurrencyRepository.php line 33

Open in your IDE?
  1. <?php
  2. namespace App\Repository\Idempiere;
  3. use App\Constant;
  4. use App\Entity\Idempiere\CCurrency;
  5. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  6. use Doctrine\Persistence\ManagerRegistry;
  7. /**
  8.  * @method CCurrency|null find($id, $lockMode = null, $lockVersion = null)
  9.  * @method CCurrency|null findOneBy(array $criteria, array $orderBy = null)
  10.  * @method CCurrency[]    findAll()
  11.  * @method CCurrency[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  12.  */
  13. class CCurrencyRepository extends ServiceEntityRepository
  14. {
  15.     public function __construct(ManagerRegistry $registry)
  16.     {
  17.         parent::__construct($registryCCurrency::class);
  18.     }
  19.     /**
  20.      * Convertir el monto con la tasa del sistema
  21.      * @param float $Amt Monto a convertir
  22.      * @param int $C_Currency_ID Moneda base
  23.      * @param int $C_Currency_To_ID Moneda destino
  24.      * @param string $Date Fecha de la tasa
  25.      * @param int $C_ConversionType_ID Tipo de conversion/tasa
  26.      * @param int $AD_Client_ID Grupo empresarial
  27.      * @param int $AD_Org_ID Organizacion
  28.      */
  29.     public function convertAmt(Float $AmtInt $C_Currency_IDInt $C_Currency_To_IDString $Date null
  30.         Int $C_ConversionType_IDInt $AD_Client_ID 0Int $AD_Org_ID 0
  31.     )
  32.     {
  33.         if ( is_null($Date) )
  34.             $Date date('Y-m-d H:i:s');
  35.         $conn $this->getEntityManager()->getConnection();
  36.         $sql    'SELECT CURRENCYCONVERT(:payamt, :currency_id, :currencytarget_id, :dateacct, :conversiontype_id, :client_id, :org_id)';
  37.         $stmt   $conn->prepare($sql);
  38.         $rs     $stmt->executeQuery([
  39.             'payamt' => $Amt,
  40.             'currency_id' => $C_Currency_ID,
  41.             'currencytarget_id' => $C_Currency_To_ID,
  42.             'dateacct' => $Date,
  43.             'conversiontype_id' => $C_ConversionType_ID,
  44.             'client_id' => $AD_Client_ID,
  45.             'org_id' => $AD_Org_ID
  46.         ]);
  47.         return $rs->fetchOne();
  48.     }
  49. }