then a function ``` function percentComplete(stage...
# suitescript
j
then a function
Copy code
function percentComplete(stage: StageStatus) {
	// both total and pending are 0 when stage has not happened
	if (stage.total === 0) {
		return 0;
	}
	if (stage.pending === 0) {
		return 100;
	}
	const pct = 100 * (stage.total - stage.pending) / stage.total;
	// round to two decimal places
	return Math.floor(100 * pct) / 100;
}