当前位置: 首页>>代码示例>>Python>>正文


Python User.set_money方法代码示例

本文整理汇总了Python中model.user.User.set_money方法的典型用法代码示例。如果您正苦于以下问题:Python User.set_money方法的具体用法?Python User.set_money怎么用?Python User.set_money使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在model.user.User的用法示例。


在下文中一共展示了User.set_money方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: encode_dict

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import set_money [as 别名]
def encode_dict(dict):
    """
    decodes user from dictionary
    :param dict: decoded user
    :return: new user
    """
    # create new user
    ret_user = User()
    # set his money
    ret_user.set_money(decimal.Decimal(dict['money']))
    for account in dict['payment list']:
        # set new accounting
        tmp_account = Accounting()
        date = account['datetime']
        # set datetime
        tmp_account.set_datetime(datetime.datetime(date['year'],
                                                   date['month'],
                                                   date['day']))
        # set sum
        tmp_account.set_sum(decimal.Decimal(account['sum']))
        # set description
        tmp_account.set_description(account['description'])
        # add account
        ret_user.add_payment(tmp_account)
        ret_user.add_money(-tmp_account.get_sum())
    return ret_user
开发者ID:misikdmitriy,项目名称:accounting,代码行数:28,代码来源:sjson.py

示例2: main

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import set_money [as 别名]
def main():
    """
    allows to append User's payments and clear them
    :return: nothing
    """
    read = serialize_type()[0]
    write = serialize_type()[1]
    main_user = read()
    if main_user is None:
        main_user = User(0.00)
    while True:
        key = get_key()
        if key == '1':
            account = View.input_accounting()
            main_user.add_payment(account)
        elif key == '2':
            main_user.clear_payments()
            main_user.set_money(0.00)
        elif key == '3':
            View.print_payments(main_user)
        elif key == '4':
            write(main_user)
            return None
        else:
            print("You've entered incorrect value")
开发者ID:misikdmitriy,项目名称:accounting,代码行数:27,代码来源:cui.py

示例3: parse_xml

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import set_money [as 别名]
def parse_xml(tree):
    """
    try to parse XML from tree
    :param tree: XML
    :return: user
    """
    # get root
    root = tree.getroot()
    # creates new user
    ret_user = User()
    # set his money
    ret_user.set_money(decimal.Decimal(root.attrib['money']))

    for account in root[0]:
        # create new account
        new_account = Accounting()
        # set its description
        new_account.set_description(account.attrib['description'])
        # set new sum
        new_account.set_sum(decimal.Decimal(account.attrib['price']))
        # get datetime
        dtime = account[0]
        # set datetime
        new_account.set_datetime(datetime.datetime(int(dtime.attrib['year']),
                                                   int(dtime.attrib['month']),
                                                   int(dtime.attrib['day'])))
        # set this payment to user
        ret_user.add_payment(new_account)
        # add money
        ret_user.add_money(-new_account.get_sum())

    return ret_user
开发者ID:KirillZaika,项目名称:accounting,代码行数:34,代码来源:sxml.py

示例4: create_user

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import set_money [as 别名]
 def create_user(self):
     """
     creates instance of User class
     with two payments
     :return: user
     """
     user = User()
     user.set_money(3.00)
     payment = Accounting()
     payment.set_sum(2.00)
     another_payment = payment
     another_payment.set_description('another')
     user.add_payment(payment)
     user.add_payment(another_payment)
     return user
开发者ID:KirillZaika,项目名称:accounting,代码行数:17,代码来源:usrtests.py


注:本文中的model.user.User.set_money方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。