private function setSubmittedSource()
    {
        // Get actual source ($this->source may be the parent, not the source to
        // execute on). Do so without trusting the input.
        $sourceType = $this->getSubmittedValue('type') === Source::Order ? Source::Order : Source::CreditNote;
        $sourceId = (int) $this->getSubmittedValue('source');
        $this->submittedSource = null;
        if ($this->source->getType() === $sourceType && $this->source->getId() === $sourceId) {
            $this->submittedSource = $this->source;
        } else {
            $creditNotes = $this->source->getCreditNotes();
            foreach ($creditNotes as $creditNote) {
                if ($creditNote->getType() === $sourceType && $creditNote->getId() === $sourceId) {
                    $this->submittedSource = $creditNote;
                }
            }
        }
    }