It was first codified in the 15th century by the Franciscan Friar, Luca Pacioli.
In deciding which account has to be debited and which account has to be credited, the golden rules of accounting are used. This is also accomplished using the accounting equation: Equity = Assets − Liabilities.
The accounting equation serves as an error detection tool. If at any point the sum of debits for all accounts does not equal the corresponding sum of credits for all accounts, an error has occurred. It follows that the sum of debits and the sum of the credits must be equal in value.