mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 04:37:38 -04:00
Create data mapper classes for tax data
This commit is contained in:
parent
2e2b9da980
commit
c9b9b8326d
21
app/DataMapper/Tax/ClientTaxData.php
Normal file
21
app/DataMapper/Tax/ClientTaxData.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\DataMapper\Tax;
|
||||||
|
|
||||||
|
use App\DataMapper\Tax\ZipTax\Response;
|
||||||
|
|
||||||
|
class ClientTaxData
|
||||||
|
{
|
||||||
|
public function __construct(public Response $origin, public Response $destination)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
21
app/DataMapper/Tax/CompanyTaxData.php
Normal file
21
app/DataMapper/Tax/CompanyTaxData.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\DataMapper\Tax;
|
||||||
|
|
||||||
|
use App\DataMapper\Tax\ZipTax\Response;
|
||||||
|
|
||||||
|
class CompanyTaxData
|
||||||
|
{
|
||||||
|
public function __construct(public Response $origin)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
21
app/DataMapper/Tax/InvoiceTaxData.php
Normal file
21
app/DataMapper/Tax/InvoiceTaxData.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\DataMapper\Tax;
|
||||||
|
|
||||||
|
use App\DataMapper\Tax\ZipTax\Response;
|
||||||
|
|
||||||
|
class InvoiceTaxData
|
||||||
|
{
|
||||||
|
public function __construct(public Response $origin)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -45,6 +45,8 @@ class InvoiceSum
|
|||||||
|
|
||||||
private $precision;
|
private $precision;
|
||||||
|
|
||||||
|
public InvoiceItemSum $invoice_items;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the object with Invoice and Settings object.
|
* Constructs the object with Invoice and Settings object.
|
||||||
*
|
*
|
||||||
|
@ -429,6 +429,8 @@ class Company extends BaseModel
|
|||||||
'convert_payment_currency',
|
'convert_payment_currency',
|
||||||
'convert_expense_currency',
|
'convert_expense_currency',
|
||||||
'notify_vendor_when_paid',
|
'notify_vendor_when_paid',
|
||||||
|
'calculate_taxes',
|
||||||
|
'tax_all_products',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $hidden = [
|
protected $hidden = [
|
||||||
|
@ -582,7 +582,7 @@ class Invoice extends BaseModel
|
|||||||
/**
|
/**
|
||||||
* Access the invoice calculator object.
|
* Access the invoice calculator object.
|
||||||
*
|
*
|
||||||
* @return stdClass The invoice calculator object getters
|
* @return \stdClass The invoice calculator object getters
|
||||||
*/
|
*/
|
||||||
public function calc()
|
public function calc()
|
||||||
{
|
{
|
||||||
|
@ -105,11 +105,12 @@ class Product extends BaseModel
|
|||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
use Filterable;
|
use Filterable;
|
||||||
|
|
||||||
public const PRODUCT_TAX_EXEMPT = 0;
|
|
||||||
public const PRODUCT_TYPE_PHYSICAL = 1;
|
public const PRODUCT_TYPE_PHYSICAL = 1;
|
||||||
public const PRODUCT_TYPE_SERVICE = 2;
|
public const PRODUCT_TYPE_SERVICE = 2;
|
||||||
public const PRODUCT_TYPE_DIGITAL = 3;
|
public const PRODUCT_TYPE_DIGITAL = 3;
|
||||||
public const PRODUCT_TYPE_FREIGHT = 4;
|
public const PRODUCT_TYPE_FREIGHT = 4;
|
||||||
|
public const PRODUCT_TAX_EXEMPT = 5;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'custom_value1',
|
'custom_value1',
|
||||||
@ -132,6 +133,7 @@ class Product extends BaseModel
|
|||||||
'stock_notification',
|
'stock_notification',
|
||||||
'max_quantity',
|
'max_quantity',
|
||||||
'product_image',
|
'product_image',
|
||||||
|
'tax_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $touches = [];
|
protected $touches = [];
|
||||||
|
@ -193,6 +193,8 @@ class CompanyTransformer extends EntityTransformer
|
|||||||
'convert_expense_currency' => (bool) $company->convert_expense_currency,
|
'convert_expense_currency' => (bool) $company->convert_expense_currency,
|
||||||
'notify_vendor_when_paid' => (bool) $company->notify_vendor_when_paid,
|
'notify_vendor_when_paid' => (bool) $company->notify_vendor_when_paid,
|
||||||
'invoice_task_hours' => (bool) $company->invoice_task_hours,
|
'invoice_task_hours' => (bool) $company->invoice_task_hours,
|
||||||
|
'calculate_taxes' => (bool) $company->calculate_taxes,
|
||||||
|
'tax_all_products' => (bool) $company->tax_all_products,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,6 +149,7 @@ class InvoiceTransformer extends EntityTransformer
|
|||||||
'paid_to_date' => (float) $invoice->paid_to_date,
|
'paid_to_date' => (float) $invoice->paid_to_date,
|
||||||
'subscription_id' => $this->encodePrimaryKey($invoice->subscription_id),
|
'subscription_id' => $this->encodePrimaryKey($invoice->subscription_id),
|
||||||
'auto_bill_enabled' => (bool) $invoice->auto_bill_enabled,
|
'auto_bill_enabled' => (bool) $invoice->auto_bill_enabled,
|
||||||
|
'tax_data' => $invoice->tax_data ?: '',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,7 @@ class ProductTransformer extends EntityTransformer
|
|||||||
'stock_notification_threshold' => (int) $product->stock_notification_threshold,
|
'stock_notification_threshold' => (int) $product->stock_notification_threshold,
|
||||||
'max_quantity' => (int) $product->max_quantity,
|
'max_quantity' => (int) $product->max_quantity,
|
||||||
'product_image' => (string) $product->product_image ?: '',
|
'product_image' => (string) $product->product_image ?: '',
|
||||||
|
'tax_id' => (int) $product->tax_id ?: 1,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,12 +20,17 @@ return new class extends Migration
|
|||||||
Schema::table('companies', function (Blueprint $table) {
|
Schema::table('companies', function (Blueprint $table) {
|
||||||
$table->boolean('calculate_taxes')->default(false); //setting to turn on/off tax calculations
|
$table->boolean('calculate_taxes')->default(false); //setting to turn on/off tax calculations
|
||||||
$table->boolean('tax_all_products')->default(false); //globally tax all products if none defined
|
$table->boolean('tax_all_products')->default(false); //globally tax all products if none defined
|
||||||
|
$table->boolean('tax_data');
|
||||||
});
|
});
|
||||||
|
|
||||||
Schema::table('products', function (Blueprint $table){
|
Schema::table('products', function (Blueprint $table){
|
||||||
$table->unsignedInteger('tax_id')->nullable(); // the product tax constant
|
$table->unsignedInteger('tax_id')->nullable(); // the product tax constant
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Schema::table('clients', function (Blueprint $table){
|
||||||
|
$table->boolean('tax_data');
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user