This isn't as hard as it soundmay seem at first. You just have to think of the future loan payments in terms of what they are worth today (the loan amount is equal to the present value of the future payments). Since the payment fraction will be fixed, the math is easy.
Let's say you are purchasing the house for $100. Together, you are paying $20 down payment and $80 through a loan.
Person A pays (3/4)*$20x$20 for the down payment and (1/3)*80x$80 of the loan. Their share is
[(3/4)*$20x$20 + (1/3)*$80]x$80]/$100 = 41.67%
Person B pays (1/4)*20x20 for the down payment and (2/3)*80x$80 of the loan. Their share is
[(1/4)*$20x$20 + (2/3)*$80]x$80]/$100 = 58.33%
These are the fractions of the sale price that person A and B will take, respectively.
The above treats the home as an investment asset, so it doesn't matter who uses the house in the mean time.
If I were you, I would use the above math for the purchase and sale. Then separately split up the ongoing costs of the home (upkeep, utilities, insurance, taxes, upgrades) according to the proportion of the home being used by each person.