總 分 類 帳 餘 額 表
範圍選擇 |
左右捲頁 |
重新查詢 |
原始程式
原始檔-起始 /*---------( FSACR067.C )-----------*/ #include "W_FSAC.H" #define SX 20 /*左內框 */ #define SY 10 /*上內框 */ #define SC 40 /*內框寬, 多少行 */ /*===========================================================================*/ struct { char KEY[8]; char ACN[21]; /*科目編號名稱*/ double DAMT; /*期間借方金額*/ int DNO; /*期間借方筆數*/ double CAMT; /*期間貸方金額*/ int CNO; /*期間貸方筆數*/ double DSUM; /*期間以前借總累計*/ double CSUM; /*期間以前貸總累計*/ } WORK; /*===========================================================================*/ void EndPage(int sw); void ShowData(); void ShowLast(); void ReadF001Rest(); /*讀入總分類帳並累計其上期結轉*/ /*================================================================*/ FSACF001_T ACF001; FSACF011_T ACF011; double Sum[10]; char *Table="\ \ 總分類帳科目餘額表 \ ====================================== \ 列印期間自: -------- 至: -------- \ \ 資料輸出裝置:-------- \ "; /*===========================================================================*/ void main() { USetBXYN(Table,SX,SY,SC); OPEN_ACF001; OPEN_ACF011; NamS=GET_NAME; while(1) { #include <RPT1.H> if(Field==1) UReadM(BXN(1),&Sday,0,V_WUSR,V_READ); if(Field==2) UReadM(BXN(2),&Eday,0,V_WUSR,V_READ); #include <RPT2.H> /*條件設定完畢*/ /*------------------------------------------------------------------*/ if((Sa=ChkYM(Sday,ON))==0) continue; Sm=Sday.Y*12+Sday.M; if((Ea=ChkYM(Eday,ON))==0) continue; Em=Eday.Y*12+Eday.M; Ugd_Open("檔 案 處 理 中 請 稍 候 ....."); /* Sort FSACF011 */ OPEN_WORK; ReadF001Rest(); lseek(ACF011K->ffd,0L,SEEK_SET); while(1) { if(read(ACF011K->ffd,&ACF011,sizeof(ACF011)) < 1) break; if(ACF011.KEY[0]<=SPACE) continue; if(ACF011.YM.Y < SysY) continue; if(UHowDate(Eday) < UHowDate(ACF011.YM)) continue; memset(&ACF011.AC[4],SPACE,3); /*均改為總分類帳*/ if(Ufk_Read(WORKK,&WORK,ACF011.AC)==OFF) continue; /*---------------累加在期間前的金額---------------------------*/ if(ACF011.DC=='D') WORK.DSUM+=ACF011.AMT; if(ACF011.DC=='C') WORK.CSUM+=ACF011.AMT; /*----------累加在期間內的金額-----------------*/ if(UHowDate(Sday) <= UHowDate(ACF011.YM)) { if(ACF011.DC=='D'){ WORK.DAMT+=ACF011.AMT; WORK.DNO++; } if(ACF011.DC=='C'){ WORK.CAMT+=ACF011.AMT; WORK.CNO++; } } Ufk_Write(WORKK,&WORK); } Ugd_Close(); /*------------------------------------------------------------------*/ Ugd_Open("列印中 Ctr_F7:結束列印"); lseek(WORKK->kfd,0L,SEEK_SET); while(RetKey!=ESC && RetKey) { if(Ufk_SeqRead(WORKK,&WORK,Skey,Ekey) != ON) continue; if(WORK.DSUM==0 && WORK.CSUM==0) continue; ShowData(); if(Psf=='S' && K0>=21){ EndPage(ON); UWait(OFF,"Esc:重新選擇 任一鍵繼續"); UCls(); K0=0; } if(Psf=='P' && K0>=K1){ EndPage(ON); fprintf(Stream,"%c",12); K0=0; } } ShowLast(); EndPage(OFF); LineReturn(ON); Ufk_Close(WORKK); /*要close供下一LOOP使用*/ } } /*===========================================================================*/ void ShowHead() { #ifdef HP-5L /*1998/8/27*/ LockItemHead(2,"~I",NamS,"~Z2W1L10G2X16"); #else LockItemHead(2,"~IZ2L10G2X1",NamS,"~Z1"); #endif UPrint("#自:%M------ 至 %M------ 列印日期:%M------ 第 %I- 頁 ",Sday,Eday,Day,P0); UPrint("======================================================================================================================="); UPrint("科目 科 目 名 稱 本期借方 筆數 本期貸方 筆數 本期餘額 借方累計 貸方累計 DC 總 餘 額"); UPrint("---- -------------------- ------------ ---- ------------- ---- ------------- ------------- ------------- -- -----------"); } /*===========================================================================*/ void ShowData() { double rest=WORK.DAMT-WORK.CAMT; if(WORK.DSUM >= WORK.CSUM) strcpy(TmpS,"借"); else strcpy(TmpS,"貸"); strcpy(BufS,"%S-- %S------------------ %F,--------- %I-- %F,---------- %I-- %F,---------- %F,---------- %F,---------- %S %F,--------"); UPrint(BufS,WORK.KEY,WORK.ACN,WORK.DAMT,WORK.DNO,WORK.CAMT,WORK.CNO,rest,WORK.DSUM,WORK.CSUM,TmpS,fabs(WORK.DSUM-WORK.CSUM)); Sum[0] += WORK.DAMT; Sum[1] += WORK.DNO; Sum[2] += WORK.CAMT; Sum[3] += WORK.CNO; Sum[4] += WORK.DSUM; Sum[5] += WORK.CSUM; } /*===========================================================================*/ void EndPage(int sw) { if(sw) UPrint("======================================================================================================================="); UPrint("負責人: 主管: 主辦會計: "); } /*===========================================================================*/ void ShowLast() { if(Sum[4] >= Sum[5]) strcpy(TmpS,"借"); else strcpy(TmpS,"貸"); UPrint("======================================================================================================================="); UPrint(" 合 計 ----> %F,--------- %F-- %F,---------- %F-- %F,---------- %F,---------- %S %F,--------",Sum[0],Sum[1],Sum[2],Sum[3],Sum[4],Sum[5],TmpS,fabs(Sum[4]-Sum[5])); UPrint(" "); for(I=0; I<10; I++) Sum[I]=0; } /*===========================================================================*/ void ReadF001Rest() /*讀入總分類帳並累計其上期結轉*/ { double sumD=0.0, sumC=0.0; lseek(ACF001K->ffd,0L,SEEK_SET); while(1) { if(read(ACF001K->ffd,&ACF001,sizeof(ACF001)) < 1) break; if(ACF001.KEY[0]<=SPACE || ACF001.KEY[4]>SPACE) continue; if(ACF001.KEY[0]=='Z') continue; strcpy(WORK.KEY,ACF001.KEY); strcpy(WORK.ACN,ACF001.ACN); WORK.DSUM=ACF001.AMT[0][0]; sumD+=ACF001.AMT[0][0]; WORK.CSUM=ACF001.AMT[1][0]; sumC+=ACF001.AMT[1][0]; Ufk_Write(WORKK,&WORK); /*將總分類帳存入WORKF000*/ } if(sumD != sumC) UWait(ON,"上 期 結 轉 不 平 衡 Esc:結 束"); if(RetKey==ESC) exit(0); } 原始檔-結束
Byron Wey Oct.21.1998