Zend certified PHP/Magento developer

Programtically Create Invoice with custom product price and qty

I have been working on a module which takes data from CSV file and create invoice into the system programmatically. The main problem is, the items in the invoice matches the parent order however, their price and qty can be different.

I know a method about creating an invoice using invoiceservice where you can pass the order id and item array for invoice to be created. The code works fine for it.

However, the problem is, I need to enter the custom price for the product invoiced. There seems no way to do it at present. Does anyone know a solution to it. Code done which doesn’t work is as below:

I am trying to add product to existing invoice using itemFactory

   $invoice = $this->invoiceFactory->create()->loadByIncrementId('000000001');

                    $product = $this->productRepository->get('LIN-OGS_c');
                    $orderItem = $this->itemFactory->create();
                    $orderItem->setProductId($product->getId());
                    $orderItem->setName($product->getName());
                    $orderItem->setSku($sku);
                    $orderItem->setQtyOrdered(8);
                    $orderItem->setBasePrice($price);
                    $orderItem->setPrice($price);
                    $orderItem->setOriginalPrice($price);
                    $orderItem->setTaxAmount($rowTotalTax);
                    $orderItem->setBaseTaxAmount($rowTotalTax);
                    $orderItem->setTaxPercent($taxPercentage);
                    $orderItem->setRowTotal($rowTotal);
                    $orderItem->setProductType($product->getTypeId());
                    $invoice->addItem($orderItem);
                    
                    $invoice->setGrandTotal('1');
                    $invoice->save($invoice);

Can anyone guide me if this method can work or any better method to do so?