Purchase And Purchase Return

0

Dear Support,

We notice when deleting a Purchase Return the system does not allow making a modification on the Purchase transaction because it still considering a Return is still exist.

I can summarize steps taken as below : -

1- Create a PO
2- Receive the PO
3- Create Purchase Return against the PO
4- Try to edit the Purchase Return, the system does not allowing to edit.
5- Delete the Purchase Return
6- Try to edit the PO, the system does not allowing to edit, it alert that there is a Purchase Return exists !

Is it a bug need fix ? how could we get rid of this error?

Regards,
Mazyad

Question Resolved For: Stock Manager Advance with Point of Sale Module 0 Votes 5 Answers 429 Views
Asked by Mazyad ALArdhi 6 months ago

0

Answered by Mian Saleem 6 months ago

Hello,

I am sorry as I missed replying to this question.

The orders will be locked for further editing after return. This is due to the background sync of quantity. There is no alternative to this till the next major release.

Thank you

0

Answered by Mazyad ALArdhi 6 months ago

Hello,

Thank you for reply and clarification.

When is the next major release expected to be available?

Regards,

0

Answered by Mian Saleem 6 months ago

Hello,

I am planning to have separate backend and frontends. As I am just starting to re-write and this app has grown quite a lot in last few years so the update will take more than 6 months.

Thank you

0

Answered by Enyinnaya Gift 6 months ago

Hello @Mazyad ALArdhi and [@Mian Saleem](/u/saleem)

You can actually add this block to the deletePurchase function in Purchases_model line 192 to be able to edit the purchase entries again after deleting the returned purchase.

            if ($purchase->status == 'returned') {
                $this->db->update('purchases', ['return_id' => null, 'return_purchase_ref' => null, 'return_purchase_total' => 0], ['id' => $purchase->purchase_id]);
            }

So the updated deletePurchase() will be as shown below. You can copy and replace.

    public function deletePurchase($id)
    {
        $this->db->trans_start();
        $purchase       = $this->getPurchaseByID($id);
        $purchase_items = $this->site->getAllPurchaseItems($id);
        $this->site->log('Purchase', ['model' => $purchase, 'items' => $purchase_items]);
        if ($this->db->delete('purchase_items', ['purchase_id' => $id]) && $this->db->delete('purchases', ['id' => $id])) {
            $this->db->delete('payments', ['purchase_id' => $id]);
            if ($purchase->status == 'received' || $purchase->status == 'partial') {
                foreach ($purchase_items as $oitem) {
                    $this->updateAVCO(['product_id' => $oitem->product_id, 'warehouse_id' => $oitem->warehouse_id, 'quantity' => (0 - $oitem->quantity), 'cost' => $oitem->real_unit_cost]);
                    $received = $oitem->quantity_received ? $oitem->quantity_received : $oitem->quantity;
                    if ($oitem->quantity_balance < $received) {
                        $clause = ['purchase_id' => null, 'transfer_id' => null, 'product_id' => $oitem->product_id, 'warehouse_id' => $oitem->warehouse_id, 'option_id' => $oitem->option_id];
                        $this->site->setPurchaseItem($clause, ($oitem->quantity_balance - $received));
                    }
                }
            }
            if ($purchase->status == 'returned') {
                $this->db->update('purchases', ['return_id' => null, 'return_purchase_ref' => null, 'return_purchase_total' => 0], ['id' => $purchase->purchase_id]);
            }
            $this->db->delete('attachments', ['subject_id' => $id, 'subject_type' => 'purchase']);
            $this->site->syncQuantity(null, null, $purchase_items);
        }
        $this->db->trans_complete();
        if ($this->db->trans_status() === false) {
            log_message('error', 'An errors has been occurred while adding the sale (Delete:Purchases_model.php)');
        } else {
            return true;
        }
        return false;
    }

0

Answered by Enyinnaya Gift 6 months ago

My name is @Enyinnaya Gift . I am an Independent Software Developer with in-depth knowledge of SMA system. I have done a lot of customization for many happy clients across the globe.

You can check out highlights and a demo of my latest customization by Clicking HERE - Highlights

You can also reach me via any of the following mediums for a real-time discussion on your customization request:

-Skype ID: enyinnayag
-Wechat ID: genyinnaya
-Email: [email protected]
-WhatsApp: +2348068355192

We use Cookies

We use cookies to ensure that we give you the best experience on our website. By continuing to browse the site you are agreeing to our use of cookies.