This paper presents a novel dual-function photovoltaic (PV) inverter design that simultaneously offers power generation and power quality enhancement. It details a thorough design process for the inverter control system, tasked with extracting maximum power from the PV system and integrating it into the grid. Moreover, the inverter doubles as a shunt active filter, detecting and mitigating harmonic currents from the load. The control scheme also incorporates a series active filter to correct voltage imbalances from the grid, providing voltage stability during sags and swells. The novelty of this research lies in the controller design process, seamlessly integrating the PV system with a Unified Power Quality Conditioner (UPQC), which comprises both series (SEF) and shunt active power filters (SAPF), enabling coordinated operation between the PV system and UPQC. The paper details the development and performance evaluation of a three-phase PV-UPQC system, incorporating a dual-stage 17-kW PV array. The system's efficacy under various conditions-including voltage sags, swells, changes in irradiance, unbalanced loads, and load fluctuations-was rigorously tested. The study shows that the PV-UPQC system significantly improves power quality at optimal PV operation, advancing the integration of photovoltaic technology with power quality solutions.