Is it permissible for one to masturbate in order not to commit fornication?
This is called committing the milder of the two evils such as eating a carcass in fear of death, and this happens when committing fornication is very likely to occur.
Is prayer mandatory on a dying person who goes through a state of unconsciousness, then wakes up?
If he wakes up and was conscious, then he should pray the way/manner he could, but if he wasn't, then he is exempted from obligatory prayer as Allah Says in this regard (What means): "On no soul doth God Place a burden greater than it can bear." [Al-Baqarah/286].
I work in an accounting and auditing office, and among the clients of the office are restaurants, hotels, and supermarkets that sell alcohol. Our work is limited to collecting invoices, whether purchases, sales, or expenses, and recording them in daily books. We also review income and sales taxes on behalf of these clients.
You are more knowledgeable about the nature of your work. If you see it as assisting in wrongdoing, then it is forbidden, as Allah The Exalted Says (What means): "And cooperate in righteousness and piety, but do not cooperate in sin and aggression" [Al-Ma’idah/2]. However, if your work is merely documenting the reality, then I hope there is no sin upon you. The the pious predecessors (Salaf) used to take the tithe from the traders of the People of the Book, even if it included alcohol, after knowing the value of their goods. And Allah The Almighty Knows Best.
Does fasting on behalf of a deceased person permissible?
Fasting on belhaf of a deceased person is permissible, since the Prophet (PBUH) said: "Whoever dies while he still has some fasts to make up (of the days of Ramadan), then his heir (any of them) should fast on his behalf." [Agreed upon]. The previous answer is for making up missed obligatory fasts on behalf of the deceased. But if the fasting on behlaf of the deceased was for performing a voluntary acts of devotion such as fasting....is permissible as adopted by the majority of Muslim scholars and based on the above hadith as they stated "Every good dead intended to be on behalf of the deceased its reward will reach the latter." And Allah Knows Best.