1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Export company_user with users (#3597)

This commit is contained in:
Benjamin Beganović 2020-04-07 22:43:34 +02:00 committed by GitHub
parent 602a15f648
commit 0b8b4a7505
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,9 +1,7 @@
<?php
namespace App\Traits;
use App\Models\AccountGateway;
use App\Models\AccountGatewaySettings;
use App\Models\AccountGatewayToken;
@ -195,11 +193,12 @@ trait GenerateMigrationResources
private function getClientSettings($client)
{
$settings = new \stdClass;
$settings = new \stdClass();
$settings->currency_id = $client->currency_id ? (string) $client->currency_id : (string) $client->account->currency_id;
if($client->language_id)
if ($client->language_id) {
$settings->language_id = $client->language_id;
}
return $settings;
}
@ -291,6 +290,7 @@ trait GenerateMigrationResources
'created_at' => $user->created_at ? $user->created_at->toDateString() : null,
'updated_at' => $user->updated_at ? $user->updated_at->toDateString() : null,
'deleted_at' => $user->deleted_at ? $user->deleted_at->toDateString() : null,
'company_user' => [],
];
}
@ -431,7 +431,6 @@ trait GenerateMigrationResources
return $transformed;
}
public function getInvoiceItems($items)
{
$transformed = [];
@ -614,11 +613,9 @@ trait GenerateMigrationResources
$transformed = [];
foreach ($account_gateways as $account_gateway) {
$gateway_types = $account_gateway->paymentDriver()->gatewayTypes();
foreach ($gateway_types as $gateway_type_id) {
$transformed[] = [
'id' => $account_gateway->id,
'user_id' => $account_gateway->user_id,
@ -639,7 +636,6 @@ trait GenerateMigrationResources
}
return $transformed;
}
private function getClientGatewayTokens()
@ -651,7 +647,6 @@ trait GenerateMigrationResources
$is_default = true;
foreach ($payment_methods as $payment_method) {
$contact = Contact::find($payment_method->contact_id)->first();
$agt = AccountGatewayToken::find($payment_method->account_gateway_token_id)->first();
@ -675,22 +670,21 @@ trait GenerateMigrationResources
private function convertMeta($payment_method)
{
$expiry = explode("-", $payment_method->expiration);
$expiry = explode('-', $payment_method->expiration);
if (is_array($expiry)) {
$exp_month = $expiry[1];
$exp_year = $expiry[0];
}
else{
} else {
$exp_month = '';
$exp_year = '';
}
$meta = new \stdClass;
$meta = new \stdClass();
$meta->exp_month = $exp_month;
$meta->exp_year = $exp_year;
$meta->brand = $payment_method->payment_type->name;
$meta->last4 = str_replace(",","", ($payment_method->expiration));
$meta->last4 = str_replace(',', '', ($payment_method->expiration));
$meta->type = $payment_method->payment_type->gateway_type_id;
return $meta;
@ -702,10 +696,11 @@ trait GenerateMigrationResources
->where('gateway_type_id', $gateway_type_id)
->first();
if(!$ags)
return new \stdClass;
if (! $ags) {
return new \stdClass();
}
$fees_and_limits = new \stdClass;
$fees_and_limits = new \stdClass();
$fees_and_limits->min_limit = $ags->min_limit;
$fees_and_limits->max_limit = $ags->max_limit;
$fees_and_limits->fee_amount = $ags->fee_amount;
@ -717,7 +712,6 @@ trait GenerateMigrationResources
$fees_and_limits->tax_name3 = '';
$fees_and_limits->tax_rate3 = 0;
return $fees_and_limits;
}