If you agree to write a book for someone, you have a number of things to consider.
1. You need to agree on whether it is a work-for-hire project or a royalty contract.
2. If the author decides to self-publish, I suggest that you not ask for royalty for two reasons: (a) You'll probably lose money; and (b) It's messy for individuals to keep track of the books they sell. Most self-published books sell less than a thousand copies.
3. A work-for-hire agreement means you receive a fee for your work and no additional money after that. You will have to agree whether your name goes on the cover. Before I discuss how much money to ask for (my next blog post), the only charges beyond the fee that you ask for is travel expenses. They don't pay extra for your ink jets or paper, hours of research, someone to proofread, or anything else. Build those items into your cost.