public static function GenerateCashCreditNote($clientid, $invoice, $credit, $description) { $client = Client::GetClient($clientid); $description = 'Credit Note (Inv: ' . $invoice . ') - ' . $description; $inv = SalesInvoice::GetInvoice($invoice); if ($inv->total->amount < $inv->credit->amount + $credit) { return false; } $crnote = CreditNote::CreateCashCreditNote($client, $invoice, $credit, $description); if ($crnote->generate()) { return new SalesTX($crnote, 'Credit Note'); } else { Logger::Log('SalesTX', 'Failed', 'Credit Note transaction with id:' . $crnote->id . ' and tx id:' . $this->transactionId . ' could not be completed'); return false; } }