Trump's trade war with China is reportedly costing the US more than it's supposed to be saving.

While President Donald Trump has tried to paint America as the winning side in the ongoing trade war with China, government data shows the country is actually losing money thanks to bailouts promised to farmers and other industries hit the hardest by tariffs.

US tariffs on Chinese imports have raised $20.8 billion through Tuesday, data from US Customs and Border Protection seen by the New York Times reveals. But Trump has already pledged $28 billion to help American farmers reeling from tit-for-tat tariffs, the Times said, leaving the US with a deficit of over $7 billion.

Trump has already announced two emergency relief packages for American farmers — a $12 billion package last July which provided direct funding for producers of soybeans, sorghum, corn, wheat, cotton, dairy and hogs, and another $16 billion subsidy package announced in May.

Read more: Bank of America just slashed its forecast for global economic growth — and it's blaming Trump's trade war

US President Donald Trump (L) and China's President Xi Jinping leave a business leaders event at the Great Hall of the People in Beijing on November 9, 2017. NICOLAS ASFOURI/AFP/Getty Images

Though trade negotiations between the US and China appeared to have stalled in May, Trump agreed not to impose new tariffs on Chinese exports after meeting with Chinese counterpart Xi Jinping at June's G20 summit in Tokyo.

Currently, the US imposes a 25% tariff on $250 billion worth of Chinese goods, while China has retaliated with increased tariffs on $60 billion worth of American imports.

Read more: Trump cut a deal with China to mute US support for Hong Kong protests in exchange for progress in the trade war, report says

Trump on Monday praised his trade war efforts and said tariffs have "taken in tens of billions of dollars" from China, money which he said would be reinvested in the agricultural industry.

"The United States Tariffs are having a major effect on companies wanting to leave China for non-tariffed countries," he tweeted Monday. "These Tariffs are paid for by China devaluing & pumping, not by the U.S. taxpayer!"

Still, Trump last week said China was "letting us down" by not buying from US farmers as part of promises it made to restart trade talks.

FILE - In this June 19, 2019, file photo cargo containers are stacked on a ship at the Port of Los Angeles in Los Angeles. The market for small businesses cooled for the third straight quarter. That report comes from BizBuySell.com, an online marketplace for small companies that counted 2,444 transactions reported by business brokers from April through June, down 9.6% from 2,705 in the second quarter of last year. (AP Photo/Marcio Jose Sanchez, File) Associated Press

"Mexico is doing great at the Border, but China is letting us down in that they have not been buying the agricultural products from our great Farmers that they said they would. Hopefully they will start soon!" Trump tweeted Thursday.

Read more: Trump's trade war could lead to a shortage of Bibles in the US, major publishers and religious charities warn

Tariffs appear to be having an effect on China's economy. China's economy slowed to its lowest growth rate in decades, according to China's National Bureau of Statistics, growing by 6.2% in the second quarter of 2019, a drop from 6.4% in the first quarter and 6.6% in all of 2018, according to data released by China's National Bureau of Statistics.

Still, the slowdown is not entirely unexpected. A spokesperson for China's National Bureau of Statistics said at a press conference on Monday that while the country is "facing a complex external environment," the economic growth falls within the government's target range of 6-6.5% set for 2019.