mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Fixes for migrations where the gateway is no longer supported in V5
This commit is contained in:
parent
2abc7f570b
commit
e5716ae6c0
@ -34,7 +34,7 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
protected function getAccount()
|
protected function getAccount()
|
||||||
{
|
{
|
||||||
|
info("get account");
|
||||||
if($this->account->account_tokens()->exists()){
|
if($this->account->account_tokens()->exists()){
|
||||||
$this->token = $this->account->account_tokens->first()->token;
|
$this->token = $this->account->account_tokens->first()->token;
|
||||||
}
|
}
|
||||||
@ -69,6 +69,7 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
protected function getCompany()
|
protected function getCompany()
|
||||||
{
|
{
|
||||||
|
info("get company");
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'referral_code' => $this->account->referral_code ?: '',
|
'referral_code' => $this->account->referral_code ?: '',
|
||||||
@ -95,6 +96,8 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
public function getCompanySettings()
|
public function getCompanySettings()
|
||||||
{
|
{
|
||||||
|
info("get co settings");
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'timezone_id' => $this->account->timezone_id ? (string) $this->account->timezone_id : '15',
|
'timezone_id' => $this->account->timezone_id ? (string) $this->account->timezone_id : '15',
|
||||||
'date_format_id' => $this->account->date_format_id ? (string) $this->account->date_format_id : '1',
|
'date_format_id' => $this->account->date_format_id ? (string) $this->account->date_format_id : '1',
|
||||||
@ -177,6 +180,9 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
public function getTaxRates()
|
public function getTaxRates()
|
||||||
{
|
{
|
||||||
|
info("get tax rates");
|
||||||
|
|
||||||
|
|
||||||
$rates = TaxRate::where('account_id', $this->account->id)
|
$rates = TaxRate::where('account_id', $this->account->id)
|
||||||
->withTrashed()
|
->withTrashed()
|
||||||
->get();
|
->get();
|
||||||
@ -199,7 +205,8 @@ trait GenerateMigrationResources
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function getClients()
|
protected function getClients()
|
||||||
{
|
{info("get clients");
|
||||||
|
|
||||||
$clients = [];
|
$clients = [];
|
||||||
|
|
||||||
foreach ($this->account->clients()->withTrashed()->get() as $client) {
|
foreach ($this->account->clients()->withTrashed()->get() as $client) {
|
||||||
@ -250,6 +257,9 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
private function getClientSettings($client)
|
private function getClientSettings($client)
|
||||||
{
|
{
|
||||||
|
info("get client settings");
|
||||||
|
|
||||||
|
|
||||||
$settings = new \stdClass();
|
$settings = new \stdClass();
|
||||||
$settings->currency_id = $client->currency_id ? (string) $client->currency_id : (string) $client->account->currency_id;
|
$settings->currency_id = $client->currency_id ? (string) $client->currency_id : (string) $client->account->currency_id;
|
||||||
|
|
||||||
@ -262,6 +272,8 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
protected function getClientContacts($client)
|
protected function getClientContacts($client)
|
||||||
{
|
{
|
||||||
|
info("get client contacts");
|
||||||
|
|
||||||
$contacts = Contact::where('client_id', $client->id)->withTrashed()->get();
|
$contacts = Contact::where('client_id', $client->id)->withTrashed()->get();
|
||||||
|
|
||||||
$transformed = [];
|
$transformed = [];
|
||||||
@ -297,6 +309,8 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
protected function getProducts()
|
protected function getProducts()
|
||||||
{
|
{
|
||||||
|
info("get products");
|
||||||
|
|
||||||
$products = Product::where('account_id', $this->account->id)
|
$products = Product::where('account_id', $this->account->id)
|
||||||
->withTrashed()
|
->withTrashed()
|
||||||
->get();
|
->get();
|
||||||
@ -328,6 +342,8 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
public function getUsers()
|
public function getUsers()
|
||||||
{
|
{
|
||||||
|
info("get users");
|
||||||
|
|
||||||
$users = User::where('account_id', $this->account->id)
|
$users = User::where('account_id', $this->account->id)
|
||||||
->withTrashed()
|
->withTrashed()
|
||||||
->get();
|
->get();
|
||||||
@ -362,6 +378,8 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
private function getCreditsNotes()
|
private function getCreditsNotes()
|
||||||
{
|
{
|
||||||
|
info("get credit notes");
|
||||||
|
|
||||||
$credits = [];
|
$credits = [];
|
||||||
|
|
||||||
$export_credits = Invoice::where('account_id', $this->account->id)
|
$export_credits = Invoice::where('account_id', $this->account->id)
|
||||||
@ -417,7 +435,8 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
|
|
||||||
protected function getInvoices()
|
protected function getInvoices()
|
||||||
{
|
{ info("get invoices");
|
||||||
|
|
||||||
$invoices = [];
|
$invoices = [];
|
||||||
|
|
||||||
$export_invoices = Invoice::where('account_id', $this->account->id)
|
$export_invoices = Invoice::where('account_id', $this->account->id)
|
||||||
@ -481,6 +500,9 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
protected function getRecurringInvoices()
|
protected function getRecurringInvoices()
|
||||||
{
|
{
|
||||||
|
info("get recurring invoices");
|
||||||
|
|
||||||
|
|
||||||
$invoices = [];
|
$invoices = [];
|
||||||
|
|
||||||
$export_invoices = Invoice::where('account_id', $this->account->id)
|
$export_invoices = Invoice::where('account_id', $this->account->id)
|
||||||
@ -772,6 +794,8 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
public function getResourceInvitations($items, $resourceKeyId)
|
public function getResourceInvitations($items, $resourceKeyId)
|
||||||
{
|
{
|
||||||
|
info("get resource {$resourceKeyId} invitations");
|
||||||
|
|
||||||
$transformed = [];
|
$transformed = [];
|
||||||
|
|
||||||
foreach ($items as $invitation) {
|
foreach ($items as $invitation) {
|
||||||
@ -801,6 +825,8 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
public function getCreditItems($items)
|
public function getCreditItems($items)
|
||||||
{
|
{
|
||||||
|
info("get credit items");
|
||||||
|
|
||||||
$transformed = [];
|
$transformed = [];
|
||||||
|
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
@ -838,6 +864,8 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
public function getInvoiceItems($items)
|
public function getInvoiceItems($items)
|
||||||
{
|
{
|
||||||
|
info("get invoice items");
|
||||||
|
|
||||||
$transformed = [];
|
$transformed = [];
|
||||||
|
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
@ -866,6 +894,9 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
public function getQuotes()
|
public function getQuotes()
|
||||||
{
|
{
|
||||||
|
info("get quotes");
|
||||||
|
|
||||||
|
|
||||||
$transformed = [];
|
$transformed = [];
|
||||||
|
|
||||||
$quotes = Invoice::where('account_id', $this->account->id)
|
$quotes = Invoice::where('account_id', $this->account->id)
|
||||||
@ -943,6 +974,8 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
public function getPayments()
|
public function getPayments()
|
||||||
{
|
{
|
||||||
|
info("get payments");
|
||||||
|
|
||||||
$transformed = [];
|
$transformed = [];
|
||||||
|
|
||||||
$payments = Payment::where('account_id', $this->account->id)
|
$payments = Payment::where('account_id', $this->account->id)
|
||||||
@ -1074,6 +1107,8 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
private function getCredits()
|
private function getCredits()
|
||||||
{
|
{
|
||||||
|
info("get credits");
|
||||||
|
|
||||||
$credits = Credit::where('account_id', $this->account->id)->where('balance', '>', 0)->whereIsDeleted(false)
|
$credits = Credit::where('account_id', $this->account->id)->where('balance', '>', 0)->whereIsDeleted(false)
|
||||||
->withTrashed()
|
->withTrashed()
|
||||||
->get();
|
->get();
|
||||||
@ -1102,6 +1137,8 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
private function getDocuments()
|
private function getDocuments()
|
||||||
{
|
{
|
||||||
|
info("get documents");
|
||||||
|
|
||||||
$documents = Document::where('account_id', $this->account->id)->get();
|
$documents = Document::where('account_id', $this->account->id)->get();
|
||||||
|
|
||||||
$transformed = [];
|
$transformed = [];
|
||||||
@ -1143,8 +1180,13 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
$fees_and_limits = $this->transformFeesAndLimits($gateway_type);
|
$fees_and_limits = $this->transformFeesAndLimits($gateway_type);
|
||||||
|
|
||||||
|
info("generated fees and limits = ");
|
||||||
|
info(print_r($fees_and_limits,1));
|
||||||
|
|
||||||
$translated_gateway_type = $this->translateGatewayTypeId($gateway_type);
|
$translated_gateway_type = $this->translateGatewayTypeId($gateway_type);
|
||||||
|
|
||||||
|
info("translated gateway_type = {$translated_gateway_type}");
|
||||||
|
|
||||||
$fees->{$translated_gateway_type} = $fees_and_limits;
|
$fees->{$translated_gateway_type} = $fees_and_limits;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1153,14 +1195,17 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
private function getCompanyGateways()
|
private function getCompanyGateways()
|
||||||
{
|
{
|
||||||
|
info("get get company gateways");
|
||||||
|
|
||||||
$account_gateways = AccountGateway::where('account_id', $this->account->id)->withTrashed()->get();
|
$account_gateways = AccountGateway::where('account_id', $this->account->id)->withTrashed()->get();
|
||||||
|
|
||||||
|
|
||||||
$transformed = [];
|
$transformed = [];
|
||||||
|
|
||||||
foreach ($account_gateways as $account_gateway) {
|
foreach ($account_gateways as $account_gateway) {
|
||||||
|
|
||||||
// if($account_gateway->gateway_id > 55)
|
if($this->translateGatewaysId($account_gateway->gateway_id) == 0)
|
||||||
// continue;
|
continue;
|
||||||
|
|
||||||
$gateway_types = $account_gateway->paymentDriver()->gatewayTypes();
|
$gateway_types = $account_gateway->paymentDriver()->gatewayTypes();
|
||||||
|
|
||||||
@ -1191,6 +1236,8 @@ trait GenerateMigrationResources
|
|||||||
/*converts the gateway ID to the new v5 list*/
|
/*converts the gateway ID to the new v5 list*/
|
||||||
private function translateGatewaysId($gateway_id)
|
private function translateGatewaysId($gateway_id)
|
||||||
{
|
{
|
||||||
|
info("translating gateway ID = {$gateway_id}");
|
||||||
|
|
||||||
switch ($gateway_id) {
|
switch ($gateway_id) {
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
@ -1334,6 +1381,10 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
private function getClientGatewayTokens()
|
private function getClientGatewayTokens()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
info("get client gateway tokens");
|
||||||
|
|
||||||
|
|
||||||
$payment_methods = PaymentMethod::where('account_id', $this->account->id)->withTrashed()->get();
|
$payment_methods = PaymentMethod::where('account_id', $this->account->id)->withTrashed()->get();
|
||||||
|
|
||||||
$transformed = [];
|
$transformed = [];
|
||||||
@ -1364,6 +1415,9 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
private function getPaymentTerms()
|
private function getPaymentTerms()
|
||||||
{
|
{
|
||||||
|
info("get payment terms");
|
||||||
|
|
||||||
|
|
||||||
$payment_terms = PaymentTerm::where('account_id', 0)->orWhere('account_id', $this->account->id)->withTrashed()->get();
|
$payment_terms = PaymentTerm::where('account_id', 0)->orWhere('account_id', $this->account->id)->withTrashed()->get();
|
||||||
|
|
||||||
$transformed = [];
|
$transformed = [];
|
||||||
@ -1392,6 +1446,8 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
private function getTaskStatuses()
|
private function getTaskStatuses()
|
||||||
{
|
{
|
||||||
|
info("get task statuses");
|
||||||
|
|
||||||
$task_statuses = TaskStatus::where('account_id', $this->account->id)->withTrashed()->get();
|
$task_statuses = TaskStatus::where('account_id', $this->account->id)->withTrashed()->get();
|
||||||
|
|
||||||
if($task_statuses->count() == 0)
|
if($task_statuses->count() == 0)
|
||||||
@ -1436,6 +1492,8 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
private function getExpenseCategories()
|
private function getExpenseCategories()
|
||||||
{
|
{
|
||||||
|
info("get expense categories");
|
||||||
|
|
||||||
$expense_categories = ExpenseCategory::where('account_id', $this->account->id)->withTrashed()->get();
|
$expense_categories = ExpenseCategory::where('account_id', $this->account->id)->withTrashed()->get();
|
||||||
|
|
||||||
$transformed = [];
|
$transformed = [];
|
||||||
@ -1459,6 +1517,8 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
private function getExpenses()
|
private function getExpenses()
|
||||||
{
|
{
|
||||||
|
info("get expenses");
|
||||||
|
|
||||||
$expenses = Expense::where('account_id', $this->account->id)->withTrashed()->get();
|
$expenses = Expense::where('account_id', $this->account->id)->withTrashed()->get();
|
||||||
|
|
||||||
$transformed = [];
|
$transformed = [];
|
||||||
@ -1512,6 +1572,9 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
private function getTasks()
|
private function getTasks()
|
||||||
{
|
{
|
||||||
|
info("get tasks");
|
||||||
|
|
||||||
|
|
||||||
$tasks = Task::where('account_id', $this->account->id)
|
$tasks = Task::where('account_id', $this->account->id)
|
||||||
->withTrashed()
|
->withTrashed()
|
||||||
->get();
|
->get();
|
||||||
@ -1552,6 +1615,8 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
private function getProjects()
|
private function getProjects()
|
||||||
{
|
{
|
||||||
|
info("get projects");
|
||||||
|
|
||||||
$projects = Project::where('account_id', $this->account->id)
|
$projects = Project::where('account_id', $this->account->id)
|
||||||
->withTrashed()
|
->withTrashed()
|
||||||
->get();
|
->get();
|
||||||
@ -1592,6 +1657,8 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
protected function getVendors()
|
protected function getVendors()
|
||||||
{
|
{
|
||||||
|
info("get vendors");
|
||||||
|
|
||||||
$vendor_query = Vendor::where('account_id', $this->account->id)->withTrashed()->get();
|
$vendor_query = Vendor::where('account_id', $this->account->id)->withTrashed()->get();
|
||||||
|
|
||||||
$vendors = [];
|
$vendors = [];
|
||||||
@ -1637,6 +1704,8 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
protected function getVendorContacts($contacts)
|
protected function getVendorContacts($contacts)
|
||||||
{
|
{
|
||||||
|
info("get vendor contacts");
|
||||||
|
|
||||||
$transformed = [];
|
$transformed = [];
|
||||||
|
|
||||||
foreach ($contacts as $contact) {
|
foreach ($contacts as $contact) {
|
||||||
@ -1675,6 +1744,8 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
private function convertMeta($payment_method)
|
private function convertMeta($payment_method)
|
||||||
{
|
{
|
||||||
|
info("get converting payment method meta");
|
||||||
|
|
||||||
$expiry = explode('-', $payment_method->expiration);
|
$expiry = explode('-', $payment_method->expiration);
|
||||||
|
|
||||||
if (is_array($expiry) && count($expiry) >= 2) {
|
if (is_array($expiry) && count($expiry) >= 2) {
|
||||||
@ -1697,6 +1768,7 @@ trait GenerateMigrationResources
|
|||||||
|
|
||||||
private function transformFeesAndLimits($gateway_type_id)
|
private function transformFeesAndLimits($gateway_type_id)
|
||||||
{
|
{
|
||||||
|
info("get transform fees and limits");
|
||||||
|
|
||||||
$ags = AccountGatewaySettings::where('account_id', $this->account->id)
|
$ags = AccountGatewaySettings::where('account_id', $this->account->id)
|
||||||
->where('gateway_type_id', $gateway_type_id)
|
->where('gateway_type_id', $gateway_type_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user