# Copyright (c) 2020, SolutionERP LLC and Contributors
# MIT License. See license.txt


import xhiveframework


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