"""C01构造合并底稿。仅标准库;金额为万元,条件资格由教学输入给定。""" from decimal import Decimal from pathlib import Path import json D = Decimal def clean(x): if isinstance(x,D): return format(x.quantize(D('0.000001')), 'f').rstrip('0').rstrip('.') or '0' if isinstance(x,dict): return {k:clean(v) for k,v in x.items()} if isinstance(x,(list,tuple)): return [clean(v) for v in x] return x def build(): out={} def put(n,i,**o):out[f'DJ4-{n:03}']={'inputs':i,'outputs':o} i={'period':'2026年度','unit':'万元;数量件','parent_share':D('.8'),'parent_other_profit':150,'subsidiary_other_profit':90,'lots':[{'lot':'A','units':100,'cost':4,'internal_price':6,'sold':70,'external_price':8},{'lot':'B','units':50,'cost':8,'internal_price':10,'sold':20,'external_price':13}]} rows=[] for x in i['lots']: rows.append(dict(x,internal_revenue=x['units']*x['internal_price'],seller_cost=x['units']*x['cost'],external_revenue=x['sold']*x['external_price'],buyer_cost=x['sold']*x['internal_price'],unsold=x['units']-x['sold'],buyer_inventory=(x['units']-x['sold'])*x['internal_price'],group_inventory=(x['units']-x['sold'])*x['cost'],unrealized=(x['units']-x['sold'])*(x['internal_price']-x['cost']))) sums={k:sum(x[k] for x in rows) for k in ['internal_revenue','seller_cost','external_revenue','buyer_cost','buyer_inventory','group_inventory','unrealized']} seller=sums['internal_revenue']-sums['seller_cost'];buyer=sums['external_revenue']-sums['buyer_cost'];allocation=[] for direction in ['顺流','逆流']: p=(seller if direction=='顺流' else buyer)+i['parent_other_profit'];s=(buyer if direction=='顺流' else seller)+i['subsidiary_other_profit'];u=sums['unrealized'];adjp=p-u if direction=='顺流' else p;adjs=s if direction=='顺流' else s-u allocation.append({'direction':direction,'parent_single':p,'subsidiary_single':s,'combined':p+s,'group':p+s-u,'parent':adjp+adjs*i['parent_share'],'minority':adjs*(1-i['parent_share'])}) allsold=sum((x['external_price']-x['cost'])*x['units'] for x in i['lots'])+i['parent_other_profit']+i['subsidiary_other_profit'] put(1,i,lots=rows,totals=sums,allocation=allocation,all_sold_group_profit=allsold,seller_profit=seller,buyer_profit=buyer,group_goods_profit=sums['external_revenue']-sum(x['sold']*x['cost'] for x in rows)) i={'date':'2026-01-01','original_cost':1200,'opening_accumulated_depreciation':480,'transfer_price':1080,'months_remaining':36,'residual':0,'months_each_year':[12,12,12],'alternative_first_year_months':6} book=i['original_cost']-i['opening_accumulated_depreciation'];gain=i['transfer_price']-book;elapsed=0;rows=[] for year,months in enumerate(i['months_each_year'],int(i['date'][:4])): elapsed+=months;buyer_dep=D(i['transfer_price']-i['residual'])/i['months_remaining']*months;group_dep=D(book-i['residual'])/i['months_remaining']*months rows.append({'year':year,'months':months,'buyer_original':i['transfer_price'],'group_original':i['original_cost'],'buyer_dep':buyer_dep,'group_dep':group_dep,'extra_dep':buyer_dep-group_dep,'buyer_accumulated':D(i['transfer_price'])/i['months_remaining']*elapsed,'group_accumulated':i['opening_accumulated_depreciation']+D(book)/i['months_remaining']*elapsed,'buyer_net':i['transfer_price']-D(i['transfer_price'])/i['months_remaining']*elapsed,'group_net':book-D(book)/i['months_remaining']*elapsed,'unrealized_remaining':gain-D(gain)/i['months_remaining']*elapsed,'profit_adjustment':(-gain if year==2026 else 0)+buyer_dep-group_dep}) put(2,i,transfer_book=book,transfer_gain=gain,annual_rows=rows,half_year={'months':i['alternative_first_year_months'],'buyer_dep':D(i['transfer_price'])/i['months_remaining']*i['alternative_first_year_months'],'group_dep':D(book)/i['months_remaining']*i['alternative_first_year_months'],'remaining':gain-D(gain)/i['months_remaining']*i['alternative_first_year_months'],'profit_adjustment':-gain+D(gain)/i['months_remaining']*i['alternative_first_year_months']}) i={'period':'2026年度','before_impairment_profit':{'P':200,'S':160},'receivables':[{'creditor':'P','debtor':'S','internal':True,'gross':900,'opening_allowance':18,'closing_allowance':54,'matched_payable':900},{'creditor':'P','debtor':'外客甲','internal':False,'gross':600,'opening_allowance':60,'closing_allowance':90,'matched_payable':0},{'creditor':'S','debtor':'外客乙','internal':False,'gross':400,'opening_allowance':16,'closing_allowance':20,'matched_payable':0}],'alternative_internal_payable':880} rows=[dict(x,impairment=x['closing_allowance']-x['opening_allowance'],single_net=x['gross']-x['closing_allowance'],group_gross=0 if x['internal'] else x['gross'],group_allowance=0 if x['internal'] else x['closing_allowance']) for x in i['receivables']] single={s:i['before_impairment_profit'][s]-sum(x['impairment'] for x in rows if x['creditor']==s) for s in ['P','S']};extgross=sum(x['group_gross'] for x in rows);extallow=sum(x['group_allowance'] for x in rows) put(3,i,matrix=rows,single_profit=single,group_profit=sum(single.values())+sum(x['impairment'] for x in rows if x['internal']),group_gross=extgross,group_allowance=extallow,group_net=extgross-extallow,opening_equity_restore=sum(x['opening_allowance'] for x in rows if x['internal']),current_profit_restore=sum(x['impairment'] for x in rows if x['internal']),gross_only_wrong_net=sum(x['single_net'] for x in rows)-sum(x['gross'] for x in rows if x['internal']),mismatch_case={'debtor_payable':i['alternative_internal_payable'],'unmatched':i['receivables'][0]['gross']-i['alternative_internal_payable'],'status':'差额待核,不自动抵平' if i['receivables'][0]['gross'] != i['alternative_internal_payable'] else '已匹配'}) i={'date':'2026-06-30','old_share':D('.8'),'bought_share':D('.1'),'net_assets':1800,'goodwill':240,'cash':320,'capital_premium':100,'parent_equity_before':3000,'assets_before':5000,'liabilities':1640,'alternative_cash':160} acquired=i['bought_share']*i['net_assets'];diff=i['cash']-acquired;cap=min(max(diff,0),i['capital_premium']);ret=max(diff-cap,0);minority_before=(1-i['old_share'])*i['net_assets'];minority_after=minority_before-acquired;parent_after=i['parent_equity_before']-diff put(4,i,new_share=i['old_share']+i['bought_share'],acquired_minority=acquired,equity_difference=diff,capital_used=cap,retained_used=ret,minority_before=minority_before,minority_after=minority_after,parent_equity_after=parent_after,total_equity_after=parent_after+minority_after,assets_after=i['assets_before']-i['cash'],goodwill_after=i['goodwill'],cheap_case={'cash':i['alternative_cash'],'acquired':acquired,'capital_increase':acquired-i['alternative_cash']},wrong_goodwill_increase=diff) i={'date':'2026-06-30','old_share':D('.8'),'sold_share':D('.2'),'net_assets':1800,'goodwill':240,'cash':500,'parent_equity_before':3000,'assets_before':5000,'liabilities':1640,'control_retained':True,'alternative_cash':380} fraction=i['sold_share']/i['old_share'];net=i['net_assets']*i['sold_share'];gw=i['goodwill']*fraction;shift=net+gw;cap=i['cash']-shift;mb=(1-i['old_share'])*i['net_assets'];pa=i['parent_equity_before']+cap put(5,i,new_share=i['old_share']-i['sold_share'],sold_fraction_of_parent=fraction,net_assets_shift=net,goodwill_shift=gw,total_shift=shift,capital_increase=cap,minority_before=mb,minority_after=mb+shift,parent_equity_after=pa,total_equity_after=pa+mb+shift,assets_after=i['assets_before']+i['cash'],goodwill_total_after=i['goodwill'],parent_goodwill_after=i['goodwill']-gw,wrong_capital_without_goodwill=i['cash']-net,low_price_case={'cash':i['alternative_cash'],'capital_change':i['alternative_cash']-shift}) i={'date':'2026-09-30','origin':'原非同一控制购买','old_share':D('.8'),'sold_share':D('.6'),'net_assets':1800,'subsidiary_assets':2500,'subsidiary_liabilities':700,'goodwill':240,'cash_price':1500,'remaining_fair_value':520,'cash_exited':100,'single_investment':1280,'other_group_assets':3200,'other_group_liabilities':1000,'oci':0,'alternative_remaining_fair_value':400} oldnet=i['old_share']*i['net_assets'];oldtotal=oldnet+i['goodwill'];remain=i['old_share']-i['sold_share'];gain=i['cash_price']+i['remaining_fair_value']-oldtotal;single_cost=i['single_investment']*i['sold_share']/i['old_share'];assetbefore=i['other_group_assets']+i['subsidiary_assets']+i['goodwill'];liabbefore=i['other_group_liabilities']+i['subsidiary_liabilities'];mb=(1-i['old_share'])*i['net_assets'];pb=assetbefore-liabbefore-mb;aa=i['other_group_assets']+i['cash_price']+i['remaining_fair_value'];la=i['other_group_liabilities'] put(6,i,remaining_share=remain,old_net_share=oldnet,old_total_with_goodwill=oldtotal,gain=gain,remaining_book_allocation=i['single_investment']*remain/i['old_share'],single_cost_sold=single_cost,simple_single_gain=i['cash_price']-single_cost,net_cash=i['cash_price']-i['cash_exited'],before={'assets':assetbefore,'liabilities':liabbefore,'parent':pb,'minority':mb},after={'assets':aa,'liabilities':la,'parent':aa-la,'minority':0},fair_value_down_case={'remaining_fair_value':i['alternative_remaining_fair_value'],'gain':i['cash_price']+i['alternative_remaining_fair_value']-oldtotal}) i={'purchase_date':'2026-07-01','old_share':D('.3'),'old_book':420,'old_fair_value':600,'new_share_bought':D('.4'),'new_cash':900,'fair_net_assets':1800,'cash_acquired':100,'oci':0,'common_control':False} share=i['old_share']+i['new_share_bought'];consideration=i['old_fair_value']+i['new_cash'];net=share*i['fair_net_assets'];put(7,i,total_share=share,old_remeasurement_gain=i['old_fair_value']-i['old_book'],deemed_consideration=consideration,net_assets_share=net,goodwill=consideration-net,minority=(1-share)*i['fair_net_assets'],net_cash_paid=i['new_cash']-i['cash_acquired'],wrong_historical_goodwill=i['old_book']+i['new_cash']-net,unchanged_value_case={'old_fair_value':i['old_book'],'gain':i['old_book']-i['old_book'],'goodwill':i['old_book']+i['new_cash']-net}) i={'acquisition_date':'2026-07-01','final_control_since':'2024-01-01','mother_current_revenue':3000,'mother_current_cost':2400,'mother_prior_revenue':2600,'mother_prior_cost':2200,'current_months':[{'month':m,'revenue':100+10*m,'cost':70+6*m} for m in range(1,13)],'prior_months':[{'month':m,'revenue':80+5*m,'cost':60+3*m} for m in range(1,13)],'internal_transactions':0,'alternative_final_control_since':'2026-03-01'} purchase_month=int(i['acquisition_date'][5:7]);monthly=[dict(x,profit=x['revenue']-x['cost'],common_included=True,noncommon_included=x['month']>=purchase_month) for x in i['current_months']];cases=[] for name,start,restated in [('同一控制',1,True),('非同一控制',purchase_month,False)]: cr=sum(x['revenue'] for x in monthly if x['month']>=start);cc=sum(x['cost'] for x in monthly if x['month']>=start);pr=sum(x['revenue'] for x in i['prior_months']) if restated else 0;pc=sum(x['cost'] for x in i['prior_months']) if restated else 0 cases.append({'type':name,'start_month':start,'target_revenue':cr,'target_cost':cc,'target_profit':cr-cc,'group_revenue':i['mother_current_revenue']+cr,'group_cost':i['mother_current_cost']+cc,'group_profit':i['mother_current_revenue']-i['mother_current_cost']+cr-cc,'prior_added_revenue':pr,'prior_added_cost':pc,'prior_added_profit':pr-pc,'prior_group_revenue':i['mother_prior_revenue']+pr,'prior_group_cost':i['mother_prior_cost']+pc,'prior_group_profit':i['mother_prior_revenue']-i['mother_prior_cost']+pr-pc}) put(8,i,monthly=monthly,cases=cases,excluded_first_half_profit=sum(x['profit'] for x in monthly if x['month']=int(i['alternative_final_control_since'][5:7])),'prior_added_profit':0}) i={'date':'2026-12-31','cases':[{'name':'甲','share':D('.4'),'other_shares':[D('.3'),D('.3')],'appointed':3,'board':5,'unanimous_relevant':False,'appointment_enforceable':True,'variable_returns':True,'principal':True,'facts_complete':True,'activity':'年度产品、产能与融资计划由董事会简单多数决定'}, {'name':'乙','share':D('.45'),'other_shares':[D('.3'),D('.25')],'appointed':2,'board':5,'unanimous_relevant':True,'appointment_enforceable':True,'variable_returns':True,'principal':True,'facts_complete':True,'activity':'经营预算、核心研发和融资均须三方一致同意'}, {'name':'丙','share':D('.42'),'other_shares':[D('.01')]*58,'appointed':None,'board':5,'unanimous_relevant':None,'appointment_enforceable':None,'variable_returns':True,'principal':True,'facts_complete':False,'activity':'股权分散已知,会议出席、代理及董事任免资料缺失'}]} rows=[] for x in i['cases']: power=None if not x['facts_complete'] else (not x['unanimous_relevant'] and x['appointment_enforceable'] and x['appointed']*2>x['board']) link=None if power is None else power and x['principal'];state='待核' if power is None else ('控制' if power and x['variable_returns'] and link else '不控制') rows.append({'name':x['name'],'share_total':x['share']+sum(x['other_shares']),'power':power,'variable_returns':x['variable_returns'],'power_return_link':link,'decision':state}) put(9,i,matrix=rows,missing_facts=['丙历届出席及表决记录','丙董事任免协议及执行障碍','丙潜在表决权','丙其他股东是否一致行动']) i={'date':'2026-12-31','ownership_of_subsidiary':D('1'),'P':{'cash':1000,'investment_S':600,'other_assets':2400,'liabilities':1500},'S_before':{'cash':500,'other_assets':700,'liabilities':600},'shares_bought':100,'price_per_share':2,'issued_shares':1000,'closing_market_price':D('2.6'),'classification_single':'以公允价值计量且变动计入损益;教学给定','dividends':0} cost=D(i['shares_bought'])*i['price_per_share'];fv=D(i['shares_bought'])*i['closing_market_price'];passets=sum(i['P'][k] for k in ['cash','investment_S','other_assets']);sassets=i['S_before']['cash']-cost+i['S_before']['other_assets']+fv;liab=i['P']['liabilities']+i['S_before']['liabilities'];ga=passets+sassets-i['P']['investment_S']-fv put(10,i,cost=cost,single_fair_value=fv,single_gain=fv-cost,P={'assets':passets,'liabilities':i['P']['liabilities'],'equity':passets-i['P']['liabilities']},S_after={'cash':i['S_before']['cash']-cost,'financial_asset':fv,'other_assets':i['S_before']['other_assets'],'assets':sassets,'liabilities':i['S_before']['liabilities'],'equity':sassets-i['S_before']['liabilities']},consolidated={'assets':ga,'liabilities':liab,'equity':ga-liab,'treasury_cost':cost,'group_gain':(fv-cost)-(fv-cost),'outstanding_shares':i['issued_shares']-i['shares_bought']},no_market_change={'single_asset':cost,'single_gain':0,'consolidated_equity':ga-liab},wrong_keep_asset={'assets':ga+fv,'equity':ga+fv-liab}) i={'purchase_date':'2026-07-01','share':D('.75'),'consideration':1500,'book_net_assets':1600,'asset_uplifts':[{'asset':'设备','amount':200},{'asset':'可辨认技术','amount':300},{'asset':'存货','amount':100}],'contingent_liability':80,'taxable_temporary_differences':600,'verified_tax_rate':D('.25'),'compensating_asset':0,'fees':0,'alternative_price':1400,'omitted_asset':'可辨认技术'} uplift=sum(x['amount'] for x in i['asset_uplifts']);dtl=i['taxable_temporary_differences']*i['verified_tax_rate'];net=i['book_net_assets']+uplift-i['contingent_liability']-dtl;share=net*i['share'];missing=sum(x['amount'] for x in i['asset_uplifts'] if x['asset']==i['omitted_asset']);badnet=i['book_net_assets']+uplift-missing-i['contingent_liability']-(i['taxable_temporary_differences']-missing)*i['verified_tax_rate'];good=i['consideration']-share put(11,i,asset_uplift_total=uplift,deferred_tax_liability=dtl,fair_net_assets=net,acquired_net_share=share,minority=net*(1-i['share']),goodwill=good,book_only_wrong_goodwill=i['consideration']-i['book_net_assets']*i['share'],omitted_technology={'deferred_tax':(i['taxable_temporary_differences']-missing)*i['verified_tax_rate'],'net_assets':badnet,'acquired_share':badnet*i['share'],'goodwill':i['consideration']-badnet*i['share'],'goodwill_overstatement':(net-badnet)*i['share']},low_price_case={'price':i['alternative_price'],'difference':i['alternative_price']-share,'status':'负差额须先复核,不列负商誉'}) # 显式保留文中多行桥:每个金额从上面的构造输入或计算结果继续派生。 a=out['DJ4-002'];i=a['inputs'];o=a['outputs'] o['opening_table']=[{'item':'原集团','original':i['original_cost'],'accumulated':i['opening_accumulated_depreciation'],'net':o['transfer_book'],'months':i['months_remaining']},{'item':'买方','original':i['transfer_price'],'accumulated':0,'net':i['transfer_price'],'months':i['months_remaining']}] a=out['DJ4-003'];i=a['inputs'];o=a['outputs'];rr=o['matrix'];g=sum(x['gross'] for x in rr);al=sum(x['closing_allowance'] for x in rr);ig=sum(x['gross'] for x in rr if x['internal']);ia=sum(x['closing_allowance'] for x in rr if x['internal']) o['balance_bridge']=[{'stage':'单体合计','gross':g,'allowance':al,'net':g-al,'internal_payable':sum(x['matched_payable'] for x in rr)},{'stage':'抵销变化','gross':-ig,'allowance':-ia,'net':-(ig-ia),'internal_payable':-sum(x['matched_payable'] for x in rr)},{'stage':'合并外部','gross':o['group_gross'],'allowance':o['group_allowance'],'net':o['group_net'],'internal_payable':0}] o['profit_bridge']=[] for entity in ['P','S']: before=i['before_impairment_profit'][entity];imp=sum(x['impairment'] for x in rr if x['creditor']==entity);restore=sum(x['impairment'] for x in rr if x['creditor']==entity and x['internal']);o['profit_bridge'].append({'entity':entity,'before':before,'impairment':-imp,'single':before-imp,'restore':restore,'group':before-imp+restore}) for id in ['DJ4-004','DJ4-005']: a=out[id];i=a['inputs'];o=a['outputs'];before_minor=(1-i['old_share'])*i['net_assets'];sign=-1 if id=='DJ4-004' else 1;afterasset=i['assets_before']+sign*i['cash'];beforetotal=i['parent_equity_before']+before_minor o['identity']=[{'stage':'交易前','assets':i['assets_before'],'liabilities':i['liabilities'],'parent':i['parent_equity_before'],'minority':before_minor,'equity':beforetotal},{'stage':'交易后','assets':afterasset,'liabilities':i['liabilities'],'parent':o['parent_equity_after'],'minority':o['minority_after'],'equity':o['total_equity_after']},{'stage':'变动','assets':sign*i['cash'],'liabilities':0,'parent':o['parent_equity_after']-i['parent_equity_before'],'minority':o['minority_after']-before_minor,'equity':o['total_equity_after']-beforetotal}] a=out['DJ4-004'];i=a['inputs'];o=a['outputs'];o['share_matrix']=[{'owner':'母','before':i['old_share'],'change':i['bought_share'],'after':o['new_share'],'net_before':i['net_assets']*i['old_share'],'net_after':i['net_assets']*o['new_share']},{'owner':'少数','before':1-i['old_share'],'change':-i['bought_share'],'after':1-o['new_share'],'net_before':o['minority_before'],'net_after':o['minority_after']}];o['waterfall']=[{'stage':'初始差额','opening':o['equity_difference'],'used':0,'remaining':o['equity_difference']},{'stage':'资本溢价','opening':o['equity_difference'],'used':o['capital_used'],'remaining':o['retained_used']},{'stage':'留存收益','opening':o['retained_used'],'used':o['retained_used'],'remaining':o['retained_used']-o['retained_used']}] a=out['DJ4-005'];i=a['inputs'];o=a['outputs'];o['redistribution']=[{'item':'净资产','before':i['net_assets']*i['old_share'],'shift':o['net_assets_shift'],'after':i['net_assets']*o['new_share']},{'item':'商誉','before':i['goodwill'],'shift':o['goodwill_shift'],'after':o['parent_goodwill_after']},{'item':'合计','before':i['net_assets']*i['old_share']+i['goodwill'],'shift':o['total_shift'],'after':i['net_assets']*o['new_share']+o['parent_goodwill_after']}] a=out['DJ4-006'];i=a['inputs'];o=a['outputs'];o['gain_bridge']=[{'item':'现金售价','amount':i['cash_price'],'cash':True},{'item':'剩余股权价值','amount':i['remaining_fair_value'],'cash':False},{'item':'原归母净资产','amount':-o['old_net_share'],'cash':False},{'item':'商誉','amount':-i['goodwill'],'cash':False},{'item':'投资收益','amount':o['gain'],'cash':False}];o['exit_bridge']=[{'item':k,'before':o['before'][k],'change':o['after'][k]-o['before'][k],'after':o['after'][k]} for k in ['assets','liabilities','minority','parent']];o['exit_bridge'].append({'item':'equity','before':o['before']['parent']+o['before']['minority'],'change':o['after']['parent']-o['before']['parent']-o['before']['minority'],'after':o['after']['parent']+o['after']['minority']}) a=out['DJ4-007'];i=a['inputs'];o=a['outputs'];o['three_tracks']=[{'item':'旧股','book_before':i['old_book'],'purchase_value':i['old_fair_value'],'cash_paid':0},{'item':'新股','book_before':None,'purchase_value':i['new_cash'],'cash_paid':i['new_cash']},{'item':'合计','book_before':i['old_book'],'purchase_value':o['deemed_consideration'],'cash_paid':i['new_cash']}] a=out['DJ4-009'];i=a['inputs'];o=a['outputs'];i['changed_appointment_case']={'base':'甲','appointment_enforceable':False,'other_control_rights':False};changed=i['changed_appointment_case'];power=changed['appointment_enforceable'] or changed['other_control_rights'];o['changed_case']={'name':'甲任免权不可执行','power':power,'decision':'控制' if power else '不控制(限定无其他权利)'} a=out['DJ4-010'];i=a['inputs'];o=a['outputs'];total=o['P']['assets']+o['S_after']['assets'];o['asset_bridge']=[{'item':'单体合计','amount':total},{'item':'抵销对子投资','amount':-i['P']['investment_S']},{'item':'消除母股资产','amount':-o['single_fair_value']},{'item':'合并资产','amount':o['consolidated']['assets']},{'item':'合并负债','amount':o['consolidated']['liabilities']},{'item':'合并权益','amount':o['consolidated']['equity']}];o['impact']={'cash_paid':o['cost'],'single_asset':o['single_fair_value'],'group_asset':o['single_fair_value']-o['single_fair_value'],'single_gain':o['single_gain'],'group_gain':o['single_gain']-o['single_gain'],'treasury_cost':o['cost']};o['before_purchase']={'assets':o['consolidated']['assets']+o['cost'],'liabilities':o['consolidated']['liabilities'],'equity':o['consolidated']['equity']+o['cost']} a=out['DJ4-011'];i=a['inputs'];o=a['outputs'];balance=i['book_net_assets'];bridge=[{'item':'账面净资产','change':balance,'balance':balance}] for x in i['asset_uplifts']: balance+=x['amount'];bridge.append({'item':x['asset'],'change':x['amount'],'balance':balance}) for item,amount in [('或有负债',-i['contingent_liability']),('递延税负债',-o['deferred_tax_liability'])]: balance+=amount;bridge.append({'item':item,'change':amount,'balance':balance}) o['net_asset_bridge']=bridge;o['omission_comparison']=[{'case':'完整','technology':sum(x['amount'] for x in i['asset_uplifts'] if x['asset']==i['omitted_asset']),'tax':o['deferred_tax_liability'],'net':o['fair_net_assets'],'share':o['acquired_net_share'],'goodwill':o['goodwill']},{'case':'遗漏','technology':0,'tax':o['omitted_technology']['deferred_tax'],'net':o['omitted_technology']['net_assets'],'share':o['omitted_technology']['acquired_share'],'goodwill':o['omitted_technology']['goodwill']}];o['omission_comparison'].append({'case':'遗漏减完整',**{k:o['omission_comparison'][1][k]-o['omission_comparison'][0][k] for k in ['technology','tax','net','share','goodwill']}}) assumptions={ 'DJ4-001':['母持子80%,全年控制及普通股分配比例不变','无期初存货、退货、减值和其他内部交易','单独给出顺流与逆流税前贡献,未计算所得税及递延税'], 'DJ4-002':['全资子公司持续内部持有;办公设备折旧直接计当期费用','剩余寿命与零残值不变,无减值、停用、税项及期中出售'], 'DJ4-003':['全资子公司;准备已在单体按适用规则确认','无核销、回收核销债权、汇兑及范围变动','不计算税项、内部利息及内部销售利润'], 'DJ4-004':['持续控制且普通股分配按持股比例;无一揽子、费用、税项及或有对价','净资产已按合并基础持续调整;现有商誉未减值;留存收益充足'], 'DJ4-005':['一次首次保留控制出售,原商誉全部归母','普通股分配按比例,无费用、税项、特殊分配与一揽子交易'], 'DJ4-006':['原非同一控制购买且一次丧控;保留股权不再逐项并表','无OCI或其他累计权益结转、费用、税项及未清内部交易','现金资格与剩余股权公允价值已核定;不决定剩余投资后续分类'], 'DJ4-007':['原股权采用权益法且原来只有重大影响;乙构成业务','无OCI、其他权益累计额、费用、补偿性资产、或有对价及内部交易','购买日公允价值与现金资格已核;不计算购买后损益'], 'DJ4-008':['全资收购、政策一致,无内部交易或购买基础后续调整','本年与上年利润均为所列收入减全部成本费用的税前简化结果','主案最终控制从2024年已存在,反例母公司早已受最终控制方控制'], 'DJ4-009':['三个独立制造企业均非投资性主体;除丙缺证部分外无潜在表决权与代理安排','只判断单方控制,不继续判乙共同控制或重大影响','文本中的证据事实为有效教学输入,不由算法确认真实合同效力'], 'DJ4-010':['全资子公司,原投资与子权益相等,无商誉和其他内部交易','单体金融资产分类为题设;无费用、税项、股利及其他损益','期末发行在外股数口径,不是年度加权EPS分母'], 'DJ4-011':['非同一控制、构成业务、一次取得控制;公允价值与项目资格已核','无原持股、费用、补偿性资产、或有对价与内部交易','给定税基与税率;或有负债无税影响,没有递延税资产;商誉本身不另算税项']} for identity,record in out.items(): record['inputs']['scenario']='构造教学样本' record['inputs']['amount_unit']='不适用,股权比例及证据状态' if identity=='DJ4-009' else ('人民币万元;股份万股;股价元每股' if identity=='DJ4-010' else '人民币万元') record['inputs']['assumptions']=assumptions[identity] record['inputs']['rounding']='中间不舍入,输出最多六位小数;本样本表内金额均精确' # 这些约束界定示例覆盖范围,不自动替未知合同或估值作判断。 assert len(out) == 11 assert all(0 <= x['sold'] <= x['units'] for x in out['DJ4-001']['inputs']['lots']) assert out['DJ4-005']['inputs']['control_retained'] is True assert out['DJ4-010']['inputs']['ownership_of_subsidiary'] == 1 assert out['DJ4-011']['outputs']['net_asset_bridge'][-1]['balance'] == out['DJ4-011']['outputs']['fair_net_assets'] return clean(out) if __name__ == '__main__': Path(__file__).with_suffix('.json').write_text(json.dumps(build(),ensure_ascii=False,indent=2,allow_nan=False)+'\n',encoding='utf-8',newline='\n')