はいぱぁ帳簿のスクリプト
はいぱぁ帳簿のスクリプト
card id 1002
on openStack
open card "伝票" of stack "chyoubo"
close stack "はいぱぁ帳簿Live版"
end openStack
stack “chyoubo”
--------------------------------------------------------------------------------------------------
on openStack
global SYear,SMon --使用年月。初期設定カードに記録
global DenNo --最後にいたかーど
global DenID --ユニークIDの最後の数
set itemDelimiter to tab
--初期設定から使用年度と月を読み込む
get field SYearFld of card "初期設定"
put it into SYear
get field SMonFld of card "初期設定"
put it into SMon
--最後にいたカードの番号を読み込む
get field DenNoFld of card "初期設定"
if it is empty then put 1 into it
put it into DenNo
--ユニークIDを読み込む
get field "DenIDFld" of card "初期設定"
put it into DenID
get number (lines in field "DenDataFld" of card "伝票データ" )
put it into DenNos
--伝票データから日付だけとりだしたデータを作る
sort lines of fld "DenDataFld" of card "伝票データ" datetime by item 49 of each
put fld "DenDataFld" of card "伝票データ" into Dendata
put empty into DenDT
set itemDelimiter to tab
repeat with i=1 to DenNos
put (item 49 of line i of Dendata)&return after DenDT
end repeat
put DenDT into fld "DenDTFld" of card "伝票データ"
--ここからデータのバックアップを作る
get short date
set the itemDelimiter to "/"
put item 3 of it into Y
put item 2 of it into D
put item 1 of it into M
get system time
set the itemDelimiter to ":"
put item 1 of it into H
put item 2 of it into Mt
put "20"&Y&"-"&M&"-"&D&"-"&H&"-"&Mt into DD
local tFile
get the defaultFolder
put it into DF
put DF & "/"&DD&"_Bup" into tFile
open file tFile for text write
--ここからデータを用意して書き込む
put unicodeText of fld "DenDataFld" of card "伝票データ" of stack "Chyoubo" into UniDenData
put uniDecode( UniDenData , utf8) into jpUtf8
write jpUtf8 to file tFile
close file tFile
GaInDen
if DenNos > 100 then
get field SiKey of card "初期設定" of stack "Chyoubo"
put it into SiKeyNo
if SiKeyNo is "ga8cho"
then
exit openStack
else
answer warning "はいぱぁ帳簿はシェアウェアです。気にいりましたら登録をお願いします。" with "あとで" or "登録する"
if it is "あとで" then exit openStack
if it is "登録する" then
ask question "ライセンスキーを入力してください。" titled "ライセンスキー"
if it is empty then exit openStack
if it is "*******"
then
put it into field SiKey of card "初期設定" of stack "Chyoubo"
answer "登録ありがとうございます。"
exit openStack
else
answer "ライセンスキーが間違っています。"
exit openStack
end if
end if
end if
end if
end openStack
--------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
on GaInDen
global DenNo,GDEN
set itemDelimiter to tab
put line DenNo of fld DenDataFld of card "伝票データ" into x
repeat with i=1 to 49
put item i of x into field i
end repeat
put item 47 of x into GDEN
end GaInDen
----------------------------------------------------------------------------------------------------
on GaOutDen
global DenNo,EnSyu
set itemDelimiter to tab
get fld "日付"
if it is not empty then
repeat with i=1 to 49
get fld i of card "伝票"
put it &tab after DD
end repeat
put DD into line DenNo of fld DenDataFld of card "伝票データ"
end if
put empty into EnSyu
put empty into fld "MesegeArea"
end GaOutDen
--------------------------------------------------------------------------------------------------
on IdoCheck
global EnSyu
set itemDelimiter to tab
--入力中もしくは修正中のみ、チェックする。
if isNumber(Ensyu) is false then exit IdoCheck
--金額欄をチェックする
if fld 44 is not fld 45 then
answer warning "借方金額と貸方金額が合っていないようです。"
--put "借方金額と貸方金額が合っていないようです。" into fld "MesegeArea"
exit to Top
end if
if fld 44 is empty then
if fld 45 is not empty then
answer warning "借方の合計金額が入らないうちに書き込みを終了しないでください。"
--put "借方の合計金額が入らないうちに書き込みを終了しないでください。"into fld "MesegeArea"
exit to Top
else
exit IdoCheck
end if
end if
if fld 45 is empty then
answer warning "貸方の合計金額が入らないうちに書き込みを終了しないでください。"
--put "貸方の合計金額が入らないうちに書き込みを終了しないでください。"into fld "MesegeArea"
exit to Top
end if
--修正ボタンを戻しておく
set the hilite of button "修正" to false
--スキップボタンを戻しておく
set the hilite of button "スキップ" to false
--メッセージエリアを空にする
put empty into fld "MesegeArea"
end IdoCheck
-------------------------------------------------------------------------------------------------
--カレンダーのボタンのためのスクリプト
on dayButton
global EnSyu,SDay,SYear,SMon
switch
case (EnSyu is 1) --修正中の時
put fld "借方合計" into KariGo
put fld "貸方合計" into KashiGo
if KariGo is empty then
if KashiGo is empty then
exit dayButton
end if
end if
GaOutDen
exit dayButton
exit switch
case (EnSyu is 2) --EnSyuが2の時--伝票作成ボタンが押された場合
get the short name of the target
if it is empty then exit dayButton
put SMon&"/"& it &"/"&SYear into SDay
put 1 into EnSyu
MakeDen SDay
exit switch
case (EnSyu is empty)
SonohinoDen
exit switch
end switch
end dayButton
-------------------------------------------------------------------------------------------------------
--伝票を新規作成するスクリプト
on MakeDen SDay
lock screen
global SMon,TMon,DenNo,DenID,EnSyu,GDEN,FID,KariTeki,KshiTeki,KrTekin,KsTekin
lock screen
if SMon is "1" then put "JANY" into TMon
if SMon is "2" then put "FEBY" into TMon
if SMon is "3" then put "MARH" into TMon
if SMon is "4" then put "APRL" into TMon
if SMon is "5" then put "MAYY" into TMon
if SMon is "6" then put "JUUN" into TMon
if SMon is "7" then put "JUUL" into TMon
if SMon is "8" then put "AUGT" into TMon
if SMon is "9" then put "SEPR" into TMon
if SMon is "10" then put "OCTR" into TMon
if SMon is "11" then put "NOVR" into TMon
if SMon is "12" then put "DECR" into TMon
push card
--日付データの更新と並べ直し、差し込む行の確定--foundLineがemptyの時の処理が必要
put return &SDay after fld "DenDTFld" of card "伝票データ"
sort lines of fld "DenDTFld" of cd "伝票データ" datetime
get line 1 of fld "DenDTFld" of card "伝票データ"
if it is empty then delete line 1 of fld "DenDTFld" of card "伝票データ"
--1行もデータがない時にfindがエラーになるので、こうすると回避できる。なぜかはわからない。
if fld "DenDataFld" of card "伝票データ" is empty
then
find word SDay in fld "DenDTFld"
else
find word SDay in fld "DenDTFld" of card "伝票データ"
end if
get foundLine()
put word 2 of it into DenNo
--同じ日付の行があるかどうか調べる
repeat
put (DenNo +1) into DenNo2
get line DenNo2 of fld "DenDTFld" of card "伝票データ"
if it is not SDay then exit repeat
add 1 to DenNo
end repeat
--新しい伝票が作られたことを記録しておく
put SMon into field ("Kioku"&SMon) of card "初期設定"
--新しい行を確保する
put return before line DenNo of fld "DenDataFld" of card "伝票データ"
pop card
--ここから伝票作成--まず各行を空にする
repeat with i=1 to 49
put empty into field i of card "伝票"
end repeat
--DenIDの数を一つ進めて、所定の位置に表示する
add 1 to DenID
put DenID into field 46 of card "伝票"
--日付を所定の位置に表示する。月を隠しフィールドに入れる
set the itemDelimiter to "/"
put item 1 of SDay into TUKI
put item 2 of SDay into HINICHI
put item 3 of SDay into NEN
put TUKI&"."&HINICHI into field 1
put TMon into field 48 of card "伝票"
put SDay into field 49 of card "伝票"
put 1 into Ensyu
if GDEN is "振替伝票" then
put "振替伝票" into field 47
put 2 into FID
put "1行目の借方科目を選んで下さい。"into fld "MesegeArea"
put empty into KariTeKi
get the imagedata of image "振替伝票" of card 1 of stack "はいぱぁ帳簿Live版"
set the imagedata of image "DenDrow" to it
end if
if GDEN is "入 金" then
put "入 金" into field 47
put 3 into FID
put "1行目の貸方科目を選んで下さい。" into fld "MesegeArea"
get the imagedata of image "入金伝票" of card 1 of stack "はいぱぁ帳簿Live版"
set the imagedata of image "DenDrow" to it
get number (lines in field "tekiyouichiran" of card "現 金" of stack tekiyou )
put it into T
put empty into field KariTekiFld
put empty into field KariBiFld
set the itemDelimiter to tab
put empty into KrTekin
repeat with i= 1 to T
put item 1 of line i of field "tekiyouichiran" of card "現 金" of stack tekiyou & return after field KariTekiFld
put item 2 of line i of field "tekiyouichiran" of card "現 金" of stack tekiyou & return after KrTekin
end repeat
put "現 金" into KariTeki
end if
if GDEN is "出 金" then
put "出 金" into field 47
put 2 into FID
put "1行目の借方科目を選んで下さい。" into fld "MesegeArea"
get the imagedata of image "出金伝票" of card 1 of stack "はいぱぁ帳簿Live版"
set the imagedata of image "DenDrow" to it
get number (lines in field "tekiyouichiran" of card "現 金" of stack tekiyou )
put it into T
put empty into field KashiTekiFld
put empty into field KashiBiFld
set the itemDelimiter to tab
put empty into KsTekin
repeat with i= 1 to T
put item 1 of line i of field "tekiyouichiran" of card "現 金" of stack tekiyou & return after field KashiTekiFld
put item 2 of line i of field "tekiyouichiran" of card "現 金" of stack tekiyou & return after KsTekin
end repeat
put "現 金" into KshiTeki
end if
unlock screen
end MakeDen
-------------------------------------------------------------------------------------
--勘定科目を伝票に書き込むスクリプト Zは勘定科目 Sはシフトキーかオプションキーが押されていたとき
on Kankamo Z,S
global FID --開いているフィールド
global GDEN --伝票の種類
global KrTekin
global KsTekin
global KariTeki
global KshiTeki
global KariNaKa
global KashiNaka
global EnSyu
global LDN
global Kamoku
global Skip
global TBS
set itemDelimiter to tab
if Z is empty then exit Kankamo
-- --シフトキーが押されていたときの処理
-- If S is 1 then
-- if GDEN is not "入 金" then
-- put (FID+6) mod 6 into Famari
-- if Famari is not 2 then exit Kankamo
-- end if
-- if GDEN is "入 金" then
-- put (FID+6) mod 6 into Famari
-- if Famari is not 3 then exit Kankamo
-- end if
-- IdoCheck
-- set itemDelimiter to "."
-- get item 2 of field 1
-- put it &"月" into x
-- --go card x of Z
-- put empty into EnSyu
-- exit Kankamo
-- end if
-- --オプションキーが押されていた時の処理
-- if S is 2 then
-- if GDEN is not "入 金" then
-- put (FID+6) mod 6 into Famari
-- if Famari is not 2 then exit Kankamo
-- end if
-- if GDEN is "入 金" then
-- put (FID+6) mod 6 into Famari
-- if Famari is not 3 then exit Kankamo
-- end if
-- IdoCheck
-- --go card Z of stack "tekiyou"
-- put empty into EnSyu
-- exit Kankamo
--end if
--EnSyuフラグが1以外ならハンドルを抜ける
if EnSyu is not 1 then exit Kankamo
lock screen
--フラグが1なら処理開始
--FIDから今の行を割り出す
if FID >39 then exit Kankamo
put (FID+6) mod 6 into Famari
if GDEN is "振替伝票" then
--スキップされていない状態で、借方勘定の場合
if Skip is empty then
if Famari is 2 then
put Z into field FID
--set the textfont of fld FID to "Hiragino Sans GB W3"
put (FID+4)/6 into LDN
add 1 to FID --入力するフィールドを一つ進める
get number (lines in field "tekiyouichiran" of card Z of stack "tekiyou" )
put it into T
put empty into field KariTekiFld
repeat with i= 1 to T
put item 1 of line i of field "tekiyouichiran" of card Z of stack "tekiyou" & return after field KariTekiFld
end repeat
put empty into fld KariBiFld
put empty into KrTekin
repeat with i= 1 to T
put item 2 of line i of field "tekiyouichiran" of card Z of stack "tekiyou" & return after KrTekin
end repeat
put Z into KariTeki
put Z into KariNaka
-- put "??" into Kamoku
put LDN&"行目の貸方の勘定科目を選んで下さい。" into fld "MesegeArea"
put empty into KshiTeKI
exit Kankamo
end if
--スキップされていない状態で貸方勘定の時
if Famari is 3 then
put Z into field FID
--set the textfont of fld FID to "Hiragino Sans GB W3"
put (FID+3)/6 into LDN
add 1 to FID---入力するフィールドを一つ進める
get number (lines in field "tekiyouichiran"of card Z of stack "tekiyou" )
put it into T
put empty into field KashiTekiFld
repeat with i= 1 to T
put item 1 of line i of field "tekiyouichiran" of card Z of stack "tekiyou" & return after field KashiTekiFld
end repeat
put empty into fld KashiBiFld
put empty into KsTekin
repeat with i= 1 to T
put item 2 of line i of field "tekiyouichiran" of card Z of stack "tekiyou" & return after KsTekin
end repeat
put Z into KshiTeki
put Z into KashiNaKa
-- put "??" into Kamoku
put LDN&"行目の摘要を選んで下さい。" into fld "MesegeArea"
exit kankamo
end if
--スキップされている時
else
if Skip is "貸方" then
if Famari is 2 then
put Z into field FID
--set the textfont of fld FID to "Hiragino Sans GB W3"
put (FID+4)/6 into LDN
add 2 to FID --入力するフィールドを一つ進める
--借方摘要を表示、借方備考を空白に
get number (lines in field "tekiyouichiran" of card Z of stack "tekiyou" )
put it into T
put empty into field KariTekiFld
repeat with i= 1 to T
put item 1 of line i of field "tekiyouichiran" of card Z of stack "tekiyou" & return after field KariTekiFld
end repeat
put empty into fld KariBiFld
put empty into KrTekin
repeat with i= 1 to T
put item 2 of line i of field "tekiyouichiran" of card Z of stack "tekiyou" & return after KrTekin
end repeat
put Z into KariTeki
put Z into KariNaKa
put LDN&"行目の摘要を選んで下さい。" into fld "MesegeArea"
exit Kankamo
end if
else
if Famari is 3 then
put Z into field FID
--set the textfont of fld FID to "Hiragino Sans GB W3"
put (FID+3)/6 into LDN
add 1 to FID --入力するフィールドを一つ進める
--貸方摘要を表示、貸方備考を空白に
get number (lines in field "tekiyouichiran"of card Z of stack "tekiyou" )
put it into T
put empty into field KashiTekiFld
repeat with i= 1 to T
put item 1 of line i of field "tekiyouichiran" of card Z of stack "tekiyou" & return after field KashiTekiFld
end repeat
put empty into fld KashiBiFld
put empty into KsTekin
repeat with i= 1 to T
put item 2 of line i of field "tekiyouichiran" of card Z of stack "tekiyou" & return after KsTekin
end repeat
put Z into KshiTeki
put Z into KashiNaKa
put LDN&"行目の摘要を選んで下さい。" into fld "MesegeArea"
exit kankamo
end if
end if
end if
end if
if GDEN is "出 金" then
if Famari is 2 then
put Z into field FID
--set the textfont of fld FID to "Hiragino Sans GB W3"
put (FID+4)/6 into LDN
put "現 金" into field (FID+1)
put Z into KariTeki
put Z into KariNaKa
get number (lines in field "tekiyouichiran" of card KariTeki of stack "tekiyou" )
put it into T
put empty into field KariTekiFld
put empty into KrTekin
put empty into fld KariBiFld
repeat with i= 1 to T
put item 1 of line i of field "tekiyouichiran" of card Z of stack "tekiyou" & return after field KariTekiFld
put item 2 of line i of field "tekiyouichiran" of card Z of stack "tekiyou" & return after KrTekin
end repeat
put "借方" into Kamoku
add 2 to FID
put LDN&"行目の摘要を選んで下さい。" into fld "MesegeArea"
exit Kankamo
end if
end if
if GDEN is "入 金" then
if Famari is 3 then
put Z into field FID
--set the textfont of fld FID to "Hiragino Sans GB W3"
put (FID+3)/6 into LDN
put "現 金" into field (FID-1)
put z into KshiTeki
put z into KashiNaKa
get number (lines in field "tekiyouichiran" of card Z of stack "tekiyou" )
put it into T
put empty into field KashiTekiFld
put empty into KsTekin
put empty into fld KashiBiFld
repeat with i= 1 to T
put item 1 of line i of field "tekiyouichiran" of card Z of stack "tekiyou" & return after field KashiTekiFld
put item 2 of line i of field "tekiyouichiran" of card Z of stack "tekiyou" & return after KsTekin
end repeat
put "貸方" into Kamoku
add 1 to FID
put LDN&"行目の摘要を選んで下さい。" into fld "MesegeArea"
exit Kankamo
end if
end if
end Kankamo
-------------------------------------------------------------------------------------------------------
on CalHyouji Calend
put shell(Calend) into Cal
set the lockScreen to true
put 2 into pos
repeat while char pos of line 3 of Cal is space
put "." into char pos of line 3 of Cal
put pos +3 into pos
end repeat
get return & "......."
put Cal & it & it into Cal
repeat with Coo = 0 to 7*6-1
put Coo +11 into bNum
put Coo mod 7 into hLoc
put Coo div 7 into vLoc
get line vLoc +3 of Cal
get word hLoc +1 of it
if it is "." then
get empty
end if
set name of button bNum to it
if it is empty then
set disabled of button bNum to true
set the fillFore of button bNum to 44
set the showPen of button bNum to false
else
set disabled of button bNum to false
set the fillFore of button bNum to 117
set the showPen of button bNum to true
end if
end repeat
end CalHyouji
--------------------------------------------------------------------
--------------------------------------------------------------------
on TENKI WW
lock screen
set itemDelimiter to tab
--WWは数字のみ。Kiokuフォルダー1から12まで
put WW into X
if X is "1" then put "JANY" into MX
if X is "2" then put "FEBY" into MX
if X is "3" then put "MARH" into MX
if X is "4" then put "APRL" into MX
if X is "5" then put "MAYY" into MX
if X is "6" then put "JUUN" into MX
if X is "7" then put "JUUL" into MX
if X is "8" then put "AUGT" into MX
if X is "9" then put "SEPR" into MX
if X is "10" then put "OCTR" into MX
if X is "11" then put "NOVR" into MX
if X is "12" then put "DECR" into MX
push card
-- JAN等のキーワードを使って伝票データから特定の月のデータだけを取り出し変数TenDataに入れる
--転記はじめの行を探す
go card "伝票データ" of stack "chyoubo"
find string MX in fld "DenDataFld" of card "伝票データ" of stack "chyoubo"
get foundLine()
put word 2 of it into TenkiHajime
if TenkiHajime is empty then
pop card
exit TENKI
end if
--転記はじめが12月の時、全体の行の終わりをTenkiOwariにいれる
if MX="DECR" then
get number of lines of fld "DenDataFld" of card "伝票データ" of stack "chyoubo"
put it into TenkiOwari
else
--転記はじめが1月から11月までのとき次の月を探す
repeat
add 1 to X
if X is "2" then put "FEBY" into MXLL
if X is "3" then put "MARH" into MXLL
if X is "4" then put "APRL" into MXLL
if X is "5" then put "MAYY" into MXLL
if X is "6" then put "JUUN" into MXLL
if X is "7" then put "JUUL" into MXLL
if X is "8" then put "AUGT" into MXLL
if X is "9" then put "SEPR" into MXLL
if X is "10" then put "OCTR" into MXLL
if X is "11" then put "NOVR" into MXLL
if X is "12" then put "DECR" into MXLL
find string MXLL in fld "DenDataFld" of card "伝票データ" of stack "chyoubo"
get foundLine()
put word 2 of it into TenkiOwari
if the result is empty then
subtract 1 from TenkiOwari
exit repeat --見つければ-1してここで抜ける
end if
--12月まできても見つけられない時
if MXLL="DECR" then
get number of lines of fld "DenDataFld" of card "伝票データ" of stack "chyoubo"
put it into TenkiOwari
exit repeat
end if
end repeat
end if
pop card
get fld "DenDataFld" of cd "伝票データ"
put it into TenData
repeat with CN= TenkiHajime to TenkiOwari
set the cursor to busy
put 2 into Tno
repeat until Tno > 38
put item Tno of line CN of TenData into K
if K is EMPTY then exit repeat
put K&tab after J--借方勘定科目
put (item 1 of line CN of TenData)&tab after J--日付
put (item (Tno + 2) of line CN of TenData)&tab after J--摘要
put (item (Tno + 3) of line CN of TenData)&tab after J--備考
put (item (Tno + 4) of line CN of TenData)&tab after J--借方金額
put " "&tab after J--貸方金額を空ける
put (item 46 of line CN of TenData) after J--ID
put " "&tab after J
put (item 49 of line CN of TenData)& return after J--日付つ゛け2
put Tno+ 6 into Tno
end repeat
put 3 into Tno
repeat until Tno > 39
put item Tno of line CN of TenData into K
if K is EMPTY then exit repeat
put K&tab after J--貸方勘定科目
put (item 1 of line CN of TenData)&tab after J--日付
put (item (Tno+ 1) of line CN of TenData)&tab after J
put (item (Tno + 2) of line CN of TenData)&tab after J
put " "&tab after J
put (item (Tno + 4) of line CN of TenData)&tab after J
put (item 46 of line CN of TenData) after J
put " "&tab after J
put (item 49 of line CN of TenData)& return after J
put Tno + 6 into Tno
end repeat
end repeat
sort lines of J by item 1 of each
--ここまででは、motodataフィールドに月ごとに科目順に、収納される。これを各元帳に振り分ける
get item 1 of line 1 of J
put it into Kamoku
put WW&"月" into TUKI
-- Tuki は"◯月"
get number of lines of J
put it into EndL
repeat with i=1 to EndL
get item 1 of line i of J
if it is Kamoku then
put line i of J after H
put return after H
else
set the TUKI of card Kamoku of stack "motochyou" to H
put it into Kamoku
put empty into H
put line i of J after H
put return after H
end if
end repeat
--ここで科目の月のカスタムプロパティに書き込む
set the TUKI of card Kamoku of stack "motochyou" to H
unlock screen
end TENKI
--------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------
on KEISANBLUE Kamoku,WW
set itemDelimiter to tab
--月を設定して科目からデータを取り出す
repeat with m = WW to 12
put m&"月" into TUKI
put m&"月開始金額" into Kaishi
put m&"月合計金額" into GouKei
put (m+1)&"月開始金額" into Tugi
get the TUKI of card Kamoku of stack "motochyou"
put it into KeisanData
get the Kaishi of card Kamoku of stack "motochyou"
put it into ZANDAKA
put the number of lines of KeisanData into KL
repeat with i = 1 to KL
put item 5 of line i of KeisanData into ATAI
if isNumber(ATAI) is false then put 0 into ATAI
add ATAI to ZANDAKA
put item 6 of line i of KeisanData into ATAI
if isNumber(ATAI) is false then put 0 into ATAI
subtract ATAI from ZANDAKA
put ZANDAKA into item 8 of line i of KeisanData
end repeat
--借方の月計を計算
put item 5 of line 1 of KeisanData into ATAI
if isNumber(ATAI) is false then put 0 into ATAI
repeat with i = 2 to KL
put item 5 of line i of KeisanData into TASU
if isNumber(TASU) is false then put 0 into TASU
add TASU to ATAI
end repeat
put ATAI into Karigoukei
--貸方の月計を計算
put item 6 of line 1 of KeisanData into ATAI2
if isNumber(ATAI2) is false then put 0 into ATAI2
repeat with i = 2 to KL
put item 6 of line i of KeisanData into TASU2
if isNumber(TASU2) is false then put 0 into TASU2
add TASU2 to ATAI2
end repeat
put ATAI2 into Kashigoukei
set the TUKI of card Kamoku of stack "motochyou" to KeisanData
put Karigoukei&tab&Kashigoukei&tab&ZANDAKA into GG
set the GouKei of card Kamoku of stack "motochyou" to GG
if m=12 then exit repeat
set the Tugi of card Kamoku of stack "motochyou" to ZANDAKA
end repeat
end KEISANBLUE
-----------------------------------------------------------
on KEISANRED Kamoku,WW
set itemDelimiter to tab
--月を設定して科目からデータを取り出す
repeat with m = WW to 12
put m&"月" into Tuki
put m&"月開始金額" into Kaishi
put m&"月合計金額" into GouKei
put (m+1)&"月開始金額" into Tugi
get the TUKI of card Kamoku of stack "motochyou"
put it into KeisanData
get the Kaishi of card Kamoku of stack "motochyou"
put it into ZANDAKA
put the number of lines of KeisanData into KL
repeat with i = 1 to KL
put item 6 of line i of KeisanData into ATAI
if isNumber(ATAI) is false then put 0 into ATAI
add ATAI to ZANDAKA
put item 5 of line i of KeisanData into ATAI
if isNumber(ATAI) is false then put 0 into ATAI
subtract ATAI from ZANDAKA
put ZANDAKA into item 8 of line i of KeisanData
end repeat
--借方の月計を計算
put item 5 of line 1 of KeisanData into ATAI
if isNumber(ATAI) is false then put 0 into ATAI
repeat with i = 2 to KL
put item 5 of line i of KeisanData into TASU
if isNumber(TASU) is false then put 0 into TASU
add TASU to ATAI
end repeat
put ATAI into Karigoukei
--貸方の月計を計算
put item 6 of line 1 of KeisanData into ATAI2
if isNumber(ATAI2) is false then put 0 into ATAI2
repeat with i = 2 to KL
put item 6 of line i of KeisanData into TASU2
if isNumber(TASU2) is false then put 0 into TASU2
add TASU2 to ATAI2
end repeat
put ATAI2 into Kashigoukei
set the TUKI of card Kamoku of stack "motochyou" to KeisanData
put Karigoukei&tab&Kashigoukei&tab&ZANDAKA into GG
set the GouKei of card Kamoku of stack "motochyou" to GG
if m=12 then exit repeat
set the Tugi of card Kamoku of stack "motochyou" to ZANDAKA
end repeat
end KEISANRED
-----------------------------------------------------------
on KingakuInput BikouKin,BikouKinZ
global GDEN,FID,LDN,KariTeki,KshiTeki,Skip
switch
case (GDEN is "出 金")
put BikouKin into fld (FID +1) of card "伝票"
put BikouKin into fld (FID +2) of card "伝票"
put (FID+1)/6 into LDN
add 3 to FID
if FID > 38 then
put "この伝票はこれ以上書き込めません。" into fld "MesegeArea"
exit switch
end if
put LDN+1&"行目の借方の勘定科目を選んで下さい。" into fld "MesegeArea"
exit switch
case (GDEN is "入 金")
put BikouKin into fld (FID +1) of card "伝票"
put BikouKin into fld (FID +2) of card "伝票"
put (FID+1)/6 into LDN
add 4 to FID
if FID > 39 then
put "この伝票はこれ以上書き込めません。" into fld "MesegeArea"
exit switch
end if
put LDN+1&"行目の貸方の勘定科目を選んで下さい。" into fld "MesegeArea"
exit switch
case (GDEN is "振替伝票")
if SKIP is empty then
put BikouKin into fld (FID +1) of card "伝票"
--ここで貸方に金額を入力
if BikouKinZ is empty then put BikouKin into BikouKinZ
repeat
ask question KshiTeki&"の金額はいくらですか?" with BikouKinZ titled "貸方金額"
put it into BikouKin
if isNumber(BikouKin) is false then next repeat
exit repeat
end repeat
put it into fld (FID +2) of card "伝票"
--摘要カードの金額欄に書き込む
set itemDelimiter to tab
get the number of items of line 1 of field "tekiyouichiran" of card KshiTeki of stack "tekiyou"
if it > 2 then
put BikouKin into item 2 of line 1 of field "tekiyouichiran" of card KshiTeki of stack "tekiyou"
put BikouKin into item 4 of line 1 of field "tekiyouichiran" of card KshiTeki of stack "tekiyou"
else
put BikouKin into item 2 of line 1 of field "tekiyouichiran" of card KshiTeki of stack "tekiyou"
end if
put (FID+1)/6 into LDN
add 3 to FID
if FID > 38 then
put "この伝票はこれ以上書き込めません。" into fld "MesegeArea"
exit switch
end if
put LDN+1&"行目の借方の勘定科目を選んで下さい。" into fld "MesegeArea"
end if
if SKIP is "借方" then
if BikouKinZ is empty then put BikouKin into BikouKinZ
put BikouKinZ into fld (FID +2) of card "伝票"
put (FID+1)/6 into LDN
add 4 to FID
if FID > 39 then
put "この伝票はこれ以上書き込めません。" into fld "MesegeArea"
exit switch
end if
put LDN+1&"行目の貸方の勘定科目を選んで下さい。" into fld "MesegeArea"
end if
if SKIP is "貸方" then
put BikouKin into fld (FID +1) of card "伝票"
put (FID+1)/6 into LDN
add 3 to FID
if FID > 38 then
put "この伝票はこれ以上書き込めません。" into fld "MesegeArea"
exit switch
end if
put LDN+1&"行目の借方の勘定科目を選んで下さい。" into fld "MesegeArea"
end if
end switch
end KingakuInput
--------------------------------------------------------------------------------------------------------------------
on DenGoukei
put field 5 + field 12 + field 18 + field 24 + field 30 + field 36 + field 42 into field 44
put field 7 + field 13 + field 19 + field 25 + field 31 + field 37 + field 43 into field 45
end DenGoukei
--------------------------------------------------------------------------------------------------------------------
on SYOKIKA WW
put WW&"月" into TUKI
put WW&"月合計金額" into TUKIGO
--先に変数に空をいれておく
put empty into EN
--資産勘定を初期化。カスタムプロパティに空の変数をセットする。
put the number of lines of fld "資産選択" of card "伝票" into KL
repeat with i=1 to KL
put line i of fld "資産選択" of card "伝票" into Kamoku
set the TUKI of card Kamoku of stack "motochyou" to EN
set the TUKIGO of card Kamoku of stack "motochyou" to EN
end repeat
--経費勘定を初期化。カスタムプロパティに空の変数をセットする。
put the number of lines of fld "経費選択" of card "伝票" into KL
repeat with i=1 to KL
put line i of fld "経費選択" of card "伝票" into Kamoku
set the TUKI of card Kamoku of stack "motochyou" to EN
set the TUKIGO of card Kamoku of stack "motochyou" to EN
end repeat
--収入勘定を初期化。カスタムプロパティに空の変数をセットする。
put the number of lines of fld "収入選択" of card "伝票" into KL
repeat with i=1 to KL
put line i of fld "収入選択" of card "伝票" into Kamoku
set the TUKI of card Kamoku of stack "motochyou" to EN
set the TUKIGO of card Kamoku of stack "motochyou" to EN
end repeat
--負債勘定を初期化。カスタムプロパティに空の変数をセットする。
put the number of lines of fld "負債選択" of card "伝票" into KL
repeat with i=1 to KL
put line i of fld "負債選択" of card "伝票" into Kamoku
set the TUKI of card Kamoku of stack "motochyou" to EN
set the TUKIGO of card Kamoku of stack "motochyou" to EN
end repeat
end SYOKIKA
--------------------------------------------------------------------------------------------------------------------
on SonohinoDen D
global SYear,SMon,SDay,DenNo,GDEN
If EnSyu is not empty then
GaoutDen
end if
get the short name of the target
if it is empty then exit SonohinoDen
put SMon&"/"&it&"/"&SYear into SDay
lock screen
-- 一度表紙に移動
put DenNo into DN
push card
go card "伝票データ"
-- 日付データのリストと照合して行を得る
find word SDay in fld "DenDTFld"
get foundLine()
-- 伝票に戻る
pop card
--go cd "元帳作業"
--lineOffsetは見つからなかったとき0を返すから
if it is empty
then
put "その日の伝票はありません。" into fld "MesegeArea"
exit SonohinoDen
end if
put word 2 of it into DenNo
GaInDen
if GDEN is "出 金" then
get the imagedata of image "出金伝票" of card 1 of stack "はいぱぁ帳簿Live版"
set the imagedata of image "DenDrow" to it
end if
if GDEN is "入 金" then
get the imagedata of image "入金伝票" of card 1 of stack "はいぱぁ帳簿Live版"
set the imagedata of image "DenDrow" to it
end if
if GDEN is "振替伝票" then
get the imagedata of image "振替伝票" of card 1 of stack "はいぱぁ帳簿Live版"
set the imagedata of image "DenDrow" to it
end if
end sonohinoDen
function shisyagonyu x
if x >= 0 then return trunc (x + 0.5)
if x < 0 then return trunc ( x - 0.5)
end shisyagonyu
on closestack
global SYear,SMon --使用年月。初期設定カードに記録
global DenNo --最後にいたかーど
global DenID --ユニークIDの最後の数
save this stack
--ここからデータのバックアップを作る
get short date
set the itemDelimiter to "/"
put item 3 of it into Y
put item 2 of it into D
put item 1 of it into M
get system time
set the itemDelimiter to ":"
put item 1 of it into H
put item 2 of it into Mt
put "20"&Y&"-"&M&"-"&D&"-"&H&"-"&Mt into DD
local tFile
get the defaultFolder
put it into DF
put DF & "/"&DD&"_Bup" into tFile
open file tFile for text write
--ここからデータを用意して書き込む
put unicodeText of fld "DenDataFld" of card "伝票データ" of stack "Chyoubo" into UniDenData
put uniDecode( UniDenData , utf8) into jpUtf8
write jpUtf8 to file tFile
close file tFile
end closestack
card “伝票”
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
on closecard
put "伝票が閉じられました。" into fld "MesegeArea"
global RemFidKari,RemFidKshi,EnSyu,SMon
global DenNo,DenID
put empty into RemFidKari
put empty into RemFidKshi
if EnSyu is not empty then
IdoCheck
GaOutDen
end if
--EnSyuを空にして勘定科目、摘要項目のクリックを無効にする
put empty into EnSyu
put empty into fld "MesegeArea" of cd "伝票"
put DenNo into fld "DenNoFld" of cd "初期設定"
put SMon into fld "SMonFld" of cd "初期設定"
put DenID into fld "DenIDFld" of cd "初期設定"
--save this stack as "chyoubo"
save this stack
end closecard
-----------------------------------------------------------------------------------------------------------
on SyuseiKin MotonoKin,FidName
global EnSyu
if EnSyu is empty then exit SyuseiKin
ask question "金額はいくらに直しますか?" with MotonoKin titled "金額修正"
if it is empty then exit SyuseiKin
put it into fld FidName of card "伝票"
put field 7 + field 13 + field 19 + field 25 + field 31 + field 37 + field 43 into field 45
put field 6 + field 12 + field 18 + field 24 + field 30 + field 36 + field 42 into field 44
end SyuseiKin
-----------------------------------------------------------------------------------------------------------
on SyuseiKamo MotonoKamo,FidName
global EnSyu,FID
if EnSyu is empty then exit SyuseiKamo
answer question "入れ替える勘定科目のリストをクリックしてください。" with "やめる" or "はい"
if it is "やめる" then exit SyuseiKamo
put FidName into FID
end SyuseiKamo
-----------------------------------------------------------------------------------------------------------
on DELKAMO FidName
global FID,GDEN,EnSyu,Skip
lock screen
--入力中以外は処理を終了
if isNumber(EnSyu) is false then exit DELKAMO
put (FidName+6) div 6 into Gyo
put (FidName+6) mod 6 into Yamari
answer error Gyo&&"行目を削除します。取り消しできませんので気をつけて下さい。" with "やめる"or"はい"
if it is "やめる" then exit DELKAMO
repeat with i=1 to 6
put empty into fld (6*Gyo-5+i)
end repeat
--上から下に一段ずらす
repeat with e=Gyo to 6
repeat with i=1 to 6
put fld (6*e+1+i) into fld (6*e-5+i)
end repeat
end repeat
put field 7 + field 13 + field 19 + field 25 + field 31 + field 37 + field 43 into field 45
put field 6 + field 12 + field 18 + field 24 + field 30 + field 36 + field 42 into field 44
if GDEN is "出 金" then
repeat with i=1 to 7
if fld (6*i-4) is empty
then
put (6*i-4) into FID
put i into Gyo
put Gyo&"行目の借方科目から入力しなおして下さい。" into fld "MesegeArea"
exit repeat
end if
end repeat
end if
if GDEN is "入 金" then
repeat with i=1 to 7
if field (6*i-3) is empty
then
put (6*i-3) into FID
put i into Gyo
put Gyo&"行目の貸方科目から入力しなおして下さい。" into fld "MesegeArea"
exit repeat
end if
end repeat
end if
if GDEN is "振替伝票" then
repeat with i= 1 to 7
if field (6*i-4) is not empty
then
put (6*i+2) into RemFidKari
else
put (6*i-4) into RemFidKari
exit repeat
end if
end repeat
repeat with i= 1 to 7
if field (6*i-3) is not empty
then
put (6*i+3) into RemFidKshi
else
put(6*i-3) into RemFidKshi
exit repeat
end if
end repeat
if (RemFidKari+1)<RemFidKshi
then
put RemFidKshi into FID
else
put RemFidKari into FID
end if
put (FID+6) div 6 into Gyo
put Gyo&"行目の借方科目から入力しなおして下さい。" into fld "MesegeArea"
end if
--修正ボタンを戻しておく
set the hilite of button "修正" to false
--スキップボタンを戻しておく
put empty into Skip
put empty into button "スキップ"
set the hilite of button "スキップ" to false
end DELKAMO
-----------------------------------------------------------------------------------------------------------
on Sakujo
global DenNo,GDEN,EnSyu,Skip
lock screen
if DenNo is 0 then exit Sakujo
set itemDelimiter to "."
put item 1 of fld "日付" of card "伝票" of stack "chyoubo" into Mon
set itemDelimiter to tab
delete line DenNo of fld "DenDataFld" of card "伝票データ"
delete line DenNo of fld "DenDTFld" of card "伝票データ"
put (DenNo-1)into DenNo
--伝票の削除があったことを記録しておく
if Mon is not empty then
put Mon into field ("Kioku"&Mon) of card "初期設定" of stack "chyoubo"
end if
GaInDen
if GDEN is "出 金" then
get the imagedata of image "出金伝票" of card 1 of stack "はいぱぁ帳簿Live版"
set the imagedata of image "DenDrow" to it
end if
if GDEN is "入 金" then
get the imagedata of image "入金伝票" of card 1 of stack "はいぱぁ帳簿Live版"
set the imagedata of image "DenDrow" to it
end if
if GDEN is "振替伝票" then
get the imagedata of image "振替伝票" of card 1 of stack "はいぱぁ帳簿Live版"
set the imagedata of image "DenDrow" to it
end if
--修正ボタンを戻しておく
set the hilite of button "修正" to false
--スキップボタンを戻しておく
set the hilite of button "スキップ" to false
put empty into Skip
--メッセージエリアを空にする
put empty into fld "MesegeArea"
--フラグを消しておく
put empty into EnSyu
end Sakujo
----------------------------------------------------------
on SyuseiTeki motonoTeki,FidName
global EnSyu,FID
lock screen
--EnSyuフラグが立っていないときは終了
if EnSyu is empty then exit SyuseiTeki
set itemDelimiter to tab
get fld (FidName -2)
put it into Z
get number (lines in field "tekiyouichiran" of card Z of stack "tekiyou" )
put it into T
put empty into field KariTekiFld
repeat with i= 1 to T
put item 1 of line i of field "tekiyouichiran" of card Z of stack "tekiyou" & return after field KariTekiFld
end repeat
put empty into fld KariBiFld
put empty into KrTekin
repeat with i= 1 to T
put item 2 of line i of field "tekiyouichiran" of card Z of stack "tekiyou" & return after KrTekin
end repeat
get fld (FidName -1)
put it into Z
get number (lines in field "tekiyouichiran"of card Z of stack "tekiyou" )
put it into T
put empty into field KashiTekiFld
repeat with i= 1 to T
put item 1 of line i of field "tekiyouichiran" of card Z of stack "tekiyou" & return after field KashiTekiFld
end repeat
put empty into fld KashiBiFld
put empty into KsTekin
repeat with i= 1 to T
put item 2 of line i of field "tekiyouichiran" of card Z of stack "tekiyou" & return after KsTekin
end repeat
answer question "入れ替える摘要のリストをクリックしてください。" with "やめる" or "はい"
if it is "やめる" then exit SyuseiTeki
put FidName into FID
end SyuseiTeki
field “借方科目1”
on mouseUp
get me
if it is empty
then
exit mouseUp
else
put it into MotonoKamo
end if
put word 2 of clickField() into FidName
wait 20 ticks
if the mouseclick then
DELKAMO FidName
else
SyuseiKamo MotonoKamo,FidName
end if
end mouseUp
field “摘要”
on mouseUp
get me
if it is empty
then
exit mouseUp
else
put it into MotonoTeki
end if
get number of me
put it into FidName
SyuseiTeki MotonoTeki,FidName
end mouseUp
field “資産選択”
on mouseUp
get the value of the clickline
if it is empty then exit mouseup
put it into Z
if the shiftkey is down then put 1 into S
if the optionkey is down then put 2 into S
Kankamo Z,S
set the hilitedLine of field "資産選択" to none
end mouseUp
on mouseDown
put word 2 of clickline() into CL
set the hilitedLine of field "資産選択" to CL
end mouseDown
field “KariTekiFld”
----------------借方勘定の側の摘要がクリックされた時の処理
on mouseup
global GDEN
global KrTeKin
global KariTeki,KshiTeki
global FID --このハンドラが呼ばれる時は時は4とその+6された数のはず
global EnSyu --このハンドラが呼ばれるときは1のはず
global KashiNaka
global KariNaka
--global Tekiyou
global CLN
global SelKrKs
global Skip
global Kamoku
global TekiLn
global TekiBikin
global LDN
--global BikouSet
set the hilitedLine of field "KariTekiFld" to none
set itemDelimiter to tab
--条件が合わない時は処理を終了する
--EnSyu が 1 FIDが4
if EnSyu is not 1 then exit mouseUp
if (FID + 6) mod 6 is not 4 then exit mouseUp
put the value of the clickline into XX
if XX is empty then exit mouseup
put "借方" into Kamoku
if KariTeki is empty then put KariNaka into KariTeki
put KariTeki into SelKrKs
--摘要をフィールドに表示する
put XX into field FID
put empty into fld "MesegeArea"
--クリックした行をCLNに保存
put word 2 of the clickLine into CLN
put KariNaka into TekiKari
--摘要を取り出す
get line CLN of field "tekiyouichiran" of card KariTeki of stack "tekiyou"
get number (items of it)
--備考が2行以上すでにあるときの処理
if it >2
then
put empty into TekiBikin
put "備考を入力しない" & return into BikouNakami
put item 2 of line CLN of field "tekiyouichiran" of card KariTeki of stack "tekiyou" & return after TekiBikin
repeat with i= 2 to it
put item (i*2-1) of line CLN of field "tekiyouichiran" of card KariTeki of stack "tekiyou" & return after BikouNakami
put item (i*2) of line CLN of field "tekiyouichiran" of card KariTeki of stack "tekiyou" & return after TekiBikin
end repeat
--備考をフィールドに表示する
--FIDを一つ増やす。FID=5になる
--メッセージを出す
put BikouNakami into fld KariBiFld of card "伝票"
add 1 to FID
put XX&"の備考を選んで下さい。" into fld "MesegeArea"
get line CLN of field "tekiyouichiran" of card KariTeki of stack "tekiyou"
delete line CLN of field "tekiyouichiran" of card KariTeki of stack "tekiyou"
put it & return before line 1 of field "tekiyouichiran" of card KariTeki of stack "tekiyou"
put 1 into CLN
exit mouseUp
--備考項目があるときはここでEXIT。
end if
--備考がまだない時、金額を入力
get item 2 of line CLN of field "tekiyouichiran" of card KariTeki of stack "tekiyou"
if it is empty then
put 0 into TekiBiKin
else
put it into TekiBiKin
end if
ask question XX &"の金額はいくらですか。備考を入れても結構です。" with TekiBiKin titled "摘要金額"
if it is empty then exit mouseUp
put it into BikouKin
if isNumber(BikouKin) is false
--数字以外が入っている場合、備考が入ったと認める
then
put BikouKin into NewBikou
repeat
ask question NewBikou&"の金額はいくらですか?" with "0" titled "借方金額"
if isNumber(it) is false then next repeat
exit repeat
end repeat
if it is empty then exit mouseUp
put it into BikouKin
--備考を伝票に記入する
put NewBikou into fld (FID +1) of card "伝票"
-- 金額はあとで
--新規に摘要と備考が同時に入った場合、摘要カードに書き込むだけ
put XX &tab &BikouKin & tab & NewBikou &tab &BikouKin & tab into line CLN of field "tekiyouichiran" of card KariTeki of stack "tekiyou"
--金額はあとで
else
--新規に摘要と金額だけが入った場合
put XX &tab &BikouKin& tab into line CLN of field "tekiyouichiran" of card KariTeki of stack "tekiyou"
end if
--摘要の順番入れ替え
get line CLN of field "tekiyouichiran" of card KariTeki of stack "tekiyou"
delete line CLN of field "tekiyouichiran" of card KariTeki of stack "tekiyou"
put it & return before line 1 of field "tekiyouichiran" of card KariTeki of stack "tekiyou"
--FIDを進めて金額を入力する
add 1 to FID
KingakuInput BikouKin
put field 7 + field 13 + field 19 + field 25 + field 31 + field 37 + field 43 into field 45
put field 6 + field 12 + field 18 + field 24 + field 30 + field 36 + field 42 into field 44
end mouseup
on mouseDown
put word 2 of clickline() into CL
set the hilitedLine of field "KariTekiFld" to CL
end mouseDown
field “KashiTekiFld”
----------------貸方勘定の側の摘要がクリックされた時の処理
on mouseup
global GDEN
global KrTeKin
global KariTeki
global KshiTeki
global KsTekin
global FID --このハンドラが呼ばれる時は時は4とその+6された数のはず
global EnSyu --このハンドラが呼ばれるときは1のはず
global KashiNaka
global KariNaka
--global Tekiyou
global CLN
global SelKrKs
global Skip
global Kamoku
global TekiLn
global TekiBikin
global LDN
--global BikouSet
set the hilitedLine of field "KashiTekiFld" to none
set itemDelimiter to tab
--条件が合わない時は処理を終了する
--EnSyu が 1 FIDが4
if EnSyu is not 1 then exit mouseUp
if (FID + 6) mod 6 is not 4 then exit mouseUp
put the value of the clickline into XX
if XX is empty then exit mouseup
put "貸方" into Kamoku
if KshiTeki is empty then put KashiNaka into KshiTeki
put KshiTeki into SelKrKs
--摘要をフィールドに表示する
put XX into field FID
put empty into fld "MesegeArea"
--クリックした行をCLNに保存
put word 2 of the clickLine into CLN
put KashiNaka into TekiKashi
--摘要を取り出す
get line CLN of field "tekiyouichiran" of card KshiTeki of stack "tekiyou"
get number (items of it)
--備考が2行以上すでにあるときの処理
if it >2
then
put empty into TekiBikin
put "備考を入力しない" & return into BikouNakami
put item 2 of line CLN of field "tekiyouichiran" of card KshiTeki of stack "tekiyou" & return after TekiBikin
repeat with i= 2 to it
put item (i*2-1) of line CLN of field "tekiyouichiran" of card KshiTeki of stack "tekiyou" & return after BikouNakami
put item (i*2) of line CLN of field "tekiyouichiran" of card KshiTeki of stack "tekiyou" & return after TekiBikin
end repeat
--備考をフィールドに表示する
--FIDを一つ増やす。FID=5になる
--メッセージを出す
put BikouNakami into fld KashiBiFld of card "伝票"
add 1 to FID
put XX&"の備考を選んで下さい。" into fld "MesegeArea"
--選ばれた摘要を一行目に移動しておく
get line CLN of field "tekiyouichiran" of card KshiTeki of stack "tekiyou"
delete line CLN of field "tekiyouichiran" of card KshiTeki of stack "tekiyou"
put it & return before line 1 of field "tekiyouichiran" of card KshiTeki of stack "tekiyou"
exit mouseUp
--備考項目があるときはここでEXIT。
end if
--備考がまだない時、金額を入力
get item 2 of line CLN of field "tekiyouichiran" of card KshiTeki of stack "tekiyou"
if it is empty then
put 0 into TekiBiKin
else
put it into TekiBiKin
end if
ask question XX &"の金額はいくらですか。備考を入れても結構です。" with TekiBiKin titled "摘要金額"
if it is empty then exit mouseUp
put it into BikouKin
if isNumber(BikouKin) is false
--数字以外が入っている場合、備考が入ったと認める
then
put BikouKin into NewBikou
repeat
ask question NewBikou&"の金額はいくらですか?" with "0" titled "借方金額"
if isNumber(it) is false then next repeat
exit repeat
end repeat
if it is empty then exit mouseUp
put it into BikouKin
--伝票に記入する
put NewBikou into fld (FID +1) of card "伝票"
-- 金額はあとで
--新規に摘要と備考が同時に入った場合
put XX &tab &BikouKin & tab & NewBikou &tab &BikouKin & tab into line CLN of field "tekiyouichiran" of card KshiTeki of stack "tekiyou"
-- 金額はあとで
else
--新規に摘要と金額だけが入った場合
put XX &tab &BikouKin& tab into line CLN of field "tekiyouichiran" of card KshiTeki of stack "tekiyou"
end if
--摘要の順番入れ替え
get line CLN of field "tekiyouichiran" of card KshiTeki of stack "tekiyou"
delete line CLN of field "tekiyouichiran" of card KshiTeki of stack "tekiyou"
put it & return before line 1 of field "tekiyouichiran" of card KshiTeki of stack "tekiyou"
--FIDを進めて金額を入力する
add 1 to FID
put empty into BikouKinZ
KingakuInput BikouKin,BikouKinZ
put field 7 + field 13 + field 19 + field 25 + field 31 + field 37 + field 43 into field 45
put field 6 + field 12 + field 18 + field 24 + field 30 + field 36 + field 42 into field 44
end mouseup
on mouseDown
put word 2 of clickline() into CL
set the hilitedLine of field "KashiTekiFld" to CL
end mouseDown
field “KariBiFld”
on mouseUp
global Kamoku
global KariNaka,KashiNaka
global KariTeki,KshiTeki
global BikouSet
global TekiBiKin
--global BikouKin
global FID
global CLN
global GDEN
global EnSyu
set the hilitedLine of field "KariBiFld" to none
--条件が合わない時は処理を終了する
--EnSyu が 1 FIDが5
if EnSyu is not 1 then exit mouseUp
if (FID + 6) mod 6 is not 5 then exit mouseUp
lock screen
set itemDelimiter to tab
put the value of the clickline into XX
if XX is empty then exit mouseup
if XX is "備考を入力しない" then
get item 1 of line CLN of field "tekiyouichiran" of card KariTeki of stack "tekiyou"
if it is empty then exit mouseup
put it into XX
end if
put word 2 of the clickLine into BiLin
if Kamoku is "借方" then
repeat
put line BiLin of TekiBikin into ZZ
ask question XX&"の金額はいくらですか?" with ZZ titled "借方金額"
if it is empty then exit mouseup --入力がないときハンドラを抜けることになっているがもう一度摘要を選ぶようにしないといけない
put it into BikouKin
if isNumber(BikouKin) is false then next repeat--ここは絶対金額でなければならない
--摘要カードでの作業
if BiLin is 1 then
--備考に何も入れない
put empty into fld (FID) of card "伝票"
--摘要カードに書き込む
put BikouKin into item 2 of line 1 of field "tekiyouichiran" of card KariTeki of stack "tekiyou"
else
put XX into fld (FID) of card "伝票"
delete item (BiLin *2 -1)to (BiLin*2)of line 1 of field "tekiyouichiran" of card KariTeki of stack "tekiyou"
put tab & XX &tab &BikouKin after item 2 of line 1of field "tekiyouichiran" of card KariTeki of stack "tekiyou"
end if
exit repeat
end repeat
end if
KingakuInput BikouKin
put field 7 + field 13 + field 19 + field 25 + field 31 + field 37 + field 43 into field 45
put field 6 + field 12 + field 18 + field 24 + field 30 + field 36 + field 42 into field 44
end mouseUp
on mouseDown
put word 2 of clickline() into CL
set the hilitedLine of field "KariBiFld" to CL
end mouseDown
button “スキップ”
on mouseUp
global FID,Ensyu,Skip
If Ensyu is not 1 then exit mouseUp
if FID < 4 then exit mouseUp
if FID > 36 then exit mouseUp
if Skip is not empty then exit mouseUp
set the hilite of me to true
put (FID+6) mod 6 into Famari
put (FID+6) div 6 into Gyo
if Famari is 2 then
put Gyo&"行目の貸方科目を選んでください。" into fld "MesegeArea"
put "借方" into Skip
add 1 to FID
exit mouseUp
end if
if Famari is 3 then
put Gyo&"行目の摘要を選んでください。" into fld "MesegeArea"
put "貸方" into Skip
add 1 to FID
exit mouseUp
end if
if Famari is 4 then exit mouseUp
if Famari is 0 then exit mouseUp
if Famari is 1 then exit mouseUp
end mouseUp
button “btnTran”
on mouseUp
global DenData,DenNo
global GDEN
global Skip
global EnSyu
global SelKrKs
IdoCheck
If EnSyu is not empty then
GaoutDen
end if
put "出金伝票を作ります。カレンダーで日にちを選んでください。" into fld "MesegeArea"
put "出 金" into GDEN
put 2 into EnSyu
put empty into Skip
put empty into SelKrKs
end mouseUp
button “修正”
on mouseDown
global EnSyu
get the hilite of me
if EnSyu is empty then --編集モードでないとき
if it is false then --点灯していなければ
set the hilite of me to true --点灯させて、mouseUpへ
end if
else
if it is true then
set the hilite of me to false
GaOutDen
put "データベースへこの伝票を書き込みました。" into fld "MesegeArea"
put empty into EnSyu
end if
end if
end mouseDown
-----------------------------------------------------------------------------------------------------------------
on mouseUp
global EnSyu,SMon,FID,GDEN,SKIP
get the hilite of me
if it is true then
answer warning "この伝票を修正しますか追記しますか。" with "やめる" or "追記" or "修正"
lock screen
if it is "やめる" then
set the hilite of me to false
put empty into EnSyu
put empty into fld "MesegeArea"
exit mouseUp
end if
if it is "追記" then
--EnSyuに1を入れて入力中モードにする
put 1 into EnSyu
--FIDを求める
if GDEN is "出 金" then
repeat with i=1 to 7
if fld (6*i-4) is empty
then
put (6*i-4) into FID
put i into Gyo
put Gyo&"行目の借方科目から入力して下さい。" into fld "MesegeArea"
exit repeat
end if
end repeat
end if
if GDEN is "入 金" then
repeat with i=1 to 7
if field (6*i-3) is empty
then
put (6*i-3) into FID
put i into Gyo
put Gyo&"行目の貸方科目から入力して下さい。" into fld "MesegeArea"
exit repeat
end if
end repeat
end if
if GDEN is "振替伝票" then
repeat with i= 1 to 7
if field (6*i-4) is not empty then put (6*i+2) into RemFidKari
if field (6*i-3) is not empty then put (6*i+3) into RemFidKshi
end repeat
if (RemFidKari+1)<RemFidKshi
then
put RemFidKshi into FID
else
put RemFidKari into FID
end if
put (FID+6) div 6 into Gyo
put Gyo&"行目の借方科目から入力して下さい。" into fld "MesegeArea"
end if
set itemDelimiter to "."
put item 1 of fld "日付" of card "伝票" of stack "chyoubo" into Mon
--伝票の修正があったことを記録しておく
put Mon into field ("Kioku"&Mon) of card "初期設定" of stack "chyoubo"
set itemDelimiter to tab
exit mouseUp
end if
--修正するのとき
put "修正する項目をクリックしてください。" into fld "MesegeArea"
put 1 into EnSyu
set the hilite of me to true
set itemDelimiter to "."
put item 1 of fld "日付" of card "伝票" of stack "chyoubo" into Mon
if Mon is empty then exit mouseup
--伝票の修正があったことを記録しておく
put Mon into field ("Kioku"&Mon) of card "初期設定" of stack "chyoubo"
set itemDelimiter to tab
end if
end mouseUp
button “新規貸方摘要”
on mouseup
global GDEN
global KrTeKin
global KariTeki
global KshiTeki
global FID --このハンドラが呼ばれる時は時は4とその+6された数のはず
global EnSyu --このハンドラが呼ばれるときは1のはず
global KashiNaka
global KariNaka
--global Tekiyou
global CLN
global SelKrKs
global Skip
global Kamoku
global TekiLn
global TekiBikin
--global BikouSet
--条件が合わない時は処理を終了する
--EnSyu が 1 FIDが4
--Kamokuが 借方
if EnSyu is not 1 then exit mouseUp
if (FID + 6) mod 6 is not 4 then exit mouseUp
-- if Kamoku is not "貸方" then exit mouseUp
--摘要を入力
ask question KshiTeki &"の摘要を入力してください。" with "新規摘要項目" titled "新規摘要項目"
if it is empty then exit mouseUP
put it into NewTeki
--摘要を表示
put NewTeki into field FID
--金額を入力
ask question NewTeki &"の金額はいくらですか。備考を入れても結構です。" with "0" titled "摘要金額"
if it is empty then exit mouseUp
put it into BikouKin
if isNumber(BikouKin) is false
--数字以外が入っている場合、備考が入ったと認める
then
put BikouKin into NewBikou
repeat
ask question NewBikou&"の金額はいくらですか?" with "0" titled "貸方金額"
if isNumber(it) is false then next repeat
exit repeat
end repeat
if it is empty then exit mouseUp
put it into BikouKin
--伝票に記入する
put NewBikou into fld (FID +1) of card "伝票"
--金額は後で
--新規に摘要と備考が同時に入った場合
put NewTeki &tab &BikouKin & tab & NewBikou &tab &BikouKin & tab & return before line 1 of field "tekiyouichiran" of card KshiTeki of stack "tekiyou"
--金額は後で
if GDEN is "振替伝票" then
answer question KariTeki&"にも登録しますか?" with "いいえ" or "はい"
if it is "はい" then
put NewTeki &tab &BikouKin & tab & NewBikou &tab &BikouKin & tab & return before line 1 of field "tekiyouichiran" of card KariTeki of stack "tekiyou"
end if
end if
else
--新規に摘要と金額だけが入った場合
put NewTeki &tab &BikouKin & tab & return before line 1 of field "tekiyouichiran" of card KshiTeki of stack "tekiyou"
if GDEN is "振替伝票" then
answer question KariTeki&"にも登録しますか?" with "いいえ" or "はい"
if it is "はい" then
put NewTeki &tab &BikouKin & tab & return before line 1 of field "tekiyouichiran" of card KariTeki of stack "tekiyou"
end if
end if
end if
--FIDを進めて金額を入力する
add 1 to FID
KingakuInput BikouKin
put field 7 + field 13 + field 19 + field 25 + field 31 + field 37 + field 43 into field 45
put field 6 + field 12 + field 18 + field 24 + field 30 + field 36 + field 42 into field 44
end mouseup
button “転記”
on mouseUp
global EnSyu
if isNumber(EnSyu) is true then
GaOutDen
end if
set itemDelimiter to tab
--DenDataFldを日付でソートする
sort lines of fld "DenDataFld" of cd "伝票データ" numeric by item 46 of each
sort lines of fld "DenDataFld" of cd "伝票データ" datetime by item 49 of each
--初期設定のKiokuフィールドをチェックする
repeat with WW = 1 to 12
put "Kioku"&WW into KF
get fld KF of cd "初期設定"
if it is not empty
then
exit repeat
else
if WW = 12 then
put "転記していない伝票はありません。" into fld "MesegeArea"
exit mouseUp
end if
next repeat
end if
end repeat
repeat with WW = 1 to 12
put "Kioku"&WW into KF
get fld KF of cd "初期設定" of stack "Chyoubo"
if it is empty then next repeat
unlock screen
put WW&"月を転記します。" into fld "MesegeArea"
lock screen
SYOKIKA WW
TENKI WW
end repeat
-- ここから計算
repeat with WW = 1 to 12
put "Kioku"&WW into KF
get fld KF of cd "初期設定" of stack "Chyoubo"
if it is empty then next repeat
unlock screen
put WW&"月から計算中。" into fld "MesegeArea"
lock screen
--資産勘定を計算
put the number of lines of fld "資産選択" into KL
repeat with i=1 to KL
put line i of fld "資産選択" into Kamoku
KEISANBLUE kamoku,WW
end repeat
--経費勘定を計算
put the number of lines of fld "経費選択" into KL
repeat with i=1 to KL
put line i of fld "経費選択" into Kamoku
KEISANBLUE kamoku,WW
end repeat
--収入勘定を計算
put the number of lines of fld "収入選択" into KL
repeat with i=1 to KL
put line i of fld "収入選択" into Kamoku
KEISANRED kamoku,WW
end repeat
--負債勘定を計算
put the number of lines of fld "負債選択" into KL
repeat with i=1 to KL
put line i of fld "負債選択" into Kamoku
KEISANRED kamoku,WW
end repeat
--end repeat
--記憶フィールドを空に
repeat with i=1 to 12
put "Kioku"&i into KF
put empty into fld KF of cd "初期設定"
end repeat
--ここまできたら処理終了
exit repeat
end repeat
put "転記と計算が終わりました。" into fld "MesegeArea"
end mouseUp