How to populate all items in a dataset with aggregated (Sum) data from another dataset?

I would probably create an earnings tab in the vendors dataset then every time a purchase is made query the vendors dataset and set the filter to the vendor ID. You can return the earnings table. From there just add the total amount of the new purchase to the earnings amount and save the new updated amount in the vendors database. The query would look something like this:

wixData.query("Vendors").hasAll("vendorID", Value)
.then(vendorInfo => {
	let transactionTotal = vendorInfo.earnings + price
	$w("#Vendors").setFieldValue("earnings", transactionTotal)
	$w("#Vendors").save()
}

This code SHOULD work to get you started. I would test this on a dummy database just in case. The only thing that I am not 100% sure on is calling setFieldValue inside the .then statement. In theory it should work but it might be smart to test it out before changing any data in the live dataset.