I forget if you told us how you're doing things, but assuming you are calculating to a value of a field in a library entry, you could use a JavaScript field. Something like this...
if (field("Type") == "Expense")
-field("Amount");
else
field("Amount");
If you are in a Updating an entry Before saving trigger script in Accounts, you could have something like...
var e = entry();
if (e.field("Type") == "Expense")
e.set("Balance", e.field("Balance") - e.field("Amount"));
else
e.set("Balance", e.field("Balance") + e.field("Amount"));
So, when I just wrote that, a question entered my mind. If you're linked down (many-to-many parent to child), when you add an entry to Expenses, it appears as Creating a new entry to Expenses, but as Updating an existing entry to Accounts -- an interesting thing to keep in mind if you have triggers in both places. What I am most accustomed to doing is linking bottom up, so Accounts has no knowledge of my adding an entry to Expenses. Only the Expenses trigger fires.
Also, per our earlier conversation, I confess that I have a couple of often-used libraries right now that link both ways. The main link is from the child back to the parent, but sometimes when I'm in the parent, I want to see the children, so I link to the child from the parent, also. I know I could get caught chasing/eating my tail, though, so I always keep in mind that the parent-to-child link is secondary, but so far, so good, with my current usage. I could maybe get in trouble when I start deleting entries, I suppose. We'll see.