def get_latest_docdata_payment(payment):
    """
    Get the latest docdata payment (DocDataPayment) for given payment (DocDataPaymentOrder).
    """
    if payment.docdata_payments.count() > 0:
        return payment.docdata_payments.order_by('-created').all()[0]
    return None