⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fnbrcredence.pas

📁 详细的ERP设计资料
💻 PAS
📖 第 1 页 / 共 4 页
字号:
    +' ( select GoalUnitID from FNCredDetail where OriginTable='
    +Quotedstr('FNExpenseMaster_1')+' )'
    +' and a.ID in '
    +' ( select GoalUnitID from FNCredDetail where OriginTable='
    +Quotedstr('FNExpenseMaster')+' )'
    +' group by e.ID, a.ID,a.Code  ';
  VouchTranTemp.ExecSQL; //插入子表贷方金额===

  VouchTranTemp.Close;  //插入子表贷方金额---(付款帐户)
  VouchTranTemp.SQL.Text :=' Insert Into FNCredDetail ( '
    +' MasterID,GoodsID, PriceCost,GoalUnitID, OriginTable,GoodsSpec )'
    +' select '+NewVoucherID+' as MasterID , '
    +' e.ID as GoodsID, '
    +' sum(isnull(a.AmountC,0)*Isnull(ModeDC,1)*Isnull(ModeC,1))            '
    +' as PriceCost, a.ID  as GoalUnitID,               '
    +Quotedstr('FNExpenseMaster_2')+' as OriginTable , ( '
    +Quotedstr('费用报销:')+' +a.code) as Memo '
    +' from FNExpenseMaster a                                     '
    +' left outer join FNAccounts  b on b.ID=a.AccountsID       '
    +' left outer join DASubject d on d.ID=b.GeneralACID       '
    +' Left outer join DASubject e on                          '
    +'   e.RelativeTable='+Quotedstr('FNAccounts')+ ' and        '
    +'   e.RelativeID=a.AccountsID and substring(d.subCode,1,4)='
    +'   substring(e.subCode,1,4)'
    +' where a.RecordState<>'+Quotedstr('删除')
    +' and a.RecordState<>'+ Quotedstr('作废')
    +' and isnull(a.AmountC,0)<>0  and  a.date<='
    +Quotedstr(DateToStr(FEndDate))+' and a.ID not in '
    +' ( select GoalUnitID from FNCredDetail where OriginTable='
    +Quotedstr('FNExpenseMaster_2')+' )'
    +' and a.ID in '
    +' ( select GoalUnitID from FNCredDetail where OriginTable='
    +Quotedstr('FNExpenseMaster')+' )'
    +' group by a.ID,e.ID, a.Code  ';

//  Memo1.Text := VouchTranTemp.SQL.Text ;

  VouchTranTemp.ExecSQL; //插入子表贷方金额---


end;

procedure TFNCredenceBrowseForm.DoingCase7;
begin
  if VourchTranIniADS.FieldByName('Code').AsString<>'是' then Exit;
// 转换资金调动
  VouchTranTemp.Close;
  VouchTranTemp.SQL.Text :=' select ID from FNCashOutInMaster '
    +' where RecordState<>'+Quotedstr('删除')
    +' and RecordState<>'+ Quotedstr('作废')+' and '
    +' ID not in (select GoalUnitID from FNCredDetail where '
    +' OriginTable=' +Quotedstr('FNCashOutInMaster')
    +' ) and  Date<=' +Quotedstr(DateToStr(FEndDate));

  VouchTranTemp.Open;

  if VouchTranTemp.IsEmpty then exit;
  NewVoucherCode :=GetMaxCode('Code','FNCredMaster',number);
  VouchTranTemp.Close;
  VouchTranTemp.SQL.Text :=' Insert into FNCredMaster ( '
    +' CreateUserID,Code,Date,BillMode,ModeDC,ModeC,Brief,Memo)'
    +' Values ( '+Inttostr(Guarder.UserID)+' , '+ Quotedstr(NewVoucherCode)
    +' , '+Quotedstr(DateToStr(FEndDate))+' , '+ Quotedstr('自动转换')
    +' , 1, 1 ,'+ Quotedstr('自动转换')+' , '+ Quotedstr('资金调动自动转换凭证')
    +' ) ';
  VouchTranTemp.ExecSQL;  //插入凭证头

  VouchTranTemp.Close;
  VouchTranTemp.SQL.Text :=' select ID from FNCredMaster where Code='
    +Quotedstr(NewVoucherCode);
  VouchTranTemp.Open;
  NewVoucherID :=Inttostr(VouchTranTemp.fieldbyname('ID').AsInteger);

  VouchTranTemp.Close;  //插入子表贷方金额---(调出帐户)
  VouchTranTemp.SQL.Text :=' Insert Into FNCredDetail ( '
    +' MasterID,GoodsID, PriceCost,GoalUnitID, OriginTable,GoodsSpec )'
    +' select '+NewVoucherID+' as MasterID , '
    +' e.ID as GoodsID, '
    +' sum(isnull(a.AmountD,0)*Isnull(ModeDC,1)*Isnull(ModeC,1))            '
    +' as PriceCost, a.ID  as GoalUnitID,               '
    +Quotedstr('FNCashOutInMaster')+' as OriginTable , ( '
    +Quotedstr('资金调动:')+' +a.code) as Memo '
    +' from FNCashOutInMaster a                                     '
    +' left outer join FNAccounts  b on b.ID=a.ClientID       '
    +' left outer join DASubject d on d.ID=b.GeneralACID       '
    +' Left outer join DASubject e on                          '
    +'   e.RelativeTable='+Quotedstr('FNAccounts')+ ' and        '
    +'   e.RelativeID=a.ClientID and substring(d.subCode,1,4)='
    +'   substring(e.subCode,1,4)'
    +' where a.RecordState<>'+Quotedstr('删除')
    +' and a.RecordState<>'+ Quotedstr('作废')
    +' and isnull(a.AmountD,0)<>0  and  a.date<='
    +Quotedstr(DateToStr(FEndDate))+' and a.ID not in '
    +' ( select GoalUnitID from FNCredDetail where OriginTable='
    +Quotedstr('FNCashOutInMaster')+' )'
    +' group by a.ID,e.ID, a.Code  ';
  VouchTranTemp.ExecSQL; //插入子表贷方金额---调出

  VouchTranTemp.Close;  //插入子表借方金额===调入
  VouchTranTemp.SQL.Text :=' Insert Into FNCredDetail ( '
    +' MasterID,GoodsID, PriceBase,GoalUnitID, OriginTable,GoodsSpec )'
    +' select '+NewVoucherID+' as MasterID , '
    +' e.ID as GoodsID, '
    +' sum(isnull(a.AmountD,0)*Isnull(ModeDC,1)*Isnull(ModeC,1))            '
    +' as PriceBase, a.ID  as GoalUnitID,               '
    +Quotedstr('FNCashOutInMaster_1')+' as OriginTable , ( '
    +Quotedstr('资金调动:')+' +a.code) as Memo '
    +' from FNCashOutInMaster a                                     '
    +' left outer join FNAccounts  b on b.ID=a.AccountsID       '
    +' left outer join DASubject d on d.ID=b.GeneralACID       '
    +' Left outer join DASubject e on                          '
    +'   e.RelativeTable='+Quotedstr('FNAccounts')+ ' and        '
    +'   e.RelativeID=a.AccountsID and substring(d.subCode,1,4)='
    +'   substring(e.subCode,1,4)'
    +' where a.RecordState<>'+Quotedstr('删除')
    +' and a.RecordState<>'+ Quotedstr('作废')
    +' and isnull(a.AmountD,0)<>0  and  a.date<='
    +Quotedstr(DateToStr(FEndDate))+' and a.ID not in '
    +' ( select GoalUnitID from FNCredDetail where OriginTable='
    +Quotedstr('FNCashOutInMaster_1')+' )'
    +' and a.ID in '
    +' ( select GoalUnitID from FNCredDetail where OriginTable='
    +Quotedstr('FNCashOutInMaster')+' )'
    +' group by a.ID,e.ID, a.Code  ';
//  Memo1.Text :=   VouchTranTemp.SQL.Text ;
  VouchTranTemp.ExecSQL; //插入子表借方金额===调入
end;

procedure TFNCredenceBrowseForm.DoingCase8;
begin
  if VourchTranIniADS.FieldByName('Code').AsString<>'是' then Exit;
// exit;
//转换采购成本
  VouchTranTemp.Close;
  VouchTranTemp.SQL.Text :=' select ID from STGoodsOutCostMaster '
    +' where RecordState<>'+Quotedstr('删除')
    +' and RecordState<>'+ Quotedstr('作废')
    +' and BillMode='+ Quotedstr('采购成本核算')+ ' and '
    +' ID not in (select GoalUnitID from FNCredDetail where '
    +' OriginTable=' +Quotedstr('STGoodsOutCostMaster')
    +' ) and  Date<=' +Quotedstr(DateToStr(FEndDate));
  VouchTranTemp.Open;
  if VouchTranTemp.IsEmpty then exit;

  VouchTranTemp.Close;  //汇总转换金额
  VouchTranTemp.SQL.Text :=' select '
    +' sum(isnull(b.Amount,0)*Isnull(ModeDC,1)*Isnull(ModeC,1)) as AmountA  ,    '
    +' sum(isnull(b.SundryFee,0)*Isnull(ModeDC,1)*Isnull(ModeC,1)) as AmountA1      '
    +' from STGoodsOutCostMaster a                             '
    +' left outer join STGoodsOutCostDetail b on b.MasterID=a.ID       '
    +' where a.RecordState<>'+Quotedstr('删除')
    +' and a.RecordState<>'+ Quotedstr('作废')
    +' and BillMode='+ Quotedstr('采购成本核算')
    +' and a.date<='
    +Quotedstr(DateToStr(FEndDate))+' and a.ID not in '
    +' ( select GoalUnitID from FNCredDetail where OriginTable='
    +Quotedstr('STGoodsOutCostMaster')+' )' ;
  VouchTranTemp.Open;//汇总转换金额
  AmountA := VouchTranTemp.FieldByName('AmountA').AsFloat+
     VouchTranTemp.FieldByName('AmountA1').AsFloat;
  VouchTranTemp.Close;  //汇总转换金额
  VouchTranTemp.SQL.Text :=' select '
    +' sum(isnull(a.IndirectFee,0)*Isnull(ModeDC,1)*Isnull(ModeC,1)) as AmountB     '
    +' from STGoodsOutCostMaster a                             '
    +' where a.RecordState<>'+Quotedstr('删除')
    +' and a.RecordState<>'+ Quotedstr('作废')
    +' and BillMode='+ Quotedstr('采购成本核算')
    +' and isnull(a.IndirectFee,0)<>0 and a.date<='
    +Quotedstr(DateToStr(FEndDate))+' and a.ID not in '
    +' ( select GoalUnitID from FNCredDetail where OriginTable='
    +Quotedstr('STGoodsOutCostMaster')+' )' ;
  VouchTranTemp.Open;//汇总转换金额
  AmountB := VouchTranTemp.FieldByName('AmountB').AsFloat ;

  NewVoucherCode :=GetMaxCode('Code','FNCredMaster',number);
  VouchTranTemp.Close;
  VouchTranTemp.SQL.Text :=' Insert into FNCredMaster ( '
    +' CreateUserID,Code,Date,BillMode,ModeDC,ModeC,Brief,Memo)'
    +' Values ( '+Inttostr(Guarder.UserID)+' , '+ Quotedstr(NewVoucherCode)
    +' , '+Quotedstr(DateToStr(FEndDate))+' , '+ Quotedstr('自动转换')
    +' , 1, 1 ,'+ Quotedstr('自动转换')+' , '+ Quotedstr('采购成本核算自动转换凭证')
    +' ) ';
  VouchTranTemp.ExecSQL;  //插入凭证头
  VouchTranTemp.Close;
  VouchTranTemp.SQL.Text :=' select ID from FNCredMaster where Code='
    +Quotedstr(NewVoucherCode);
  VouchTranTemp.Open;
  NewVoucherID :=Inttostr(VouchTranTemp.fieldbyname('ID').AsInteger);
  VouchTranTemp.Close;  //插入子表借方金额---
  VouchTranTemp.SQL.Text :=' Insert Into FNCredDetail ( '
    +' MasterID,GoodsID, PriceBase,GoalUnitID, OriginTable,GoodsSpec )'
    +' select '+NewVoucherID+' as MasterID ,'
    +' e.ID as GoodsID, '
    +' (sum(isnull(b.Amount,0)*Isnull(ModeDC,1)*Isnull(ModeC,1))                   '
    +' +sum(isnull(b.SundryFee,0)*Isnull(ModeDC,1)*Isnull(ModeC,1)))               '
    +' as PriceBase, a.ID  as GoalUnitID,               '
    +Quotedstr('STGoodsOutCostMaster')+' as OriginTable , ( '
    +Quotedstr('采购成本核算:')+' +a.code) as Memo '
    +' from STGoodsOutCostMaster a                                     '
    +' left outer join STGoodsOutCostDetail b on b.MasterID=a.ID       '
    +' left outer join DaGoods c on c.ID=b.GoodsID           '
    +' left outer join DaGoodsClass  I on I.ID=C.GoodsClassID           '
    +' left outer join DASubject d on d.ID=I.GeneralACID       '
    +' Left outer join DASubject e on                          '
    +'   e.RelativeTable='+Quotedstr('DAGoods')+ ' and        '
    +'   e.RelativeID=b.GoodsID and substring(d.subCode,1,4)='
    +'   substring(e.subCode,1,4)'
    +' where a.RecordState<>'+Quotedstr('删除')
    +' and a.RecordState<>'+ Quotedstr('作废')
    +' and BillMode='+ Quotedstr('采购成本核算')
    +' and (isnull(b.Amount,0)+isnull(b.SundryFee,0) )<>0 and a.date<='
    +Quotedstr(DateToStr(FEndDate))+' and a.ID not in '
    +' ( select GoalUnitID from FNCredDetail where OriginTable='
    +Quotedstr('STGoodsOutCostMaster')+' )'
    +' group by a.ID,e.ID, a.Code  ';
  VouchTranTemp.ExecSQL; //插入子表借方金额---

  if AmountA<>0 then
  begin
    VouchTranTemp.Close;  //插入子表贷方金额====
    VouchTranTemp.SQL.Text :=' Insert Into FNCredDetail ( '
      +' MasterID,GoodsID, PriceCost,GoodsSpec )'
      +' Values ( '+NewVoucherID+'   ,'
      + Inttostr(VourchTranIniADS.FieldByName('AccountFID').AsInteger)
      +' , ' + Floattostr(AmountA-AmountB)+' , '
      +Quotedstr('采购成本核算')+' ) ';
    VouchTranTemp.ExecSQL; //插入子表贷方金额 ====
  end;
  if AmountB<>0 then
  begin
    VouchTranTemp.Close;  //插入子表贷方金额****
    VouchTranTemp.SQL.Text :=' Insert Into FNCredDetail ( '
      +' MasterID,GoodsID, PriceCost,GoodsSpec,Memo)'
      +' Values ( '+NewVoucherID + ' ,'
      + Inttostr(VourchTranIniADS.FieldByName('AccountGID').AsInteger)
      + ' , '   + Floattostr(AmountB)+' , '
      +Quotedstr('间接费用')+' , '
      +Quotedstr('间接费用分摊')+' ) ';
    VouchTranTemp.ExecSQL; //插入子表贷方金额****
  end;
//转换完成后,关闭转换参数
  VourchTranIniADS.Edit;
  VourchTranIniADS.FieldByName('Code').AsString :='否';
  VourchTranIniADS.Post;
end;

procedure TFNCredenceBrowseForm.DoingCase9;
begin
//外币兑换
  if VourchTranIniADS.FieldByName('Code').AsString<>'是' then Exit;
//
//转换完成后,关闭转换参数
  VourchTranIniADS.Edit;
  VourchTranIniADS.FieldByName('Code').AsString :='否';
  VourchTranIniADS.Post;

end;

procedure TFNCredenceBrowseForm.DoingCaseA;
begin
//领料成本核算
  if VourchTranIniADS.FieldByName('Code').AsString<>'是' then Exit;
//
//转换完成后,关闭转换参数
  VourchTranIniADS.Edit;
  VourchTranIniADS.FieldByName('Code').AsString :='否';
  VourchTranIniADS.Post;
end;

procedure TFNCredenceBrowseForm.DoingCaseB;
begin
//外发加工核算
  if VourchTranIniADS.FieldByName('Code').AsString<>'是' then Exit;
//
//转换完成后,关闭转换参数
  VourchTranIniADS.Edit;
  VourchTranIniADS.FieldByName('Code').AsString :='否';
  VourchTranIniADS.Post;
end;

procedure TFNCredenceBrowseForm.DoingCaseC;
begin
//生产成本核算

//转换完成后,关闭转换参数
  VourchTranIniADS.Edit;
  VourchTranIniADS.FieldByName('Code').AsString :='否';
  VourchTranIniADS.Post;
end;

procedure TFNCredenceBrowseForm.DoingCaseD;
begin
//销售成本核算
  if VourchTranIniADS.FieldByName('Code').AsString<>'是' then Exit;
//
//转换完成后,关闭转换参数
  VourchTranIniADS.Edit;
  VourchTranIniADS.FieldByName('Code').AsString :='否';
  VourchTranIniADS.Post;
end;

procedure TFNCredenceBrowseForm.ToolButton6Click(Sender: TObject);
begin
  Application.CreateForm(TFNVouchTranIniForm, FNVouchTranIniForm);
  FNVouchTranIniForm.ShowModal;
  FNVouchTranIniForm.Free;
end;


end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -