fixed #777
This commit is contained in:
parent
98d95a93cb
commit
a855ebf017
@ -245,6 +245,18 @@ class Bills extends Controller
|
|||||||
*/
|
*/
|
||||||
public function destroy(Bill $bill)
|
public function destroy(Bill $bill)
|
||||||
{
|
{
|
||||||
|
// Decrease stock
|
||||||
|
$bill->items()->each(function ($bill_item) {
|
||||||
|
$item = Item::find($bill_item->item_id);
|
||||||
|
|
||||||
|
if (empty($item)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$item->quantity += (double) $bill_item->quantity;
|
||||||
|
$item->save();
|
||||||
|
});
|
||||||
|
|
||||||
$this->deleteRelationships($bill, ['items', 'item_taxes', 'histories', 'payments', 'recurring', 'totals']);
|
$this->deleteRelationships($bill, ['items', 'item_taxes', 'histories', 'payments', 'recurring', 'totals']);
|
||||||
$bill->delete();
|
$bill->delete();
|
||||||
|
|
||||||
|
@ -257,6 +257,18 @@ class Invoices extends Controller
|
|||||||
*/
|
*/
|
||||||
public function destroy(Invoice $invoice)
|
public function destroy(Invoice $invoice)
|
||||||
{
|
{
|
||||||
|
// Increase stock
|
||||||
|
$invoice->items()->each(function ($invoice_item) {
|
||||||
|
$item = Item::find($invoice_item->item_id);
|
||||||
|
|
||||||
|
if (empty($item)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$item->quantity += (double) $invoice_item->quantity;
|
||||||
|
$item->save();
|
||||||
|
});
|
||||||
|
|
||||||
$this->deleteRelationships($invoice, ['items', 'item_taxes', 'histories', 'payments', 'recurring', 'totals']);
|
$this->deleteRelationships($invoice, ['items', 'item_taxes', 'histories', 'payments', 'recurring', 'totals']);
|
||||||
$invoice->delete();
|
$invoice->delete();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user