Explorar el Código

合同支付单独设置小数位数

MaiXinRong hace 8 años
padre
commit
bf10713780

+ 2 - 0
DataModules/DealPaymentDm.pas

@@ -102,6 +102,8 @@ begin
   inherited Create(nil);
   FProjectData := AProjectData;
   FPayFormula := TPayFormula.Create(FProjectData);
+  with TProjectData(FProjectData) do
+    FPayFormula.Decimal := ProjProperties.DecimalManager.DealPay;
 end;
 
 destructor TDealPaymentData.Destroy;

+ 2 - 0
DataModules/PhasePayDm.pas

@@ -73,6 +73,8 @@ begin
   inherited Create(nil);
   FPhaseData := APhaseData;
   FPayFormula := TPayFormula.Create(TPhaseData(FPhaseData).ProjectData);
+  with TProjectData(TPhaseData(FPhaseData).ProjectData) do
+    FPayFormula.Decimal := ProjProperties.DecimalManager.DealPay;
 end;
 
 procedure TPhasePayData.Delete(AID: Integer);

+ 85 - 55
Forms/ProjectPropertiesFrm.dfm

@@ -225,8 +225,8 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           Width = 438
           Height = 247
           HorzScrollBar.Range = 401
-          VertScrollBar.Position = 782
-          VertScrollBar.Range = 1133
+          VertScrollBar.Position = 789
+          VertScrollBar.Range = 1180
           Align = alClient
           AutoScroll = False
           BevelInner = bvNone
@@ -243,7 +243,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           OnVScroll = msbBaseVScroll
           object lblDealInfo: TLabel
             Left = 7
-            Top = -778
+            Top = -785
             Width = 48
             Height = 12
             Caption = #21512#21516#20449#24687
@@ -256,28 +256,28 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object lblBuilder: TLabel
             Left = 34
-            Top = -674
+            Top = -681
             Width = 60
             Height = 12
             Caption = #24314#35774#21333#20301#65306
           end
           object lblConstructor: TLabel
             Left = 34
-            Top = -590
+            Top = -597
             Width = 60
             Height = 12
             Caption = #25215#21253#21333#20301#65306
           end
           object lblSupervisor: TLabel
             Left = 34
-            Top = -506
+            Top = -513
             Width = 60
             Height = 12
             Caption = #30417#29702#21333#20301#65306
           end
           object lblTechParameters: TLabel
             Left = 7
-            Top = -411
+            Top = -418
             Width = 48
             Height = 12
             Caption = #25216#26415#21442#25968
@@ -290,14 +290,14 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object lblLoadLevel: TLabel
             Left = 34
-            Top = -389
+            Top = -396
             Width = 60
             Height = 12
             Caption = #20844#36335#31561#32423#65306
           end
           object lblDealPayTitle: TLabel
             Left = 7
-            Top = -251
+            Top = -258
             Width = 48
             Height = 12
             Caption = #21512#21516#25903#20184
@@ -310,7 +310,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object lblSafeTitel: TLabel
             Left = 7
-            Top = -147
+            Top = -154
             Width = 48
             Height = 12
             Caption = #25991#20214#23433#20840
@@ -323,14 +323,14 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object lblUnlockPassword: TLabel
             Left = 36
-            Top = -123
+            Top = -130
             Width = 84
             Height = 12
             Caption = #35299#38145#33410#28857#23494#30721#65306
           end
           object lblPasswordHint: TLabel
             Left = 128
-            Top = -122
+            Top = -129
             Width = 90
             Height = 12
             Caption = 'lblPasswordHint'
@@ -344,7 +344,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object lblCalcParametersTitel: TLabel
             Left = 7
-            Top = -19
+            Top = -26
             Width = 48
             Height = 12
             Caption = #35745#31639#21442#25968
@@ -355,16 +355,16 @@ object ProjectPropertiesForm: TProjectPropertiesForm
             Font.Style = []
             ParentFont = False
           end
-          object Label1: TLabel
+          object lblDigit: TLabel
             Left = 36
-            Top = 5
+            Top = -2
             Width = 84
             Height = 12
             Caption = #20445#30041#23567#25968#20301#25968#65306
           end
           object lblDateTime: TLabel
             Left = 7
-            Top = 108
+            Top = 147
             Width = 48
             Height = 12
             Caption = #26102#38388#21442#25968
@@ -377,21 +377,21 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object lblBaseline: TLabel
             Left = 36
-            Top = 131
+            Top = 170
             Width = 60
             Height = 12
             Caption = #36215#22987#26085#26399#65306
           end
           object lblDeadline: TLabel
             Left = 36
-            Top = 155
+            Top = 194
             Width = 60
             Height = 12
             Caption = #25130#27490#26085#26399#65306
           end
           object lblDateHint: TLabel
             Left = 37
-            Top = 176
+            Top = 215
             Width = 192
             Height = 12
             Caption = #24403#21069#25130#27490#26085#26399' '#65308' '#36215#22987#26085#26399#65292#35831#26680#26597
@@ -404,7 +404,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object pnlDealInfoBar: TPanel
             Left = 62
-            Top = -773
+            Top = -780
             Width = 339
             Height = 2
             BevelOuter = bvLowered
@@ -412,7 +412,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object leProjectName: TLabeledEdit
             Left = 33
-            Top = -746
+            Top = -753
             Width = 330
             Height = 18
             Ctl3D = False
@@ -424,7 +424,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object leDealName: TLabeledEdit
             Left = 33
-            Top = -706
+            Top = -713
             Width = 152
             Height = 18
             Ctl3D = False
@@ -436,7 +436,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object leDealIndex: TLabeledEdit
             Left = 195
-            Top = -706
+            Top = -713
             Width = 80
             Height = 18
             Ctl3D = False
@@ -448,7 +448,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object leBName: TLabeledEdit
             Left = 101
-            Top = -659
+            Top = -666
             Width = 261
             Height = 18
             Ctl3D = False
@@ -460,7 +460,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object leBLegal: TLabeledEdit
             Left = 101
-            Top = -618
+            Top = -625
             Width = 137
             Height = 18
             Ctl3D = False
@@ -472,7 +472,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object leBDate: TLabeledEdit
             Left = 245
-            Top = -618
+            Top = -625
             Width = 119
             Height = 18
             Ctl3D = False
@@ -484,7 +484,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object leCName: TLabeledEdit
             Left = 101
-            Top = -575
+            Top = -582
             Width = 262
             Height = 18
             Ctl3D = False
@@ -496,7 +496,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object leCLegal: TLabeledEdit
             Left = 101
-            Top = -534
+            Top = -541
             Width = 137
             Height = 18
             Ctl3D = False
@@ -508,7 +508,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object leCDate: TLabeledEdit
             Left = 245
-            Top = -534
+            Top = -541
             Width = 119
             Height = 18
             Ctl3D = False
@@ -520,7 +520,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object leSName: TLabeledEdit
             Left = 101
-            Top = -491
+            Top = -498
             Width = 262
             Height = 18
             Ctl3D = False
@@ -532,7 +532,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object leSLegal: TLabeledEdit
             Left = 101
-            Top = -451
+            Top = -458
             Width = 137
             Height = 18
             Ctl3D = False
@@ -544,7 +544,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object leSDate: TLabeledEdit
             Left = 245
-            Top = -451
+            Top = -458
             Width = 119
             Height = 18
             Ctl3D = False
@@ -556,7 +556,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object pnlTechParametersBar: TPanel
             Left = 62
-            Top = -406
+            Top = -413
             Width = 339
             Height = 2
             BevelOuter = bvLowered
@@ -564,7 +564,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object leStartPeg: TLabeledEdit
             Left = 34
-            Top = -331
+            Top = -338
             Width = 132
             Height = 18
             Ctl3D = False
@@ -576,7 +576,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object leEndPeg: TLabeledEdit
             Left = 176
-            Top = -331
+            Top = -338
             Width = 131
             Height = 18
             Ctl3D = False
@@ -588,7 +588,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object leLength: TLabeledEdit
             Left = 34
-            Top = -291
+            Top = -298
             Width = 132
             Height = 18
             Ctl3D = False
@@ -600,7 +600,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object leLaneCount: TLabeledEdit
             Left = 176
-            Top = -291
+            Top = -298
             Width = 132
             Height = 18
             Ctl3D = False
@@ -612,7 +612,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object cbLoadLevel: TComboBox
             Left = 34
-            Top = -372
+            Top = -379
             Width = 132
             Height = 20
             Ctl3D = False
@@ -629,7 +629,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object pnlDealPayBar: TPanel
             Left = 62
-            Top = -245
+            Top = -252
             Width = 339
             Height = 2
             BevelOuter = bvLowered
@@ -637,7 +637,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object leContractPrice: TLabeledEdit
             Left = 133
-            Top = -230
+            Top = -237
             Width = 117
             Height = 18
             BiDiMode = bdLeftToRight
@@ -655,7 +655,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object leStartedSubsist: TLabeledEdit
             Left = 133
-            Top = -203
+            Top = -210
             Width = 118
             Height = 18
             Ctl3D = False
@@ -669,7 +669,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object leMaterialSubsist: TLabeledEdit
             Left = 133
-            Top = -177
+            Top = -184
             Width = 119
             Height = 18
             Ctl3D = False
@@ -683,7 +683,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object pnlSafeBar: TPanel
             Left = 62
-            Top = -141
+            Top = -148
             Width = 339
             Height = 2
             BevelOuter = bvLowered
@@ -691,7 +691,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object pnlUnlockPassword: TPanel
             Left = 40
-            Top = -109
+            Top = -116
             Width = 361
             Height = 85
             BevelOuter = bvNone
@@ -919,7 +919,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object leDealType: TLabeledEdit
             Left = 283
-            Top = -706
+            Top = -713
             Width = 80
             Height = 18
             Ctl3D = False
@@ -931,7 +931,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object pnlCalcParametersBar: TPanel
             Left = 62
-            Top = -13
+            Top = -20
             Width = 339
             Height = 2
             BevelOuter = bvLowered
@@ -939,7 +939,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object leQuantityDigit: TLabeledEdit
             Left = 100
-            Top = 22
+            Top = 15
             Width = 87
             Height = 18
             EditLabel.Width = 36
@@ -951,7 +951,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object leTotalPriceDigit: TLabeledEdit
             Left = 264
-            Top = 22
+            Top = 15
             Width = 87
             Height = 18
             EditLabel.Width = 36
@@ -963,7 +963,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object udQuantity: TUpDown
             Left = 187
-            Top = 22
+            Top = 15
             Width = 16
             Height = 18
             Associate = leQuantityDigit
@@ -973,7 +973,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object udTotalPrice: TUpDown
             Left = 351
-            Top = 22
+            Top = 15
             Width = 16
             Height = 18
             Associate = leTotalPriceDigit
@@ -982,9 +982,9 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object gbPM_Digit: TGroupBox
             Left = 52
-            Top = 48
+            Top = 94
             Width = 349
-            Height = 49
+            Height = 44
             Caption = #20215#24046
             TabOrder = 31
             Visible = False
@@ -1012,7 +1012,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object pnlDateTime: TPanel
             Left = 62
-            Top = 114
+            Top = 153
             Width = 339
             Height = 2
             BevelOuter = bvLowered
@@ -1020,7 +1020,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object dtpBaseline: TDateTimePicker
             Left = 104
-            Top = 127
+            Top = 166
             Width = 105
             Height = 20
             Date = 0.457352881945553200
@@ -1031,7 +1031,7 @@ object ProjectPropertiesForm: TProjectPropertiesForm
           end
           object dtpDeadline: TDateTimePicker
             Left = 104
-            Top = 151
+            Top = 190
             Width = 105
             Height = 20
             Date = 0.457352881945553200
@@ -1040,6 +1040,36 @@ object ProjectPropertiesForm: TProjectPropertiesForm
             TabOrder = 34
             OnChange = dtpBaselineChange
           end
+          object cbDealPayAloneDigiy: TCheckBox
+            Left = 62
+            Top = 42
+            Width = 131
+            Height = 17
+            Caption = #21512#21516#25903#20184#21333#29420#35774#32622
+            TabOrder = 35
+            OnClick = cbDealPayAloneDigiyClick
+          end
+          object leDealPayTotalPriceDigit: TLabeledEdit
+            Left = 100
+            Top = 66
+            Width = 87
+            Height = 18
+            EditLabel.Width = 36
+            EditLabel.Height = 12
+            EditLabel.Caption = #37329#39069#65306
+            LabelPosition = lpLeft
+            TabOrder = 36
+            Text = '0'
+          end
+          object udDealPayTotalPriceDigit: TUpDown
+            Left = 187
+            Top = 66
+            Width = 16
+            Height = 18
+            Associate = leDealPayTotalPriceDigit
+            Max = 10
+            TabOrder = 37
+          end
         end
       end
     end

+ 26 - 4
Forms/ProjectPropertiesFrm.pas

@@ -95,7 +95,7 @@ type
     pnlCalcParametersBar: TPanel;
     lblCalcParametersTitel: TLabel;
     leQuantityDigit: TLabeledEdit;
-    Label1: TLabel;
+    lblDigit: TLabel;
     leTotalPriceDigit: TLabeledEdit;
     udQuantity: TUpDown;
     udTotalPrice: TUpDown;
@@ -114,6 +114,9 @@ type
     lblDeadline: TLabel;
     dtpDeadline: TDateTimePicker;
     lblDateHint: TLabel;
+    cbDealPayAloneDigiy: TCheckBox;
+    leDealPayTotalPriceDigit: TLabeledEdit;
+    udDealPayTotalPriceDigit: TUpDown;
     procedure btnOkClick(Sender: TObject);
     procedure leContractPriceClick(Sender: TObject);
     procedure msbBaseMouseWheel(Sender: TObject; Shift: TShiftState;
@@ -138,6 +141,7 @@ type
     procedure leUnlockPasswordExit(Sender: TObject);
     procedure cbShowReportShadingClick(Sender: TObject);
     procedure dtpBaselineChange(Sender: TObject);
+    procedure cbDealPayAloneDigiyClick(Sender: TObject);
   private
     FProjectData: TProjectData;
     FStaffData: TStaffData;
@@ -326,7 +330,7 @@ begin
     ResetContentsCheck(tobtnDealPayment.Tag)
   else if msbBase.VertScrollBar.Position < 758 then
     ResetContentsCheck(tobtnSafe.Tag)
-  else if msbBase.VertScrollBar.Position < 886 then
+  else if msbBase.VertScrollBar.Position < 933 then
     ResetContentsCheck(tobtnCalcParameters.Tag)
   else
     ResetContentsCheck(tobtnDateTime.Tag);
@@ -351,7 +355,7 @@ begin
   else if ATag = tobtnCalcParameters.Tag then
     msbBase.VertScrollBar.Position := 758
   else if ATag = tobtnDateTime.Tag then
-    msbBase.VertScrollBar.Position := 886;
+    msbBase.VertScrollBar.Position := 933;
 end;
 
 procedure TProjectPropertiesForm.InitDealInfo;
@@ -569,9 +573,12 @@ begin
     FProjProperties.TotalPriceDigit := udTotalPrice.Position;
     FProjectData.ResetFloatDigitView;
     FProjProperties.DecimalManager.Common.Quantity.Digit := udQuantity.Position;
-    FProjProperties.DecimalManager.Common.TotalPrice.Digit := udTotalPrice.Position;    
+    FProjProperties.DecimalManager.Common.TotalPrice.Digit := udTotalPrice.Position;
     FProjProperties.DecimalManager.PriceMargin.Quantity.Digit := udQuantity.Position;
     FProjProperties.DecimalManager.PriceMargin.TotalPrice.Digit := udTotalPrice.Position;
+
+    FProjProperties.DealPayAloneDigit := cbDealPayAloneDigiy.Checked;
+    FProjProperties.DecimalManager.DealPay.TotalPrice.Digit := udDealPayTotalPriceDigit.Position;
   end;
   if (FProjProperties.PhaseCount = 1) and not FProjectData.PriceMarginReadOnly then
     FProjProperties.DecimalManager.PriceMargin.Price.Digit := udPM_PriceDigit.Position;
@@ -589,6 +596,14 @@ begin
   udPM_PriceDigit.Position := FProjProperties.DecimalManager.PriceMargin.Price.Digit;
   lePM_PriceDigit.ReadOnly := FProjectData.PriceMarginReadOnly and (FProjProperties.PhaseCount > 1);
   udPM_PriceDigit.Enabled := not lePM_PriceDigit.ReadOnly;
+
+  cbDealPayAloneDigiy.Checked := FProjProperties.DealPayAloneDigit;
+  cbDealPayAloneDigiy.Enabled := FProjProperties.PhaseCount = 0;
+
+  udDealPayTotalPriceDigit.Position := FProjProperties.DecimalManager.DealPay.TotalPrice.Digit;
+  leDealPayTotalPriceDigit.ReadOnly := (FProjProperties.PhaseCount > 0);
+  leDealPayTotalPriceDigit.Enabled := cbDealPayAloneDigiy.Checked;
+  udDealPayTotalPriceDigit.Enabled := (FProjProperties.PhaseCount = 0) and cbDealPayAloneDigiy.Checked;
 end;
 
 procedure TProjectPropertiesForm.SaveProjectView;
@@ -641,4 +656,11 @@ begin
   CheckDate;
 end;
 
+procedure TProjectPropertiesForm.cbDealPayAloneDigiyClick(Sender: TObject);
+begin
+  leDealPayTotalPriceDigit.ReadOnly := (FProjProperties.PhaseCount > 0);
+  leDealPayTotalPriceDigit.Enabled := cbDealPayAloneDigiy.Checked;
+  udDealPayTotalPriceDigit.Enabled := (FProjProperties.PhaseCount = 0) and cbDealPayAloneDigiy.Checked;
+end;
+
 end.

+ 67 - 6
Units/CalcDecimal.pas

@@ -11,9 +11,11 @@ type
     FDigit: Integer;
     FFormat: string;
     FLinkViewCols: TList;
+    FRelaDecimal: TDecimal;
     procedure SetDigit(const Value: Integer);
 
     function GetDisplayFormat(ADigit: Integer): string;
+    procedure SetRelaDecimal(const Value: TDecimal);
   public
     constructor Create;
     destructor Destroy; override;
@@ -28,6 +30,8 @@ type
 
     property Digit: Integer read FDigit write SetDigit;
     property Format: string read FFormat;
+
+    property RelaDecimal: TDecimal read FRelaDecimal write SetRelaDecimal;
   end;
 
   TCalcDecimal = class
@@ -35,6 +39,8 @@ type
     FQuantity: TDecimal;
     FTotalPrice: TDecimal;
     FPrice: TDecimal;
+    FRelaCalcDecimal: TCalcDecimal;
+    procedure SetRelaCalcDecimal(const Value: TCalcDecimal);
   public
     constructor Create;
     destructor Destroy; override;
@@ -44,14 +50,17 @@ type
     property Quantity: TDecimal read FQuantity;
     property TotalPrice: TDecimal read FTotalPrice;
     property Price: TDecimal read FPrice;
+
+    property RelaCalcDecimal: TCalcDecimal read FRelaCalcDecimal write SetRelaCalcDecimal;
   end;
 
   TDecimalManager = class
   private
     FProjectData: TObject;
     FCommon: TCalcDecimal;
-    FCompile:TCalcDecimal;
+    FCompile: TCalcDecimal;
     FPriceMargin: TCalcDecimal;
+    FDealPay: TCalcDecimal;
   public
     constructor Create(AProjectData: TObject);
     destructor Destroy; override;
@@ -61,6 +70,7 @@ type
     property Common: TCalcDecimal read FCommon;
     property Compile: TCalcDecimal read FCompile;
     property PriceMargin: TCalcDecimal read FPriceMargin;
+    property DealPay: TCalcDecimal read FDealPay;
   end;
 
 implementation
@@ -119,15 +129,25 @@ begin
   begin
     ViewCol := TsdViewColumn(FLinkViewCols.Items[i]);
     if not Assigned(ViewCol) then Continue;
-
-    ViewCol.DisplayFormat := FFormat;
-    ViewCol.EditFormat := FFormat;
+    if Assigned(RelaDecimal) then
+    begin
+      ViewCol.DisplayFormat := FRelaDecimal.FFormat;
+      ViewCol.EditFormat := FRelaDecimal.FFormat;
+    end
+    else
+    begin
+      ViewCol.DisplayFormat := FFormat;
+      ViewCol.EditFormat := FFormat;
+    end;
   end;
 end;
 
 function TDecimal.RoundTo(AValue: Double): Double;
 begin
-  Result := ScRoundTo(AValue, -Digit);
+  if Assigned(RelaDecimal) then
+    Result := FRelaDecimal.RoundTo(AValue)
+  else
+    Result := ScRoundTo(AValue, -Digit);
 end;
 
 procedure TDecimal.SetDigit(const Value: Integer);
@@ -140,9 +160,18 @@ begin
   end;
 end;
 
+procedure TDecimal.SetRelaDecimal(const Value: TDecimal);
+begin
+  FRelaDecimal := Value;
+  RefreshLinkViewColsFormat;
+end;
+
 function TDecimal.StrRoundTo(const AValue: string): string;
 begin
-  Result := FloatToStr(RoundTo(StrToFloatDef(AValue, 0)));
+  if Assigned(FRelaDecimal) then
+    Result := RelaDecimal.StrRoundTo(AValue)
+  else
+    Result := FloatToStr(RoundTo(StrToFloatDef(AValue, 0)));
 end;
 
 { TCalcDecimal }
@@ -169,6 +198,23 @@ begin
   Price.RefreshLinkViewColsFormat;
 end;
 
+procedure TCalcDecimal.SetRelaCalcDecimal(const Value: TCalcDecimal);
+begin
+  FRelaCalcDecimal := Value;
+  if Assigned(FRelaCalcDecimal) then
+  begin
+    Quantity.RelaDecimal := FRelaCalcDecimal.Quantity;
+    TotalPrice.RelaDecimal := FRelaCalcDecimal.TotalPrice;
+    Price.RelaDecimal := FRelaCalcDecimal.Price;
+  end
+  else
+  begin
+    Quantity.RelaDecimal := nil;
+    TotalPrice.RelaDecimal := nil;
+    Price.RelaDecimal := nil;
+  end;
+end;
+
 { TDecimalManager }
 
 constructor TDecimalManager.Create(AProjectData: TObject);
@@ -177,10 +223,12 @@ begin
   FCommon := TCalcDecimal.Create;
   FCompile := TCalcDecimal.Create;
   FPriceMargin := TCalcDecimal.Create;
+  FDealPay := TCalcDecimal.Create;
 end;
 
 destructor TDecimalManager.Destroy;
 begin
+  FDealPay.Free;
   FPriceMargin.Free;
   FCompile.Free;
   FCommon.Free;
@@ -309,6 +357,17 @@ procedure TDecimalManager.ResetLinkViewColumns;
     end;
   end;
 
+  procedure ResetDealPayLink;
+  begin
+    with TProjectData(FProjectData).DealPaymentData.sdvDealPayment do
+    begin
+      FDealPay.TotalPrice.AddLinkViewCol(Columns.FindColumn('CurTotalPrice'));
+      FDealPay.TotalPrice.AddLinkViewCol(Columns.FindColumn('TotalPrice'));
+      FDealPay.TotalPrice.AddLinkViewCol(Columns.FindColumn('StartPrice'));
+      FDealPay.TotalPrice.AddLinkViewCol(Columns.FindColumn('RangePrice'));
+    end;
+  end;
+
 begin
   {ResetCommonLink;
   FCommon.RefreshLinkViewColumnsFormat;
@@ -316,6 +375,8 @@ begin
   FCompile.RefreshLinkViewColumnsFormat;}
   ResetPriceMarginLink;
   FPriceMargin.RefreshLinkViewColumnsFormat;
+  ResetDealPayLink;
+  FDealPay.RefreshLinkViewColumnsFormat;
 end;
 
 end.

+ 8 - 2
Units/FormulaCalc.pas

@@ -3,7 +3,7 @@ unit FormulaCalc;
 interface
 
 uses
-  sdIDTree, ZhAPI, Math;
+  sdIDTree, ZhAPI, Math, CalcDecimal;
 
 const
   ArithmeticCharSet: set of Char = ['0'..'9', '.', '(','[','{', ')',']','}', '+','-','*','/','^', '%', '='];
@@ -52,6 +52,7 @@ type
     FProjectData: TObject;
     FDisplayText: string;
     FStartedPrice: Double;
+    FDecimal: TCalcDecimal;
 
     // ǩԼºÏͬ¼Û
     function ContractPrice: Double;
@@ -71,6 +72,8 @@ type
     destructor Destroy; override;
 
     function Calculate(const ADisplayText: string; AStartedPrice: Double = 0): Double;
+
+    property Decimal: TCalcDecimal read FDecimal write FDecimal;
   end;
 
 implementation
@@ -283,7 +286,10 @@ end;
 
 function TPayFormula.GetValue: Double;
 begin
-  Result := TotalPriceRoundTo(EvaluateExprs(GetCalcText));
+  if Assigned(Decimal) then
+    Result := Decimal.TotalPrice.RoundTo(EvaluateExprs(GetCalcText))
+  else
+    Result := TotalPriceRoundTo(EvaluateExprs(GetCalcText));
 end;
 
 function TPayFormula.MaterialSubsist: Double;

+ 1 - 1
Units/ProjectData.pas

@@ -1794,7 +1794,7 @@ procedure TProjectData.ResetFloatDigitView;
 begin
   SetBillsCompileDigit;
   SetBillsMeasureDigit;
-  SetDealPaymentDigit;
+  //SetDealPaymentDigit;
   SetBillsGatherDigit;
   SetBGLDigit;
   SetOtherMeasureDigit;

+ 30 - 1
Units/ProjectProperty.pas

@@ -79,6 +79,7 @@ type
     FReportShading: string;
     FBaseline: string;
     FDeadline: string;
+    FDealPayAloneDigit: Boolean;
 
     function GetBoolPropertyDef(const AName: string; ADef: Boolean): Boolean;
     function GetIntPropertyDef(const AName: string; ADef: Integer): Integer;
@@ -124,6 +125,7 @@ type
     procedure SetShowReportShading(const Value: Boolean);
     procedure SetBaseline(const Value: string);
     procedure SetDeadline(const Value: string);
+    procedure SetDealPayAloneDigit(const Value: Boolean);
   public
     constructor Create(AProjectData: TObject);
     destructor Destroy; override;
@@ -193,6 +195,8 @@ type
     property UnlockInfoPassword: string read FUnlockInfoPassword write SetUnlockInfoPassword;
 
     {小数位数}
+    // 是否单独设置合同支付小数位数
+    property DealPayAloneDigit: Boolean read FDealPayAloneDigit write SetDealPayAloneDigit;
     property DecimalManager: TDecimalManager read FDecimalManager;
     // 数量
     property QuantityDigit: Integer read FQuantityDigit write SetQuantityDigit;
@@ -428,6 +432,8 @@ end;
 
 procedure TProjProperties.LoadCalcParameters;
 begin
+  FDealPayAloneDigit := GetBoolPropertyDef('DealPayAloneDigit', False);
+
   FQuantityDigit := GetIntPropertyDef('QuantityDigit', 3);
   FQuantityFormat := GetDisplayFormat(FQuantityDigit);
   FTotalPriceDigit := GetIntPropertyDef('TotalPriceDigit', 0);
@@ -453,6 +459,14 @@ begin
     PriceMargin.TotalPrice.Digit := Common.TotalPrice.Digit;
     PriceMargin.Price.Digit := 3;//GetIntPropertyDef('PM_PriceDigit', Common.Price.Digit);
   end;
+  with FDecimalManager do
+  begin
+    DealPay.TotalPrice.Digit := GetIntPropertyDef('DealPayTPDigit', Common.TotalPrice.Digit);
+    if FDealPayAloneDigit then
+      DealPay.RelaCalcDecimal := nil
+    else
+      DealPay.RelaCalcDecimal := Common;
+  end;
 end;
 
 procedure TProjProperties.LoadDateTime;
@@ -528,18 +542,24 @@ begin
   SaveDealInfo;
   SaveTechParameters;
   SaveCalcParameters;
+  // 无意义,不可删除,Sql最后一句不执行,写多一句,以保证完整执行
+  FPropertyInqurity.Value['Complete'] := True;
 end;
 
 procedure TProjProperties.SaveCalcParameters;
 begin
+  if FPhaseCount > 0 then Exit;
+  
+  FPropertyInqurity.Value['DealPayAloneDigit'] := FDealPayAloneDigit;
   with FDecimalManager do
   begin
     {FPropertyInqurity.Value['QuantityDigit'] := Common.Quantity.Digit;
     FPropertyInqurity.Value['TotalPriceDigit'] := Common.TotalPrice.Digit;
     FPropertyInqurity.Value['QuantityDigit1'] := Compile.Quantity.Digit;
     FPropertyInqurity.Value['TotalPriceDigit1'] := Compile.TotalPrice.Digit;}
-    
+
     //FPropertyInqurity.Value['PM_PriceDigit'] := PriceMargin.Price.Digit;
+    FPropertyInqurity.Value['DealPayTPDigit'] := DealPay.TotalPrice.Digit;
   end;
 end;
 
@@ -597,6 +617,15 @@ begin
   FPropertyInqurity.Value['Deadline'] := Value;
 end;
 
+procedure TProjProperties.SetDealPayAloneDigit(const Value: Boolean);
+begin
+  FDealPayAloneDigit := Value;
+  if Value then
+    DecimalManager.DealPay.RelaCalcDecimal := nil
+  else
+    DecimalManager.DealPay.RelaCalcDecimal := DecimalManager.Common;
+end;
+
 procedure TProjProperties.SetFinalAuditCount(const Value: Integer);
 begin
   FPropertyInqurity.Value['FinalAuditCount'] := Value;