Pārlūkot izejas kodu

合同支付,计算问题

MaiXinRong 5 gadi atpakaļ
vecāks
revīzija
2aaacef2dd
3 mainītis faili ar 25 papildinājumiem un 4 dzēšanām
  1. 10 0
      DataModules/DealPaymentDm.pas
  2. 14 4
      DataModules/PhasePayDm.pas
  3. 1 0
      Units/PhaseData.pas

+ 10 - 0
DataModules/DealPaymentDm.pas

@@ -54,6 +54,7 @@ type
     function CheckReachPlan(ARec: TsdDataRecord): Boolean;
     function GetAllowTotalPrice(AID: Integer; ATotalPrice, APreTotalPrice: Double): Double;
     procedure UpdateTotalPrice(AID: Integer; ATotalPrice: Double);
+    procedure SetTotalPrice(AID: Integer; ATotalPrice: Double);
 
     function DealPayRecord(const AName: string): TsdDataRecord;
 
@@ -785,4 +786,13 @@ begin
   Allow := VarToStrDef(ARecord.ValueByName('Name').CachedValue, '') <> '';
 end;
 
+procedure TDealPaymentData.SetTotalPrice(AID: Integer;
+  ATotalPrice: Double);
+var
+  Rec: TsdDataRecord;
+begin
+  Rec := sddDealPayment.FindKey('idxID', AID);
+  Rec.ValueByName('TotalPrice').AsFloat := ATotalPrice;
+end;
+
 end.

+ 14 - 4
DataModules/PhasePayDm.pas

@@ -167,7 +167,7 @@ begin
     with TProjectData(TPhaseData(FPhaseData).ProjectData).DealPaymentData do
       UpdateTotalPrice(AValue.Owner.ValueByName('ID').AsInteger, AValue.AsFloat - FBeforeChangeTotalPrice);
   end;
-  CalculateCurPay;      
+  CalculateCurPay;
 end;
 
 procedure TPhasePayData.CalculateAll;
@@ -183,8 +183,7 @@ begin
     Rec := sddPhasePay.Records[iIndex];
     if GetCalcType(Rec.ValueByName('ID').AsInteger) in [0, 3] then
       Calculate(Rec.ValueByName('ID').AsInteger);
-  end;
-  CalculateCurPay;
+  end;  CalculateCurPay;
 end;
 
 procedure TPhasePayData.Calculate(AID: Integer);
@@ -249,6 +248,8 @@ begin
   // ¼ÆËã½ØÖ¹Êý¾Ý
   Rec.ValueByName('End' + sTPField).AsFloat := FDecimal.TotalPrice.RoundTo(Rec.ValueByName(sTPField).AsFloat
       + Rec.ValueByName('Pre' + sTPField).AsFloat);
+  with TProjectData(TPhaseData(FPhaseData).ProjectData).DealPaymentData do
+    SetTotalPrice(AID, Rec.ValueByName('End' + sTPField).AsFloat);
 end;
 
 function TPhasePayData.GetPayablePrice(AIndex: Integer): Double;
@@ -478,11 +479,14 @@ procedure TPhasePayData.CopyPrePhasePayData(const APreFile: string;
 const
   sCopySql = 'Insert Into %s (' +
              '    ID, PreTotalPrice0, EndTotalPrice0, Formula0, StopCalc' +
-             '  ) Select ID, PreTotalPrice%d, EndTotalPrice%d, Formula%d, StopCalc' +
+             '  ) Select ID, EndTotalPrice%d, EndTotalPrice%d, Formula%d, StopCalc' +
              ' From %s' +
              ' In ''%s''';
 var
   sPre, sSql: string;
+  i: Integer;
+  vRec: TsdDataRecord;
+  fValue: Double;
 begin
   try
     sSql := Format(sCopySql, [TableName, APreFinalIndex, APreFinalIndex,
@@ -490,6 +494,12 @@ begin
     ExecuteSql(TPhaseData(FPhaseData).ADOConnection, sSql);
   finally
     sddPhasePay.Reload;
+    for i := 0 to sddPhasePay.RecordCount - 1 do
+    begin
+      vRec := sddPhasePay.Records[i];
+      if TryStrToFloat(vRec.ValueByName('Formula0').AsString, fValue) then
+        vRec.ValueByName('Formula0').AsString := '';
+    end;
   end;
 end;
 

+ 1 - 0
Units/PhaseData.pas

@@ -240,6 +240,7 @@ begin
 
     StageData.CopyPrePhaseData(sTempFile, FPrePhaseData.StageTableName[FPrePhaseData.PhaseProperty.AuditCount]);
     PhasePayData.CopyPrePhasePayData(sTempFile, FPrePhaseData.PhaseProperty.AuditCount);
+    PhasePayData.CalculateAll;
   finally  
     DeleteFile(sTempFile);
     FPrePhaseData.Free;