Creates [[BillForm]] from [[Bill]].

@param Bill $bill
@param string $scenario
@return BillForm
345875
public static function createFromBill($bill, $scenario)
    {
        $attributes = $bill->getAttributes([
            'id', 'object_id', 'client_id', 'currency', 'type',
            'gtype', 'sum', 'time', 'quantity', 'unit', 'label', 'object', 'class',
        ]);

        $form = new self(['scenario' => $scenario]);
        $form->setAttributes($attributes, false);

        $form->charges = array_map(function ($model) use ($scenario) {
            $model->scenario = $scenario;

            return $model;
        }, $bill->charges);

        return $form;
    }
571737
public static function create_plan($plan) {
        global $PAGE;

        $params = self::validate_parameters(self::create_plan_parameters(), array('plan' => $plan));
        $params = $params['plan'];

        $context = context_user::instance($params['userid']);
        self::validate_context($context);
        $output = $PAGE->get_renderer('core');

        $params = (object) $params;

        $result = api::create_plan($params);
        $exporter = new plan_exporter($result, array('template' => null));
        return $exporter->export($output);
    }
1237408
def bills(self, member_id, type='introduced'):
        ""
        path = "members/{0}/bills/{1}.json".format(member_id, type)
        return self.fetch(path)
1157326
public function create($subscription, $plan, array $parameters = [])
    {
        $parameters = array_merge($parameters, compact('plan', 'subscription'));

        return $this->_post('subscription_items', $parameters);
    }
635643
public function invoiceFor($description, $amount, array $options = [])
    {
        if (!$this->stripe_id) {
            throw new InvalidArgumentException('User is not a customer. See the createAsStripeCustomer method.');
        }

        $options = array_merge([
            'customer' => $this->stripe_id,
            'amount' => $amount,
            'currency' => $this->preferredCurrency(),
            'description' => $description,
        ], $options);

        StripeInvoiceItem::create(
            $options, ['api_key' => $this->getStripeKey()]
        );

        return $this->invoice();
    }
101892
public static function createThreeOfAKind(CardCollection $cards, Hand $hand): self
    {
        $cardGroups = $cards->groupByValue();

        $firstCard = $cardGroups->get(0)->first();
        $kicker = $cardGroups->get(1)->first();
        $definition = sprintf('3 of a Kind - %ss', $firstCard->name());

        return new static(
            self::THREE_OF_A_KIND,
            [$firstCard->value(), $kicker->value()],
            $cards,
            $definition,
            $hand
        );
    }
1313001
public UserScenario createUserScenario(final UserScenario scenario) {
        return invoke(USER_SCENARIOS,
                new RequestClosure<JsonObject>() {
                    @Override
                    public JsonObject call(Invocation.Builder request) {
                        String         json = scenario.toJSON().toString();
                        Entity<String> data = Entity.entity(json, MediaType.APPLICATION_JSON_TYPE);
                        return request.post(data, JsonObject.class);
                    }
                },
                new ResponseClosure<JsonObject, UserScenario>() {
                    @Override
                    public UserScenario call(JsonObject json) {
                        return new UserScenario(json);
                    }
                }
        );
    }
49140
public static function calculateAmount($bill, $amountQuery)
	{
		//Берём общую сумму счёта
		$amountBill = $bill->amount;
		//Берём суммы прошлых возвратов
		$refundsBefore = Refund::whereBillId($bill->bill_id)->get();
		$amount_refund = 0;
		foreach ($refundsBefore as $one) {
			$amount_refund += $one->amount;
		}
		//Вычисляем возможную сумму возвтрата и отдаём её
		$rest = $amountBill - $amount_refund;
		$amount = ($amountQuery > $rest)
			? $rest
			: $amountQuery;

		return $amount;
	}
747557
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $services = $serviceLocator->getServiceLocator();
        /* @var $options ModuleOptionsInterface */
        $options = $services->get(ModuleOptions::class);
        $element = new Money('money');
        return $element;
    }
1331208
public function calculateScenarioHeaderWidth(Scenario $scenario, $indentation)
    {
        $indentText = str_repeat(' ', intval($indentation));

        if ($scenario instanceof ExampleNode) {
            $header = sprintf('%s%s', $indentText, $scenario->getTitle());
        } else {
            $title = $scenario->getTitle();
            $lines = explode("\n", $title);
            $header = sprintf('%s%s: %s', $indentText, $scenario->getKeyword(), array_shift($lines));
        }

        return mb_strlen(rtrim($header), 'utf8');
    }
1214528
public function format(OutlineNode $scenario)
    {
        if (! $scenario->hasExamples()) {
            return;
        }

        // TODO: refactor this part
        return implode(
            array_merge(
                [
                    $this->indent(self::INDENTATION * 2) . rtrim($scenario->getExampleTable()->getKeyword()) . ":\n",
                ],
                array_map(
                    function ($arguments) {
                        return $this->indent(self::INDENTATION * 2 + 2) . trim($arguments) . "\n";
                    },
                    explode("\n", $scenario->getExampleTable()->getTableAsString())
                )
            )
        );
    }
231586
public function andScenarioState($scenario, $scenarioState)
    {
        $this->scenarioName = $scenario;
        $this->scenarioIs = $scenarioState;

        return $this;
    }
517217
public static function emailToQueue($bill_id)
	{
		$bill = Bill::whereBillId($bill_id)->first();
		$merchant = $bill->merchant;

		Queue::connection('ff-qiwi-gate')->push('FintechFab\QiwiGate\Queue\SendEmail', array(
			'email'       => $merchant->email,
			'merchant_id' => $merchant->id,
			'bill_id'     => $bill->bill_id,
			'status'      => $bill->status,
			'amount'      => $bill->amount,
			'user'        => $bill->user,
			'prv_name'    => $bill->prv_name,
			'ccy'         => $bill->ccy,
			'comment'     => $bill->comment,
		));
	}
525990
public function setBilling($billing)
    {
        foreach ($billing as $key => $val) {
            $this->billing[$key] = $val;
        }
        $this->billingSet = true;
    }
697286
public static function jobBillToQueue($bill_id)
	{
		$bill = Bill::whereBillId($bill_id)->first();
		$merchant = $bill->merchant;
		$command = 'bill';
		$error = 0;
		$key = $merchant->key;
		$sign = '';
		if ('' != $key) {
			$signData = $bill->amount . '|' . $bill->bill_id . '|' . $bill->ccy . '|' . $command . '|' .
				$bill->comment . '|' . $error . '|' . $bill->prv_name . '|' . $bill->status . '|' . $bill->user;
			$sign = base64_encode(hash_hmac('sha1', $signData, $key));
		}
		Queue::connection('ff-qiwi-gate')->push('FintechFab\QiwiGate\Queue\SendCallback', array(
			'url'           => $merchant->callback_url,
			'merchant_id'   => $merchant->id,
			'merchant_pass' => $merchant->password,
			'bill_id'       => $bill->bill_id,
			'status'        => $bill->status,
			'error'         => $error,
			'amount'        => $bill->amount,
			'user'          => $bill->user,
			'prv_name'      => $bill->prv_name,
			'ccy'           => $bill->ccy,
			'comment'       => $bill->comment,
			'command'       => $command,
			'sign'          => $sign,
		));
	}
922206
public function download($bill): string
    {
        $this->payload['method'] = 'alipay.data.dataservice.bill.downloadurl.query';
        $this->payload['biz_content'] = json_encode(is_array($bill) ? $bill : ['bill_type' => 'trade', 'bill_date' => $bill]);
        $this->payload['sign'] = Support::generateSign($this->payload);

        Events::dispatch(Events::METHOD_CALLED, new Events\MethodCalled('Alipay', 'Download', $this->gateway, $this->payload));

        $result = Support::requestApi($this->payload);

        return ($result instanceof Collection) ? $result->get('bill_download_url') : '';
    }
436062
protected function drawBillet()
    {
        // Add document to assignor
        $assignor = $this->title->assignment->assignor;
        $this->fields['assignor']['value'] .= '     '
            . $assignor->person->getFormattedDocument(true);

        // Draw billet
        $dict = $this->dictionary;

        $this->AddPage();

        $this->drawPageHeader();

        $this->billetSetFont('cell_data');
        $this->drawDash($dict['client_receipt']);

        $this->drawBillhead();

        $this->drawTable('demonstrative');

        $this->Ln(4);

        $this->billetSetFont('cell_title');
        $this->drawDash($dict['compensation']);

        $this->SetY($this->GetY() - 3);

        $this->drawTable('instructions');

        $this->SetY($this->GetY() - 3);
        $this->drawBarCode();
    }