Skip to content

Copy quote does not populate item product fields #998

@chegel

Description

@chegel

Copy quote does not populate items product fields.

Expected Behavior

All quote items fields should be copied.

Current Behavior

When I make a copy of the quote fields such as item_product_id are not populated in the database for copied items. As result, fields such as $item->product_sku are not available in pdf templates in copied quotes.

Screenshots

item_product_id are null after quote with id 554 was copied, 563 was created as result:
null-fields

how it should be:
fixed

Possible Solution

I suggest adding item_product_id, item_discount_amount, item_product_unit and item_product_unit_id to the copy_quote function.

Steps to Reproduce

  1. create a quote
  2. copy the quote
  3. check ip_quote_items table

Context (Environment)

IP 1.6.0, nginx, Ubuntu 22.04

Detailed Description

I suggest to add missing fields to the copy_quote function.

Possible Implementation

Add item_product_id, item_discount_amount, item_product_unit and item_product_unit_id to the copy_quote function:

    public function copy_quote($source_id, $target_id)
    {
        $this->load->model('quotes/mdl_quote_items');

        $quote_items = $this->mdl_quote_items->where('quote_id', $source_id)->get()->result();

        foreach ($quote_items as $quote_item) {
            $db_array = array(
                'quote_id' => $target_id,
                'item_tax_rate_id' => $quote_item->item_tax_rate_id,
                'item_product_id' => $quote_item->item_product_id,
                'item_name' => $quote_item->item_name,
                'item_description' => $quote_item->item_description,
                'item_quantity' => $quote_item->item_quantity,
                'item_price' => $quote_item->item_price,
                'item_discount_amount' => $quote_item->item_discount_amount,
                'item_order' => $quote_item->item_order,
                'item_product_unit' => $quote_item->item_product_unit,
                'item_product_unit_id' => $quote_item->item_product_unit_id,
            );
      ....
    }

Failure Logs

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions