コード例 #1
0
ファイル: str_methods.py プロジェクト: zobelhelas/gnucash
def __split__str__(self, encoding=None, error=None):
    """__str__(self, encoding=None, error=None) -> object

    Serialize the Split object and return as a new Unicode object.

    Keyword arguments:
    encoding -- defaults to str_methods.default_encoding
    error -- defaults to str_methods.default_error
    See help(unicode) for more details or http://docs.python.org/howto/unicode.html.

    """

    from gnucash import Split
    import time
    #self=Split(instance=self)

    lot = self.GetLot()
    if lot:
        if type(lot).__name__ == 'SwigPyObject':
            lot = gnucash.GncLot(instance=lot)
        lot_str = lot.get_title()
    else:
        lot_str = '---'

    transaction = self.GetParent()

    # This dict and the return statement can be changed according to individual needs
    fmt_dict = {
        "account": self.GetAccount().name,
        "value": self.GetValue(),
        "memo": self.GetMemo(),
        "lot": lot_str
    }

    fmt_str = ("Account: {account:20} " + "Value: {value:>10} " +
               "Memo: {memo:30} ")

    if self.optionflags & self.OPTIONFLAGS_BY_NAME["PRINT_TRANSACTION"]:
        fmt_t_dict = {
            "transaction_time": time.ctime(transaction.GetDate()),
            "transaction2": transaction.GetDescription()
        }
        fmt_t_str = ("Transaction: {transaction_time:30} " +
                     "- {transaction2:30} " + "Lot: {lot:10}")
        fmt_dict.update(fmt_t_dict)
        fmt_str += fmt_t_str

    return fmt_str.format(
        **all_as_classwithcutting__format__keys(encoding, error, **fmt_dict))
コード例 #2
0
ファイル: gncinvoicefkt.py プロジェクト: zkw03/gnucash
def get_all_invoices_from_lots(account):
  """Return all invoices in account and descendants

  This is based on lots. So invoices without lots will be missed."""

  lot_list=get_all_lots(account)
  invoice_list=[]
  for lot in lot_list:
    if type(lot).__name__ == 'SwigPyObject':
        lot = gnucash.GncLot(instance=lot)

    invoice=gnucash.gnucash_core_c.gncInvoiceGetInvoiceFromLot(lot.instance)
    if invoice:
      invoice_list.append(Invoice(instance=invoice))
  return invoice_list
コード例 #3
0
ファイル: gnc_convenience.py プロジェクト: zobelhelas/gnucash
def find_lot(lot_list, search_string):
    """Searches lots in lot_list for search_string.

  returns list of lots where title contains search_string.

  options:

  lot_list:       List of Lots to search in.
  search_string:  String to search for.
  
  """

    rlist = []
    for lot in lot_list:
        if type(lot).__name__ == 'SwigPyObject':
            lot = gnucash.GncLot(instance=lot)
        ltitle = lot.get_title()
        if search_string in ltitle:
            rlist.append(lot)
    return rlist