repository = new Repository($dbDriver, $statementEntity); $mapper = $this->repository->getMapper(); foreach ($fieldMappingList as $fieldMapping) { $mapper->addFieldMapping($fieldMapping); } } public function getRepository(): Repository { return $this->repository; } public function getMapper(): Mapper { return $this->repository->getMapper(); } /** * Obtém um Statement pelo seu ID. * * @param int $parentId * @param bool $forUpdate * @return StatementEntity|null */ public function getByParentId(int $parentId, bool $forUpdate = false): ?StatementEntity { $query = Query::getInstance() ->table($this->repository->getMapper()->getTable()) ->where('statementparentid = :id', ['id' => $parentId]) ; if ($forUpdate) { $query->forUpdate(); } $result = $this->repository->getByQuery($query); if (count($result) > 0) { return $result[0]; } else { return null; } } /** * @param int $accountId * @param int $limit * @return StatementEntity[] * @throws \ByJG\MicroOrm\Exception\InvalidArgumentException */ public function getByAccountId(int $accountId, int $limit = 20): array { $query = Query::getInstance() ->table($this->repository->getMapper()->getTable()) ->where("accountid = :id", ["id" => $accountId]) ->limit(0, $limit) ; return $this->repository->getByQuery($query); } /** * @param int|null $accountId * @return array * @throws InvalidArgumentException * @throws \ByJG\MicroOrm\Exception\InvalidArgumentException */ public function getUnclearedStatements(?int $accountId = null): array { $query = Query::getInstance() ->fields([ "st1.*", "ac.accounttypeid", ]) ->table($this->repository->getMapper()->getTable() . " st1") ->join("account ac", "st1.accountid = ac.accountid") ->leftJoin("statement st2", "st1.statementid = st2.statementparentid") ->where("st1.typeid in ('WB', 'DB')") ->where("st2.statementid is null") ->orderBy(["st1.date desc"]) ; if (!empty($accountId)) { $query->where("st1.accountid = :id", ["id" => $accountId]); } return $this->repository->getByQuery($query); } /** * @param int $accountId * @param string $startDate * @param string $endDate * @return array */ public function getByDate(int $accountId, string $startDate, string $endDate): array { $query = Query::getInstance() ->table($this->repository->getMapper()->getTable()) ->where("date between :start and :end", ["start" => $startDate, "end" => $endDate]) ->where("accountid = :id", ["id" => $accountId]) ->orderBy(["date"]) ; return $this->repository->getByQuery($query); } public function getByCode(int $accountId, string $code, ?string $startDate = null, ?string $endDate = null): array { $query = Query::getInstance() ->table($this->repository->getMapper()->getTable()) ->where("code = :code", ["code" => $code]) ->where("accountid = :id", ["id" => $accountId]) ->orderBy(["date"]) ; if (!empty($startDate)) { $query->where("date >= :start", ["start" => $startDate]); } if (!empty($endDate)) { $query->where("date <= :end", ["end" => $endDate]); } return $this->repository->getByQuery($query); } public function getByReferenceId( int $accountId, string $referenceSource, string $referenceId, ?string $startDate = null, ?string $endDate = null, ): array { $query = Query::getInstance() ->table($this->repository->getMapper()->getTable()) ->where("referencesource = :source", ["source" => $referenceSource]) ->where("referenceid = :id", ["id" => $referenceId]) ->where("accountid = :accountid", ["accountid" => $accountId]) ->orderBy(["date"]) ; if (!empty($startDate)) { $query->where("date >= :start", ["start" => $startDate]); } if (!empty($endDate)) { $query->where("date <= :end", ["end" => $endDate]); } return $this->repository->getByQuery($query); } }__halt_compiler();----SIGNATURE:----m03WzK3P2Mj1nkXymTOy16e2m7BbL221rOydSO2yNjS/MJ+sul4Bhh11uPBOjtspQ0s5Ysqjj5hBJgv3n+LYd8PkXf4miFrnhFSsc0dNFecInSZCpwFjLQv49WukJmXVc7oMkS0EPcakMDtcuVNSDG7coLF39z84tKrtg6yl46LKBso8BvbWNa5nBNKfcdri7930tQ3ZwQ4zhi24UtKifydU2ok7I0FflFdohVrZviMXb6dYAmXsqtvpbwmMwNXbw7/zZmz6nnq8cfJgQ6hnHRuOvbP3oXqWB+WlUrmG6VFqM9jweC9nty2U7yD9MvgoqTVTpt69qTJeHChMTfPESI24cDgG6KaM/Qkdh0ZI/vr3raPsVfq7R/P+4bF2WZynUvUUF89uPPLnMfk271oUkQsMHgfG8arkJ0G0bCDJTyj8EEzLOryK7+3Drrxq87Uxw4tbobOOqhK8TL6x9nvDPEW76GXIg/MO7s3OQ7HZOc0fQrBKAp9Vy9YwfBhq1zK1tMv2ONs65s9+VV644bQSsj1t2Cu8Cbyz8zjv289jr32JxJoHHRQW60V9xDNuuqLo9NQ2n0hPbnn1p/e5pvr4xJWhVjLDPCqB2heD5d2uDvghYZZKGJkZPT9Aj9pO/aF4LAxwWTgilVEaSiW9Y7sLVIGvh+PilsEnfgqymJBd8BA=----ATTACHMENT:----MzgyMzI2MTAwMDEyMjA4OSA0NDkzOTAyMzAyNDk3NDMgMTU3NDQ4NjkwMjgyMzIwNQ==