If the amount due the contractor shall not be sufficient to pay all liens in full, the court shall order and direct the payment of the same, after deducting the costs of the action, to the persons whose liens are adjudged valid, ratably in proportion to the amounts of their several claims; and may render proper judgment against the contractor for any deficiencies.
The public body shall not be liable in any event for more than the amount due to the contractor under provisions of these statutes for any costs of the action.
SDCL 5-22-6