Improvements to check data script

This commit is contained in:
Hillel Coren 2017-07-12 23:34:57 +03:00
parent 756fca49fe
commit e4a7f4c614
2 changed files with 5 additions and 5 deletions

View File

@ -76,7 +76,7 @@ class CheckData extends Command
$this->checkDraftSentInvoices(); $this->checkDraftSentInvoices();
} }
//$this->checkInvoices(); $this->checkInvoices();
$this->checkBalances(); $this->checkBalances();
$this->checkContacts(); $this->checkContacts();
$this->checkUserAccounts(); $this->checkUserAccounts();
@ -148,14 +148,14 @@ class CheckData extends Command
->get(['id', 'balance']); ->get(['id', 'balance']);
foreach ($invoices as $invoice) { foreach ($invoices as $invoice) {
$link = $invoice->getInvitationLink(); $link = $invoice->getInvitationLink('view', true, true);
$this->logMessage('Checking invoice: ' . $invoice->id . ' - ' . $invoice->balance); $this->logMessage('Checking invoice: ' . $invoice->id . ' - ' . $invoice->balance);
$result = CurlUtils::phantom('GET', $link . '?phantomjs=true&phantomjs_balances=true&phantomjs_secret=' . env('PHANTOMJS_SECRET')); $result = CurlUtils::phantom('GET', $link . '?phantomjs=true&phantomjs_balances=true&phantomjs_secret=' . env('PHANTOMJS_SECRET'));
$result = floatval(strip_tags($result)); $result = floatval(strip_tags($result));
$this->logMessage('Result: ' . $result); $this->logMessage('Result: ' . $result);
if ($result && $result != $invoice->balance) { if ($result && $result != $invoice->balance) {
$this->logMessage("Amounts do not match - PHP: {$invoice->balance}, JS: {$result}"); $this->logMessage("Amounts do not match {$link} - PHP: {$invoice->balance}, JS: {$result}");
$this->isValid = false; $this->isValid = false;
} }
} }

View File

@ -699,13 +699,13 @@ class Invoice extends EntityModel implements BalanceAffecting
return self::calcLink($this); return self::calcLink($this);
} }
public function getInvitationLink($type = 'view', $forceOnsite = false) public function getInvitationLink($type = 'view', $forceOnsite = false, $forcePlain = false)
{ {
if (! $this->relationLoaded('invitations')) { if (! $this->relationLoaded('invitations')) {
$this->load('invitations'); $this->load('invitations');
} }
return $this->invitations[0]->getLink($type, $forceOnsite); return $this->invitations[0]->getLink($type, $forceOnsite, $forcePlain);
} }
/** /**