1

enter image description here

when i click on the print button it will show an empty page enter image description here

Edit 1:

Call to undefined method Ced\Gst\Helper\Data::getShippingSource() in /var/www/html/tech/app/code/Ced/Gst/Model/Order/Pdf/Items/Invoice/DefaultInvoice.php on line 133

Defaultinvoice.php

<?php

namespace Ced\Gst\Model\Order\Pdf\Items\Invoice;

/**
 * Sales Order Invoice Pdf default items renderer
 */
class DefaultInvoice extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems
{
    /**
     * Core string
     *
     * @var \Magento\Framework\Stdlib\StringUtils
     */
    protected $string;

    /**
     * @param \Magento\Framework\Model\Context $context
     * @param \Magento\Framework\Registry $registry
     * @param \Magento\Tax\Helper\Data $taxData
     * @param \Magento\Framework\Filesystem $filesystem
     * @param \Magento\Framework\Filter\FilterManager $filterManager
     * @param \Magento\Framework\Stdlib\StringUtils $string
     * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
     * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
     * @param array $data
     */
    public function __construct(
        \Magento\Framework\ObjectManagerInterface $objectManager,
        \Magento\Framework\Model\Context $context,
        \Magento\Framework\Registry $registry,
        \Magento\Tax\Helper\Data $taxData,
        \Magento\Framework\Filesystem $filesystem,
        \Magento\Framework\Filter\FilterManager $filterManager,
        \Magento\Framework\Stdlib\StringUtils $string,
        \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
        \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
        array $data = []
    ) {
        $this->_objectManager = $objectManager;
        $this->string = $string;
        parent::__construct(
            $context,
            $registry,
            $taxData,
            $filesystem,
            $filterManager,
            $resource,
            $resourceCollection,
            $data
        );
    }

    /**
     * Draw item line
     *
     * @return void
     */
    public function draw()
    {
        $order = $this->getOrder();
        $item = $this->getItem();
        $pdf = $this->getPdf();
        $page = $this->getPage();
        $lines = [];

        // draw Product name
        $lines[0] = [['text' => $this->string->split($item->getName(), 35, true, true), 'feed' => 35]];

        // draw SKU
        $lines[0][] = [
            'text' => $this->string->split($this->getSku($item), 17),
            'feed' => 200,
            'align' => 'right',
        ];

        // draw QTY
        $lines[0][] = ['text' => $item->getQty() * 1, 'feed' => 280, 'align' => 'right'];

        // draw item Prices
        $i = 0;
        $prices = $this->getItemPricesForDisplay();
        $feedPrice = 296;
        $feedSubtotal = $feedPrice + 270;
        foreach ($prices as $priceData) {
            if (isset($priceData['label'])) {
                // draw Price label
                $lines[$i][] = ['text' => $priceData['label'], 'feed' => $feedPrice, 'align' => 'right'];
                // draw Subtotal label
                $lines[$i][] = ['text' => $priceData['label'], 'feed' => $feedSubtotal, 'align' => 'right'];
                $i++;
            }
            // draw Price
            $lines[$i][] = [
                'text' => $priceData['price'],
                'feed' => $feedPrice,
                'font' => 'bold',
                'align' => 'right',
            ];
            // draw Subtotal
            $lines[$i][] = [
                'text' => $priceData['subtotal'],
                'feed' => $feedSubtotal,
                'font' => 'bold',
                'align' => 'right',
            ];
            $i++;
        }




        $igst = 'N/A';
        $sgst = 'N/A';
        $cgst = 'N/A';
        $helper = $this->_objectManager->create('Ced\Gst\Helper\Data');
        $warehouse = $helper->getWarehouse();
        $shipping_source = $helper->getShippingSource($order->getShippingAddressId());
        $qty = (int)$item->getQty();
        $amt = $item->getTaxAmount();

        $hsn = $helper->getHsnByProductId($item->getProductId());
        //$rate = $helper->getGstRate($hsn);

        if ($hsn && $amt > 0) {
            if ($warehouse == $shipping_source) {
                $igst = 'N/A';
                $sgst = $order->formatPriceTxt($amt/2);
                $cgst = $order->formatPriceTxt($amt/2);
            }else{
                $sgst = 'N/A';
                $cgst = 'N/A';
                $igst = $order->formatPriceTxt($amt);
            }
        }else{
            $igst = 'N/A';
            $sgst = 'N/A';
            $cgst = 'N/A';
        }








            $lines[0][] = [
            'text' => $igst,
            'feed' => 380,
            'font' => 'bold',
            'align' => 'right',
            ];



            $lines[0][] = [
            'text' => $sgst,
            'feed' => 440,
            'font' => 'bold',
            'align' => 'right',
            ];




            $lines[0][] = [
            'text' => $cgst,
            'feed' => 500,
            'font' => 'bold',
            'align' => 'right',
            ];

        //end tax draw for gst






        // custom options
        $options = $this->getItemOptions();

        if ($options) {
            foreach ($options as $option) {
                // draw options label
                $lines[][] = [
                    'text' => $this->string->split($this->filterManager->stripTags($option['label']), 40, true, true),
                    'font' => 'italic',
                    'feed' => 35,
                ];

                if ($option['value']) {
                    if (isset($option['print_value'])) {
                        $printValue = $option['print_value'];
                    } else {
                        $printValue = $this->filterManager->stripTags($option['value']);
                    }
                    $values = explode(', ', $printValue);
                    foreach ($values as $value) {
                        $lines[][] = ['text' => $this->string->split($value, 30, true, true), 'feed' => 40];
                    }
                }
            }
        }



        $lineBlock = ['lines' => $lines, 'height' => 20];

        $page = $pdf->drawLineBlocks($page, [$lineBlock], ['table_header' => true]);
        $this->setPage($page);
    }
}

how i can fix this???

0

Open app/bootstrap.php find

#ini_set('display_errors', 1);

Remove the # and that will allow you to see what error is happening.

Once you have done this and know the error id suggest updating your question

  • app/bootstrap.php where is app/bootstrap.php – prabhakaran7 Apr 12 at 13:34
  • In your magneto root directory go into the app folder and you will see a file called bootstrap.php – Dava Gordon Apr 12 at 13:38
  • i updated .............my question – prabhakaran7 Apr 12 at 13:49
  • Can you update your question with the author of the extension and 10 lines above and below line 133 of /app/code/Ced/Gst/Model/Order/Pdf/Items/Invoice/DefaultInvoice.php – Dava Gordon Apr 12 at 13:52
  • i updated file... – prabhakaran7 Apr 12 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.