/**
   * Adds the given accountingLine to the appropriate form-related data structures.
   *
   * @param isSource
   * @param financialDocumentForm
   * @param line
   */
  protected void insertAccountingLine(
      boolean isSource,
      KualiAccountingDocumentFormBase financialDocumentForm,
      AccountingLine line) {
    AccountingDocument tdoc = financialDocumentForm.getFinancialDocument();
    if (isSource) {
      // add it to the document
      tdoc.addSourceAccountingLine((SourceAccountingLine) line);

      // add PK fields to sales tax if needed
      if (line.isSalesTaxRequired()) {
        populateSalesTax(line);
      }

      // Update the doc total
      if (tdoc instanceof AmountTotaling)
        ((FinancialSystemDocumentHeader) financialDocumentForm.getDocument().getDocumentHeader())
            .setFinancialDocumentTotalAmount(((AmountTotaling) tdoc).getTotalDollarAmount());
    } else {
      // add it to the document
      tdoc.addTargetAccountingLine((TargetAccountingLine) line);

      // add PK fields to sales tax if needed
      if (line.isSalesTaxRequired()) {
        populateSalesTax(line);
      }
    }
  }