mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-11 13:42:49 +01:00
commit
577f2a4809
@ -1 +1 @@
|
|||||||
5.5.35
|
5.5.36
|
@ -205,11 +205,14 @@ class Handler extends ExceptionHandler
|
|||||||
return response()->json(['message' => $exception->getMessage()], 400);
|
return response()->json(['message' => $exception->getMessage()], 400);
|
||||||
} elseif ($exception instanceof StripeConnectFailure) {
|
} elseif ($exception instanceof StripeConnectFailure) {
|
||||||
return response()->json(['message' => $exception->getMessage()], 400);
|
return response()->json(['message' => $exception->getMessage()], 400);
|
||||||
} elseif ($exception instanceof QueryException) {
|
|
||||||
return response()->json(['message' => 'We had a problem executing this query. Please retry.'], 500);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// elseif ($exception instanceof QueryException) {
|
||||||
|
// return response()->json(['message' => 'We had a problem executing this query. Please retry.'], 500);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return parent::render($request, $exception);
|
return parent::render($request, $exception);
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ class SwissQrGenerator
|
|||||||
// Optionally, add some human-readable information about what the bill is for.
|
// Optionally, add some human-readable information about what the bill is for.
|
||||||
$qrBill->setAdditionalInformation(
|
$qrBill->setAdditionalInformation(
|
||||||
QrBill\DataGroup\Element\AdditionalInformation::create(
|
QrBill\DataGroup\Element\AdditionalInformation::create(
|
||||||
$this->invoice->public_notes ?: ctrans('texts.invoice_number_placeholder', ['invoice' => $invoice_number])
|
$this->invoice->public_notes ? substr($this->invoice->public_notes, 0, 139) : ctrans('texts.invoice_number_placeholder', ['invoice' => $invoice_number])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ class StoreSetupRequest extends Request
|
|||||||
'terms_of_service' => 'required',
|
'terms_of_service' => 'required',
|
||||||
'first_name' => 'required',
|
'first_name' => 'required',
|
||||||
'last_name' => 'required',
|
'last_name' => 'required',
|
||||||
'email' => 'required|email:rfc,dns',
|
'email' => 'required|email',
|
||||||
'password' => 'required',
|
'password' => 'required',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -61,6 +61,44 @@ class AdjustProductInventory implements ShouldQueue
|
|||||||
return $this->newInventoryAdjustment();
|
return $this->newInventoryAdjustment();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function handleDeletedInvoice()
|
||||||
|
{
|
||||||
|
|
||||||
|
MultiDB::setDb($this->company->db);
|
||||||
|
|
||||||
|
foreach ($this->invoice->line_items as $item) {
|
||||||
|
|
||||||
|
$p = Product::where('product_key', $item->product_key)->where('company_id', $this->company->id)->first();
|
||||||
|
|
||||||
|
if (! $p) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$p->in_stock_quantity += $item->quantity;
|
||||||
|
|
||||||
|
$p->saveQuietly();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handleRestoredInvoice()
|
||||||
|
{
|
||||||
|
|
||||||
|
MultiDB::setDb($this->company->db);
|
||||||
|
|
||||||
|
foreach ($this->invoice->line_items as $item) {
|
||||||
|
$p = Product::where('product_key', $item->product_key)->where('company_id', $this->company->id)->first();
|
||||||
|
|
||||||
|
if (! $p) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$p->in_stock_quantity -= $item->quantity;
|
||||||
|
$p->saveQuietly();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function middleware()
|
public function middleware()
|
||||||
{
|
{
|
||||||
return [new WithoutOverlapping($this->company->company_key)];
|
return [new WithoutOverlapping($this->company->company_key)];
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace App\Services\Invoice;
|
namespace App\Services\Invoice;
|
||||||
|
|
||||||
|
use App\Jobs\Inventory\AdjustProductInventory;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Paymentable;
|
use App\Models\Paymentable;
|
||||||
use App\Services\AbstractService;
|
use App\Services\AbstractService;
|
||||||
@ -68,6 +69,11 @@ class HandleRestore extends AbstractService
|
|||||||
->setAdjustmentAmount()
|
->setAdjustmentAmount()
|
||||||
->adjustPayments();
|
->adjustPayments();
|
||||||
|
|
||||||
|
if ($this->invoice->company->track_inventory) {
|
||||||
|
(new AdjustProductInventory($this->invoice->company, $this->invoice, []))->handleRestoredInvoice();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return $this->invoice;
|
return $this->invoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace App\Services\Invoice;
|
namespace App\Services\Invoice;
|
||||||
|
|
||||||
|
use App\Jobs\Inventory\AdjustProductInventory;
|
||||||
use App\Jobs\Ninja\TransactionLog;
|
use App\Jobs\Ninja\TransactionLog;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\TransactionEvent;
|
use App\Models\TransactionEvent;
|
||||||
@ -22,7 +23,7 @@ class MarkInvoiceDeleted extends AbstractService
|
|||||||
{
|
{
|
||||||
use GeneratesCounter;
|
use GeneratesCounter;
|
||||||
|
|
||||||
private $invoice;
|
public $invoice;
|
||||||
|
|
||||||
private $adjustment_amount = 0;
|
private $adjustment_amount = 0;
|
||||||
|
|
||||||
@ -41,6 +42,10 @@ class MarkInvoiceDeleted extends AbstractService
|
|||||||
return $this->invoice;
|
return $this->invoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->invoice->company->track_inventory) {
|
||||||
|
(new AdjustProductInventory($this->invoice->company, $this->invoice, []))->handleDeletedInvoice();
|
||||||
|
}
|
||||||
|
|
||||||
$this->cleanup()
|
$this->cleanup()
|
||||||
->setAdjustmentAmount()
|
->setAdjustmentAmount()
|
||||||
->deletePaymentables()
|
->deletePaymentables()
|
||||||
|
@ -14,8 +14,8 @@ return [
|
|||||||
'require_https' => env('REQUIRE_HTTPS', true),
|
'require_https' => env('REQUIRE_HTTPS', true),
|
||||||
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
||||||
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
||||||
'app_version' => '5.5.35',
|
'app_version' => '5.5.36',
|
||||||
'app_tag' => '5.5.35',
|
'app_tag' => '5.5.36',
|
||||||
'minimum_client_version' => '5.0.16',
|
'minimum_client_version' => '5.0.16',
|
||||||
'terms_version' => '1.0.1',
|
'terms_version' => '1.0.1',
|
||||||
'api_secret' => env('API_SECRET', ''),
|
'api_secret' => env('API_SECRET', ''),
|
||||||
|
@ -84,27 +84,23 @@ class InventoryManagementTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(90, $product->in_stock_quantity);
|
$this->assertEquals(90, $product->in_stock_quantity);
|
||||||
|
|
||||||
// $arr = $response->json();
|
$data = $response->json();
|
||||||
// $invoice_hashed_id = $arr['data']['id'];
|
|
||||||
|
|
||||||
// $invoice_item = new InvoiceItem;
|
$invoice = Invoice::find($this->decodePrimaryKey($data['data']['id']));
|
||||||
// $invoice_item->type_id = 1;
|
|
||||||
// $invoice_item->product_key = $product->product_key;
|
|
||||||
// $invoice_item->notes = $product->notes;
|
|
||||||
// $invoice_item->quantity = 5;
|
|
||||||
// $invoice_item->cost = 100;
|
|
||||||
|
|
||||||
// $line_items2[] = $invoice_item;
|
$invoice->service()->markDeleted()->save();
|
||||||
// $invoice->line_items = $line_items2;
|
$invoice->is_deleted = true;
|
||||||
|
$invoice->save();
|
||||||
|
|
||||||
|
$this->assertEquals(100, $product->fresh()->in_stock_quantity);
|
||||||
|
|
||||||
|
$invoice = Invoice::withTrashed()->find($this->decodePrimaryKey($data['data']['id']));
|
||||||
|
|
||||||
|
$invoice->service()->handleRestore()->save();
|
||||||
|
|
||||||
|
$this->assertEquals(90, $product->fresh()->in_stock_quantity);
|
||||||
|
|
||||||
// $response = $this->withHeaders([
|
|
||||||
// 'X-API-SECRET' => config('ninja.api_secret'),
|
|
||||||
// 'X-API-TOKEN' => $this->token,
|
|
||||||
// ])->put('/api/v1/invoices/'.$invoice_hashed_id, $invoice->toArray())
|
|
||||||
// ->assertStatus(200);
|
|
||||||
|
|
||||||
// $product = $product->refresh();
|
|
||||||
|
|
||||||
// $this->assertEquals(95, $product->in_stock_quantity);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user