StageDm.pas 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963
  1. unit StageDm;
  2. // 原报、审核数据通用
  3. // 原报 - Refer
  4. // 审核 - Audit1, Audit2 ...
  5. interface
  6. uses
  7. mDataRecord, BillsTree,
  8. SysUtils, Classes, sdDB, sdProvider, ADODB, ZhAPI, sdIDTree;
  9. type
  10. TStageData = class(TDataModule)
  11. sdpStage: TsdADOProvider;
  12. sddStage: TsdDataSet;
  13. procedure sddStageAfterValueChanged(AValue: TsdValue);
  14. procedure sddStageBeforeValueChange(AValue: TsdValue;
  15. const NewValue: Variant; var Allow: Boolean);
  16. procedure sddStageGetRecordClass(var ARecordClass: TsdRecordClass);
  17. private
  18. FPhaseData: TObject;
  19. FIndex: Integer;
  20. FBeforeChangeQuantity: Double;
  21. FBeforeChangeTotalPrice: Double;
  22. procedure BeforeBatchOperation;
  23. procedure AfterBatchOperation;
  24. procedure UpdateParentRecord(ABillsID: Integer; ATotalPrice: Double; const AFieldName: string);
  25. procedure UpdateComplete(ABillsID: Integer; AQuantity, ATotalPrice: Double);
  26. function HasPriceMarginBills: Boolean;
  27. // 向父项增量--PM_TotalPrice
  28. procedure UpdateParentPriceMargin(ABillsID: Integer; ADiffer: Double);
  29. // 向价差调整节点增量--GatherTotalPrice
  30. procedure UpdatePriceMarginNode(ADiffer: Double);
  31. // 重新计算相关的项目工料的价差数据
  32. procedure UpdateProjectGL(ABillsID: Integer);
  33. procedure CalculateDeal(ABillsID: Integer);
  34. procedure CalculateQuantityChange(ABillsID: Integer);
  35. procedure CalculatePriceChange(ABillsID: Integer);
  36. procedure CalculateParent(ANode: TMeasureBillsIDTreeNode);
  37. procedure CalculateLeaf(ANode: TMeasureBillsIDTreeNode);
  38. procedure CalculateSpecialLeaf(ANode: TMeasureBillsIDTreeNode);
  39. function GetTotalPrice(ABillsID, AType, AStageIndex: Integer): Double;
  40. function GetCalcType(ABillsID: Integer): Integer;
  41. function GetBillsUnitPriceMargin(ABillsID: Integer): Double;
  42. function GetBillsPrice(ABillsID: Integer): Double;
  43. function GetBillsNewPrice(ABillsID: Integer): Double;
  44. function GetBillsPriceDiffer(ABillsID: Integer): Double;
  45. function GetMainBillsTree: TBillsIDTree;
  46. function GetBuildLoadInterest(AType, AIndex: Integer): Double;
  47. function GetFirstPart(AType, AIndex: Integer): Double;
  48. function GetOtherFee(AType, AIndex: Integer): Double;
  49. function GetOtherProjectFee(AType, AIndex: Integer): Double;
  50. function GetRecyclingFee(AType, AIndex: Integer): Double;
  51. function GetReservedFee(AType, AIndex: Integer): Double;
  52. function GetSecondPart(AType, AIndex: Integer): Double;
  53. function GetStageSettlement(AType, AIndex: Integer): Double;
  54. function GetThirdPart(AType, AIndex: Integer): Double;
  55. function GetActive: Boolean;
  56. procedure SetTableName(const Value: string);
  57. function GetChapterStageGather(AChapter: Integer): Double;
  58. public
  59. constructor Create(APhaseData: TObject);
  60. destructor Destroy; override;
  61. procedure Open(AConnection: TADOConnection);
  62. procedure Save;
  63. // 计算任一清单节点的价差金额,并增量汇总至父项
  64. procedure CalculatePriceMargin(ABillsID: Integer);
  65. // 计算材料调差节点
  66. procedure CalculatePriceMarginNode;
  67. procedure CalculateNode(ANode: TsdIDTreeNode);
  68. procedure CalculateAll;
  69. function AddPhaseData(ABillsID: Integer;
  70. const AField, ANewValue: string): Boolean;
  71. function AddStageRecord(ABillsID: Integer): TStageRecord;
  72. procedure DeletePhaseRecord(ABillsID: Integer);
  73. procedure ReCalculate(ABillsID: Integer);
  74. procedure UpdateBGLInfo(ARec: TsdDataRecord; const AType: string);
  75. // 查找
  76. function StageRecord(ABillsID: Integer): TStageRecord;
  77. // 查找,如未找到则新增
  78. function StageRecordWithAdd(ABillsID: Integer): TStageRecord;
  79. // 将Bills表中存的累计计量数据拷贝至截止本期计量、截止上期计量,除新增一期计量外不可调用
  80. procedure CopyPrePhaseData;
  81. property Active: Boolean read GetActive;
  82. property TableName: string Write SetTableName;
  83. property MainBillsTree: TBillsIDTree read GetMainBillsTree;
  84. {可选计算数}
  85. // AType表示不同类型,取值如下:
  86. // 1: 本期数据 2: 截止本期数据 3: 截止上期数据
  87. // AIndex表示AType下不同数据类型,取值如下:
  88. // 1: 合同计量 2: 数量变更计量 3: 单价变更计量 4: 完成计量
  89. // 第一部分
  90. property FirstPart[AType, AIndex: Integer]: Double read GetFirstPart;
  91. // 第二部分
  92. property SecondPart[AType, AIndex: Integer]: Double read GetSecondPart;
  93. // 第三部分
  94. property ThirdPart[AType, AIndex: Integer]: Double read GetThirdPart;
  95. // 预留费用
  96. property ReservedFee[AType, AIndex: Integer]: Double read GetReservedFee;
  97. // 其他费用项目
  98. property OtherFee[AType, AIndex: Integer]: Double read GetOtherFee;
  99. // 建设期贷款利息
  100. property BuildLoadInterest[AType, AIndex: Integer]: Double read GetBuildLoadInterest;
  101. // 回收金额
  102. property RecyclingFee[AType, AIndex: Integer]: Double read GetRecyclingFee;
  103. // 公路工程以外的工程费用
  104. property OtherProjectFee[AType, AIndex: Integer]: Double read GetOtherProjectFee;
  105. // 本期结算价
  106. property StageSettlement[AType, AIndex: Integer]: Double read GetStageSettlement;
  107. // 100/200/.../900章本期完成计量
  108. property ChapterStageGather[AChapter: Integer]: Double read GetChapterStageGather;
  109. end;
  110. implementation
  111. uses
  112. ProjectData, BillsDm, PhaseData, Math, BGLDm, BillsMeasureDm,
  113. UtilMethods, ConditionalDefines, FormulaCalc, DetailGLDm, ConstUnit,
  114. ProjectGLDm;
  115. {$R *.dfm}
  116. { TPhaseData }
  117. function TStageData.AddPhaseData(ABillsID: Integer;
  118. const AField, ANewValue: string): Boolean;
  119. procedure SetPhaseRecord(ARec: TsdDataRecord; const AField, AValue: string);
  120. begin
  121. if CheckNumeric(ANewValue) then
  122. ARec.ValueByName(AField).AsString := AValue
  123. else
  124. begin
  125. ARec.ValueByName(AField).AsFloat := EvaluateExprs(AValue);
  126. ARec.ValueByName(StringReplace(AField, 'Quantity', 'Flag', [])).AsInteger := 1;
  127. ARec.ValueByName(StringReplace(AField, 'Quantity', 'Formula', [])).AsString := AValue;
  128. end;
  129. end;
  130. var
  131. Rec: TsdDataRecord;
  132. begin
  133. if Assigned(sddStage.FindKey('idxBID', ABillsID)) then Exit;
  134. Rec := sddStage.Add;
  135. Rec.ValueByName('BillsID').AsInteger := ABillsID;
  136. SetPhaseRecord(Rec, AField, ANewValue);
  137. end;
  138. function TStageData.AddStageRecord(ABillsID: Integer): TStageRecord;
  139. begin
  140. Result := TStageRecord(sddStage.FindKey('idxBID', ABillsID));
  141. if Assigned(Result) then Exit;
  142. Result := TStageRecord(sddStage.Add(True));
  143. try
  144. Result.ValueByName('BillsID').AsInteger := ABillsID;
  145. finally
  146. Result.EndUpdate;
  147. end;
  148. end;
  149. procedure TStageData.CalculateDeal(ABillsID: Integer);
  150. var
  151. Rec: TsdDataRecord;
  152. fQtyDiffer, fTPDiffer: Double;
  153. begin
  154. Rec := sddStage.FindKey('idxBID', ABillsID);
  155. if GetCalcType(ABillsID) = 0 then
  156. Rec.ValueByName('DealTotalPrice').AsFloat :=
  157. TotalPriceRoundTo(Rec.ValueByName('DealQuantity').AsFloat * GetBillsPrice(ABillsID));
  158. fQtyDiffer := Rec.ValueByName('DealQuantity').AsFloat - FBeforeChangeQuantity;
  159. fTPDiffer := Rec.ValueByName('DealTotalPrice').AsFloat - FBeforeChangeTotalPrice;
  160. Rec.ValueByName('EndDealQuantity').AsFloat := QuantityRoundTo(
  161. Rec.ValueByName('EndDealQuantity').AsFloat + fQtyDiffer);
  162. Rec.ValueByName('EndDealTotalPrice').AsFloat := TotalPriceRoundTo(
  163. Rec.ValueByName('EndDealTotalPrice').AsFloat + fTPDiffer);
  164. UpdateParentRecord(ABillsID, fTPDiffer, 'DealTotalPrice');
  165. UpdateComplete(ABillsID, fQtyDiffer, fTPDiffer);
  166. if TPhaseData(FPhaseData).IsLastStage then
  167. with TProjectData(TPhaseData(FPhaseData).ProjectData).BillsMeasureData do
  168. UpdateRecordDeal(ABillsID, fQtyDiffer, fTPDiffer);
  169. CalculatePriceMargin(ABillsID);
  170. TPhaseData(FPhaseData).PhasePayData.CalculateAll;
  171. end;
  172. procedure TStageData.CalculatePriceChange(ABillsID: Integer);
  173. var
  174. Rec: TsdDataRecord;
  175. fQtyDiffer, fTPDiffer: Double;
  176. begin
  177. Rec := sddStage.FindKey('idxBID', ABillsID);
  178. if GetCalcType(ABillsID) < 2 then
  179. Rec.ValueByName('PcTotalPrice').AsFloat :=
  180. TotalPriceRoundTo(Rec.ValueByName('PcQuantity').AsFloat * GetBillsPriceDiffer(ABillsID));
  181. fQtyDiffer := Rec.ValueByName('PcQuantity').AsFloat - FBeforeChangeQuantity;
  182. fTPDiffer := Rec.ValueByName('PcTotalPrice').AsFloat - FBeforeChangeTotalPrice;
  183. Rec.ValueByName('EndPcQuantity').AsFloat := QuantityRoundTo(
  184. Rec.ValueByName('EndPcQuantity').AsFloat + fQtyDiffer);
  185. Rec.ValueByName('EndPcTotalPrice').AsFloat := TotalPriceRoundTo(
  186. Rec.ValueByName('EndPcTotalPrice').AsFloat + fTPDiffer);
  187. UpdateParentRecord(ABillsID, fTPDiffer, 'PcTotalPrice');
  188. UpdateComplete(ABillsID, 0, fTPDiffer);
  189. if TPhaseData(FPhaseData).IsLastStage then
  190. with TProjectData(TPhaseData(FPhaseData).ProjectData).BillsMeasureData do
  191. UpdateRecordPc(ABillsID, fQtyDiffer, fTPDiffer);
  192. TPhaseData(FPhaseData).PhasePayData.CalculateAll;
  193. end;
  194. procedure TStageData.CalculateQuantityChange(ABillsID: Integer);
  195. var
  196. Rec: TsdDataRecord;
  197. fQtyDiffer, fTPDiffer: Double;
  198. begin
  199. Rec := sddStage.FindKey('idxBID', ABillsID);
  200. if GetCalcType(ABillsID) = 0 then
  201. Rec.ValueByName('QcTotalPrice').AsFloat :=
  202. TotalPriceRoundTo(Rec.ValueByName('QcQuantity').AsFloat * GetBillsPrice(ABillsID));
  203. fQtyDiffer := Rec.ValueByName('QcQuantity').AsFloat - FBeforeChangeQuantity;
  204. fTPDiffer := Rec.ValueByName('QcTotalPrice').AsFloat - FBeforeChangeTotalPrice;
  205. Rec.ValueByName('EndQcQuantity').AsFloat := QuantityRoundTo(
  206. Rec.ValueByName('EndQcQuantity').AsFloat + fQtyDiffer);
  207. Rec.ValueByName('EndQcTotalPrice').AsFloat := TotalPriceRoundTo(
  208. Rec.ValueByName('EndQcTotalPrice').AsFloat + fTPDiffer);
  209. UpdateParentRecord(ABillsID, fTPDiffer, 'QcTotalPrice');
  210. UpdateComplete(ABillsID, fQtyDiffer, fTPDiffer);
  211. if TPhaseData(FPhaseData).IsLastStage then
  212. with TProjectData(TPhaseData(FPhaseData).ProjectData).BillsMeasureData do
  213. UpdateRecordQc(ABillsID, fQtyDiffer, fTPDiffer);
  214. CalculatePriceMargin(ABillsID);
  215. TPhaseData(FPhaseData).PhasePayData.CalculateAll;
  216. end;
  217. constructor TStageData.Create(APhaseData: TObject);
  218. begin
  219. inherited Create(nil);
  220. FPhaseData := APhaseData;
  221. end;
  222. procedure TStageData.DeletePhaseRecord(ABillsID: Integer);
  223. var
  224. Rec: TsdDataRecord;
  225. begin
  226. Rec := sddStage.FindKey('idxBID', ABillsID);
  227. if Assigned(Rec) then
  228. sddStage.Remove(Rec);
  229. end;
  230. destructor TStageData.Destroy;
  231. begin
  232. inherited;
  233. end;
  234. function TStageData.GetBillsNewPrice(ABillsID: Integer): Double;
  235. begin
  236. Result := MainBillsTree.FindNode(ABillsID).Rec.ValueByName('NewPrice').AsFloat;
  237. end;
  238. function TStageData.GetBillsPrice(ABillsID: Integer): Double;
  239. begin
  240. Result := MainBillsTree.FindNode(ABillsID).Rec.ValueByName('Price').AsFloat;
  241. end;
  242. procedure TStageData.Open(AConnection: TADOConnection);
  243. begin
  244. sdpStage.Connection := AConnection;
  245. sddStage.Open;
  246. if not Assigned(sddStage.IndexList.FindByName('idxBID')) then
  247. sddStage.AddIndex('idxBID', 'BillsID');
  248. sddStage.FieldByName('DealQuantity').ValidChars := sddStage.FieldByName('DealQuantity').ValidChars + ArithmeticCharSet;
  249. sddStage.FieldByName('DealTotalPrice').ValidChars := sddStage.FieldByName('DealQuantity').ValidChars;
  250. end;
  251. function TStageData.StageRecord(ABillsID: Integer): TStageRecord;
  252. begin
  253. Result := nil;
  254. if Assigned(sddStage.IndexList.FindByName('idxBID')) then
  255. Result := TStageRecord(sddStage.FindKey('idxBID', ABillsID));
  256. end;
  257. procedure TStageData.ReCalculate(ABillsID: Integer);
  258. var
  259. Rec: TsdDataRecord;
  260. fDiffer: Double;
  261. begin
  262. Rec := sddStage.FindKey('idxBID', ABillsID);
  263. if not Assigned(Rec) then Exit;
  264. if Rec.ValueByName('DealFlag').AsInteger = 1 then
  265. Rec.ValueByName('DealQuantity').AsFloat := QuantityRoundTo(
  266. EvaluateExprs(Rec.ValueByName('DealFormula').AsString));
  267. if Rec.ValueByName('DealFlag').AsInteger < 2 then
  268. begin
  269. fDiffer := Rec.ValueByName('DealQuantity').AsFloat * GetBillsPrice(ABillsID)
  270. - Rec.ValueByName('DealTotalPrice').AsFloat;
  271. Rec.ValueByName('DealTotalPrice').AsFloat := TotalPriceRoundTo(
  272. Rec.ValueByName('DealQuantity').AsFloat * GetBillsPrice(ABillsID));
  273. end;
  274. Rec.ValueByName('EndDealQuantity').AsFloat := QuantityRoundTo(
  275. Rec.ValueByName('PreDealQuantity').AsFloat + Rec.ValueByName('DealQuantity').AsFloat);
  276. Rec.ValueByName('EndDealTotalPrice').AsFloat := TotalPriceRoundTo(
  277. Rec.ValueByName('PreDealTotalPrice').AsFloat + Rec.ValueByName('DealTotalPrice').AsFloat);
  278. if Rec.ValueByName('QcFlag').AsInteger = 1 then
  279. Rec.ValueByName('QcQuantity').AsFloat := QuantityRoundTo(
  280. EvaluateExprs(Rec.ValueByName('QcFormula').AsString));
  281. if Rec.ValueByName('QcFlag').AsInteger < 2 then
  282. begin
  283. fDiffer := Rec.ValueByName('QcQuantity').AsFloat * GetBillsPrice(ABillsID)
  284. - Rec.ValueByName('QcTotalPrice').AsFloat;
  285. Rec.ValueByName('QcTotalPrice').AsFloat := TotalPriceRoundTo(
  286. Rec.ValueByName('QcQuantity').AsFloat * GetBillsPrice(ABillsID));
  287. end;
  288. Rec.ValueByName('EndQcQuantity').AsFloat := QuantityRoundTo(
  289. Rec.ValueByName('PreQcQuantity').AsFloat + Rec.ValueByName('QcQuantity').AsFloat);
  290. Rec.ValueByName('EndQcTotalPrice').AsFloat := TotalPriceRoundTo(
  291. Rec.ValueByName('PreQcTotalPrice').AsFloat + Rec.ValueByName('QcTotalPrice').AsFloat);
  292. if Rec.ValueByName('PcFlag').AsInteger = 1 then
  293. Rec.ValueByName('PcQuantity').AsFloat := QuantityRoundTo(
  294. EvaluateExprs(Rec.ValueByName('PcFormula').AsString));
  295. if Rec.ValueByName('DealFlag').AsInteger < 2 then
  296. begin
  297. fDiffer := Rec.ValueByName('PcQuantity').AsFloat * GetBillsNewPrice(ABillsID)
  298. - Rec.ValueByName('PcTotalPrice').AsFloat;
  299. Rec.ValueByName('PcTotalPrice').AsFloat := TotalPriceRoundTo(
  300. Rec.ValueByName('PcQuantity').AsFloat * GetBillsNewPrice(ABillsID));
  301. end;
  302. Rec.ValueByName('EndPcQuantity').AsFloat := QuantityRoundTo(
  303. Rec.ValueByName('PrePcQuantity').AsFloat + Rec.ValueByName('PcQuantity').AsFloat);
  304. Rec.ValueByName('EndPcTotalPrice').AsFloat := TotalPriceRoundTo(
  305. Rec.ValueByName('PrePcTotalPrice').AsFloat + Rec.ValueByName('PcTotalPrice').AsFloat);
  306. end;
  307. procedure TStageData.Save;
  308. begin
  309. sddStage.Save;
  310. end;
  311. procedure TStageData.sddStageAfterValueChanged(AValue: TsdValue);
  312. var
  313. iBillsID: Integer;
  314. stnNode: TsdIDTreeNode;
  315. begin
  316. iBillsID := AValue.Owner.ValueByName('BillsID').AsInteger;
  317. stnNode := MainBillsTree.FindNode(iBillsID);
  318. if not Assigned(stnNode) or stnNode.HasChildren then Exit;
  319. if (AValue.FieldName = 'DealQuantity') or
  320. (AValue.FieldName = 'DealFormula') or
  321. (AValue.FieldName = 'DealTotalPrice') then
  322. CalculateDeal(iBillsID);
  323. if (AValue.FieldName = 'QcQuantity') or
  324. (AValue.FieldName = 'QcFormula') or
  325. (AValue.FieldName = 'QcTotalPrice') then
  326. CalculateQuantityChange(iBillsID);
  327. if (AValue.FieldName = 'PcQuantity') or
  328. (AValue.FieldName = 'PcFormula') or
  329. (AValue.FieldName = 'PcTotalPrice') then
  330. CalculatePriceChange(iBillsID);
  331. if (AValue.FieldName = 'DealQuantity') or
  332. (AValue.FieldName = 'QcQuantity') then
  333. UpdateProjectGL(iBillsID);
  334. end;
  335. function TStageData.GetMainBillsTree: TBillsIDTree;
  336. begin
  337. with TProjectData(TPhaseData(FPhaseData).ProjectData) do
  338. Result := BillsMeasureData.BillsMeasureTree;
  339. end;
  340. procedure TStageData.sddStageBeforeValueChange(AValue: TsdValue;
  341. const NewValue: Variant; var Allow: Boolean);
  342. procedure SetBeforeChangeValue(const AType: string);
  343. begin
  344. if SameText(AValue.FieldName, AType + 'Quantity') or
  345. SameText(AValue.FieldName, AType + 'Formula') or
  346. SameText(AValue.FieldName, AType + 'TotalPrice') then
  347. begin
  348. FBeforeChangeQuantity := AValue.Owner.ValueByName(AType + 'Quantity').AsFloat;
  349. FBeforeChangeTotalPrice := AValue.Owner.ValueByName(AType + 'TotalPrice').AsFloat;
  350. end;
  351. end;
  352. procedure CheckOverRange;
  353. var
  354. vNode: TsdIDTreeNode;
  355. fAvailableQty: Double;
  356. begin
  357. if SameText(AValue.FieldName, 'DealQuantity') then
  358. begin
  359. vNode := MainBillsTree.FindNode(AValue.Owner.ValueByName('BillsID').AsInteger);
  360. fAvailableQty := vNode.Rec.ValueByName('Quantity').AsFloat
  361. - vNode.Rec.ValueByName('AddDealQuantity').AsFloat + AValue.AsFloat;
  362. if VarToFloatDef(NewValue, 0) > fAvailableQty then
  363. DataSetErrorMessage(Allow, '不可超过0号台账合同数量!');
  364. end;
  365. end;
  366. begin
  367. // 不检查超计
  368. //CheckOverRange;
  369. SetBeforeChangeValue('Deal');
  370. SetBeforeChangeValue('Qc');
  371. SetBeforeChangeValue('Pc');
  372. end;
  373. procedure TStageData.AfterBatchOperation;
  374. begin
  375. sddStage.BeforeValueChange := sddStageBeforeValueChange;
  376. sddStage.AfterValueChanged := sddStageAfterValueChanged;
  377. end;
  378. procedure TStageData.BeforeBatchOperation;
  379. begin
  380. sddStage.BeforeValueChange := nil;
  381. sddStage.AfterValueChanged := nil;
  382. end;
  383. function TStageData.GetBillsPriceDiffer(ABillsID: Integer): Double;
  384. begin
  385. with MainBillsTree.FindNode(ABillsID).Rec do
  386. Result := ValueByName('NewPrice').AsFloat - ValueByName('Price').AsFloat;
  387. end;
  388. procedure TStageData.UpdateComplete(ABillsID: Integer; AQuantity,
  389. ATotalPrice: Double);
  390. var
  391. Rec: TsdDataRecord;
  392. begin
  393. if ABillsID = -1 then Exit;
  394. Rec := StageRecord(ABillsID);
  395. Rec.ValueByName('GatherQuantity').AsFloat := QuantityRoundTo(
  396. Rec.ValueByName('GatherQuantity').AsFloat + AQuantity);
  397. Rec.ValueByName('GatherTotalPrice').AsFloat := TotalPriceRoundTo(
  398. Rec.ValueByName('GatherTotalPrice').AsFloat + ATotalPrice);
  399. Rec.ValueByName('EndGatherQuantity').AsFloat := QuantityRoundTo(
  400. Rec.ValueByName('EndGatherQuantity').AsFloat + AQuantity);
  401. Rec.ValueByName('EndGatherTotalPrice').AsFloat := TotalPriceRoundTo(
  402. Rec.ValueByName('EndGatherTotalPrice').AsFloat + ATotalPrice);
  403. // 数量不向上汇总
  404. UpdateParentRecord(ABillsID, ATotalPrice, 'GatherTotalPrice');
  405. end;
  406. procedure TStageData.UpdateParentRecord(ABillsID: Integer;
  407. ATotalPrice: Double; const AFieldName: string);
  408. var
  409. iParentID: Integer;
  410. Rec: TsdDataRecord;
  411. begin
  412. iParentID := MainBillsTree.FindNode(ABillsID).ParentID;
  413. if iParentID = -1 then Exit;
  414. Rec := StageRecordWithAdd(iParentID);
  415. Rec.ValueByName(AFieldName).AsFloat := TotalPriceRoundTo(
  416. Rec.ValueByName(AFieldName).AsFloat + ATotalPrice);
  417. Rec.ValueByName('End' + AFieldName).AsFloat := TotalPriceRoundTo(
  418. Rec.ValueByName('End' + AFieldName).AsFloat + ATotalPrice);
  419. UpdateParentRecord(iParentID, ATotalPrice, AFieldName);
  420. end;
  421. function TStageData.GetBuildLoadInterest(AType, AIndex: Integer): Double;
  422. begin
  423. Result := GetTotalPrice(34, AType, AIndex);
  424. end;
  425. function TStageData.GetFirstPart(AType, AIndex: Integer): Double;
  426. begin
  427. Result := GetTotalPrice(1, AType, AIndex);
  428. end;
  429. function TStageData.GetOtherFee(AType, AIndex: Integer): Double;
  430. begin
  431. Result := GetTotalPrice(15, AType, AIndex);
  432. end;
  433. function TStageData.GetOtherProjectFee(AType, AIndex: Integer): Double;
  434. begin
  435. Result := GetTotalPrice(9, AType, AIndex);
  436. end;
  437. function TStageData.GetRecyclingFee(AType, AIndex: Integer): Double;
  438. begin
  439. Result := GetTotalPrice(16, AType, AIndex);
  440. end;
  441. function TStageData.GetReservedFee(AType, AIndex: Integer): Double;
  442. begin
  443. Result := GetTotalPrice(7, AType, AIndex);
  444. end;
  445. function TStageData.GetSecondPart(AType, AIndex: Integer): Double;
  446. begin
  447. Result := GetTotalPrice(2, AType, AIndex);
  448. end;
  449. function TStageData.GetStageSettlement(AType, AIndex: Integer): Double;
  450. begin
  451. // 全国
  452. // 第一部分+第二部分+第三部分+预备费+新增加费用项目(其他费用_广东)-回收金额
  453. Result := FirstPart[AType, AIndex] + SecondPart[AType, AIndex] + ThirdPart[AType, AIndex]
  454. + ReservedFee[AType, AIndex] + OtherFee[AType, AIndex] - RecyclingFee[AType, AIndex];
  455. // 广东
  456. // 全国的基础上+建设期贷款利息+公路功能以外的项目
  457. if _IsGuangDong then
  458. Result := Result + BuildLoadInterest[AType, AIndex] + OtherProjectFee[AType, AIndex]
  459. end;
  460. function TStageData.GetThirdPart(AType, AIndex: Integer): Double;
  461. begin
  462. Result := GetTotalPrice(3, AType, AIndex);
  463. end;
  464. function TStageData.GetTotalPrice(ABillsID, AType, AStageIndex: Integer): Double;
  465. var
  466. Rec: TsdDataRecord;
  467. sFieldName: string;
  468. begin
  469. Result := 0;
  470. Rec := StageRecord(ABillsID);
  471. if not Assigned(Rec) then Exit;
  472. case AType of
  473. 1: sFieldName := '';
  474. 2: sFieldName := 'End';
  475. 3: sFieldName := 'Pre';
  476. end;
  477. case AStageIndex of
  478. 1: sFieldName := sFieldName + 'DealTotalPrice';
  479. 2: sFieldName := sFieldName + 'QcTotalPrice';
  480. 3: sFieldName := sFieldName + 'PcTotalPrice';
  481. 4: sFieldName := sFieldName + 'GatherTotalPrice';
  482. end;
  483. Result := Rec.ValueByName(sFieldName).AsFloat;
  484. end;
  485. procedure TStageData.CopyPrePhaseData;
  486. var
  487. iRecord: Integer;
  488. Rec: TBillsRecord;
  489. NewRec: TStageRecord;
  490. begin
  491. BeforeBatchOperation;
  492. try
  493. with TProjectData(TPhaseData(FPhaseData).ProjectData).BillsData do
  494. for iRecord := 0 to sddBills.RecordCount - 1 do
  495. begin
  496. Rec := TBillsRecord(sddBills.Records[iRecord]);
  497. if (Rec.AddGatherTotalPrice.AsFloat = 0) and
  498. (Rec.AddDealTotalPrice.AsFloat = 0) and
  499. (Rec.AddQcTotalPrice.AsFloat = 0) and
  500. (Rec.AddPcTotalPrice.AsFloat = 0) and
  501. (Rec.PM_AddTotalPrice.AsFloat = 0) then Continue;
  502. NewRec := TStageRecord(sddStage.Add);
  503. NewRec.BillsID.AsInteger := Rec.ID.AsInteger;
  504. NewRec.EndDealQuantity.AsFloat := Rec.AddDealQuantity.AsFloat;
  505. NewRec.EndDealTotalPrice.AsFloat := Rec.AddDealTotalPrice.AsFloat;
  506. NewRec.EndQcQuantity.AsFloat := Rec.AddQcQuantity.AsFloat;
  507. NewRec.EndQcTotalPrice.AsFloat := Rec.AddQcTotalPrice.AsFloat;
  508. NewRec.EndQcBGLCode.AsString := Rec.AddQcBGLCode.AsString;
  509. NewRec.EndQcBGLNum.AsString := Rec.AddQcBGLNum.AsString;
  510. NewRec.EndPcQuantity.AsFloat := Rec.AddPcQuantity.AsFloat;
  511. NewRec.EndPcTotalPrice.AsFloat := Rec.AddPcTotalPrice.AsFloat;
  512. NewRec.EndPcBGLCode.AsString := Rec.AddPcBGLCode.AsString;
  513. NewRec.EndPcBGLNum.AsString := Rec.AddPcBGLNum.AsString;
  514. NewRec.EndGatherQuantity.AsFloat := Rec.AddGatherQuantity.AsFloat;
  515. NewRec.EndGatherTotalPrice.AsFloat := Rec.AddGatherTotalPrice.AsFloat;
  516. NewRec.PreDealQuantity.AsFloat := Rec.AddDealQuantity.AsFloat;
  517. NewRec.PreDealTotalPrice.AsFloat := Rec.AddDealTotalPrice.AsFloat;
  518. NewRec.PreQcQuantity.AsFloat := Rec.AddQcQuantity.AsFloat;
  519. NewRec.PreQcTotalPrice.AsFloat := Rec.AddQcTotalPrice.AsFloat;
  520. NewRec.PreQcBGLCode.AsString := Rec.AddQcBGLCode.AsString;
  521. NewRec.PreQcBGLNum.AsString := Rec.AddQcBGLNum.AsString;
  522. NewRec.PrePcQuantity.AsFloat := Rec.AddPcQuantity.AsFloat;
  523. NewRec.PrePcTotalPrice.AsFloat := Rec.AddPcTotalPrice.AsFloat;
  524. NewRec.PrePcBGLCode.AsString := Rec.AddPcBGLCode.AsString;
  525. NewRec.PrePcBGLNum.AsString := Rec.AddPcBGLNum.AsString;
  526. NewRec.PreGatherQuantity.AsFloat := Rec.AddGatherQuantity.AsFloat;
  527. NewRec.PreGatherTotalPrice.AsFloat := Rec.AddGatherTotalPrice.AsFloat;
  528. NewRec.PM_PreTotalPrice.AsFloat := Rec.PM_AddTotalPrice.AsFloat;
  529. end;
  530. finally
  531. AfterBatchOperation;
  532. end;
  533. end;
  534. procedure TStageData.UpdateBGLInfo(ARec: TsdDataRecord; const AType: string);
  535. var
  536. sPreBGLCode, sPreBGLNum, sCurBGLCode, sCurBGLNum: string;
  537. begin
  538. sPreBGLCode := ARec.ValueByName('Pre' + AType + 'BGLCode').AsString;
  539. sPreBGLNum := ARec.ValueByName('Pre' + AType + 'BGLNum').AsString;
  540. sCurBGLCode := ARec.ValueByName(AType + 'BGLCode').AsString;
  541. sCurBGLNum := ARec.ValueByName(AType + 'BGLNum').AsString;
  542. MergeRelaBGLAndNum(sPreBGLCode, sPreBGLNum, sCurBGLCode, sCurBGLNum);
  543. ARec.ValueByName('End' + AType + 'BGLCode').AsString := sPreBGLCode;
  544. ARec.ValueByName('End' + AType + 'BGLNum').AsString := sPreBGLNum;
  545. end;
  546. procedure TStageData.CalculateAll;
  547. begin
  548. BeforeBatchOperation;
  549. CalculateNode(MainBillsTree.FirstNode);
  550. AfterBatchOperation;
  551. end;
  552. procedure TStageData.CalculateNode(ANode: TsdIDTreeNode);
  553. function IsSpecialNode: Boolean;
  554. begin
  555. Result := ANode.ID = iPriceMarginID;
  556. end;
  557. begin
  558. if not Assigned(ANode) then Exit;
  559. if ANode.HasChildren then
  560. begin
  561. CalculateNode(ANode.FirstChild);
  562. CalculateParent(TMeasureBillsIDTreeNode(ANode));
  563. end
  564. else
  565. begin
  566. if IsSpecialNode then
  567. CalculateSpecialLeaf(TMeasureBillsIDTreeNode(ANode))
  568. else
  569. CalculateLeaf(TMeasureBillsIDTreeNode(ANode));
  570. end;
  571. CalculateNode(ANode.NextSibling);
  572. end;
  573. procedure TStageData.CalculateParent(ANode: TMeasureBillsIDTreeNode);
  574. var
  575. iChild: Integer;
  576. ChildNode: TMeasureBillsIDTreeNode;
  577. fDeal, fQc, fPc, fPM: Double;
  578. begin
  579. if not Assigned(ANode.StageRec) then Exit;
  580. fDeal := 0;
  581. fQc := 0;
  582. fPc := 0;
  583. fPM := 0;
  584. for iChild := 0 to ANode.ChildCount - 1 do
  585. begin
  586. ChildNode := TMeasureBillsIDTreeNode(ANode.ChildNodes[iChild]);
  587. if not Assigned(ChildNode.StageRec) then Continue;
  588. fDeal := TotalPriceRoundTo(fDeal + ChildNode.StageRec.DealTotalPrice.AsFloat);
  589. fQc := TotalPriceRoundTo(fQc + ChildNode.StageRec.QcTotalPrice.AsFloat);
  590. fPc := TotalPriceRoundTo(fPc + ChildNode.StageRec.PcTotalPrice.AsFloat);
  591. fPM := TotalPriceRoundTo(fPM + ChildNode.StageRec.PM_TotalPrice.AsFloat);
  592. end;
  593. with ANode.StageRec do
  594. begin
  595. if (DealTotalPrice.AsFloat <> fDeal) or
  596. (QcTotalPrice.AsFloat <> fQc) or
  597. (PcTotalPrice.AsFloat <> fPc) then
  598. begin
  599. DealTotalPrice.AsFloat := fDeal;
  600. QcTotalPrice.AsFloat := fQc;
  601. PcTotalPrice.AsFloat := fPc;
  602. GatherTotalPrice.AsFloat := TotalPriceRoundTo(fDeal + fQc + fPc);
  603. EndDealTotalPrice.AsFloat := TotalPriceRoundTo(PreDealTotalPrice.AsFloat + fDeal);
  604. EndQcTotalPrice.AsFloat := TotalPriceRoundTo(PreQcTotalPrice.AsFloat + fQc);
  605. EndPcTotalPrice.AsFloat := TotalPriceRoundTo(PrePcTotalPrice.AsFloat + fPc);
  606. EndGatherTotalPrice.AsFloat := TotalPriceRoundTo(
  607. PreGatherTotalPrice.AsFloat + GatherTotalPrice.AsFloat);
  608. end;
  609. if PM_TotalPrice.AsFloat <> fPM then
  610. PM_TotalPrice.AsFloat := fPM;
  611. end;
  612. end;
  613. procedure TStageData.CalculateLeaf(ANode: TMeasureBillsIDTreeNode);
  614. procedure CalculateMeasure(ARec: TsdDataRecord; const AType: string);
  615. begin
  616. if GetCalcType(ANode.ID) = 0 then
  617. begin
  618. if ARec.ValueByName(AType + 'Formula').AsString <> '' then
  619. ARec.ValueByName(AType + 'Quantity').AsFloat :=
  620. EvaluateExprs(ARec.ValueByName(AType + 'Formula').AsString);
  621. ARec.ValueByName(AType + 'TotalPrice').AsFloat := TotalPriceRoundTo(
  622. ARec.ValueByName(AType + 'Quantity').AsFloat * GetBillsPrice(ANode.ID));
  623. end;
  624. ARec.ValueByName('End' + AType + 'Quantity').AsFloat := QuantityRoundTo(
  625. ARec.ValueByName('Pre' + AType + 'Quantity').AsFloat + ARec.ValueByName(AType + 'Quantity').AsFloat);
  626. ARec.ValueByName('End' + AType + 'TotalPrice').AsFloat := TotalPriceRoundTo(
  627. ARec.ValueByName('Pre' + AType + 'TotalPrice').AsFloat + ARec.ValueByName(AType + 'TotalPrice').AsFloat);
  628. end;
  629. procedure CalculatePriceMargin(ARec: TStageRecord);
  630. var
  631. fPrice: Double;
  632. begin
  633. fPrice := GetBillsUnitPriceMargin(ARec.BillsID.AsInteger);
  634. ARec.SetFloatValue(ARec.PM_TotalPrice, TotalPriceRoundTo(ARec.GatherQuantity.AsFloat * fPrice));
  635. end;
  636. var
  637. Rec: TStageRecord;
  638. begin
  639. Rec := ANode.StageRec;
  640. if not Assigned(Rec) then Exit;
  641. CalculateMeasure(Rec, 'Deal');
  642. CalculateMeasure(Rec, 'Pc');
  643. CalculateMeasure(Rec, 'Qc');
  644. Rec.GatherQuantity.AsFloat := QuantityRoundTo(
  645. Rec.DealQuantity.AsFloat + Rec.QcQuantity.AsFloat);
  646. Rec.GatherTotalPrice.AsFloat := TotalPriceRoundTo(
  647. Rec.DealTotalPrice.AsFloat + Rec.QcTotalPrice.AsFloat + Rec.PcTotalPrice.AsFloat);
  648. Rec.EndGatherQuantity.AsFloat := QuantityRoundTo(
  649. Rec.PreGatherQuantity.AsFloat + Rec.GatherQuantity.AsFloat);
  650. Rec.EndGatherTotalPrice.AsFloat := TotalPriceRoundTo(
  651. Rec.PreGatherTotalPrice.AsFloat + Rec.GatherTotalPrice.AsFloat);
  652. CalculatePriceMargin(Rec);
  653. end;
  654. function TStageData.GetActive: Boolean;
  655. begin
  656. Result := sddStage.Active;
  657. end;
  658. procedure TStageData.SetTableName(const Value: string);
  659. begin
  660. sdpStage.TableName := Value;
  661. end;
  662. procedure TStageData.sddStageGetRecordClass(
  663. var ARecordClass: TsdRecordClass);
  664. begin
  665. ARecordClass := TStageRecord;
  666. end;
  667. function TStageData.GetChapterStageGather(AChapter: Integer): Double;
  668. function CheckCodeChapter(const ACode: string): Boolean;
  669. var
  670. iFirst: Integer;
  671. sgs: TStrings;
  672. begin
  673. sgs := TStringList.Create;
  674. try
  675. sgs.Delimiter := '-';
  676. sgs.DelimitedText := ACode;
  677. if sgs.Count > 1 then
  678. begin
  679. iFirst := StrToIntDef(sgs[0], 0) div 100;
  680. Result := iFirst = AChapter;
  681. end
  682. else
  683. Result := False;
  684. finally
  685. sgs.Free;
  686. end;
  687. end;
  688. var
  689. iIndex: Integer;
  690. Rec: TsdDataRecord;
  691. stnNode: TsdIDTreeNode;
  692. begin
  693. Result := 0;
  694. for iIndex := 0 to sddStage.RecordCount - 1 do
  695. begin
  696. Rec := sddStage.Records[iIndex];
  697. stnNode := MainBillsTree.FindNode(Rec.ValueByName('BillsID').AsInteger);
  698. if not stnNode.HasChildren and CheckCodeChapter(stnNode.Rec.ValueByName('B_Code').AsString) then
  699. Result := Result + Rec.ValueByName('GatherTotalPrice').AsFloat;
  700. end;
  701. end;
  702. function TStageData.GetCalcType(ABillsID: Integer): Integer;
  703. begin
  704. Result := MainBillsTree.FindNode(ABillsID).Rec.ValueByName('CalcType').AsInteger;
  705. end;
  706. procedure TStageData.CalculatePriceMarginNode;
  707. var
  708. Rec: TStageRecord;
  709. fDiffer: Double;
  710. begin
  711. if not HasPriceMarginBills then Exit;
  712. with TProjectData(TPhaseData(FPhaseData).ProjectData) do
  713. begin
  714. Rec := StageRecord(iPriceMarginID);
  715. if not Assigned(Rec) then
  716. Rec := AddStageRecord(iPriceMarginID);
  717. fDiffer := TotalPriceRoundTo(ProjectGLData.PM_TotalPrice - Rec.GatherTotalPrice.AsFloat);
  718. if fDiffer <> 0 then
  719. begin
  720. Rec.AddDifferValue(Rec.GatherTotalPrice, fDiffer);
  721. Rec.AddDifferValue(Rec.EndGatherTotalPrice, fDiffer);
  722. UpdateParentRecord(Rec.BillsID.AsInteger, fDiffer, 'GatherTotalPrice');
  723. end;
  724. end;
  725. end;
  726. function TStageData.GetBillsUnitPriceMargin(ABillsID: Integer): Double;
  727. var
  728. vGLs: TList;
  729. iGL: Integer;
  730. GLRec: TDetailGLRecord;
  731. begin
  732. Result := 0;
  733. vGLs := TList.Create;
  734. try
  735. with TProjectData(TPhaseData(FPhaseData).ProjectData).DetailGLData do
  736. LoadDetailGLs(ABillsID, vGLs);
  737. for iGL := 0 to vGLs.Count - 1 do
  738. begin
  739. GLRec := TDetailGLRecord(vGLs.Items[iGL]);
  740. Result := Result + GLRec.Quantity.AsFloat * GLRec.RelaProjectGL.ValidDeltaPrice.AsFloat;
  741. end;
  742. finally
  743. vGLs.Free;
  744. end;
  745. end;
  746. procedure TStageData.CalculatePriceMargin(ABillsID: Integer);
  747. var
  748. Rec: TStageRecord;
  749. fPM, fPMDiffer: Double;
  750. begin
  751. if not HasPriceMarginBills then Exit;
  752. Rec := StageRecord(ABillsID);
  753. if not Assigned(Rec) then Exit;
  754. fPM := TotalPriceRoundTo(Rec.GatherQuantity.AsFloat * GetBillsUnitPriceMargin(ABillsID));
  755. if fPM <> Rec.PM_TotalPrice.AsFloat then
  756. begin
  757. fPMDiffer := fPM - Rec.PM_TotalPrice.AsFloat;
  758. Rec.PM_TotalPrice.AsFloat := fPM;
  759. UpdateParentPriceMargin(ABillsID, fPMDiffer);
  760. UpdatePriceMarginNode(fPMDiffer);
  761. with TProjectData(TPhaseData(FPhaseData).ProjectData).BillsMeasureData do
  762. UpdateRecordPM(ABillsID, fPMDiffer);
  763. end;
  764. end;
  765. procedure TStageData.UpdatePriceMarginNode(ADiffer: Double);
  766. var
  767. Rec: TStageRecord;
  768. begin
  769. Rec := StageRecordWithAdd(iPriceMarginID);
  770. Rec.AddDifferValue(Rec.GatherTotalPrice, ADiffer);
  771. Rec.AddDifferValue(Rec.EndGatherTotalPrice, ADiffer);
  772. UpdateParentRecord(iPriceMarginID, ADiffer, 'GatherTotalPrice');
  773. with TProjectData(TPhaseData(FPhaseData).ProjectData).BillsMeasureData do
  774. UpdateGather(Rec.BillsID.AsInteger, ADiffer);
  775. end;
  776. procedure TStageData.UpdateParentPriceMargin(ABillsID: Integer; ADiffer: Double);
  777. var
  778. iParentID: Integer;
  779. Rec: TStageRecord;
  780. begin
  781. iParentID := MainBillsTree.FindNode(ABillsID).ParentID;
  782. if iParentID = -1 then Exit;
  783. Rec := StageRecordWithAdd(iParentID);
  784. Rec.PM_TotalPrice.AsFloat := TotalPriceRoundTo(Rec.PM_TotalPrice.AsFloat + ADiffer);
  785. UpdateParentPriceMargin(iParentID, ADiffer);
  786. end;
  787. function TStageData.StageRecordWithAdd(ABillsID: Integer): TStageRecord;
  788. begin
  789. Result := StageRecord(ABillsID);
  790. if not Assigned(Result) then
  791. Result := AddStageRecord(ABillsID);
  792. end;
  793. procedure TStageData.UpdateProjectGL(ABillsID: Integer);
  794. var
  795. vGLs: TList;
  796. iGL: Integer;
  797. GLRec: TDetailGLRecord;
  798. begin
  799. vGLs := TList.Create;
  800. try
  801. with TProjectData(TPhaseData(FPhaseData).ProjectData) do
  802. begin
  803. DetailGLData.LoadDetailGLs(ABillsID, vGLs);
  804. ProjectGLData.CalculateGLs_PM(vGLs);
  805. end;
  806. finally
  807. vGLs.Free;
  808. end;
  809. end;
  810. procedure TStageData.CalculateSpecialLeaf(ANode: TMeasureBillsIDTreeNode);
  811. procedure GatherPriceMargin(ARec: TStageRecord);
  812. begin
  813. with TProjectData(TPhaseData(FPhaseData).ProjectData).ProjectGLData do
  814. ARec.SetFloatValue(ARec.GatherTotalPrice, PM_TotalPrice);
  815. ARec.SetFloatValue(ARec.EndGatherTotalPrice,
  816. ARec.PreGatherTotalPrice.AsFloat + ARec.GatherTotalPrice.AsFloat);
  817. end;
  818. var
  819. StageRec: TStageRecord;
  820. begin
  821. StageRec := ANode.StageRec;
  822. if not Assigned(StageRec) then Exit;
  823. case ANode.ID of
  824. iPriceMarginID: GatherPriceMargin(StageRec);
  825. end;
  826. end;
  827. function TStageData.HasPriceMarginBills: Boolean;
  828. var
  829. vPM_Node: TsdIDTreeNode;
  830. begin
  831. vPM_Node := MainBillsTree.FindNode(iPriceMarginID);
  832. Result := Assigned(vPM_Node);
  833. end;
  834. end.