import uuid


def _generate_statement_db_object(
    item,
    citizen_ids_array,
    contract_id,
    unique_suffix,
    assessment_period,
    timestamp_string,
):
    """Generates a statement id and db object and returns them as a tuple of string, dict.

    Keyword arguments:
    item -- the data item from the data file
    citizen_ids_array -- the citizen ids as an array
    contract_id - the uuid for the contract id
    unique_suffix -- a unique suffix for the first and last names
    assessment_period -- the assessment period object
    timestamp_string -- the timestamp for created and modified times
    """
    statement_id = uuid.uuid4()
    crypto_id = uuid.uuid4()

    claimant_data = []
    for offset, citizen_id in enumerate(citizen_ids_array):
        claimant_data.append(
            {
                "type": "person",
                "contractId": str(contract_id),
                "citizenId": str(citizen_id),
                "lastName": f"Bloggs{unique_suffix - (len(citizen_ids_array)-1) + offset}",
                "middleName": None,
                "firstName": f"Jo{unique_suffix - (len(citizen_ids_array)-1) + offset}",
                "email": f"jo{unique_suffix - (len(citizen_ids_array)-1) + offset}\@example.com",
                "mobileNumber": f"07{unique_suffix - (len(citizen_ids_array)-1) + offset}",
                "dateOfBirth": {
                    "type": "PersonDateOfBirth",
                    "cryptoId": str(crypto_id),
                },
                "contactPreference": "MOBILE",
                "gender": "female",
                "verifiedUsingBioQuestionsOrThirdParty": None,
                "effectiveDate": {"type": "FROM_START_OF_CLAIM"},
                "paymentEffectiveDate": {"type": "FROM_START_OF_CLAIM"},
                "declaredDateTime": "20180510",
            }
        )

    statement = {
        "_id": {"statementId": str(statement_id)},
        "_version": 1,
        "people": claimant_data,
        "assessmentPeriod": assessment_period,
        "standardAllowanceElement": "317.82",
        "housingElement": "0.00",
        "housingElementRent": "0.00",
        "housingElementServiceCharges": "0.00",
        "childElement": "0.00",
        "numberEligibleChildren": 0,
        "disabledChildElement": "0.00",
        "numberEligibleDisabledChildren": 0,
        "childcareElement": "0.00",
        "numberEligibleChildrenInChildCare": 0,
        "carerElement": "0.00",
        "numberPeopleCaredFor": 0,
        "takeHomePay": item["amount"],
        "takeHomeBreakdown": {
            "rte": "0.00",
            "selfReported": "0.00",
            "selfEmployed": "0.00",
            "selfEmployedWithMif": "0.00",
        },
        "unaffectedPayElement": "0.00",
        "totalReducedForHomePay": "0.00",
        "otherIncomeAdjustment": "0.00",
        "capitalAdjustment": "0.00",
        "totalAdjustments": "0.00",
        "fraudPenalties": "0.00",
        "sanctions": "317.82",
        "advances": "0.00",
        "deductions": "0.00",
        "totalPayment": "0.00",
        "createdDateTime": timestamp_string,
        "earningsSource": None,
        "otherBenefitAwards": [],
        "overlappingBenefits": [],
        "totalOtherBenefitsAdjustment": "0",
        "capApplied": None,
        "type": "CALCULATED",
        "preAdjustmentTotal": "317.82",
        "_entityVersion": 4,
        "_lastModifiedDateTime": timestamp_string,
        "workCapabilityElement": None,
        "benefitCapThreshold": None,
        "benefitCapAdjustment": None,
        "gracePeriodEndDate": None,
        "landlordPayment": "0",
    }

    return (statement_id, statement)