Bifunctional enzyme localized in the lumen of the endoplasmic reticulum that catalyzes the first two steps of the oxidative branch of the pentose phosphate pathway/shunt, an alternative to glycolysis and a major source of reducing power and metabolic intermediates for biosynthetic processes (By similarity). Has a hexose-6-phosphate dehydrogenase activity, with broad substrate specificity compared to glucose-6-phosphate 1-dehydrogenase/G6PD, and catalyzes the first step of the pentose phosphate pathway (PubMed:12858176, PubMed:18628520, PubMed:23132696). In addition, acts as a 6-phosphogluconolactonase and catalyzes the second step of the pentose phosphate pathway (By similarity). May have a dehydrogenase activity for alternative substrates including glucosamine 6-phosphate and glucose 6-sulfate (By similarity). The main function of this enzyme is to provide reducing equivalents such as NADPH to maintain the adequate levels of reductive cofactors in the oxidizing environment of the endoplasmic reticulum (PubMed:12858176, PubMed:18628520, PubMed:23132696). By producing NADPH that is needed by reductases of the lumen of the endoplasmic reticulum like corticosteroid 11-beta-dehydrogenase isozyme 1/HSD11B1, indirectly regulates their activity (PubMed:18628520).