# Z-score for weighted proportion

I have a question regarding the Z-Score test when it comes to compare two proportions.

Usually, one would use this formula to obtain the Z-Score:

and then compare it to a Standard Normal Distribution to find if the difference is statistically significant.

Yet, I was wondering how can we evaluate such a statistic when we have the following problem for example:

Let's say we have tow factories which produce the same set of products, some of them can break during the process. We have one proportion, which is the proportion of broken objects in each factory. We can compare this proportion between the two factories with the preceding formula.

But what if I'm interested by another proportion, that is the amount lost due to broken objects wich can be defined by :

where x(i) equals 1 if the object i is broken and 0 otherwise and P(i) is the price of the object i.

How can we derive confidence intervals and Z-score test for such a proportion ?