หากใช้ 2.49.8.12 แล้ว ให้เอา comment ตรงบรรทัดที่เขียนว่า resyncan ออกครับ
จาก
// resyncan
ให้เป็น
resyncan
แล้วลอง run ใหม่ check ตรง resyncan เอาไว้ด้วยครับ
หรือเอาตัวใหม่ไป run ก็ได้ครับ
Unit IPDIncomeBalanceCheck;
var Result_Text : Tstringlist;
fm:tform;
ListBox:TListBox;
DoButton:TButton;
CloseButton:TButton;
Panel:TPanel;
Label1,Label2:TLabel;
DateEdit1,DateEdit2:TEdit;
ClearIncithSummaryCheckBox:TCheckBox;
ResyncANCheckBox:TCheckBox;
implementation
Procedure DoButtonClick;
var fcds:TClientDataset;
rcds:TClientDataset;
ocds:TClientDataSet;
begin
Result_Text := TStringList.Create;
ListBox.Items.clear;
fcds:=TClientDataset.create(nil);
rcds:=TClientDataset.create(nil);
ocds:=TClientDataset.create(nil);
fcds.data:=HOSxP_Getdataset('select a.an,o.vstdate, o.an,a.an,a.pttype,a.item_money,a.income ,sum(o.sum_price) as sum_price '+
' from an_stat a '+
' left outer join opitemrece o on o.an=a.an '+
' where a.regdate between "'+dateedit1.text+'" and "'+dateedit2.text+'" and a.item_money <> a.income'+
' group by o.an order by a.an ');
ListBox.Items.Add('Runing check date '+dateedit1.text+' - '+dateedit2.text);
ListBox.items.Add('Record unbalance = '+inttostr(fcds.recordcount));
if ClearIncithSummaryCheckBox.checked then
begin
ListBox.items.Add('Clear incoth_summary');
fcds.first;
while not fcds.eof do
begin
ocds.data:=HOSxp_Getdataset('select * from incith_summary where an="'+fcds.fieldbyname('an').asstring+'"');
ocds.first;
while not ocds.eof do ocds.delete;
if ocds.changecount>0 then
HOSxP_updatedelta(ocds.delta,'select * from incith_summary where an="'+fcds.fieldbyname('an').asstring+'"');
fcds.next;
end;
end;
if ResyncAnCheckBox.checked then
begin
ListBox.items.Add('Resync AN...');
fcds.first;
while not fcds.eof do
begin
ListBox.items.Add('Resync AN '+fcds.fieldbyname('an').asstring);
resyncan(fcds.fieldbyname('an').asstring);
fcds.next;
end;
fcds.data:=HOSxP_Getdataset('select a.an,o.vstdate, o.an,a.an,a.pttype,a.item_money,a.income ,sum(o.sum_price) as sum_price '+
' from an_stat a '+
' left outer join opitemrece o on o.an=a.an '+
' where a.regdate between "'+dateedit1.text+'" and "'+dateedit2.text+'" and a.item_money <> a.income'+
' group by o.an order by a.an ');
end;
fcds.first;
if fcds.recordcount=0 then ListBox.Items.add('No error found.');
while not fcds.eof do
begin
ListBox.items.add('');
ListBox.Items.Add('Investigating.... '+fcds.fieldbyname('an').asstring+' Income = '+fcds.fieldbyname('income').asstring+
' Item sum price = '+fcds.fieldbyname('sum_price').asstring);
rcds.data:=HOSxP_GetDataset('select i.pttype,p.pcode,p.paidst from ipt i left outer join pttype p on p.pttype = i.pttype where i.an = "'+fcds.fieldbyname('an').asstring+'"');
listBox.items.add('pttype = '+rcds.fieldbyname('pttype').asstring+' pcode = '+
rcds.fieldbyname('pcode').asstring+' paidst = '+
rcds.fieldbyname('paidst').asstring);
rcds.data:=HOSxP_Getdataset('select r2.income as income,r2.paidst as paidst, sum(r2.rcptamt) as sp from rcpt_print r1,rcpt_print_detail r2 where r1.vn="'+fcds.fieldbyname('an').asstring+'" and r1.finance_number=r2.finance_number and r2.paidst in ("02") group by r2.income,r2.paidst');
if rcds.recordcount=0 then ListBox.Items.add('>>No rcpt_detail adjustment') else
ListBox.Items.add('>>Found rcpt_detail adjustment');
rcds.data:=HOSxP_GetDataset('select r2.income as income,r2.paidst as paidst, sum(r2.rcptamt) as sp from rcpt_print r1,rcpt_print_detail r2 where r1.vn="'+fcds.fieldbyname('an').asstring+'" and r1.finance_number=r2.finance_number and r2.paidst in ("01","03") group by r2.income,r2.paidst');
if rcds.recordcount=0 then ListBox.Items.Add('>>No rcpt_print') else
ListBox.Items.Add('>>Found rcpt_print');
rcds.data:=HOSxP_GetDataset('select income,paidst,sum(sum_price) as sp from opitemrece where an="'+fcds.fieldbyname('an').asstring+'" and paidst in ("01","03") group by income,paidst');
if rcds.recordcount=0 then ListBox.Items.Add('>>No opitemrece data (paidst 01,03)') else
begin
ListBox.Items.Add('>>Found opitemrece data (paidst 01,03)');
rcds.data:=HOSxP_GetDataset('select sum(sum_price) as sp from opitemrece where an="'+fcds.fieldbyname('an').asstring+'" and paidst in ("01","03") ');
ocds.data:=HOSxP_GetDataset('select sum(rcptamt) as sp from incith where an="'+fcds.fieldbyname('an').asstring+'" and paidst in ("01","03") ');
if rcds.fieldbyname('sp').asfloat=ocds.fieldbyname('sp').asfloat then
ListBox.items.Add('>>> opitemrece data (paidst 01,03) = incith [normal]') else
ListBox.items.Add('>>> opitemrece data (paidst 01,03) <> incith');
end;
rcds.data:=HOSxP_GetDataset('select r2.income as income,r2.paidst as paidst,sum(r2.rcptamt) as sp from rcpt_print r1,rcpt_print_detail r2 where r1.vn="'+fcds.fieldbyname('an').asstring+'" and r1.finance_number=r2.finance_number and r2.paidst = "04" group by r2.income,r2.paidst');
if rcds.recordcount=0 then ListBox.Items.Add('>>No discount data') else
ListBox.Items.Add('>>Found discount data');
rcds.data:=HOSxP_GetDataset('select r2.income,sum(r2.amount) as sp from rcpt_arrear r1,rcpt_arrear_detail r2 where r1.vn="'+fcds.fieldbyname('an').asstring+'" and r1.arrear_id = r2.arrear_id and r1.paid<>"Y" group by r2.income');
if rcds.recordcount=0 then ListBox.Items.Add('>>No arrear data') else
ListBox.Items.Add('>>Found arrear data');
rcds.data:=HOSxP_GetDataset('select * from incith_summary where an="'+fcds.fieldbyname('an').asstring+'" ');
if rcds.recordcount=0 then ListBox.Items.Add('>>No manual summary data') else
begin
ListBox.Items.Add('>>Found manual summary data');
ocds.data:=HOSxP_GetDataset('select sum(rcptamt) as cc from incith_summary where an="'+fcds.fieldbyname('an').asstring+'" ');
ListBox.Items.Add('>>>manual summary amount = '+ocds.fieldbyname('cc').asstring);
end;
fcds.next;
end;
fcds.free;
rcds.free;
ocds.free;
Result_Text.free;
end;
Procedure CloseButtonClick;
begin
fm.close;
end;
Procedure Main;
var
i:integer;
begin
fm:=TForm.create(nil);
fm.caption:='HOSxP IPD Income balance check version 0.1';
fm.width:=700;
fm.height:=500;
fm.top:=100;
fm.left:=100;
Panel:=TPanel.create(fm);
Panel.parent:=fm;
Panel.caption:='';
Panel.align:=altop;
listbox:=tlistbox.create(fm);
listbox.parent:=fm;
listbox.align:=alclient;
listbox.font.name:='Courier';
listbox.font.size:=10;
DoButton:=TButton.create(fm);
DoButton.parent:=Panel;
Dobutton.top:=5;
DoButton.left:=10;
DoButton.width:=120;
DoButton.caption:='Run Check';
DoButton.onclick:=DoButtonClick;
CloseButton:=TButton.create(fm);
CloseButton.parent:=Panel;
CloseButton.left:=620;
closebutton.width:=50;
CloseButton.top:=5;
CloseButton.caption:='Close';
CloseButton.onclick:=CloseButtonClick;
Label1:=TLabel.create(fm);
Label1.parent:=panel;
Label1.caption:='Begin Date';
label1.left:=140;
Label1.top:=9;
DateEdit1:=TEdit.create(fm);
DateEdit1.parent:=panel;
DateEdit1.left:=200;
DateEdit1.top:=5;
DateEdit1.Text:='2005-06-01';
DateEdit1.width:=70;
Label2:=TLabel.create(fm);
Label2.parent:=panel;
Label2.caption:='End Date';
label2.left:=280;
Label2.top:=9;
DateEdit2:=TEdit.create(fm);
DateEdit2.parent:=panel;
DateEdit2.left:=330;
DateEdit2.top:=5;
DateEdit2.Text:='2005-06-01';
DateEdit2.width:=70;
ResyncANCheckBox:=TCheckBox.create(fm);
ResyncANCheckBox.parent:=panel;
ResyncANCheckBox.left:=420;
ResyncANCheckBox.top:=5;
ResyncAnCheckBox.caption:='Resync AN';
ClearIncithSummaryCheckBox:=TCheckBox.create(fm);
ClearIncithSummaryCheckBox.parent:=panel;
ClearIncithSummaryCheckBox.left:=500;
ClearIncithSummaryCheckBox.top:=5;
ClearIncithSummaryCheckBox.width:=120;
ClearIncithSummaryCheckBox.caption:='Clear incith_summary';
fm.showmodal;
fm.free;
end;
end.