Creates an Invoice as well as a single associated InvoiceItem
        with the passed description (for things like gift certificates)
345423
def create_from_item(cls, amount, item_description, **kwargs):
        '''
        
        '''
        submissionUser = kwargs.pop('submissionUser', None)
        collectedByUser = kwargs.pop('collectedByUser', None)
        calculate_taxes = kwargs.pop('calculate_taxes', False)
        grossTotal = kwargs.pop('grossTotal',None)

        new_invoice = cls(
            grossTotal=grossTotal or amount,
            total=amount,
            submissionUser=submissionUser,
            collectedByUser=collectedByUser,
            buyerPaysSalesTax=getConstant('registration__buyerPaysSalesTax'),
            data=kwargs,
        )

        if calculate_taxes:
            new_invoice.calculateTaxes()

        new_invoice.save()

        InvoiceItem.objects.create(
            invoice=new_invoice,
            grossTotal=grossTotal or amount,
            total=amount,
            taxes=new_invoice.taxes,
            description=item_description,
        )
        return new_invoice
894285
def complete_invoice(self, invoice_id, complete_dict):
        
        return self._create_put_request(
            resource=INVOICES,
            billomat_id=invoice_id,
            command=COMPLETE,
            send_data=complete_dict
        )
847736
def create
      request = Request.put_xml("pre-approvals/#{code}/discount", credentials, xml_params)

      Response.new(request, self).serialize

      self
    end
752676
def create_invoice_from_albaran(pk, list_lines):
        
        context = {}
        if list_lines:
            new_list_lines = [x[0] for x in SalesLineAlbaran.objects.values_list('line_order__pk').filter(
                pk__in=[int(x) for x in list_lines]
            ).exclude(invoiced=True)]
            if new_list_lines:
                lo = SalesLineOrder.objects.values_list('order__pk').filter(pk__in=new_list_lines)[:1]
                if lo and lo[0] and lo[0][0]:
                    new_pk = lo[0][0]
                    context = GenLineProduct.create_invoice_from_order(new_pk, new_list_lines)
                    if 'error' not in context or not context['error']:
                        SalesLineAlbaran.objects.filter(
                            pk__in=[int(x) for x in list_lines]
                        ).exclude(invoiced=True).update(invoiced=True)
                    return context
                else:
                    error = _('Pedido no encontrado')
            else:
                error = _('Lineas no relacionadas con pedido')
        else:
            error = _('Lineas no seleccionadas')
        context['error'] = error
        return context
850876
def cli(env, identifier, details):
    """"""

    manager = AccountManager(env.client)
    top_items = manager.get_billing_items(identifier)

    title = "Invoice %s" % identifier
    table = formatting.Table(["Item Id", "Category", "Description", "Single",
                              "Monthly", "Create Date", "Location"], title=title)
    table.align['category'] = 'l'
    table.align['description'] = 'l'
    for item in top_items:
        fqdn = "%s.%s" % (item.get('hostName', ''), item.get('domainName', ''))
        # category id=2046, ram_usage doesn't have a name...
        category = utils.lookup(item, 'category', 'name') or item.get('categoryCode')
        description = nice_string(item.get('description'))
        if fqdn != '.':
            description = "%s (%s)" % (item.get('description'), fqdn)
        table.add_row([
            item.get('id'),
            category,
            nice_string(description),
            "$%.2f" % float(item.get('oneTimeAfterTaxAmount')),
            "$%.2f" % float(item.get('recurringAfterTaxAmount')),
            utils.clean_time(item.get('createDate'), out_format="%Y-%m-%d"),
            utils.lookup(item, 'location', 'name')
        ])
        if details:
            for child in item.get('children', []):
                table.add_row([
                    '>>>',
                    utils.lookup(child, 'category', 'name'),
                    nice_string(child.get('description')),
                    "$%.2f" % float(child.get('oneTimeAfterTaxAmount')),
                    "$%.2f" % float(child.get('recurringAfterTaxAmount')),
                    '---',
                    '---'
                ])

    env.fout(table)
30159
def create_item(self, item):
        
        item_dict = {
            'project_id': item.project_id,
            'from_user_id': item.from_user_id,
            'to_user_id': item.to_user_id,
            'role': item.auth_role,
            'user_message': item.user_message
        }
        if item.share_user_ids:
            item_dict['share_user_ids'] = item.share_user_ids
        data = json.dumps(item_dict)
        resp = requests.post(self.make_url(item.destination), headers=self.json_headers, data=data)
        self.check_response(resp)
        return resp
1053808
def Create(self,name,description=None):
		

		if not description:  description = name

		r = clc.v2.API.Call(
			'POST',
			'groups/%s' % (self.alias),
			{'name': name, 'description': description, 'parentGroupId': self.id},
			session=self.session)
		return(Group(id=r['id'],alias=self.alias,group_obj=r,session=self.session))
61825
def upload_invoice_signature(self, invoice_id, signature_dict):
        
        return self._create_put_request(
            resource=INVOICES,
            billomat_id=invoice_id,
            send_data=signature_dict,
            command=UPLOAD_SIGNATURE
        )
577291
public function load($invoiceId, $invoiceItemId, $params = [])
    {
        return $this->client()->get(
            'invoices/{invoiceId}/items/{invoiceItemId}',
            ['invoiceId' => $invoiceId, 'invoiceItemId' => $invoiceItemId] + (array) $params
        );
    }
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]
            );
    }
361092
def send(self, sender: PytgbotApiBot):
        
        return sender.send_invoice(
            # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id
            title=self.title, description=self.description, payload=self.payload, provider_token=self.provider_token, start_parameter=self.start_parameter, currency=self.currency, prices=self.prices, chat_id=self.receiver, reply_to_message_id=self.reply_id, provider_data=self.provider_data, photo_url=self.photo_url, photo_size=self.photo_size, photo_width=self.photo_width, photo_height=self.photo_height, need_name=self.need_name, need_phone_number=self.need_phone_number, need_email=self.need_email, need_shipping_address=self.need_shipping_address, send_phone_number_to_provider=self.send_phone_number_to_provider, send_email_to_provider=self.send_email_to_provider, is_flexible=self.is_flexible, disable_notification=self.disable_notification, reply_markup=self.reply_markup
        )
592538
def CreateReply(self, **attributes):
        
        return AcctPacket(AccountingResponse, self.id,
            self.secret, self.authenticator, dict=self.dict,
            **attributes)
101060
def form_valid(self,form):
        '''
        
        '''
        emailTo = form.cleaned_data.get('emailTo')
        emailType = form.cleaned_data.get('emailType')
        recipientName = form.cleaned_data.get('recipientName')
        fromName = form.cleaned_data.get('fromName')
        message = form.cleaned_data.get('message')

        logger.info('Processing gift certificate.')

        try:
            voucher = Voucher.create_new_code(
                prefix='GC_',
                name=_('Gift certificate: %s%s for %s' % (getConstant('general__currencySymbol'),self.amount, emailTo)),
                category=getConstant('vouchers__giftCertCategory'),
                originalAmount=self.amount,
                singleUse=False,
                forFirstTimeCustomersOnly=False,
                expirationDate=None,
            )
        except IntegrityError:
            logger.error('Error creating gift certificate voucher for Invoice #%s' % self.invoiceId)
            emailErrorMessage(_('Gift certificate transaction not completed'), self.invoiceId)

        template = getConstant('vouchers__giftCertTemplate')

        # Attempt to attach a PDF of the gift certificate
        rf = RequestFactory()
        pdf_request = rf.get('/')

        pdf_kwargs = {
            'currencySymbol': getConstant('general__currencySymbol'),
            'businessName': getConstant('contact__businessName'),
            'certificateAmount': voucher.originalAmount,
            'certificateCode': voucher.voucherId,
            'certificateMessage': message,
            'recipientName': recipientName,
            'fromName': fromName,
        }
        if recipientName:
            pdf_kwargs.update({})

        attachment = GiftCertificatePDFView(request=pdf_request).get(request=pdf_request,**pdf_kwargs).content or None

        if attachment:
            attachment_name = 'gift_certificate.pdf'
        else:
            attachment_name = None

        # Send a confirmation email
        email_class = EmailRecipientMixin()
        email_class.email_recipient(
            subject=template.subject,
            content=template.content,
            send_html=template.send_html,
            html_content=template.html_content,
            from_address=template.defaultFromAddress,
            from_name=template.defaultFromName,
            cc=template.defaultCC,
            to=emailTo,
            currencySymbol=getConstant('general__currencySymbol'),
            businessName=getConstant('contact__businessName'),
            certificateAmount=voucher.originalAmount,
            certificateCode=voucher.voucherId,
            certificateMessage=message,
            recipientName=recipientName,
            fromName=fromName,
            emailType=emailType,
            recipient_name=recipientName,
            attachment_name=attachment_name,
            attachment=attachment
        )

        # Remove the invoice session data
        self.request.session.pop(INVOICE_VALIDATION_STR,None)

        return HttpResponseRedirect(self.get_success_url())
809303
def process(self, request, item):
        """"""
        warn_untested()
        from paypal.pro.helpers import PayPalWPP

        wpp = PayPalWPP(request)

        # Change the model information into a dict that PayPal can understand.
        params = model_to_dict(self, exclude=self.ADMIN_FIELDS)
        params['acct'] = self.acct
        params['creditcardtype'] = self.creditcardtype
        params['expdate'] = self.expdate
        params['cvv2'] = self.cvv2
        params.update(item)

        # Create recurring payment:
        if 'billingperiod' in params:
            return wpp.createRecurringPaymentsProfile(params, direct=True)
        # Create single payment:
        else:
            return wpp.doDirectPayment(params)
1339746
private function createOrderInvoice($order, $transactionId, $amount)
    {
        if ($order->getTotalInvoiced() + $amount == $order->getGrandTotal()) {
            $invoice = $this->invoiceService->prepareInvoice($order);
        } else {
            $invoice = $this->invoiceService->prepareInvoiceWithoutItems($order, $amount);
        }

        $invoice->setRequestedCaptureCase(Invoice::CAPTURE_OFFLINE);
        $invoice->setTransactionId($transactionId);
        $invoice->setBaseGrandTotal($amount);
        $invoice->setGrandTotal($amount);
        $invoice->register();
        $invoice->save();

        $order->addRelatedObject($invoice);

        if (!$invoice->getEmailSent()) {
            $this->invoiceSender->send($invoice);
        }

        //Add notification comment to order
        $order->addStatusHistoryComment(
            __('Invoice #%1 is created. Notification email is sent to customer.', $invoice->getId())
        )->setIsCustomerNotified(true)->save();

        return $invoice;
    }
1217399
function(apiKey, contactId, creditCardId,
        payPlanId, productIds, subscriptionPlanIds, processSpecials,
        promoCodes, _leadAffiliatedId, _affiliatedId) {}
246955
def to_array(self):
        
        array = super(InvoiceMessage, self).to_array()
        array['title'] = u(self.title)  # py2: type unicode, py3: type str

        array['description'] = u(self.description)  # py2: type unicode, py3: type str

        array['payload'] = u(self.payload)  # py2: type unicode, py3: type str

        array['provider_token'] = u(self.provider_token)  # py2: type unicode, py3: type str

        array['start_parameter'] = u(self.start_parameter)  # py2: type unicode, py3: type str

        array['currency'] = u(self.currency)  # py2: type unicode, py3: type str

        array['prices'] = self._as_array(self.prices)  # type list of LabeledPrice

        if self.receiver is not None:
            if isinstance(self.receiver, None):
                array['chat_id'] = None(self.receiver)  # type Noneelif isinstance(self.receiver, str):
                array['chat_id'] = u(self.receiver)  # py2: type unicode, py3: type str
            elif isinstance(self.receiver, int):
                array['chat_id'] = int(self.receiver)  # type intelse:
                raise TypeError('Unknown type, must be one of None, str, int.')
            # end if

        if self.reply_id is not None:
            if isinstance(self.reply_id, DEFAULT_MESSAGE_ID):
                array['reply_to_message_id'] = DEFAULT_MESSAGE_ID(self.reply_id)  # type DEFAULT_MESSAGE_IDelif isinstance(self.reply_id, int):
                array['reply_to_message_id'] = int(self.reply_id)  # type intelse:
                raise TypeError('Unknown type, must be one of DEFAULT_MESSAGE_ID, int.')
            # end if

        if self.provider_data is not None:
            array['provider_data'] = u(self.provider_data)  # py2: type unicode, py3: type str

        if self.photo_url is not None:
            array['photo_url'] = u(self.photo_url)  # py2: type unicode, py3: type str

        if self.photo_size is not None:
            array['photo_size'] = int(self.photo_size)  # type int
        if self.photo_width is not None:
            array['photo_width'] = int(self.photo_width)  # type int
        if self.photo_height is not None:
            array['photo_height'] = int(self.photo_height)  # type int
        if self.need_name is not None:
            array['need_name'] = bool(self.need_name)  # type bool
        if self.need_phone_number is not None:
            array['need_phone_number'] = bool(self.need_phone_number)  # type bool
        if self.need_email is not None:
            array['need_email'] = bool(self.need_email)  # type bool
        if self.need_shipping_address is not None:
            array['need_shipping_address'] = bool(self.need_shipping_address)  # type bool
        if self.send_phone_number_to_provider is not None:
            array['send_phone_number_to_provider'] = bool(self.send_phone_number_to_provider)  # type bool
        if self.send_email_to_provider is not None:
            array['send_email_to_provider'] = bool(self.send_email_to_provider)  # type bool
        if self.is_flexible is not None:
            array['is_flexible'] = bool(self.is_flexible)  # type bool
        if self.disable_notification is not None:
            array['disable_notification'] = bool(self.disable_notification)  # type bool
        if self.reply_markup is not None:
            array['reply_markup'] = self.reply_markup.to_array()  # type InlineKeyboardMarkup

        return array