If B sued for the whole sum, A could admit that he owed the balance due and assert an affirmative defense of partial payment and would prevail on that affirmative defense. Therefore, B would only recover the remaining amount due.
The case of Cutter v. Powell (1795) sets forth a doctrine that applies to a person who had a duty to provide goods or services under a contract, but not to a person who has a duty to pay money in exchange for those goods of services.
This rule, which is still good law in all common law countries, states that to sue at all for a breach of contract, you must substantially perform your non-monetary duties under the contract, which means that you must attempt in good faith to carry out all the obligations of the contract according to its terms, even if you aren't completely successful in doing so.
If you fail to substantially perform, you recover nothing. If you substantially perform, but still do not strictly comply with the terms of the contract, then you have breached the contract and are only entitled to the full contract price less the difference between the value of your defective performance and the full contract price.
The key fact to recall in Cutter v. Powell is that this was a contract to provide labor for a fixed period of time (an entire ocean voyage) during which it would be impossible to replace the laborer's services. Also, on a ship, a lot of the work happens at the beginning and the end of the trip. So, the ship owner was deprived of a full crew at the times when it was needed.
The modern trend is to apply this framework far more generously than the court in Cutter v. Powell did, by considering most genuine attempts to perform that confer some value to involve substantial performance. Either under admiralty law, or labor law statutes, or just a more generous reading of what constitutes substantial performance under modern law, a court presented with the facts of Cutter v. Powell would probably reach a different conclusion, even though the same analytical framework would be applied to the contact law part of the analysis.
To take a more modern example, there was a case I cited recently in a brief (I can't find it quickly at hand) in which a tile layer was hired on a fixed price basis to put down tile in a room. He put down tile in 90% of the room, but quit the job when he got to the hardest part of the room to lay tile in. He then sued for 90% of the contract price.
The court held that because he didn't even try to finish 100% of the tile job that he wasn't entitled to a single penny for his efforts on a breach of contract theory, because he didn't substantially perform his entire obligation to provide services. If he had tried in good faith to do 100% of the work, but 10% of the tiles he laid ended up cracking, he would have been entitled to 100% of the contract price less the cost of fixing his mistakes. But, because he didn't even try to complete the job in full and in good faith, he was entitled to nothing under the contract.
The other modern doctrine that limits the harshness of Cutter v. Powell is that it is possible to sue for unjust enrichment of the owner based on the fair market value of the benefit conferred by the partial job, even in the absence of a right to recover under a contract theory, in some circumstances.