<commit_before>/*
 * Copyright 2010 The Kuali Foundation.
 * 
 * Licensed under the Educational Community License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.opensource.org/licenses/ecl1.php
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.kuali.kfs.module.endow.document;

import java.util.ArrayList;
import java.util.List;

import org.kuali.kfs.module.endow.businessobject.EndowmentTransactionLine;
import org.kuali.kfs.module.endow.businessobject.EndowmentTransactionTaxLotLine;
import org.kuali.rice.kew.api.exception.WorkflowException;


public abstract class EndowmentTaxLotLinesDocumentBase extends EndowmentSecurityDetailsDocumentBase implements EndowmentTaxLotLinesDocument {

    /**
     * @see org.kuali.kfs.module.endow.document.EndowmentTaxLotLinesDocument#getTaxLotLinesNumber()
     */
    public int getTaxLotLinesNumber() {
        int taxLotLinesNbr = 0;

        for (int i = 0; i < getTargetTransactionLines().size(); i++) {
            EndowmentTransactionLine transactionLine = (EndowmentTransactionLine) getTargetTransactionLines().get(i);
            taxLotLinesNbr += transactionLine.getTaxLotLines().size();
        }

        for (int i = 0; i < getSourceTransactionLines().size(); i++) {
            EndowmentTransactionLine transactionLine = (EndowmentTransactionLine) getSourceTransactionLines().get(i);
            taxLotLinesNbr += transactionLine.getTaxLotLines().size();
        }

        return taxLotLinesNbr;
    }


    /**
     * @see org.kuali.kfs.sys.document.Correctable#toErrorCorrection()
     */
    @Override
    public void toErrorCorrection() throws WorkflowException, IllegalStateException {
        super.toErrorCorrection();

        // Negate the Taxlot lines Amount, Units, Short term gain & long term gain values.
        List<EndowmentTransactionLine> lines = new ArrayList<EndowmentTransactionLine>();
        lines.addAll(sourceTransactionLines);
        lines.addAll(targetTransactionLines);

        for (EndowmentTransactionLine line : lines) {
            for (EndowmentTransactionTaxLotLine taxLotLine : line.getTaxLotLines()) {
                taxLotLine.setLotHoldingCost(taxLotLine.getLotHoldingCost().negate());
                taxLotLine.setLotUnits(taxLotLine.getLotUnits().negate());
                if (null != taxLotLine.getLotLongTermGainLoss() && 0 != taxLotLine.getLotLongTermGainLoss().intValue())
                    taxLotLine.setLotLongTermGainLoss(taxLotLine.getLotLongTermGainLoss().negate());
                if (null != taxLotLine.getLotShortTermGainLoss() && 0 != taxLotLine.getLotShortTermGainLoss().intValue())
                    taxLotLine.setLotShortTermGainLoss(taxLotLine.getLotShortTermGainLoss().negate());
            }
        }
    }

    /**
     * @see org.kuali.kfs.module.endow.document.EndowmentTransactionLinesDocumentBase#buildListOfDeletionAwareLists()
     */
    @Override
    public List buildListOfDeletionAwareLists() {
        List managedList = super.buildListOfDeletionAwareLists();

        for (EndowmentTransactionLine endowmentTransactionLine : getTargetTransactionLines()) {
            managedList.add(endowmentTransactionLine.getTaxLotLines());
        }

        for (EndowmentTransactionLine endowmentTransactionLine : getSourceTransactionLines()) {
            managedList.add(endowmentTransactionLine.getTaxLotLines());
        }

        return managedList;
    }

}<commit_msg>KFSMI-7503: The super method in buildListOfDeletionAwareLists is already collecting securities and transaction lines. We do not need to call this method in EndowmentTaxLotLinesDocumentBase class. It is duplicating the list of collections and causing problems when saving the collections.  Removed the method.<commit_after>/*
 * Copyright 2010 The Kuali Foundation.
 * 
 * Licensed under the Educational Community License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.opensource.org/licenses/ecl1.php
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.kuali.kfs.module.endow.document;

import java.util.ArrayList;
import java.util.List;

import org.kuali.kfs.module.endow.businessobject.EndowmentTransactionLine;
import org.kuali.kfs.module.endow.businessobject.EndowmentTransactionTaxLotLine;
import org.kuali.rice.kew.api.exception.WorkflowException;


public abstract class EndowmentTaxLotLinesDocumentBase extends EndowmentSecurityDetailsDocumentBase implements EndowmentTaxLotLinesDocument {

    /**
     * @see org.kuali.kfs.module.endow.document.EndowmentTaxLotLinesDocument#getTaxLotLinesNumber()
     */
    public int getTaxLotLinesNumber() {
        int taxLotLinesNbr = 0;

        for (int i = 0; i < getTargetTransactionLines().size(); i++) {
            EndowmentTransactionLine transactionLine = (EndowmentTransactionLine) getTargetTransactionLines().get(i);
            taxLotLinesNbr += transactionLine.getTaxLotLines().size();
        }

        for (int i = 0; i < getSourceTransactionLines().size(); i++) {
            EndowmentTransactionLine transactionLine = (EndowmentTransactionLine) getSourceTransactionLines().get(i);
            taxLotLinesNbr += transactionLine.getTaxLotLines().size();
        }

        return taxLotLinesNbr;
    }


    /**
     * @see org.kuali.kfs.sys.document.Correctable#toErrorCorrection()
     */
    @Override
    public void toErrorCorrection() throws WorkflowException, IllegalStateException {
        super.toErrorCorrection();

        // Negate the Taxlot lines Amount, Units, Short term gain & long term gain values.
        List<EndowmentTransactionLine> lines = new ArrayList<EndowmentTransactionLine>();
        lines.addAll(sourceTransactionLines);
        lines.addAll(targetTransactionLines);

        for (EndowmentTransactionLine line : lines) {
            for (EndowmentTransactionTaxLotLine taxLotLine : line.getTaxLotLines()) {
                taxLotLine.setLotHoldingCost(taxLotLine.getLotHoldingCost().negate());
                taxLotLine.setLotUnits(taxLotLine.getLotUnits().negate());
                if (null != taxLotLine.getLotLongTermGainLoss() && 0 != taxLotLine.getLotLongTermGainLoss().intValue())
                    taxLotLine.setLotLongTermGainLoss(taxLotLine.getLotLongTermGainLoss().negate());
                if (null != taxLotLine.getLotShortTermGainLoss() && 0 != taxLotLine.getLotShortTermGainLoss().intValue())
                    taxLotLine.setLotShortTermGainLoss(taxLotLine.getLotShortTermGainLoss().negate());
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.09164829106945976, 'fraction_numerical': 0.003858875413450937, 'mean_word_length': 3.598859315589354, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5531309', 'n_tokens_mistral': 2127, 'n_tokens_neox': 2033, 'n_words': 445}