Reread your comment - you are going to need to back up your statements with scripture:
David took a census of the people, willfully violating God’s command not to do that.
Can you share where God commanded him to not do this? I cannot find it.
By the same token, can you back up the discipline issue with scripture. I haven’t studied this out, but I do not remember this being noted as a sin. You may be able to prove me wrong though.
I really don't want to prove anyone wrong; but want to get correct info out there.
This may explain a bit better...
Question: "Who incited David to take the census in 2 Samuel 24, God or Satan?
Why was God so angry at David for taking the census?
Why did God punish the Israelite people when it was David who ordered the census?"
Satan rose up against Israel and incited David to take a census of Israel (1 Chronicles 21:1). However, the wording of 2 Samuel 24:1 says that it was God who moved David to take the census.
This discrepancy can be explained by the understanding that sometimes God sovereignly permits Satan to act in order to achieve His purposes.
God uses Satan in various ways, among them the refining, disciplining and purification of disobedient believers (Luke 22:31-32; 1 Corinthians 5:1-5; 2 Corinthians 12:7-10).
Such is the case with David. God allowed Satan to tempt him, and David sinned, revealing his pride and allowing God to deal with him for it.