import decimal


def _as_decimal(value):
	"""
	Converts the value to a `Decimal` if it is not already, or returns the existing value if it is a `Decimal`, or
	returns `Decimal(0)` if the existing value is `None`.

	:param value: The value to cast/convert
	:type value: int | long | decimal.Decimal | NoneType

	:return: The value as a `Decimal`
	:rtype: decimal.Decimal
	"""
	return value if isinstance(value, decimal.Decimal) else decimal.Decimal(value or '0')