Can the integral group ring construction be extended to groupoids in such a way that it provides a functor from Groupoids to Rings? If $G$ is a group, and $R$ is a ring, one can construct the group ring $R[G]$, which is a free $R$-module with basis $G$, and with multiplication coming from the original multiplication of $G$. 
This construction gives a functor from groups to rings because any group homomorphism $\varphi : G \to H$ can be naturally extended by linearity to a ring homomorphism $\tilde{\varphi} : R[G] \to R[H]$.

My question is whether or not there is an analogous functor in the case of groupoids; that is to say, given a groupoid $\Pi$, and a ring $R$, is there a natural way of assigning a ring/alegbra $R[\Pi]$, such that groupoid morphisms extend to ring/algebra morphisms?

In particular, I've come across a formula involving the following: a groupoid $\Pi$, with a homomorphism $h : \Pi \to G$, where $G$ is a group. For an element $x \in \mathbb{Z}[\Pi]$, how should I interpret $h(x)$? Is this just the extension of $h$ to the free module over $\Pi$, or is there some extra structure coming from the fact that $h$ is a groupoid morphism?
 A: There is the following thing you can do. Given a category $C$, the free abelian group $\mathbb{Z}[C]$ on the morphisms of $C$ can be equipped with the following multiplication: two morphisms have product their composition if it exists, and $0$ otherwise. This gives you a not-necessarily-unital ring, the "category ring" of $C$, which has a unit iff $C$ has finitely many objects (exercise). Unfortunately, this construction is not functorial! (Exercise.)
What is functorial is the following. Given a category $C$ you can construct the free $\text{Ab}$-enriched category on $C$ by replacing each homset with the free abelian group on the homset and extending composition bilinearly. When $C$ has one object this reproduces the monoid ring construction. In general this is a better-behaved version of the previous construction (which roughly speaking is obtained by taking the endomorphism ring of the direct sum of every object in the free $\text{Ab}$-enriched category on $C$), and in particular it is functorial; in fact it is left adjoint to the forgetful functor from $\text{Ab}$-enriched categories to categories. You can think of $\text{Ab}$-enriched categories as "ringoids," if you like, in that an $\text{Ab}$-enriched category with one object is precisely a ring. 
I don't think I have enough information to answer your motivational question. Where is it from? 
