Fixes for currency seeder

This commit is contained in:
David Bomba 2020-11-18 21:46:36 +11:00
parent e91c82aa8b
commit 7fb9877eca
5 changed files with 39 additions and 16 deletions

View File

@ -383,17 +383,7 @@ class CheckData extends Command
$wrong_paid_to_dates = 0;
foreach (Client::cursor() as $client) {
$invoice_balance = $client->invoices->sum('balance');
// $invoice_amounts = $client->invoices->sum('amount') - $invoice_balance;
// $credit_amounts = 0;
// foreach ($client->invoices as $invoice) {
// $credit_amounts += $invoice->credits->sum('amount');
// }
// /*To handle invoice reversals, we need to "ADD BACK" the credit amounts here*/
// $client_paid_to_date = $client->paid_to_date + $credit_amounts;
$invoice_balance = $client->invoices->where('is_deleted', false)->sum('balance');
$ledger = CompanyLedger::where('client_id', $client->id)->orderBy('id', 'DESC')->first();

View File

@ -17,6 +17,7 @@ use App\Models\Account;
use App\Models\Company;
use App\Models\CompanyToken;
use App\Models\User;
use App\Utils\Traits\AppSetup;
use App\Utils\Traits\MakesHash;
use DirectoryIterator;
use Faker\Factory;
@ -27,6 +28,8 @@ use Illuminate\Support\Str;
class ImportMigrations extends Command
{
use MakesHash;
use AppSetup;
/**
* The name and signature of the console command.
*
@ -65,6 +68,8 @@ class ImportMigrations extends Command
*/
public function handle()
{
$this->buildCache();
$path = $this->option('path') ?? storage_path('migrations/import');
$directory = new DirectoryIterator($path);
@ -72,7 +77,6 @@ class ImportMigrations extends Command
foreach ($directory as $file) {
if ($file->getExtension() === 'zip') {
$this->info('Started processing: '.$file->getBasename().' at '.now());
info("dispatching");
StartMigration::dispatch($file->getRealPath(), $this->getUser(), $this->getUser()->companies()->first());
}
}

View File

@ -148,12 +148,13 @@ class Import implements ShouldQueue
*/
private $ids = [];
public $tries = 0;
public $tries = 1;
public $timeout = 86400;
public $backoff = 86430;
// public $maxExceptions = 2;
/**
* Create a new job instance.
*
@ -175,7 +176,7 @@ class Import implements ShouldQueue
*
* @return bool
*/
public function handle() :bool
public function handle()
{
set_time_limit(0);
@ -203,7 +204,6 @@ class Import implements ShouldQueue
info('Completed🚀🚀🚀🚀🚀 at '.now());
return true;
}
private function setInitialCompanyLedgerBalances()
@ -1246,6 +1246,7 @@ class Import implements ShouldQueue
->batch();
info(print_r($exception->getMessage(), 1));
}
}

View File

@ -51,10 +51,12 @@ class StartMigration implements ShouldQueue
* @param User $user
* @param Company $company
*/
public $tries = 0;
public $tries = 1;
public $timeout = 86400;
// public $maxExceptions = 2;
//public $backoff = 86430;
public function __construct($filepath, User $user, Company $company)
@ -124,5 +126,6 @@ class StartMigration implements ShouldQueue
public function failed($exception = null)
{
info(print_r($exception->getMessage(),1));
}
}

View File

@ -102,6 +102,31 @@ class CurrenciesSeeder extends Seeder
['id' => 77, 'name' => 'Bahraini Dinar', 'code' => 'BHD', 'symbol' => 'BD ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 78, 'name' => 'Venezuelan Bolivars', 'code' => 'VES', 'symbol' => 'Bs.', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','],
['id' => 79, 'name' => 'South Korean Won', 'code' => 'KRW', 'symbol' => 'W ', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','],
['id' => 80, 'name' => 'Moroccan Dirham', 'code' => 'MAD', 'symbol' => 'MAD ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 81, 'name' => 'Jamaican Dollar', 'code' => 'JMD', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 82, 'name' => 'Angolan Kwanza', 'code' => 'AOA', 'symbol' => 'Kz', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','],
['id' => 83, 'name' => 'Haitian Gourde', 'code' => 'HTG', 'symbol' => 'G', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 84, 'name' => 'Zambian Kwacha', 'code' => 'ZMW', 'symbol' => 'ZK', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 85, 'name' => 'Nepalese Rupee', 'code' => 'NPR', 'symbol' => 'Rs. ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 86, 'name' => 'CFP Franc', 'code' => 'XPF', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], // precision should be zero
['id' => 87, 'name' => 'Mauritian Rupee', 'code' => 'MUR', 'symbol' => 'Rs', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 88, 'name' => 'Cape Verdean Escudo', 'code' => 'CVE', 'symbol' => '', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => '$'],
['id' => 89, 'name' => 'Kuwaiti Dinar', 'code' => 'KWD', 'symbol' => 'KD', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 90, 'name' => 'Algerian Dinar', 'code' => 'DZD', 'symbol' => 'DA', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 91, 'name' => 'Macedonian Denar', 'code' => 'MKD', 'symbol' => 'ден', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 92, 'name' => 'Fijian Dollar', 'code' => 'FJD', 'symbol' => 'FJ$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 93, 'name' => 'Bolivian Boliviano', 'code' => 'BOB', 'symbol' => 'Bs', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 94,'name' => 'Albanian Lek', 'code' => 'ALL', 'symbol' => 'L ', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','],
['id' => 95, 'name' => 'Serbian Dinar', 'code' => 'RSD', 'symbol' => 'din', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','],
['id' => 96, 'name' => 'Lebanese Pound', 'code' => 'LBP', 'symbol' => 'LL ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 97, 'name' => 'Armenian Dram', 'code' => 'AMD', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 98, 'name' => 'Azerbaijan Manat', 'code' => 'AZN', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 99, 'name' => 'Bosnia and Herzegovina Convertible Mark', 'code' => 'BAM', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 100, 'name' => 'Belarusian Ruble', 'code' => 'BYN', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 101, 'name' => 'Gibraltar Pound', 'code' => 'GIP', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 102, 'name' => 'Moldovan Leu', 'code' => 'MDL', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 103, 'name' => 'Kazakhstani Tenge', 'code' => 'KZT', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 104, 'name' => 'Ethiopian Birr', 'code' => 'ETB', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
];
foreach ($currencies as $currency) {