# Copyright (c) 2020, InfluxFramework LLC
# MIT License. See license.txt


import influxframework


def execute():
	influxframework.reload_doc("accounts", "doctype", "Payment Schedule")
	if influxframework.db.count("Payment Schedule"):
		influxframework.db.sql(
			"""
			UPDATE
				`tabPayment Schedule` ps
			SET
				ps.outstanding = (ps.payment_amount - ps.paid_amount)
		"""
		)
