1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Create data mapper classes for tax data

This commit is contained in:
David Bomba 2023-03-21 18:14:25 +11:00
parent 2e2b9da980
commit c9b9b8326d
11 changed files with 80 additions and 2 deletions

View 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)
{
}
}

View 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)
{
}
}

View 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)
{
}
}

View File

@ -45,6 +45,8 @@ class InvoiceSum
private $precision;
public InvoiceItemSum $invoice_items;
/**
* Constructs the object with Invoice and Settings object.
*

View File

@ -429,6 +429,8 @@ class Company extends BaseModel
'convert_payment_currency',
'convert_expense_currency',
'notify_vendor_when_paid',
'calculate_taxes',
'tax_all_products',
];
protected $hidden = [

View File

@ -582,7 +582,7 @@ class Invoice extends BaseModel
/**
* Access the invoice calculator object.
*
* @return stdClass The invoice calculator object getters
* @return \stdClass The invoice calculator object getters
*/
public function calc()
{

View File

@ -105,11 +105,12 @@ class Product extends BaseModel
use SoftDeletes;
use Filterable;
public const PRODUCT_TAX_EXEMPT = 0;
public const PRODUCT_TYPE_PHYSICAL = 1;
public const PRODUCT_TYPE_SERVICE = 2;
public const PRODUCT_TYPE_DIGITAL = 3;
public const PRODUCT_TYPE_FREIGHT = 4;
public const PRODUCT_TAX_EXEMPT = 5;
protected $fillable = [
'custom_value1',
@ -132,6 +133,7 @@ class Product extends BaseModel
'stock_notification',
'max_quantity',
'product_image',
'tax_id',
];
protected $touches = [];

View File

@ -193,6 +193,8 @@ class CompanyTransformer extends EntityTransformer
'convert_expense_currency' => (bool) $company->convert_expense_currency,
'notify_vendor_when_paid' => (bool) $company->notify_vendor_when_paid,
'invoice_task_hours' => (bool) $company->invoice_task_hours,
'calculate_taxes' => (bool) $company->calculate_taxes,
'tax_all_products' => (bool) $company->tax_all_products,
];
}

View File

@ -149,6 +149,7 @@ class InvoiceTransformer extends EntityTransformer
'paid_to_date' => (float) $invoice->paid_to_date,
'subscription_id' => $this->encodePrimaryKey($invoice->subscription_id),
'auto_bill_enabled' => (bool) $invoice->auto_bill_enabled,
'tax_data' => $invoice->tax_data ?: '',
];
}
}

View File

@ -95,6 +95,7 @@ class ProductTransformer extends EntityTransformer
'stock_notification_threshold' => (int) $product->stock_notification_threshold,
'max_quantity' => (int) $product->max_quantity,
'product_image' => (string) $product->product_image ?: '',
'tax_id' => (int) $product->tax_id ?: 1,
];
}
}

View File

@ -20,12 +20,17 @@ return new class extends Migration
Schema::table('companies', function (Blueprint $table) {
$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_data');
});
Schema::table('products', function (Blueprint $table){
$table->unsignedInteger('tax_id')->nullable(); // the product tax constant
});
Schema::table('clients', function (Blueprint $table){
$table->boolean('tax_data');
});
}
/**