Exemple #1
0
 def discount_percent(self, value):
     """Sets the discount percent of the invoice.
     """
     if value > 1 or value < -1:
         self._discount_percent = round(value / 100, 2)
     else:
         self._discount_percent = round(value, 2)
     amount = self._discount_percent * self.gross_subtotal()
     self._discount_amount = parse_money(amount, self._currency)
Exemple #2
0
 def line_extension_amount(self, price):
     """Sets the LineExtensionAmount.
     """
     if price is None:
         return
     try:
         self._line_extension_amount = parse_money(price, self._currency)
     except ValueError:
         raise ValueError(
             "Unrecognized line_extension_amount {}".format(price))
Exemple #3
0
 def price(self, price):
     """Sets the price of one item.
     """
     if price is None:
         return
     try:
         self._price = parse_money(price, self._currency)
         self._line_extension_amount = self._price * self._quantity
     except ValueError:
         raise ValueError("Unrecognized price {}".format(price))
Exemple #4
0
    def price(self, price):
        """Sets the price of one item.

        Paramters
        ---------
        price: string, integer, float
            The input must be a valid input for the Decimal class
            the Python Standard Library.

        """
        if price is None:
            return
        try:
            self._price = parse_money(price, self._currency)
            self._line_extension_amount = self._price * self._quantity
        except ValueError:
            raise ValueError("Unrecognized price {}".format(price))
Exemple #5
0
    def line_extension_amount(self, price):
        """Sets the LineExtensionAmount.

        Paramters
        ---------
        line_extension_amount: string, integer, float
            The input must be a valid input for the Decimal class
            the Python Standard Library. Computed unless the invoice
            is imported from an XML file.

        """
        if price is None:
            return
        try:
            self._line_extension_amount = parse_money(price, self._currency)
        except ValueError:
            raise ValueError(
                "Unrecognized line_extension_amount {}".format(price))
Exemple #6
0
    def discount(self, value):
        """Sets the AllowanceTotalAmount of the invoice.

        Parameters
        ----------
        value: string, integer, float
            The input must be a valid input for the Decimal class
            the Python Standard Library.

        Raises
        ------
        decimal.InvalidOperation: If the input cannot be converted
            to a Decimal.

        """
        self._discount_amount = parse_money(value, self._currency)
        self._discount_percent = round(
            self._discount_amount / self.gross_subtotal(), 2)
Exemple #7
0
    def payable_amount(self, value):
        """Sets the PayableAmount of the invoice.

        Only used when importing from an XML file.
        """
        self._payable_amount = parse_money(value, self._currency)
Exemple #8
0
    def tax_inclusive_amount(self, value):
        """Sets the TaxInclusiveAmount of the invoice.

        Only used when importing from an XML file.
        """
        self._tax_inclusive_amount = parse_money(value, self._currency)
Exemple #9
0
    def line_extension_amount(self, value):
        """Sets the LineExtensionAmount of the invoice.

        Only used when importing from an XML file.
        """
        self._line_extension_amount = parse_money(value, self._currency)
Exemple #10
0
 def discount_amount(self, value):
     """Sets the AllowanceTotalAmount of the invoice.
     """
     self._discount_amount = parse_money(value, self._currency)
     self._discount_percent = round(
         self._discount_amount / self.gross_subtotal(), 2)
Exemple #11
0
 def charge_amount(self, value):
     """Sets the ChargeTotalAmount of the invoice.
     """
     self._charge_amount = parse_money(value, self._currency)
     self._charge_percent = round(
         self._charge_amount / self.gross_subtotal(), 2)