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))
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)}
def add_position_options(data): """ 获取工资规则插件 """ if 'id' in data: options = ProjOfferMgr.get_position_options(data['id']) data['position_options'] = options
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)
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))
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)