Odpočet ZDD

@link https://demo.flexibee.eu/devdoc/odpocet-zaloh Odpočet záloh a ZDD
@param FakturaVydana $invoice zálohová faktura
@param array $odpocet Vlastnosti odpočtu

@return boolean success
352094
public function odpocetZDD($invoice, $odpocet = [])
    {
        if (!isset($odpocet['castkaZaklMen'])) {
            $odpocet['castkaZaklMen'] = $invoice->getDataValue('sumZklZakl');
        }
        if (!isset($odpocet['castkaSnizMen'])) {
            $odpocet['castkaSnizMen'] = $invoice->getDataValue('sumZklSniz');
        }
        if (!isset($odpocet['castkaSniz2Men'])) {
            $odpocet['castkaSniz2Men'] = $invoice->getDataValue('sumZklSniz2');
        }
        if (!isset($odpocet['castkaOsvMen'])) {
            $odpocet['castkaOsvMen'] = $invoice->getDataValue('sumOsv');
        }
        if (!isset($odpocet['id'])) {
            $odpocet['id'] = 'ext:odpocet1';
        }
        $odpocet['doklad'] = $invoice;

        $this->setDataValue('odpocty-zaloh', ['odpocet' => $odpocet]);
        $this->insertToFlexiBee();
        return $this->lastResponseCode == 201;
    }
748164
protected function triggerInvoiceCreated(array &$invoice, Source $invoiceSource, Result $localResult)
    {
        JPluginHelper::importPlugin('acumulus');
        $results = JEventDispatcher::getInstance()->trigger('onAcumulusInvoiceCreated', array(&$invoice, $invoiceSource, $localResult));
        if (count(array_filter($results, function ($value) {
                return $value === false;
            })) >= 1
        ) {
            $invoice = null;
        }
    }
1339571
public function registerPayment(Invoice &$invoice, Payment $payment)
    {
        return $this->connector->registerPayment($invoice, $payment);
    }
774772
function execute(Ob $o) {
		$provider = $o[Plugin::PROVIDER]; /** @var Provider $provider */
		/** @var ISearchResult|ApiSearchResult|UiSearchResult|OrderGC|InvoiceGC|CreditmemoGC $result */
		$result = $o[Plugin::RESULT];
		// 2017-08-02 For now, we do not handle «sales_order_invoice_grid_data_source»
		// and «sales_order_creditmemo_grid_data_source».
		if ('sales_order_grid_data_source' === $provider->getName()) {
			/**
			 * 2016-07-28
			 * https://github.com/magento/magento2/blob/2.1.0/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/SearchResult.php#L37-L40
			 * @see \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult::$document
			 * The document's structure is described here: https://mage2.pro/t/1908
			 */
			$cacheKey = __METHOD__; /** @var string $cacheKey */
			$prop = 'payment_method';  /** @var string $prop */
			df_map($result, function(Document $item) use($cacheKey, $prop) {
				/** @var string|null $methodCode */
				if (($methodCode = $item[$prop]) && df_starts_with($methodCode, 'dfe_')) {
					/**
					 * 2017-05-09
					 * Как оказалось, наличие приставки «dfe_» ешё не гарантирует,
					 * что @uses dfpm() (вызываемый ниже опосредованно через dfpm_title())
					 * действительно вернёт наследника @see \Df\Payment\Method
					 * Возможна ситуация, когда админтратор установил какой-либо из моих патёжных модулей,
					 * сделал платёж посредством него, а затем либо удалил модуль,
					 * либо из-за каких-то некорректных действий модуль стал отключенным,
					 * и вот тогда M2 вернёт не наследника @see \Df\Payment\Method,
					 * а экземпляр класса @see \Magento\Payment\Model\Method\Substitution:
					 * «How is @see \Magento\Payment\Model\Method\Substitution implemented and used?»
					 * https://mage2.pro/t/3924
					 * 1) @see \Magento\Sales\Model\Order\Payment\Info::getMethodInstance()
					 *	try {
					 *		$instance = $this->paymentData->getMethodInstance($this->getMethod());
					 *	} catch (\UnexpectedValueException $e) {
					 *		$instance = $this->paymentData->getMethodInstance(Substitution::CODE);
					 *	}
					 * https://github.com/magento/magento2/blob/2.1.6/app/code/Magento/Sales/Model/Order/Payment/Info.php#L113-L117
					 * 2) @see \Magento\Payment\Model\Info::getMethodInstance()
					 *	try {
					 *		$instance = $this->_paymentData->getMethodInstance($this->getMethod());
					 *	} catch (\UnexpectedValueException $e) {
					 *		$instance = $this->_paymentData->getMethodInstance(Method\Substitution::CODE);
					 *	}
					 * https://github.com/magento/magento2/blob/2.1.6/app/code/Magento/Payment/Model/Info.php#L106-L110
					 */
					$id = $item['entity_id']; /** @var int $id */
					// 2016-07-29
					// Эта операция очень ресурсоёмка:
					// для каждой строки таблицы заказов она делает кучу запросов к базе данных.
					// Поэтому кэшируем результаты в постоянном кэше.
					$item[$prop] = df_cache_get_simple([$cacheKey, $id], function() use($id) {
						$m = dfpm($o = df_order($id)); /** @var O $o */ /** @var M|Substitution $m */
						return !dfp_my($m) ? $m->getTitle() : df_cc_br(dfpm_title($m), dfp_choice($o)->title());
					});
				}
			});
		}
	}
465054
public function setOrderInvoice(\HarvestCloud\CoreBundle\Entity\Invoice\OrderInvoice $invoice = null)
    {
        $this->orderInvoice = $invoice;

        return $this;
    }
36681
public function acumulusInvoiceCreated($invoice, BaseSource $invoiceSource, Result $localResult)
    {
        $invoice = $this->supportBundleProducts($invoice, $invoiceSource, $localResult);
        $invoice = $this->supportTMExtraProductOptions($invoice, $invoiceSource, $localResult);
        return $invoice;
    }
1060515
public function create($data, $invoiceId, $invoiceItemId = null)
    {
        if (isset($invoiceItemId)) {
            return $this->client()->put(
                $data,
                'invoices/{invoiceId}/items/{invoiceItemId}',
                ['invoiceId' => $invoiceId, 'invoiceItemId' => $invoiceItemId]
            );
        }

        return $this->client()->post(
                $data,
                'invoices/{invoiceId}/items',
                ['invoiceId' => $invoiceId]
            );
    }
590799
public static function generate(Invoice $invoice, $template = 'default')
    {
        $template = strtolower($template);

        $options = new Options();

        $options->set('isRemoteEnabled', true);

        $pdf = new Dompdf($options);

        $context = stream_context_create([
            'ssl' => [
                'verify_peer'      => false,
                'verify_peer_name' => false,
                'allow_self_signed'=> true,
            ],
        ]);

        $pdf->setHttpContext($context);

        $pdf->loadHtml(View::make('invoices::'.$template, ['invoice' => $invoice]));
        $pdf->render();

        return $pdf;
    }
162490
public function invoice()
    {
        if ($this->stripe_id) {
            try {
                return StripeInvoice::create(['customer' => $this->stripe_id], $this->getStripeKey())->pay();
            } catch (InvalidRequest $e) {
                return false;
            }
        }

        return true;
    }
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;
    }
264589
protected function triggerInvoiceCreated(array &$invoice, Source $invoiceSource, Result $localResult)
    {
        $invoice = apply_filters('acumulus_invoice_created', $invoice, $invoiceSource, $localResult);
    }
390417
public function addInvoice(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Invoice\Invoice $invoice)
    {
        $this->invoices[] = $invoice;

        return $this;
    }
204573
protected function isEmptyInvoice(array $invoice)
    {
        return Number::isZero($invoice[Tag::Customer][Tag::Invoice][Meta::InvoiceAmountInc]);
    }
619258
public function invoiceAmount($invNo)
    {
        $this->_checkInvNo($invNo);

        $digestSecret = self::digest(
            $this->colon($this->_eid, $invNo, $this->_secret)
        );

        $paramList = array(
            $this->_eid,
            $invNo,
            $digestSecret
        );

        self::printDebug('invoice_amount array', $paramList);

        $result = $this->xmlrpc_call('invoice_amount', $paramList);

        //Result is in cents, fix it.
        return ($result / 100);
    }
526966
public function invoiceFor($description, $amount, array $tabOptions = [], array $invoiceOptions = [])
    {
        $this->tab($description, $amount, $tabOptions);

        return $this->invoice($invoiceOptions);
    }
525026
public function createInvoice($delivery=null, $transaction=null)
    {
        /** @var Transaction $transaction */
        if(is_null($transaction))
        $transaction = $this->getCurrentTransaction();
        
        
        $invoiceNumber = $this->manager->getRepository('EcommerceBundle:Invoice')->getNextNumber();

        $invoice = new Invoice();
        $invoice->setInvoiceNumber($invoiceNumber);
        //Actor invoices  = ONE SHOT
        
        if($transaction->getItems()->first()->getAdvert() instanceof Advert || 
           $transaction->getItems()->first()->getProduct() instanceof Product
            ){
            $invoice->setFullName($this->securityContext->getToken()->getUser()->getFullName());
            if(!is_null($delivery)){
               $invoice->setDni($delivery->getDni());
               $invoice->setAddressInfo($delivery->getAddressInfo()); 
            }else{
                $invoice->setAddressInfo($this->getBillingAddress($transaction->getActor()));
            }
            
            $invoice->setTransaction($transaction);
            $this->manager->persist($invoice);
            $this->manager->flush();

            $totals = $this->calculateTotals($transaction, $delivery);

           
            if($transaction->getItems()->first()->getProduct() instanceof Product){
                $this->mailer->sendPurchaseNotification($invoice);
                $this->mailer->sendPurchaseConfirmationMessage($invoice, $totals['amount']);
            }elseif($transaction->getItems()->first()->getAdvert() instanceof Advert){
                $this->mailer->sendAdvertPurchaseNotification($invoice);
                $this->mailer->sendAdvertPurchaseConfirmationMessage($invoice, $totals['amount']);
            }
            
        
        }
        elseif($transaction->getItems()->first()->getPlan() instanceof Plan){
            $name = $transaction->getActor()->getName();
            $invoice->setFullName($name);
            $invoice->setAddress($transaction->getActor()->getAddress());
            $invoice->setPostalCode($transaction->getActor()->getPostalCode());
            $invoice->setCity($transaction->getActor()->getCity());
            if(!is_null($transaction->getActor()->getState()))$invoice->setState($transaction->getActor()->getState());
            $invoice->setCountry($transaction->getActor()->getCountry());
            
            $invoice->setTransaction($transaction);
            $this->manager->persist($invoice);
            $this->manager->flush();

            $totals = $this->calculateTotals($transaction, $delivery);

            $this->mailer->sendPlanPurchaseNotification($invoice);
            $this->mailer->sendPlanPurchaseConfirmationMessage($invoice, $totals['amount']);

        }
       

        return $invoice;
    }
760862
public function invoice($orderId, $invoiceKey)
    {
        /** @var OrderHandler $handler */
        $handler = $this->requestHandler();
        return $handler->invoice($orderId, $invoiceKey);
    }