Explicit calculation of generating functional for complex scalar field. Where's my mistake? The generating functional (this is all in shorthand, I write $f$ instead of the customary $\varphi$ for faster latex):
$$Z[j,j^*] = \iint Df Df^* \exp i\int_x \left( f^*_x Af_x + j_x f^*_x+j^*_xf_x \right)$$
with $A = -(\Box +m^2)$, propagator $AD_{xy} = i\delta_{xy}$. Shift $f \rightarrow f +i\int_yD_{xy}j_y $. The measure doesn't change. The exponent is given by (integrals implicit on repeated indices):
$$(f^*_x -i D_{xy} \cdot j^*_y)(Af_x -j_x) +j_x f^*_x+j^*_xf_x + ij^*_x \cdot D_{xy} \cdot j_y - ij_x \cdot D_{xy} \cdot j^*_y = $$
$$= fAf -jf^* - iD_{xy} \cdot j^*_y \cdot Af_x + ij_x \cdot D_{xy} \cdot j^*_y + jf^* + j^*f + ij^*_x \cdot D_{xy} \cdot j_y- ij_x \cdot D_{xy} \cdot j^*_y$$
There's 8 terms. Terms 1 and 7 are supposed to stay. Terms 2 and 5 cancel. Terms 4 and 8 cancel. Terms 3 and 6 must cancel but they don't. $A$ can be moved with two integrations by parts:
$$-iD_{xy} \cdot j^*_y \cdot Af_x = -iAD_{xy} \cdot j^*_y \cdot f_x = j^*_x \cdot f_x = j^*f $$
Instead of cancelling, they add. There's a missing minus sign. I've done this calculation at least five times, I can't find it. I'd appreciate if someone could show me where I made a mistake or link me this explicit calculation (it must be solved somewhere, this is a popular exercise).
I'm beginning to think this might be a conceptual rather than calculational problem? Perhaps the minus sign emerges somehow from the complex conjugate? This calculation should be totally analogous to the real case, but for some reason, it doesn't work for me.
 A: Assuming that you want to integrate out the scalar field, I'll provide an answer. What is needed in that case is to complete the square. One can demonstrate the basics in simple algebra.
Assume one has
$$ p=Axy+Bx+Cy , $$
one can write this (pedantically) as
$$ p=xAy+x\frac{1}{A}AB+CA\frac{1}{A}y . $$
The idea is now the add and subtract the same term to allow one to complete the square. Hence,
$$ p=xAy+xA\frac{1}{A}B+C\frac{1}{A}Ay + C\frac{1}{A}A\frac{1}{A}B - C\frac{1}{A}A\frac{1}{A}B \\
=\left(x+C\frac{1}{A}\right)A\left(y+\frac{1}{A}B\right) - C\frac{1}{A}B . $$
We want to do the analog of this in scalar field theory. So what you have is a generating function (changing notion liberaly)
$$ Z[J,J^{\dagger}] = \int \exp\left(i\int{\cal L}[J,J^{\dagger}]\right) {\cal D}[\phi,\phi^{\dagger}] , $$
where
$$ {\cal L}[J,J^{\dagger}] = \phi^{\dagger} D \phi + \phi^{\dagger} J + J^{\dagger} \phi , $$
with $D$ denoting the operator in the equation of motion. To complete the square we start by writing it as
$$ {\cal L}[J,J^{\dagger}] = \phi^{\dagger} D \phi + \phi^{\dagger} D G J + J^{\dagger} G D^{\dagger} \phi , $$
where $G$ is the propagator (Green function) such that $DG=1$. Now we add and subtract the appropriate term
$$ {\cal L}[J,J^{\dagger}] = \phi^{\dagger} D \phi + \phi^{\dagger} D G J + J^{\dagger} G D \phi + J^{\dagger} G D G J  - J^{\dagger} G D G J \\ 
= (\phi^{\dagger} + J^{\dagger} G) D (\phi + G J)  - J^{\dagger} G J . $$
Now one can shift the sources into the scalar fields and integrate out the scalar field so that only the propagator, dressed by the source fields, remains.
