功亏一篑

gōng kuī yī kuì

lit. to ruin the enterprise for the sake of one basketful

to fail through lack of a final effort; to spoil the ship for a ha'penny worth of tar (idiom)

gōng

meritorious deed or service

kuī

to lose (money); to have a deficit

one

kuì

basket for carrying soil