<commit_before>/*
    * Calculate registration type based on
    *    Age,
    *    registration type,
    *    accommodations,
    *    days,
    *    date created (early or late discount),
    *   carbon tax
    */
calculateRegistrationPrice = function (registration) {
    var accommodationsFee; // Used for accommodations price
    var calculatedDiscount; // Used for discount price
    var linens; // used for overnight registrations
    var earlyDiscountOrLateFee; // holds early discount or late fee, if any
    var subtotal; // Hold subtotal prior to discount
    var total; // Hold total registration price
    var carbonTax; // Get the optional carbon tax amount

    // Calculate accommodations fee
    try {
        accommodationsFee = calculateAccommodationsFee(registration);
    } catch (error) {
        console.log(error.message);
    }

    // Calculate linens fee, if applicable
    try {
        linens = calculateLinensFee(registration);
    } catch (error) {
        console.log(error.message);
    }

    // Calculate discount based on half days
    try {
        calculatedDiscount = calculateDiscount(registration);
    } catch (error) {
        console.log(error.message);
    }

    // Calculate the percentage-based fee used for early discount or late fee, if applicable
    try {
        var earlyOrLateFee = calculateEarlyOrLatePercentage(accommodationsFee);
    } catch (error) {
        console.log(error.message);
    }

    // Determine if the registration qualifies for early discount or late fee
    try {
        var earlyOrLate = determineEarlyOrLate(registration.createdAt);
    } catch (error) {
        console.log(error.message);
    }

    // Calculate carbon tax
    try {
        carbonTax = calculateCarbonTax(registration);
    } catch (error) {
        console.log(error.message);
    }

    // Get the subtotal used for final calculations
    // based on accommodations, linens, and first time attender/half day discounts
    subtotal = accommodationsFee + linens - calculatedDiscount + carbonTax;

    // Calculate total to include early or late fee, if applicable
    if (earlyOrLate === 'early') {
        // subtract early discount from subtotal
        total = subtotal - earlyOrLateFee;
    } else if (earlyOrLate === 'late') {
        // add late fee to subtotal
        total = subtotal + earlyOrLateFee;
    } else if (earlyOrLate === 'regular') {
        // regular registration fee calculation
        total = accommodationsFee + linens - calculatedDiscount;
    }

    // Make sure we don't have a negative, or undefined total
    if (!total || total < 0) {
        return 0;
    } else {
        return parseInt(total);
    }
};<commit_msg>Include donation in calculation<commit_after>/*
    * Calculate registration type based on
    *    Age,
    *    registration type,
    *    accommodations,
    *    days,
    *    date created (early or late discount),
    *   carbon tax
    */
calculateRegistrationPrice = function (registration) {
    var accommodationsFee; // Used for accommodations price
    var calculatedDiscount; // Used for discount price
    var linens; // used for overnight registrations
    var earlyDiscountOrLateFee; // holds early discount or late fee, if any
    var subtotal; // Hold subtotal prior to discount
    var total; // Hold total registration price
    var carbonTax; // Get the optional carbon tax amount
    var donation; // Used for optional donation field

    // Calculate accommodations fee
    try {
        accommodationsFee = calculateAccommodationsFee(registration);
    } catch (error) {
        console.log(error.message);
    }

    // Calculate linens fee, if applicable
    try {
        linens = calculateLinensFee(registration);
    } catch (error) {
        console.log(error.message);
    }

    // Calculate discount based on half days
    try {
        calculatedDiscount = calculateDiscount(registration);
    } catch (error) {
        console.log(error.message);
    }

    // Calculate the percentage-based fee used for early discount or late fee, if applicable
    try {
        var earlyOrLateFee = calculateEarlyOrLatePercentage(accommodationsFee);
    } catch (error) {
        console.log(error.message);
    }

    // Determine if the registration qualifies for early discount or late fee
    try {
        var earlyOrLate = determineEarlyOrLate(registration.createdAt);
    } catch (error) {
        console.log(error.message);
    }

    // Calculate carbon tax
    try {
        carbonTax = calculateCarbonTax(registration);
    } catch (error) {
        console.log(error.message);
    }

    // Calculate donation
    try {
        donation = calculateDonation(registration);
    } catch (error) {
        console.log(error.message);
    }

    // Get the subtotal used for final calculations
    // based on accommodations, linens, and first time attender/half day discounts
    subtotal = accommodationsFee + linens - calculatedDiscount + carbonTax;

    // Calculate total to include early or late fee, if applicable
    if (earlyOrLate === 'early') {
        // subtract early discount from subtotal
        total = subtotal - earlyOrLateFee + donation;
    } else if (earlyOrLate === 'late') {
        // add late fee to subtotal
        total = subtotal + earlyOrLateFee + donation;
    } else if (earlyOrLate === 'regular') {
        // regular registration fee calculation
        total = accommodationsFee + linens - calculatedDiscount + donation;
    }

    // Make sure we don't have a negative, or undefined total
    if (!total || total < 0) {
        return 0;
    } else {
        return parseInt(total);
    }
};
{'fraction_non_alphanumeric': 0.08565877781702579, 'fraction_numerical': 0.0007064641469445425, 'mean_word_length': 2.497838171710933, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '805967', 'n_tokens_mistral': 1568, 'n_tokens_neox': 1467, 'n_words': 493}