Exemplo n.º 1
0
def update_offer(offer_id, form):
    offer = ProjOfferMgr.get(offer_id)
    if offer is None:
        return dict(status='error', msg='报价单不存在')
    ProjOfferMgr.update(offer, **form)
    # 新增操作记录
    __add_proj_op_log(web_util.get_operator_id(), offer.id,
                      proj_constant.PROJ_OP_TYPE_UPDATE, "更改报价单信息", 0, 0)
    return dict(status='ok', data=to_dict(offer))
Exemplo n.º 2
0
 def list_proj_offers(proj_id, page, page_size=10):
     """获取项目列表并分页"""
     filter_condition = {'is_del': 0, 'proj_id': proj_id}
     count = ProjOfferMgr.count(filter_conditions=filter_condition)
     if page_size > 5000:
         page_size = 5000
     records = ProjOfferMgr.query(
         filter_conditions=filter_condition,
         limit=page_size,
         offset=(page - 1) * page_size,
         order_list=[ProjOfferMgr.model.start_time.desc()])
     return {'total_count': count, 'datas': to_dict(records)}
Exemplo n.º 3
0
 def add_position_options(data):
     """
     获取工资规则插件
     """
     if 'id' in data:
         options = ProjOfferMgr.get_position_options(data['id'])
         data['position_options'] = options
Exemplo n.º 4
0
def calculate(proj_id, date):
    offers = ProjOfferMgr.query({'proj_id': proj_id, 'is_del': 0})
    date_timestamp = time_util.dateString2timestampCommon(date)
    raw_datas = WageRawDataMgr.query({'proj_id': proj_id, 'wage_time': date_timestamp, 'is_del': 0})
    calculated_datas = []
    for offer in offers:
        if offer.position != '所有':
            data = {'offer': to_dict(offer), 'raw_datas': to_dict(raw_datas), 'calculated_datas': []}
            result = execute_plugin('offer', offer.id, 'on_position_calculate', {}, data)
            calculated_datas.extend(result['data']['calculated_datas'])

    wage_maps = {}
    for data in calculated_datas:
        key = '%s_%s_%s' % (data['supplier_id'], data['offer_type'], data['crew_id'])
        if key in wage_maps:
            wage_maps[key]['amount'] += data['amount']
            wage_maps[key]['work_rate'] += data['work_rate']
        else:
            wage_maps[key] = data
    for offer in offers:
        if offer.position == '所有':
            data = {'offer': to_dict(offer), 'wage_datas': wage_maps.values()}
            result = execute_plugin('offer', offer.id, 'on_position_agregate_calculate', {}, data)
            for item in result['data']['wage_datas']:
                WageMgr.create_override_if_exist(item)
Exemplo n.º 5
0
def create_offer(form):

    proj_id = get_request_proj_id()
    offer = ProjOfferMgr.create(proj_id=proj_id, **form)

    # 新增操作记录
    __add_proj_op_log(web_util.get_operator_id(), offer.id,
                      proj_constant.PROJ_OP_TYPE_CREATE, "新建一个报价单", 0, 0)
    return dict(status='ok', data=to_dict(offer))
Exemplo n.º 6
0
 def add_plugins(supplier_id, offer_type, position, data):
     """
     工作数据产生日期yyyy-mm-dd
     """
     offer = ProjOfferMgr.query_first({
         'supplier_id': supplier_id,
         'offer_type': offer_type,
         'position': position,
         'is_del': 0
     })
     if offer:
         plugins = PluginMgr.query({
             'bus_type': 'offer',
             'bus_id': offer.id,
             'is_del': 0
         })
         data['plugins'] = to_dict(plugins)