|
@@ -30,6 +30,14 @@ type
|
|
|
|
|
|
procedure UpdateParentRecord(ABillsID: Integer; ATotalPrice: Double; const AFieldName: string);
|
|
procedure UpdateParentRecord(ABillsID: Integer; ATotalPrice: Double; const AFieldName: string);
|
|
procedure UpdateComplete(ABillsID: Integer; AQuantity, ATotalPrice: Double);
|
|
procedure UpdateComplete(ABillsID: Integer; AQuantity, ATotalPrice: Double);
|
|
|
|
+
|
|
|
|
+ // 向父项增量--PM_TotalPrice
|
|
|
|
+ procedure UpdateParentPriceMargin(ABillsID: Integer; ADiffer: Double);
|
|
|
|
+ // 向价差调整节点增量--GatherTotalPrice
|
|
|
|
+ procedure UpdatePriceMarginNode(ADiffer: Double);
|
|
|
|
+ // 重新计算相关的项目工料的价差数据
|
|
|
|
+ procedure UpdateProjectGL(ABillsID: Integer);
|
|
|
|
+
|
|
procedure CalculateDeal(ABillsID: Integer);
|
|
procedure CalculateDeal(ABillsID: Integer);
|
|
procedure CalculateQuantityChange(ABillsID: Integer);
|
|
procedure CalculateQuantityChange(ABillsID: Integer);
|
|
procedure CalculatePriceChange(ABillsID: Integer);
|
|
procedure CalculatePriceChange(ABillsID: Integer);
|
|
@@ -39,6 +47,8 @@ type
|
|
|
|
|
|
function GetTotalPrice(ABillsID, AType, AStageIndex: Integer): Double;
|
|
function GetTotalPrice(ABillsID, AType, AStageIndex: Integer): Double;
|
|
|
|
|
|
|
|
+ function GetBillsUnitPriceMargin(ABillsID: Integer): Double;
|
|
|
|
+
|
|
function GetBillsPrice(ABillsID: Integer): Double;
|
|
function GetBillsPrice(ABillsID: Integer): Double;
|
|
function GetBillsNewPrice(ABillsID: Integer): Double;
|
|
function GetBillsNewPrice(ABillsID: Integer): Double;
|
|
function GetBillsPriceDiffer(ABillsID: Integer): Double;
|
|
function GetBillsPriceDiffer(ABillsID: Integer): Double;
|
|
@@ -62,6 +72,10 @@ type
|
|
procedure Open(AConnection: TADOConnection);
|
|
procedure Open(AConnection: TADOConnection);
|
|
procedure Save;
|
|
procedure Save;
|
|
|
|
|
|
|
|
+ // 计算任一清单节点的价差金额,并增量汇总至父项
|
|
|
|
+ procedure CalculatePriceMargin(ABillsID: Integer);
|
|
|
|
+ // 计算材料调差节点
|
|
|
|
+ procedure CalculatePriceMarginNode;
|
|
procedure CalculateNode(ANode: TsdIDTreeNode);
|
|
procedure CalculateNode(ANode: TsdIDTreeNode);
|
|
procedure CalculateAll;
|
|
procedure CalculateAll;
|
|
|
|
|
|
@@ -74,7 +88,10 @@ type
|
|
procedure ReCalculate(ABillsID: Integer);
|
|
procedure ReCalculate(ABillsID: Integer);
|
|
procedure UpdateBGLInfo(ARec: TsdDataRecord; const AType: string);
|
|
procedure UpdateBGLInfo(ARec: TsdDataRecord; const AType: string);
|
|
|
|
|
|
|
|
+ // 查找
|
|
function StageRecord(ABillsID: Integer): TStageRecord;
|
|
function StageRecord(ABillsID: Integer): TStageRecord;
|
|
|
|
+ // 查找,如未找到则新增
|
|
|
|
+ function StageRecordWithAdd(ABillsID: Integer): TStageRecord;
|
|
|
|
|
|
// 将Bills表中存的累计计量数据拷贝至截止本期计量、截止上期计量,除新增一期计量外不可调用
|
|
// 将Bills表中存的累计计量数据拷贝至截止本期计量、截止上期计量,除新增一期计量外不可调用
|
|
procedure CopyPrePhaseData;
|
|
procedure CopyPrePhaseData;
|
|
@@ -115,7 +132,7 @@ implementation
|
|
|
|
|
|
uses
|
|
uses
|
|
ProjectData, BillsDm, PhaseData, Math, BGLDm, BillsMeasureDm,
|
|
ProjectData, BillsDm, PhaseData, Math, BGLDm, BillsMeasureDm,
|
|
- UtilMethods, ConditionalDefines, FormulaCalc;
|
|
|
|
|
|
+ UtilMethods, ConditionalDefines, FormulaCalc, DetailGLDm, ConstUnit;
|
|
|
|
|
|
{$R *.dfm}
|
|
{$R *.dfm}
|
|
|
|
|
|
@@ -181,6 +198,9 @@ begin
|
|
if TPhaseData(FPhaseData).IsLastStage then
|
|
if TPhaseData(FPhaseData).IsLastStage then
|
|
with TProjectData(TPhaseData(FPhaseData).ProjectData).BillsMeasureData do
|
|
with TProjectData(TPhaseData(FPhaseData).ProjectData).BillsMeasureData do
|
|
UpdateRecordDeal(ABillsID, fQtyDiffer, fTPDiffer);
|
|
UpdateRecordDeal(ABillsID, fQtyDiffer, fTPDiffer);
|
|
|
|
+
|
|
|
|
+ CalculatePriceMargin(ABillsID);
|
|
|
|
+
|
|
TPhaseData(FPhaseData).PhasePayData.CalculateAll;
|
|
TPhaseData(FPhaseData).PhasePayData.CalculateAll;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -233,6 +253,9 @@ begin
|
|
if TPhaseData(FPhaseData).IsLastStage then
|
|
if TPhaseData(FPhaseData).IsLastStage then
|
|
with TProjectData(TPhaseData(FPhaseData).ProjectData).BillsMeasureData do
|
|
with TProjectData(TPhaseData(FPhaseData).ProjectData).BillsMeasureData do
|
|
UpdateRecordQc(ABillsID, fQtyDiffer, fTPDiffer);
|
|
UpdateRecordQc(ABillsID, fQtyDiffer, fTPDiffer);
|
|
|
|
+
|
|
|
|
+ CalculatePriceMargin(ABillsID);
|
|
|
|
+
|
|
TPhaseData(FPhaseData).PhasePayData.CalculateAll;
|
|
TPhaseData(FPhaseData).PhasePayData.CalculateAll;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -354,15 +377,19 @@ begin
|
|
if (AValue.FieldName = 'DealQuantity') or
|
|
if (AValue.FieldName = 'DealQuantity') or
|
|
(AValue.FieldName = 'DealFormula') or
|
|
(AValue.FieldName = 'DealFormula') or
|
|
(AValue.FieldName = 'DealTotalPrice') then
|
|
(AValue.FieldName = 'DealTotalPrice') then
|
|
- CalculateDeal(AValue.Owner.ValueByName('BillsID').AsInteger);
|
|
|
|
|
|
+ CalculateDeal(iBillsID);
|
|
if (AValue.FieldName = 'QcQuantity') or
|
|
if (AValue.FieldName = 'QcQuantity') or
|
|
(AValue.FieldName = 'QcFormula') or
|
|
(AValue.FieldName = 'QcFormula') or
|
|
(AValue.FieldName = 'QcTotalPrice') then
|
|
(AValue.FieldName = 'QcTotalPrice') then
|
|
- CalculateQuantityChange(AValue.Owner.ValueByName('BillsID').AsInteger);
|
|
|
|
|
|
+ CalculateQuantityChange(iBillsID);
|
|
if (AValue.FieldName = 'PcQuantity') or
|
|
if (AValue.FieldName = 'PcQuantity') or
|
|
(AValue.FieldName = 'PcFormula') or
|
|
(AValue.FieldName = 'PcFormula') or
|
|
(AValue.FieldName = 'PcTotalPrice') then
|
|
(AValue.FieldName = 'PcTotalPrice') then
|
|
- CalculatePriceChange(AValue.Owner.ValueByName('BillsID').AsInteger);
|
|
|
|
|
|
+ CalculatePriceChange(iBillsID);
|
|
|
|
+
|
|
|
|
+ if (AValue.FieldName = 'DealQuantity') or
|
|
|
|
+ (AValue.FieldName = 'QcQuantity') then
|
|
|
|
+ UpdateProjectGL(iBillsID);
|
|
end;
|
|
end;
|
|
|
|
|
|
function TStageData.GetMainBillsTree: TBillsIDTree;
|
|
function TStageData.GetMainBillsTree: TBillsIDTree;
|
|
@@ -399,7 +426,7 @@ procedure TStageData.sddStageBeforeValueChange(AValue: TsdValue;
|
|
DataSetErrorMessage(Allow, '不可超过0号台账合同数量!');
|
|
DataSetErrorMessage(Allow, '不可超过0号台账合同数量!');
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
-
|
|
|
|
|
|
+
|
|
begin
|
|
begin
|
|
// 不检查超计
|
|
// 不检查超计
|
|
//CheckOverRange;
|
|
//CheckOverRange;
|
|
@@ -453,9 +480,7 @@ var
|
|
begin
|
|
begin
|
|
iParentID := MainBillsTree.FindNode(ABillsID).ParentID;
|
|
iParentID := MainBillsTree.FindNode(ABillsID).ParentID;
|
|
if iParentID = -1 then Exit;
|
|
if iParentID = -1 then Exit;
|
|
- Rec := StageRecord(iParentID);
|
|
|
|
- if not Assigned(Rec) then
|
|
|
|
- Rec := AddStageRecord(iParentID);
|
|
|
|
|
|
+ Rec := StageRecordWithAdd(iParentID);
|
|
Rec.ValueByName(AFieldName).AsFloat := TotalPriceRoundTo(
|
|
Rec.ValueByName(AFieldName).AsFloat := TotalPriceRoundTo(
|
|
Rec.ValueByName(AFieldName).AsFloat + ATotalPrice);
|
|
Rec.ValueByName(AFieldName).AsFloat + ATotalPrice);
|
|
Rec.ValueByName('End' + AFieldName).AsFloat := TotalPriceRoundTo(
|
|
Rec.ValueByName('End' + AFieldName).AsFloat := TotalPriceRoundTo(
|
|
@@ -551,8 +576,9 @@ begin
|
|
if (Rec.ValueByName('AddGatherTotalPrice').AsFloat = 0) and
|
|
if (Rec.ValueByName('AddGatherTotalPrice').AsFloat = 0) and
|
|
(Rec.ValueByName('AddDealTotalPrice').AsFloat = 0) and
|
|
(Rec.ValueByName('AddDealTotalPrice').AsFloat = 0) and
|
|
(Rec.ValueByName('AddQcTotalPrice').AsFloat = 0) and
|
|
(Rec.ValueByName('AddQcTotalPrice').AsFloat = 0) and
|
|
- (Rec.ValueByName('AddPcTotalPrice').AsFloat = 0) then Continue;
|
|
|
|
-
|
|
|
|
|
|
+ (Rec.ValueByName('AddPcTotalPrice').AsFloat = 0) and
|
|
|
|
+ (Rec.ValueByName('PM_AddTotalPrice').AsFloat = 0) then Continue;
|
|
|
|
+
|
|
NewRec := sddStage.Add;
|
|
NewRec := sddStage.Add;
|
|
NewRec.ValueByName('BillsID').AsInteger := Rec.ValueByName('ID').AsInteger;
|
|
NewRec.ValueByName('BillsID').AsInteger := Rec.ValueByName('ID').AsInteger;
|
|
NewRec.ValueByName('EndDealQuantity').AsFloat := Rec.ValueByName('AddDealQuantity').AsFloat;
|
|
NewRec.ValueByName('EndDealQuantity').AsFloat := Rec.ValueByName('AddDealQuantity').AsFloat;
|
|
@@ -579,6 +605,8 @@ begin
|
|
NewRec.ValueByName('PrePcBGLNum').AsString := Rec.ValueByName('AddPcBGLNum').AsString;
|
|
NewRec.ValueByName('PrePcBGLNum').AsString := Rec.ValueByName('AddPcBGLNum').AsString;
|
|
NewRec.ValueByName('PreGatherQuantity').AsFloat := Rec.ValueByName('AddGatherQuantity').AsFloat;
|
|
NewRec.ValueByName('PreGatherQuantity').AsFloat := Rec.ValueByName('AddGatherQuantity').AsFloat;
|
|
NewRec.ValueByName('PreGatherTotalPrice').AsFloat := Rec.ValueByName('AddGatherTotalPrice').AsFloat;
|
|
NewRec.ValueByName('PreGatherTotalPrice').AsFloat := Rec.ValueByName('AddGatherTotalPrice').AsFloat;
|
|
|
|
+
|
|
|
|
+ NewRec.ValueByName('PM_PreTotalPrice').AsFloat := Rec.ValueByName('PM_AddTotalPrice').AsFloat;
|
|
end;
|
|
end;
|
|
finally
|
|
finally
|
|
AfterBatchOperation;
|
|
AfterBatchOperation;
|
|
@@ -622,13 +650,14 @@ procedure TStageData.CalculateParent(ANode: TBillsIDTreeNode);
|
|
var
|
|
var
|
|
iChild: Integer;
|
|
iChild: Integer;
|
|
ChildNode: TBillsIDTreeNode;
|
|
ChildNode: TBillsIDTreeNode;
|
|
- fDeal, fQc, fPc: Double;
|
|
|
|
|
|
+ fDeal, fQc, fPc, fPM: Double;
|
|
begin
|
|
begin
|
|
if not Assigned(ANode.StageRec) then Exit;
|
|
if not Assigned(ANode.StageRec) then Exit;
|
|
|
|
|
|
fDeal := 0;
|
|
fDeal := 0;
|
|
fQc := 0;
|
|
fQc := 0;
|
|
- FPc := 0;
|
|
|
|
|
|
+ fPc := 0;
|
|
|
|
+ fPM := 0;
|
|
for iChild := 0 to ANode.ChildCount - 1 do
|
|
for iChild := 0 to ANode.ChildCount - 1 do
|
|
begin
|
|
begin
|
|
ChildNode := TBillsIDTreeNode(ANode.ChildNodes[iChild]);
|
|
ChildNode := TBillsIDTreeNode(ANode.ChildNodes[iChild]);
|
|
@@ -636,19 +665,28 @@ begin
|
|
fDeal := TotalPriceRoundTo(fDeal + ChildNode.StageRec.DealTotalPrice.AsFloat);
|
|
fDeal := TotalPriceRoundTo(fDeal + ChildNode.StageRec.DealTotalPrice.AsFloat);
|
|
fQc := TotalPriceRoundTo(fQc + ChildNode.StageRec.QcTotalPrice.AsFloat);
|
|
fQc := TotalPriceRoundTo(fQc + ChildNode.StageRec.QcTotalPrice.AsFloat);
|
|
fPc := TotalPriceRoundTo(fPc + ChildNode.StageRec.PcTotalPrice.AsFloat);
|
|
fPc := TotalPriceRoundTo(fPc + ChildNode.StageRec.PcTotalPrice.AsFloat);
|
|
|
|
+ fPM := TotalPriceRoundTo(fPM + ChildNode.StageRec.PM_TotalPrice.AsFloat);
|
|
end;
|
|
end;
|
|
|
|
|
|
with ANode.StageRec do
|
|
with ANode.StageRec do
|
|
begin
|
|
begin
|
|
- DealTotalPrice.AsFloat := fDeal;
|
|
|
|
- QcTotalPrice.AsFloat := fQc;
|
|
|
|
- PcTotalPrice.AsFloat := fPc;
|
|
|
|
- GatherTotalPrice.AsFloat := TotalPriceRoundTo(fDeal + fQc + fPc);
|
|
|
|
- EndDealTotalPrice.AsFloat := TotalPriceRoundTo(PreDealTotalPrice.AsFloat + fDeal);
|
|
|
|
- EndQcTotalPrice.AsFloat := TotalPriceRoundTo(PreQcTotalPrice.AsFloat + fQc);
|
|
|
|
- EndPcTotalPrice.AsFloat := TotalPriceRoundTo(PrePcTotalPrice.AsFloat + fPc);
|
|
|
|
- EndGatherTotalPrice.AsFloat := TotalPriceRoundTo(
|
|
|
|
- PreGatherTotalPrice.AsFloat + GatherTotalPrice.AsFloat);
|
|
|
|
|
|
+ if (DealTotalPrice.AsFloat <> fDeal) or
|
|
|
|
+ (QcTotalPrice.AsFloat <> fQc) or
|
|
|
|
+ (PcTotalPrice.AsFloat <> fPc) then
|
|
|
|
+ begin
|
|
|
|
+ DealTotalPrice.AsFloat := fDeal;
|
|
|
|
+ QcTotalPrice.AsFloat := fQc;
|
|
|
|
+ PcTotalPrice.AsFloat := fPc;
|
|
|
|
+ GatherTotalPrice.AsFloat := TotalPriceRoundTo(fDeal + fQc + fPc);
|
|
|
|
+ EndDealTotalPrice.AsFloat := TotalPriceRoundTo(PreDealTotalPrice.AsFloat + fDeal);
|
|
|
|
+ EndQcTotalPrice.AsFloat := TotalPriceRoundTo(PreQcTotalPrice.AsFloat + fQc);
|
|
|
|
+ EndPcTotalPrice.AsFloat := TotalPriceRoundTo(PrePcTotalPrice.AsFloat + fPc);
|
|
|
|
+ EndGatherTotalPrice.AsFloat := TotalPriceRoundTo(
|
|
|
|
+ PreGatherTotalPrice.AsFloat + GatherTotalPrice.AsFloat);
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ if PM_TotalPrice.AsFloat <> fPM then
|
|
|
|
+ PM_TotalPrice.AsFloat := fPM;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -673,6 +711,14 @@ procedure TStageData.CalculateLeaf(ANode: TBillsIDTreeNode);
|
|
ARec.ValueByName('Pre' + AType + 'TotalPrice').AsFloat + ARec.ValueByName(AType + 'TotalPrice').AsFloat);
|
|
ARec.ValueByName('Pre' + AType + 'TotalPrice').AsFloat + ARec.ValueByName(AType + 'TotalPrice').AsFloat);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ procedure CalculatePriceMargin(ARec: TStageRecord);
|
|
|
|
+ var
|
|
|
|
+ fPrice: Double;
|
|
|
|
+ begin
|
|
|
|
+ fPrice := GetBillsUnitPriceMargin(ARec.BillsID.AsInteger);
|
|
|
|
+ ARec.PM_TotalPrice.AsFloat := TotalPriceRoundTo(ARec.GatherQuantity.AsFloat * fPrice);
|
|
|
|
+ end;
|
|
|
|
+
|
|
var
|
|
var
|
|
Rec: TStageRecord;
|
|
Rec: TStageRecord;
|
|
begin
|
|
begin
|
|
@@ -689,6 +735,8 @@ begin
|
|
Rec.PreGatherQuantity.AsFloat + Rec.GatherQuantity.AsFloat);
|
|
Rec.PreGatherQuantity.AsFloat + Rec.GatherQuantity.AsFloat);
|
|
Rec.EndGatherTotalPrice.AsFloat := TotalPriceRoundTo(
|
|
Rec.EndGatherTotalPrice.AsFloat := TotalPriceRoundTo(
|
|
Rec.PreGatherTotalPrice.AsFloat + Rec.GatherTotalPrice.AsFloat);
|
|
Rec.PreGatherTotalPrice.AsFloat + Rec.GatherTotalPrice.AsFloat);
|
|
|
|
+
|
|
|
|
+ CalculatePriceMargin(Rec);
|
|
end;
|
|
end;
|
|
|
|
|
|
function TStageData.GetActive: Boolean;
|
|
function TStageData.GetActive: Boolean;
|
|
@@ -745,4 +793,110 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TStageData.CalculatePriceMarginNode;
|
|
|
|
+var
|
|
|
|
+ Rec: TStageRecord;
|
|
|
|
+ fTotalPrice: Double;
|
|
|
|
+begin
|
|
|
|
+ with TProjectData(TPhaseData(FPhaseData).ProjectData) do
|
|
|
|
+ begin
|
|
|
|
+ Rec := StageRecord(iPriceMarginID);
|
|
|
|
+ if not Assigned(Rec) then
|
|
|
|
+ Rec := AddStageRecord(iPriceMarginID);
|
|
|
|
+
|
|
|
|
+ fTotalPrice := TotalPriceRoundTo(ProjectGLData.PM_TotalPrice - Rec.GatherTotalPrice.AsFloat);
|
|
|
|
+ if fTotalPrice <> 0 then
|
|
|
|
+ begin
|
|
|
|
+ Rec.GatherTotalPrice.AsFloat := Rec.GatherTotalPrice.AsFloat + fTotalPrice;
|
|
|
|
+ UpdateParentRecord(Rec.BillsID.AsInteger, fTotalPrice, 'GatherTotalPrice');
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TStageData.GetBillsUnitPriceMargin(ABillsID: Integer): Double;
|
|
|
|
+var
|
|
|
|
+ vGLs: TList;
|
|
|
|
+ iGL: Integer;
|
|
|
|
+ GLRec: TDetailGLRecord;
|
|
|
|
+begin
|
|
|
|
+ Result := 0;
|
|
|
|
+ vGLs := TList.Create;
|
|
|
|
+ try
|
|
|
|
+ with TProjectData(TPhaseData(FPhaseData).ProjectData).DetailGLData do
|
|
|
|
+ LoadDetailGLs(ABillsID, vGLs);
|
|
|
|
+ for iGL := 0 to vGLs.Count - 1 do
|
|
|
|
+ begin
|
|
|
|
+ GLRec := TDetailGLRecord(vGLs.Items[iGL]);
|
|
|
|
+ Result := Result + GLRec.Quantity.AsFloat * GLRec.RelaProjectGL.ValidDeltaPrice.AsFloat;
|
|
|
|
+ end;
|
|
|
|
+ finally
|
|
|
|
+ vGLs.Free;
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TStageData.CalculatePriceMargin(ABillsID: Integer);
|
|
|
|
+var
|
|
|
|
+ Rec: TStageRecord;
|
|
|
|
+ fPM, fPMDiffer: Double;
|
|
|
|
+begin
|
|
|
|
+ Rec := StageRecord(ABillsID);
|
|
|
|
+ if not Assigned(Rec) then Exit;
|
|
|
|
+
|
|
|
|
+ fPM := TotalPriceRoundTo(Rec.GatherQuantity.AsFloat * GetBillsUnitPriceMargin(ABillsID));
|
|
|
|
+ if fPM <> Rec.PM_TotalPrice.AsFloat then
|
|
|
|
+ begin
|
|
|
|
+ fPMDiffer := fPM - Rec.PM_TotalPrice.AsFloat;
|
|
|
|
+ Rec.PM_TotalPrice.AsFloat := fPM;
|
|
|
|
+ UpdateParentPriceMargin(ABillsID, fPMDiffer);
|
|
|
|
+ UpdatePriceMarginNode(fPMDiffer);
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TStageData.UpdatePriceMarginNode(ADiffer: Double);
|
|
|
|
+var
|
|
|
|
+ Rec: TStageRecord;
|
|
|
|
+begin
|
|
|
|
+ Rec := StageRecord(iPriceMarginID);
|
|
|
|
+ Rec.GatherTotalPrice.AsFloat := Rec.GatherTotalPrice.AsFloat + ADiffer;
|
|
|
|
+ UpdateParentRecord(iPriceMarginID, ADiffer, 'GatherTotalPrice');
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TStageData.UpdateParentPriceMargin(ABillsID: Integer; ADiffer: Double);
|
|
|
|
+var
|
|
|
|
+ iParentID: Integer;
|
|
|
|
+ Rec: TStageRecord;
|
|
|
|
+begin
|
|
|
|
+ iParentID := MainBillsTree.FindNode(ABillsID).ParentID;
|
|
|
|
+ if iParentID = -1 then Exit;
|
|
|
|
+
|
|
|
|
+ Rec := StageRecordWithAdd(iParentID);
|
|
|
|
+ Rec.PM_TotalPrice.AsFloat := TotalPriceRoundTo(Rec.PM_TotalPrice.AsFloat + ADiffer);
|
|
|
|
+ UpdateParentPriceMargin(iParentID, ADiffer);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TStageData.StageRecordWithAdd(ABillsID: Integer): TStageRecord;
|
|
|
|
+begin
|
|
|
|
+ Result := StageRecord(ABillsID);
|
|
|
|
+ if not Assigned(Result) then
|
|
|
|
+ Result := AddStageRecord(ABillsID);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TStageData.UpdateProjectGL(ABillsID: Integer);
|
|
|
|
+var
|
|
|
|
+ vGLs: TList;
|
|
|
|
+ iGL: Integer;
|
|
|
|
+ GLRec: TDetailGLRecord;
|
|
|
|
+begin
|
|
|
|
+ vGLs := TList.Create;
|
|
|
|
+ try
|
|
|
|
+ with TProjectData(TPhaseData(FPhaseData).ProjectData) do
|
|
|
|
+ begin
|
|
|
|
+ DetailGLData.LoadDetailGLs(ABillsID, vGLs);
|
|
|
|
+ ProjectGLData.CalculateGLs_PM(vGLs);
|
|
|
|
+ end;
|
|
|
|
+ finally
|
|
|
|
+ vGLs.Free;
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
end.
|
|
end.
|