added payments api
added check_payment_allocation() trigger to prevent sales/purchase payments from being over-allocated