Collect grand total  amount
@param Invoice $invoice
@return $this
777750
public function collect(Invoice $invoice)
    {
        parent::collect($invoice);

        $baseInterest = (float) $invoice->getBaseGabrielqsInstallmentsInterestAmount();
        $interest = (float) $invoice->getGabrielqsInstallmentsInterestAmount();
        if ($baseInterest) {
            $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseInterest);
            $invoice->setGrandTotal($invoice->getGrandTotal() + $interest);
        }

        return $this;
    }
231634
public function saveInvoice(Invoice $invoice): bool
    {
        if ($invoice->id) {
            $record = InvoiceRecord::findOne($invoice->id);

            if (!$record) {
                throw new Exception(Craft::t('commerce-stripe', 'No invoice exists with the ID “{id}”', ['id' => $invoice->id]));
            }
        } else {
            $record = new InvoiceRecord();
        }

        // Only allow this for new invoices
        if (!$invoice->id) {
            $record->reference = $invoice->reference;
            $record->subscriptionId = $invoice->subscriptionId;
        }

        $record->invoiceData = $invoice->invoiceData;

        if ($invoice->validate()) {
            $event = new SaveInvoiceEvent(['invoice' => $invoice]);

            // Fire a 'beforeSaveInvoice' event.
            $this->trigger(self::EVENT_BEFORE_SAVE_INVOICE, $event);

            if (!$event->isValid) {
                return false;
            }

            $record->save(false);
            $invoice->id = $record->id;

            // Fire a 'afterSaveInvoice' event.
            if ($this->hasEventHandlers(self::EVENT_SAVE_INVOICE)) {
                $this->trigger(self::EVENT_SAVE_INVOICE, new SaveInvoiceEvent(['invoice' => $invoice]));
            }

            return true;
        }

        return false;
    }
777789
public function removeInvoiceAsVendor(\HarvestCloud\CoreBundle\Entity\Invoice\Invoice $invoiceAsVendor)
    {
        $this->invoicesAsVendor->removeElement($invoiceAsVendor);
    }
1339571
public function registerPayment(Invoice &$invoice, Payment $payment)
    {
        return $this->connector->registerPayment($invoice, $payment);
    }
30600
public function sendPurchaseNotification($invoice)
    {
        $templateName = 'PaymentBundle:Email:sale.notification.admin.html.twig';

        if($invoice->getTransaction()->getItems()->first()->getProduct() instanceof Product){
            $product = $invoice->getTransaction()->getItems()->first()->getProduct();
        }
        
        $sellerEmails = array();
        if($invoice->getTransaction()->getItems()->first()->getProduct()->getActor() instanceof Actor){
            $sellerEmails[] = $invoice->getTransaction()->getItems()->first()->getProduct()->getActor()->getEmail();
        } 
            
        $context = array(
            'order_number'    => $invoice->getTransaction()->getTransactionKey(),
            'invoice_date'      => $invoice->getCreated(),
            'user_email'        => $invoice->getTransaction()->getActor()->getEmail(),
            'seller_email'        => implode(',', $sellerEmails),
            'order_details_url' => $this->router->generate('payment_checkout_showinvoice', array('number' => $invoice->getInvoiceNumber()), UrlGeneratorInterface::ABSOLUTE_URL),
        );

        $this->sendMessage($templateName, $context, $this->twigGlobal->getParameter('admin_email'), $this->twigGlobal->getParameter('admin_email'));
    }
227220
public function upcomingInvoice(): ?Invoice
    {
        try {
            $stripeInvoice = StripeInvoice::upcoming(
                ['customer' => $this->stripe_id], ['api_key' => $this->getStripeKey()]
            );

            return new Invoice($this, $stripeInvoice);
        } catch (InvalidRequest $e) {
        }
    }
1172925
public static function generate($invoice)
    {
        if ($invoice->getNumber() !== null) {
            return $invoice->getNumber();
        }

        $repo = self::$em->getRepository(Invoice::class);
        $regexp = sprintf('^%s(\d{%d})$', self::$codePrefix, self::$codeLength);
        $res = $repo->createQueryBuilder('i')
            ->select('i.number')
            ->where("SUBSTRING(i.number, '$regexp') != ''")
            ->setMaxResults(1)
            ->addOrderBy('i.number', 'desc')
            ->getQuery()
            ->getScalarResult();
        $max = $res ? (int) $res[0]['number'] : 0;

        return sprintf('%s%0' . self::$codeLength . 'd', self::$codePrefix, $max + 1);
    }
1313703
protected function triggerInvoiceCreated(array &$invoice, Source $invoiceSource, Result $localResult)
    {
	    $route = 'model/' . Registry::getInstance()->getLocation() . '/invoiceCreated/after';
        $args = array('invoice' => &$invoice, 'source' => $invoiceSource, 'localResult' => $localResult);
	    $this->getEvent()->trigger($route, array(&$route, $args));
    }
353104
private static BigDecimal computeInvoiceAmountAdjustedForAccountCredit(final Currency currency, final Iterable<InvoiceItem> invoiceItems) {
        BigDecimal amountAdjusted = BigDecimal.ZERO;
        if (invoiceItems == null || !invoiceItems.iterator().hasNext()) {
            return KillBillMoney.of(amountAdjusted, currency);
        }

        for (final InvoiceItem invoiceItem : invoiceItems) {
            final Iterable<InvoiceItem> otherInvoiceItems = Iterables.filter(invoiceItems, new Predicate<InvoiceItem>() {
                @Override
                public boolean apply(final InvoiceItem input) {
                    return !input.getId().equals(invoiceItem.getId());
                }
            });

            if (InvoiceItemType.CREDIT_ADJ.equals(invoiceItem.getInvoiceItemType()) &&
                (Iterables.size(otherInvoiceItems) == 1 &&
                 InvoiceItemType.CBA_ADJ.equals(otherInvoiceItems.iterator().next().getInvoiceItemType()) &&
                 otherInvoiceItems.iterator().next().getInvoiceId().equals(invoiceItem.getInvoiceId()) &&
                 otherInvoiceItems.iterator().next().getAmount().compareTo(invoiceItem.getAmount().negate()) == 0)) {
                amountAdjusted = amountAdjusted.add(invoiceItem.getAmount());
            }
        }

        return KillBillMoney.of(amountAdjusted, currency);
    }
390417
public function addInvoice(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Invoice\Invoice $invoice)
    {
        $this->invoices[] = $invoice;

        return $this;
    }
590801
private static function updatePaymentStatus($invoice)
    {
        if (! $invoice->payment || $invoice->getStatus() === 'payed') {
            return $invoice;
        }
        $receipt = $invoice->get_payment();
        Bank_Service::update($receipt);
        if ($invoice->get_payment()->isPayed()){
            $invoice->setStatus('payed');
            $invoice->update();
        }
        return $invoice;
    }
911300
public function initTotals()
    {
        /** @var \Magento\Sales\Block\Adminhtml\Order\Totals $parent */
        $parent = $this->getParentBlock();
        /** @var \Magento\Sales\Model\Order $order */
        $order = $parent->getOrder();
        /* check collected partial totals (for currently processed invoices only) */
        $invoices = $order->getInvoiceCollection();
        $invoice = $invoices->getFirstItem();
        $partialBase = $invoice->getData(Cfg::CODE_TOTAL_PARTIAL_AMOUNT_BASE);
        $partial = $invoice->getData(Cfg::CODE_TOTAL_PARTIAL_AMOUNT);
        if (!$partialBase) {
            /* check sales registry in repo */
            $orderId = $order->getId();
            $found = $this->daoPartialSale->getById($orderId);
            if ($found) {
                $partialBase = $found->getBasePartialAmount();
                $partial = $found->getBasePartialAmount();
            }
        }
        if ($partialBase) {
            /* add partial to parent totals */
            $this->zTotalPartial->addTotalWallet($parent, $partialBase, $partial);
        }
        return $this;
    }
965965
public function setAmount($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->amount !== $v) {
            $this->amount = $v;
            $this->modifiedColumns[GamecurrencyTableMap::COL_AMOUNT] = true;
        }

        return $this;
    }
31878
public function odpocetZalohy($invoice, $odpocet = [])
    {
        if (!isset($odpocet['castkaMen'])) {
            $odpocet['castkaMen'] = $invoice->getDataValue('sumCelkem');
        }
        $odpocet['doklad'] = $invoice;

        $this->setDataValue('odpocty-zaloh', ['odpocet' => $odpocet]);
        $this->insertToFlexiBee();
        return $this->lastResponseCode == 201;
    }
557854
public function saveHistory(History $history, Invoice $invoice)
    {
        return $this->connector->save($history, $invoice);
    }
671791
protected function download($oInvoice)
    {
        //  Business details
        $this->data['business'] = (object) [
            'name'       => appSetting('business_name', 'nails/module-invoice'),
            'address'    => appSetting('business_address', 'nails/module-invoice'),
            'telephone'  => appSetting('business_telephone', 'nails/module-invoice'),
            'email'      => appSetting('business_email', 'nails/module-invoice'),
            'vat_number' => appSetting('business_vat_number', 'nails/module-invoice'),
        ];

        $oInvoiceSkinService   = Factory::service('InvoiceSkin', 'nails/module-invoice');
        $sEnabledSkin          = $oInvoiceSkinService->getEnabledSlug() ?: self::DEFAULT_INVOICE_SKIN;
        $this->data['invoice'] = $oInvoice;
        $this->data['isPdf']   = true;
        $sHtml                 = $oInvoiceSkinService->view($sEnabledSkin, 'render', $this->data, true);

        $oPdf = Factory::service('Pdf', 'nails/module-pdf');
        $oPdf->setPaperSize('A4', 'portrait');
        $oPdf->load_html($sHtml);

        $oPdf->download('INVOICE-' . $oInvoice->ref . '.pdf');
    }
264589
protected function triggerInvoiceCreated(array &$invoice, Source $invoiceSource, Result $localResult)
    {
        $invoice = apply_filters('acumulus_invoice_created', $invoice, $invoiceSource, $localResult);
    }