mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
fix estimate & invoice tax issue
This commit is contained in:
@ -49,9 +49,11 @@ class Estimate extends Model
|
|||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'total' => 'float',
|
'total' => 'integer',
|
||||||
'tax' => 'float',
|
'tax' => 'integer',
|
||||||
'sub_total' => 'float'
|
'sub_total' => 'integer',
|
||||||
|
'discount' => 'float',
|
||||||
|
'discount_val' => 'integer',
|
||||||
];
|
];
|
||||||
|
|
||||||
public static function getNextEstimateNumber($value)
|
public static function getNextEstimateNumber($value)
|
||||||
|
|||||||
@ -145,7 +145,7 @@ class EstimatesController extends Controller
|
|||||||
|
|
||||||
if (array_key_exists('taxes', $estimateItem) && $estimateItem['taxes']) {
|
if (array_key_exists('taxes', $estimateItem) && $estimateItem['taxes']) {
|
||||||
foreach ($estimateItem['taxes'] as $tax) {
|
foreach ($estimateItem['taxes'] as $tax) {
|
||||||
if ($tax['amount']) {
|
if (gettype($tax['amount']) !== "NULL") {
|
||||||
$tax['company_id'] = $request->header('company');
|
$tax['company_id'] = $request->header('company');
|
||||||
$item->taxes()->create($tax);
|
$item->taxes()->create($tax);
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ class EstimatesController extends Controller
|
|||||||
|
|
||||||
if ($request->has('taxes')) {
|
if ($request->has('taxes')) {
|
||||||
foreach ($request->taxes as $tax) {
|
foreach ($request->taxes as $tax) {
|
||||||
if ($tax['amount']) {
|
if (gettype($tax['amount']) !== "NULL") {
|
||||||
$tax['company_id'] = $request->header('company');
|
$tax['company_id'] = $request->header('company');
|
||||||
$estimate->taxes()->create($tax);
|
$estimate->taxes()->create($tax);
|
||||||
}
|
}
|
||||||
@ -291,7 +291,7 @@ class EstimatesController extends Controller
|
|||||||
|
|
||||||
if (array_key_exists('taxes', $estimateItem) && $estimateItem['taxes']) {
|
if (array_key_exists('taxes', $estimateItem) && $estimateItem['taxes']) {
|
||||||
foreach ($estimateItem['taxes'] as $tax) {
|
foreach ($estimateItem['taxes'] as $tax) {
|
||||||
if ($tax['amount']) {
|
if (gettype($tax['amount']) !== "NULL") {
|
||||||
$tax['company_id'] = $request->header('company');
|
$tax['company_id'] = $request->header('company');
|
||||||
$item->taxes()->create($tax);
|
$item->taxes()->create($tax);
|
||||||
}
|
}
|
||||||
@ -301,7 +301,7 @@ class EstimatesController extends Controller
|
|||||||
|
|
||||||
if ($request->has('taxes')) {
|
if ($request->has('taxes')) {
|
||||||
foreach ($request->taxes as $tax) {
|
foreach ($request->taxes as $tax) {
|
||||||
if ($tax['amount']) {
|
if (gettype($tax['amount']) !== "NULL") {
|
||||||
$tax['company_id'] = $request->header('company');
|
$tax['company_id'] = $request->header('company');
|
||||||
$estimate->taxes()->create($tax);
|
$estimate->taxes()->create($tax);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -145,8 +145,7 @@ class InvoicesController extends Controller
|
|||||||
if (array_key_exists('taxes', $invoiceItem) && $invoiceItem['taxes']) {
|
if (array_key_exists('taxes', $invoiceItem) && $invoiceItem['taxes']) {
|
||||||
foreach ($invoiceItem['taxes'] as $tax) {
|
foreach ($invoiceItem['taxes'] as $tax) {
|
||||||
$tax['company_id'] = $request->header('company');
|
$tax['company_id'] = $request->header('company');
|
||||||
|
if (gettype($tax['amount']) !== "NULL") {
|
||||||
if ($tax['amount']) {
|
|
||||||
$item->taxes()->create($tax);
|
$item->taxes()->create($tax);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,7 +156,7 @@ class InvoicesController extends Controller
|
|||||||
foreach ($request->taxes as $tax) {
|
foreach ($request->taxes as $tax) {
|
||||||
$tax['company_id'] = $request->header('company');
|
$tax['company_id'] = $request->header('company');
|
||||||
|
|
||||||
if ($tax['amount']) {
|
if (gettype($tax['amount']) !== "NULL") {
|
||||||
$invoice->taxes()->create($tax);
|
$invoice->taxes()->create($tax);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -317,7 +316,6 @@ class InvoicesController extends Controller
|
|||||||
foreach ($oldTaxes as $oldTax) {
|
foreach ($oldTaxes as $oldTax) {
|
||||||
Tax::destroy($oldTax['id']);
|
Tax::destroy($oldTax['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($invoiceItems as $invoiceItem) {
|
foreach ($invoiceItems as $invoiceItem) {
|
||||||
$invoiceItem['company_id'] = $request->header('company');
|
$invoiceItem['company_id'] = $request->header('company');
|
||||||
$item = $invoice->items()->create($invoiceItem);
|
$item = $invoice->items()->create($invoiceItem);
|
||||||
@ -325,8 +323,7 @@ class InvoicesController extends Controller
|
|||||||
if (array_key_exists('taxes', $invoiceItem) && $invoiceItem['taxes']) {
|
if (array_key_exists('taxes', $invoiceItem) && $invoiceItem['taxes']) {
|
||||||
foreach ($invoiceItem['taxes'] as $tax) {
|
foreach ($invoiceItem['taxes'] as $tax) {
|
||||||
$tax['company_id'] = $request->header('company');
|
$tax['company_id'] = $request->header('company');
|
||||||
|
if (gettype($tax['amount']) !== "NULL") {
|
||||||
if ($tax['amount']) {
|
|
||||||
$item->taxes()->create($tax);
|
$item->taxes()->create($tax);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -337,7 +334,7 @@ class InvoicesController extends Controller
|
|||||||
foreach ($request->taxes as $tax) {
|
foreach ($request->taxes as $tax) {
|
||||||
$tax['company_id'] = $request->header('company');
|
$tax['company_id'] = $request->header('company');
|
||||||
|
|
||||||
if ($tax['amount']) {
|
if (gettype($tax['amount']) !== "NULL") {
|
||||||
$invoice->taxes()->create($tax);
|
$invoice->taxes()->create($tax);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user