All perfect praise be to Allah the Lord of the Worlds. May His peace and blessings be upon our Prophet Mohammad and upon all his family and companions.
According to the general rule in Islamic jurisprudence, gold is to be paid for with gold, both being of equal weight and the same quantities. The proof of this is that Allah's Messenger (PBUH) said: "Gold is to be paid for with gold, both being of equal weight and of same quantities; silver is to be paid for with silver, both being of equal weight and of same quantities. If anyone gives more or asks for more of it, it is then usury." [Reported by Muslim]. However, if the additional amount is not explicitly specified and there is no agreement on it, it is considered a good practice in settling debts. This is based on the Prophet's saying (peace be upon him): "(Certainly, the best of people is he who discharges his debt in the best manner)." [Reported by Muslim].
If a piece of gold with a known weight, type, and description is borrowed, it must be repaid with an equivalent weight, type, and description. However, if the lender stipulates including the goldsmith's fee on the borrower, it is not permissible. This is because adding the goldsmith's fee is considered usury. In fact, gold is considered one of the usurious assets, and equivalence in exchange should be achieved based on its kind. The criterion is the equality of the actual weight of pure gold. Quality and craftsmanship are not considerable; the Sharia provisions have emphasized equivalence and did not delve into the description that leads to a difference in value.
Sheikh al-Islam Imam al-Taqi al-Subki, may Allah have mercy on him, said: "As for quality, the Sharia has excluded it, as it stated: 'Its good and bad are equal.'" [Takmilat al-Majmu' Sharh al-Muhadhdhab, Vol. 10/Page 70]. The difference in quality between new and old gold does not affect the ruling. The focus is on the equality of the weight of pure gold at the time of the contract. Therefore, replacing a new piece for an old one is permissible, provided that they are equal in weight and description.
Imam al-Shafi'i, may Allah have mercy on him, said: "It isn`t acceptable for a man to hand over silver to a jeweler for the purpose of making silver jewelry and paying him the fees of craftsmanship, as this involves exchanging silver for silver of unequal weight, which isn`t permissible." [Al-Umm, Vol. 3/Page 35].
In conclusion, gold is considered from the riba-based wealth for which equivalence must be achieved in its exchange with its own kind. The criterion is the actual weight of pure gold since, in general, quality and craftsmanship do not affect the ruling. And Allah the Almighty knows best.