1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Fixes for freshbooks imports

This commit is contained in:
David Bomba 2021-12-11 08:43:14 +11:00
parent 0cebfd1f56
commit d80d440ca3

View File

@ -440,57 +440,52 @@ class CSVImport implements ShouldQueue {
'tax_names' => [], 'tax_names' => [],
]; ];
$clients = Client::where('company_id', $this->company->id)->cursor()->each(function ($client){ Client::where('company_id', $this->company->id)->cursor()->each(function ($client){
$this->addClientToMaps( $client ); $this->addClientToMaps( $client );
}); });
$contacts = ClientContact::where('company_id', $this->company->id)->cursor()->each(function ($contact){ ClientContact::where('company_id', $this->company->id)->cursor()->each(function ($contact){
$this->addContactToMaps( $contact ); $this->addContactToMaps( $contact );
}); });
$invoices = Invoice::where('company_id', $this->company->id)->cursor()->each(function ($invoice){ Invoice::where('company_id', $this->company->id)->cursor()->each(function ($invoice){
$this->addInvoiceToMaps( $invoice ); $this->addInvoiceToMaps( $invoice );
}); });
$products = Product::where('company_id', $this->company->id)->cursor()->each(function ($product){ Product::where('company_id', $this->company->id)->cursor()->each(function ($product){
$this->addProductToMaps( $product ); $this->addProductToMaps( $product );
}); });
$projects = Project::where('company_id', $this->company->id)->cursor()->each(function ($project){ Project::where('company_id', $this->company->id)->cursor()->each(function ($project){
$this->addProjectToMaps( $project ); $this->addProjectToMaps( $project );
}); });
$countries = Country::all(); Country::all()->each(function ($country){
foreach ( $countries as $country ) {
$this->maps['countries'][ strtolower( $country->name ) ] = $country->id; $this->maps['countries'][ strtolower( $country->name ) ] = $country->id;
$this->maps['countries2'][ strtolower( $country->iso_3166_2 ) ] = $country->id; $this->maps['countries2'][ strtolower( $country->iso_3166_2 ) ] = $country->id;
} });
$currencies = Currency::all(); Currency::all()->each(function ($currency){
foreach ( $currencies as $currency ) {
$this->maps['currencies'][ strtolower( $currency->code ) ] = $currency->id; $this->maps['currencies'][ strtolower( $currency->code ) ] = $currency->id;
} });
$payment_types = PaymentType::all(); PaymentType::all()->each(function ($payment_type){
foreach ( $payment_types as $payment_type ) {
$this->maps['payment_types'][ strtolower( $payment_type->name ) ] = $payment_type->id; $this->maps['payment_types'][ strtolower( $payment_type->name ) ] = $payment_type->id;
} });
$vendors = Vendor::where('company_id', $this->company->id)->cursor()->each(function ($vendor){ Vendor::where('company_id', $this->company->id)->cursor()->each(function ($vendor){
$this->addVendorToMaps( $vendor ); $this->addVendorToMaps( $vendor );
}); });
$expenseCaegories = ExpenseCategory::where('company_id', $this->company->id)->get(); ExpenseCategory::where('company_id', $this->company->id)->cursor()->each(function ($category){
foreach ( $expenseCaegories as $category ) {
$this->addExpenseCategoryToMaps( $category ); $this->addExpenseCategoryToMaps( $category );
} });
$taxRates = TaxRate::where('company_id', $this->company->id)->get(); TaxRate::where('company_id', $this->company->id)->cursor()->each(function ($taxRate){
foreach ( $taxRates as $taxRate ) {
$name = trim( strtolower( $taxRate->name ) ); $name = trim( strtolower( $taxRate->name ) );
$this->maps['tax_rates'][ $name ] = $taxRate->rate; $this->maps['tax_rates'][ $name ] = $taxRate->rate;
$this->maps['tax_names'][ $name ] = $taxRate->name; $this->maps['tax_names'][ $name ] = $taxRate->name;
} });
} }
/** /**