Absolute error loss minimization

From Robert (The Bayesian Choice, 2001), it is proposed that the Bayes Estimator associated with the prior distribution $\pi$ and the multilinear loss is a $(k_2/(k_1+k_2))$ fractile of $\pi(\theta|x)$.

The proof follows that

$$E^\pi[L_{k_1,k_2}(\theta,d|x)] = k_1\int\limits_{-\infty}^{d} (d-\theta)\pi(\theta|x)d\theta + k_2\int\limits_{d}^{+\infty}(\theta-d)\pi(\theta|x)d\theta$$

Then, using the identity

$$\int\limits_{c<y} (y-c)f(y)dy = P(y>c)$$

I would get to

$$E^\pi[L_{k_1,k_2}(\theta,d|x)] = k_2P^\pi(\theta>d|x) - k_1P^\pi(\theta<d|x)$$

But he gets to

$$E^\pi[L_{k_1,k_2}(\theta,d|x)] = k_1\int\limits_{-\infty}^{d} P^\pi(\theta<y|x)dy + k_2\int\limits_{d}^{+\infty} P^\pi(\theta>y|x)dy$$

And then takes the derivative in $d$. What am I'm missing, and why he does this last step? Thanks!

-
Using his notation, for the loss defined by $$L_{k_1,k_2}(\theta,d) = \begin{cases} k_2(\theta-d) & \textrm{if \theta>d,} \\ k_1(d-\theta) & \textrm{otherwise,} \end{cases}$$ Robert uses this identity to get
$$E^\pi[L_{k_1,k_2}(\theta,d)\mid x] = k_1\int\limits_{-\infty}^{d} P^\pi(\theta<y\mid x)\,dy + k_2\int\limits_{d}^{+\infty} P^\pi(\theta>y\mid x)\,dy\, .$$ You want the decision $d$ which minimizes this expectation, so you take the derivative with respect to $d$ and make it equal to zero, which gives $$\frac{\partial E^\pi[L_{k_1,k_2}(\theta,d)\mid x]}{\partial d} = k_1 P^\pi(\theta<d\mid x) -k_2 P^\pi(\theta>d\mid x) = 0 \, ,$$ where we've used the Fundamental Theorem of Calculus, and this is equivalent to $$P^\pi(\theta<d\mid x) = \frac{k_2}{k_1 + k_2} \, ,$$ as desired.