1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 12:42:36 +01:00

Add recurring expenses into export data

This commit is contained in:
David Bomba 2021-09-12 11:29:46 +10:00
parent 37126963f6
commit 4c6c71a85d

View File

@ -303,13 +303,13 @@ trait GenerateMigrationResources
public function getTaxRates()
{
info("get tax rates");
$rates = TaxRate::where('account_id', $this->account->id)
->withTrashed()
->get();
info("get tax rates => " . $rates->count());
$transformed = [];
foreach ($rates as $rate) {
@ -328,10 +328,12 @@ trait GenerateMigrationResources
}
protected function getClients()
{info("get clients");
{
$clients = [];
info("get clients => ". $this->account->clients()->count());
foreach ($this->account->clients()->withTrashed()->get() as $client) {
$number = $client->id_number;
@ -401,6 +403,8 @@ trait GenerateMigrationResources
$transformed = [];
info("Importing contacts => " . $contacts->count());
foreach ($contacts as $contact) {
$transformed[] = [
'id' => $contact->id,
@ -475,12 +479,13 @@ trait GenerateMigrationResources
protected function getProducts()
{
info("get products");
$products = Product::where('account_id', $this->account->id)
->withTrashed()
->get();
info("get products " . $products->count());
$transformed = [];
foreach ($products as $product) {
@ -509,12 +514,13 @@ trait GenerateMigrationResources
public function getUsers()
{
info("get users");
$users = User::where('account_id', $this->account->id)
->withTrashed()
->get();
info("get users " . $users->count());
$transformed = [];
foreach ($users as $user) {
@ -545,7 +551,6 @@ trait GenerateMigrationResources
private function getCreditsNotes()
{
info("get credit notes");
$credits = [];
@ -556,6 +561,8 @@ trait GenerateMigrationResources
->withTrashed()
->get();
info("get credit notes => " . $export_credits->count());
foreach ($export_credits as $credit) {
$credits[] = [
'id' => $credit->id,
@ -602,7 +609,7 @@ trait GenerateMigrationResources
protected function getInvoices()
{ info("get invoices");
{
$invoices = [];
@ -613,6 +620,8 @@ trait GenerateMigrationResources
->withTrashed()
->get();
info("get invoices -> ". $export_invoices->count());
foreach ($export_invoices as $invoice) {
$invoices[] = [
'id' => $invoice->id,
@ -685,8 +694,6 @@ trait GenerateMigrationResources
protected function getRecurringExpenses()
{
info("get recurring Expenses");
$expenses = [];
@ -694,8 +701,10 @@ trait GenerateMigrationResources
->withTrashed()
->get();
info("get recurring Expenses => " . $export_expenses->count());
foreach ($export_expenses as $expense) {
$invoices[] = [
$expenses[] = [
'id' => $expense->id,
'amount' => $expense->amount,
'company_id' => $this->account->id,
@ -728,7 +737,7 @@ trait GenerateMigrationResources
];
}
return $invoices;
return $expenses;
@ -736,8 +745,6 @@ trait GenerateMigrationResources
protected function getRecurringInvoices()
{
info("get recurring invoices");
$invoices = [];
@ -745,7 +752,9 @@ trait GenerateMigrationResources
->where('amount', '>=', 0)
->where('is_recurring', true)
->withTrashed()
->get();
->get();
info("get recurring invoices => " . $export_invoices->count());
foreach ($export_invoices as $invoice) {
$invoices[] = [
@ -1202,8 +1211,6 @@ trait GenerateMigrationResources
public function getQuotes()
{
info("get quotes");
$transformed = [];
@ -1212,6 +1219,8 @@ trait GenerateMigrationResources
->withTrashed()
->get();
info("get quotes => " . $quotes->count());
foreach ($quotes as $quote) {
$transformed[] = [
'id' => $quote->id,
@ -1237,7 +1246,7 @@ trait GenerateMigrationResources
'tax_name2' => $quote->tax_name2,
'tax_rate1' => $quote->tax_rate1,
'tax_rate2' => $quote->tax_rate2,
'invoice_id' => Quote::getPrivateId($quote->quote_invoice_id),
'invoice_id' => Invoice::getPrivateId($quote->quote_invoice_id),
'custom_surcharge1' => $quote->custom_value1 ?: '',
'custom_surcharge2' => $quote->custom_value2 ?: '',
'custom_value1' => $quote->custom_text_value1 ?: '',
@ -1287,7 +1296,6 @@ trait GenerateMigrationResources
public function getPayments()
{
info("get payments");
$transformed = [];
@ -1296,6 +1304,9 @@ trait GenerateMigrationResources
->withTrashed()
->get();
info("get payments => " . $payments->count());
foreach ($payments as $payment) {
$transformed[] = [
'id' => $payment->id,
@ -1423,12 +1434,13 @@ trait GenerateMigrationResources
private function getCredits()
{
info("get credits");
$credits = Credit::where('account_id', $this->account->id)->where('balance', '>', 0)->whereIsDeleted(false)
->withTrashed()
->get();
info("get credits => " . $credits->count());
$transformed = [];
foreach ($credits as $credit) {
@ -1453,10 +1465,12 @@ trait GenerateMigrationResources
private function getDocuments()
{
info("get documents");
$documents = Document::where('account_id', $this->account->id)->get();
info("get documents => " . $documents->count());
$transformed = [];
foreach ($documents as $document) {
@ -1508,10 +1522,11 @@ trait GenerateMigrationResources
private function getCompanyGateways()
{
info("get get company gateways");
$account_gateways = AccountGateway::where('account_id', $this->account->id)->withTrashed()->get();
info("get get company gateways => " . $account_gateways->count());
$transformed = [];
foreach ($account_gateways as $account_gateway) {
@ -1708,11 +1723,10 @@ trait GenerateMigrationResources
private function getClientGatewayTokens()
{
info("get client gateway tokens");
$payment_methods = PaymentMethod::where('account_id', $this->account->id)->withTrashed()->get();
info("get client gateway tokens => " . $payment_methods->count());
$transformed = [];
$is_default = true;
@ -1744,11 +1758,11 @@ trait GenerateMigrationResources
private function getPaymentTerms()
{
info("get payment terms");
$payment_terms = PaymentTerm::where('account_id', 0)->orWhere('account_id', $this->account->id)->withTrashed()->get();
info("get payment terms => " . $payment_terms->count());
$transformed = [];
foreach($payment_terms as $payment_term)
@ -1775,10 +1789,10 @@ trait GenerateMigrationResources
private function getTaskStatuses()
{
info("get task statuses");
$task_statuses = TaskStatus::where('account_id', $this->account->id)->withTrashed()->get();
info("get task statuses => " . $task_statuses->count());
if($task_statuses->count() == 0)
{
$defaults = [
@ -1821,10 +1835,10 @@ trait GenerateMigrationResources
private function getExpenseCategories()
{
info("get expense categories");
$expense_categories = ExpenseCategory::where('account_id', $this->account->id)->withTrashed()->get();
info("get expense categories => " . $expense_categories->count());
$transformed = [];
foreach ($expense_categories as $category)
@ -1846,10 +1860,10 @@ trait GenerateMigrationResources
private function getExpenses()
{
info("get expenses");
$expenses = Expense::where('account_id', $this->account->id)->withTrashed()->get();
info("get expenses => " . $expenses->count());
$transformed = [];
foreach ($expenses as $expense)
@ -1901,13 +1915,13 @@ trait GenerateMigrationResources
private function getTasks()
{
info("get tasks");
$tasks = Task::where('account_id', $this->account->id)
->withTrashed()
->get();
info("get tasks => " . $tasks->count());
$transformed = [];
foreach ($tasks as $task)
@ -1944,12 +1958,14 @@ trait GenerateMigrationResources
private function getProjects()
{
info("get projects");
$projects = Project::where('account_id', $this->account->id)
->withTrashed()
->get();
info("get projects => " . $projects);
$transformed = [];
foreach ($projects as $project)
@ -1986,10 +2002,10 @@ trait GenerateMigrationResources
protected function getVendors()
{
info("get vendors");
$vendor_query = Vendor::where('account_id', $this->account->id)->withTrashed()->get();
info("get vendors => " . $vendor_query->count());
$vendors = [];
foreach ($vendor_query as $vendor) {
@ -2033,7 +2049,7 @@ trait GenerateMigrationResources
protected function getVendorContacts($contacts)
{
info("get vendor contacts");
info("get vendor contacts => " . $contacts->count());
$transformed = [];