|
@@ -52,7 +52,7 @@ type
|
|
|
// 扣款项是否已达起扣金额
|
|
|
function CheckStartedPrice(AID: Integer): Boolean;
|
|
|
function CheckReachPlan(ARec: TsdDataRecord): Boolean;
|
|
|
- function GetAllowTotalPrice(AID: Integer; ATotalPrice: Double): Double;
|
|
|
+ function GetAllowTotalPrice(AID: Integer; ATotalPrice, APreTotalPrice: Double): Double;
|
|
|
procedure UpdateTotalPrice(AID: Integer; ATotalPrice: Double);
|
|
|
|
|
|
function DealPayRecord(const AName: string): TsdDataRecord;
|
|
@@ -111,7 +111,7 @@ begin
|
|
|
end;
|
|
|
|
|
|
function TDealPaymentData.GetAllowTotalPrice(AID: Integer;
|
|
|
- ATotalPrice: Double): Double;
|
|
|
+ ATotalPrice, APreTotalPrice: Double): Double;
|
|
|
var
|
|
|
Rec: TsdDataRecord;
|
|
|
fAllowPrice: Double;
|
|
@@ -119,7 +119,7 @@ begin
|
|
|
Result := ATotalPrice;
|
|
|
Rec := sddDealPayment.FindKey('idxID', AID);
|
|
|
if Rec.ValueByName('RangePrice').AsFloat = 0 then Exit;
|
|
|
- fAllowPrice := Rec.ValueByName('RangePrice').AsFloat - Rec.ValueByName('TotalPrice').AsFloat;
|
|
|
+ fAllowPrice := Rec.ValueByName('RangePrice').AsFloat - APreTotalPrice;
|
|
|
if not CheckReachPlan(Rec) then
|
|
|
Result := Min(fAllowPrice, ATotalPrice)
|
|
|
else
|
|
@@ -321,23 +321,32 @@ procedure TDealPaymentData.sdvDealPaymentNeedLookupRecord(
|
|
|
|
|
|
procedure SetNewRecData(APayRec: TsdDataRecord);
|
|
|
var
|
|
|
- AID: Integer;
|
|
|
+ iID: Integer;
|
|
|
sTPField, sFField: string;
|
|
|
- fTotalPrice: Double;
|
|
|
+ fTotalPrice, fAllow: Double;
|
|
|
begin
|
|
|
sTPField := 'TotalPrice' + IntToStr(TProjectData(FProjectData).PhaseData.StageIndex);
|
|
|
sFField := 'Formula' + IntToStr(TProjectData(FProjectData).PhaseData.StageIndex);
|
|
|
if CheckNumeric(ANewText) then
|
|
|
- APayRec.ValueByName(sTPField).AsString := ANewText
|
|
|
+ fTotalPrice := StrToFloat(ANewText)
|
|
|
else
|
|
|
begin
|
|
|
- AID := ARecord.ValueByName('ID').AsInteger;
|
|
|
APayRec.ValueByName(sFField).AsString := ANewText;
|
|
|
ARecord.ValueByName('Formula').AsString := ANewText;
|
|
|
- fTotalPrice := FPayFormula.Calculate(ANewText, ARecord.ValueByName('StartedPrice').AsFloat);
|
|
|
- if CheckStartedPrice(AID) then
|
|
|
- APayRec.ValueByName(sTPField).AsFloat := GetAllowTotalPrice(AID, fTotalPrice);
|
|
|
+ fTotalPrice := FPayFormula.Calculate(ANewText);
|
|
|
end;
|
|
|
+ iID := ARecord.ValueByName('ID').AsInteger;
|
|
|
+ if CheckStartedPrice(iID) then
|
|
|
+ begin
|
|
|
+ fAllow := GetAllowTotalPrice(iID, fTotalPrice, 0);
|
|
|
+ APayRec.ValueByName(sTPField).AsFloat := fAllow;
|
|
|
+ if fAllow < fTotalPrice then
|
|
|
+ TipMessage(Format('“%s”已达扣款限额,本期金额计%s。', [ARecord.ValueByName('Name').AsString, FloatToStr(fAllow)]))
|
|
|
+ else if fAllow > fTotalPrice then
|
|
|
+ TipMessage(Format('“%s”已达计提期限,本期金额计%s。', [ARecord.ValueByName('Name').AsString, FloatToStr(fAllow)]));
|
|
|
+ end
|
|
|
+ else
|
|
|
+ TipMessage(Format('“%s”未达到起扣金额,本期金额计零。', [ARecord.ValueByName('Name').AsString]));
|
|
|
end;
|
|
|
|
|
|
var
|
|
@@ -433,9 +442,9 @@ procedure TDealPaymentData.sdvDealPaymentSetText(var Text: string;
|
|
|
|
|
|
procedure DoCurTotalPriceChanged;
|
|
|
var
|
|
|
- AID: Integer;
|
|
|
- sFField: string;
|
|
|
- fTotalPrice: Double;
|
|
|
+ iID: Integer;
|
|
|
+ sFField, sPreField: string;
|
|
|
+ fTotalPrice, fAllow: Double;
|
|
|
Rec: TsdDataRecord;
|
|
|
begin
|
|
|
Rec := sddDealPayment.FindKey('idxID', ARecord.ValueByName('ID').AsInteger);
|
|
@@ -444,26 +453,29 @@ procedure TDealPaymentData.sdvDealPaymentSetText(var Text: string;
|
|
|
begin
|
|
|
Rec.ValueByName('Formula').AsString := '';
|
|
|
AValue.Owner.ValueByName(sFField).AsString := '';
|
|
|
- {AID := ARecord.ValueByName('ID').AsInteger;
|
|
|
- fTotalPrice := StrToFloatDef(Text, 0) - AValue.AsFloat;
|
|
|
- if CheckStartedPrice(AID) then
|
|
|
- Text := FloatToStr(AValue.AsFloat + GetAllowTotalPrice(AID, fTotalPrice))
|
|
|
- else
|
|
|
- Text := '';}
|
|
|
+ fTotalPrice := StrToFloatDef(Text, 0);
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
Rec.ValueByName('Formula').AsString := Text;
|
|
|
AValue.Owner.ValueByName(sFField).AsString := Text;
|
|
|
- AID := ARecord.ValueByName('ID').AsInteger;
|
|
|
- if ARecord.ValueByName('Pre' + AValue.FieldName).AsFloat = 0 then
|
|
|
- fTotalPrice := FPayFormula.Calculate(Text, Rec.ValueByName('StartedPrice').AsFloat) - AValue.AsFloat
|
|
|
- else
|
|
|
- fTotalPrice := FPayFormula.Calculate(Text) - AValue.AsFloat;
|
|
|
- if CheckStartedPrice(AID) then
|
|
|
- Text := FloatToStr(AValue.AsFloat + GetAllowTotalPrice(AID, fTotalPrice))
|
|
|
- else
|
|
|
- Text := '';
|
|
|
+ fTotalPrice := FPayFormula.Calculate(Text);
|
|
|
+ end;
|
|
|
+ iID := ARecord.ValueByName('ID').AsInteger;
|
|
|
+ if CheckStartedPrice(iID) then
|
|
|
+ begin
|
|
|
+ sPreField := StringReplace(AValue.FieldName, 'TotalPrice', 'PreTotalPrice', []);
|
|
|
+ fAllow := GetAllowTotalPrice(iID, fTotalPrice, ARecord.ValueByName(sPreField).AsFloat);
|
|
|
+ Text := FloatToStr(fAllow);
|
|
|
+ if fAllow < fTotalPrice then
|
|
|
+ TipMessage(Format('“%s”已达扣款限额,本期金额计%s。', [Rec.ValueByName('Name').AsString, Text]))
|
|
|
+ else if fAllow > fTotalPrice then
|
|
|
+ TipMessage(Format('“%s”已达计提期限,本期金额计%s。', [Rec.ValueByName('Name').AsString, Text]));
|
|
|
+ end
|
|
|
+ else
|
|
|
+ begin
|
|
|
+ Text := '';
|
|
|
+ TipMessage(Format('“%s”未达到起扣金额,本期金额计零。', [Rec.ValueByName('Name').AsString]));
|
|
|
end;
|
|
|
end;
|
|
|
|
|
@@ -494,7 +506,7 @@ begin
|
|
|
DoStartedPriceChanged;
|
|
|
if SameText('RangePrice', AValue.FieldName) then
|
|
|
DoRangePriceChanged;
|
|
|
- if Pos('TotalPrice', AValue.FieldName) = 1 then
|
|
|
+ if SameText('CurTotalPrice', AColumn.FieldName) then
|
|
|
if TProjectData(FProjectData).ProjProperties.PhaseCount > 0 then
|
|
|
DoCurTotalPriceChanged
|
|
|
else
|