<% Function TyoboSonekiKeisansyo(EnshuCD, KaisyaCD, SakuseiKaisyaCD, BunsyoSyuruiCD, BunsyoNaiyoCD, AutoFlg, PrintFlg, Param1, Param2, Param3, KurikoshiKubun) Dim RowBreakNum, RowCount Dim Page RowCount = 0 Dim pp pp = 0 If PrintFlg = 1 Then RowBreakNum = 30 Else RowBreakNum = MaxRowBreakNum MaxPage = 1 End If Dim Query Dim Content Dim Torihikibi Dim kk Dim DSP_Zandaka Dim KaikeiKaishibi, KaikeiSyuryobi Query = "exec SPM演習取得 '" & GB_SystemCD & "','" & EnshuCD & "'" Set Content = OpenQuery(Query) If Not(Content.BOF Or Content.EOF) Then KaikeiKaishibi = Content.Fields("会計開始日") KaikeiSyuryobi = Content.Fields("会計終了日") End If If Param1 = "" Then Param1 = KaikeiKaishibi End If If Param2 = "" Then Param2 = KaikeiSyuryobi End If Dim bExistSyuseiKinyu bExistSyuseiKinyu = 0 Query = "exec SPK伝票集計取得 '" & GB_SystemCD & "','" & EnshuCD & "', '" & KaisyaCD & "', '', -1, -1, 9" Set Content = OpenQuery(Query) If Not(Content.BOF Or Content.EOF) Then bExistSyuseiKinyu = 1 End If Dim Nikubun, NikubunFlg, TanaorosiKubun, TanaorosiFlg If bExistSyuseiKinyu = 0 Then TanaorosiKubun = Param3 Else Nikubun = Param3 End If If TanaorosiKubun = "1" Then 'チェックあり TanaorosiFlg = "checked" Else TanaorosiFlg = "" End If If Nikubun = "1" Then 'チェックあり NikubunFlg = "checked" Else NikubunFlg = "" End If If KurikoshiKubun = "1" Then KurikoshiKubun = "10" Else KurikoshiKubun = "9" End If Dim SyoruiMei If AutoFlg = 0 Then Query = "exec SPK帳簿_損益計算書取得 '" & GB_SystemCD & "','" & EnshuCD & "', '" & KaisyaCD & "'" SyoruiMei = "損益計算書" ElseIf AutoFlg = 1 Then Query = "exec SPK自動転記帳簿_財務諸表2 '" & GB_SystemCD & "', '" & EnshuCD & "', '" & KaisyaCD & "','" & Param1 & "','" & Param2 & "','P', 0, " & KurikoshiKubun SyoruiMei = "損益計算書(自動)" Else Query = "SELECT * FROM TC1システムM WHERE 1 = 0" SyoruiMei = "損益計算書" Param1 = "" Param2 = "" End If Set Content = OpenQuery(Query) Dim RecordCount, ShowCount If AutoFlg = 1 Then RecordCount = 0 ShowCount = 0 MaxCount = 0 Do While Not(Content.BOF Or Content.EOF) RecordCount = RecordCount + 1 Content.MoveNext Loop Set Content = OpenQuery(Query) ShowCount = RecordCount MaxCount = RecordCount + 3 ' RowBreakNum = MaxCount ReDim WK_Zandaka(MaxCount) For jj = 0 To MaxCount WK_Zandaka(jj) = Array("", "", "", "", "", "", "", "") Next 'ワーク「残高F」を作成 Do While Not(Content.BOF Or Content.EOF) ii = ii + 1 WK_Zandaka(ii)(1) = Content.Fields("勘定CD") WK_Zandaka(ii)(2) = Content.Fields("勘定名称") WK_Zandaka(ii)(3) = Content.Fields("借方金額") WK_Zandaka(ii)(4) = Content.Fields("貸方金額") ' WK_Zandaka(ii)(5) = Content.Fields("勘定科目貸借区分") WK_Zandaka(ii)(6) = Content.Fields("貸借区分") WK_Zandaka(ii)(7) = Content.Fields("諸表集計CD") Content.MoveNext Loop '棚卸の調整ここから If (bExistSyuseiKinyu = 0 And TanaorosiKubun = "1") Or (bExistSyuseiKinyu = 1 And Nikubun = "1") Then '在庫数をチェックする。 Dim KimatsuSyohinTanaoroshidaka, KisyuSyohinTanaoroshidaka KisyuSyohinTanaoroshidaka = KisyuTanaoroshiKingaku(Param2) KimatsuSyohinTanaoroshidaka = KimatsuTanaoroshiKingaku(Param2) Dim KurikosiFLG, InsertNo Dim i ,j ' For jj = 1 To RecordCount ' Response.Write(jj & "-" & WK_Zandaka(jj)(1) & "
") ' Next Dim KanjyoCDShiire, KanjyoCDKurikoshiSyohin Dim KanjyoCDKisyuSyohinTanaoroshidaka, KanjyoCDKimatsuSyohinTanaoroshidaka Query = "exec SPM勘定科目取得特別勘定 '" & GB_SystemCD & "','" & EnshuCD & "', ''" Set Content = OpenQuery(Query) Do While Not(Content.BOF OR Content.EOF) If Content.Fields("特別勘定区分") = "DL" Then KanjyoCDShiire = Content.Fields("勘定CD") ElseIf Content.Fields("特別勘定区分") = "DG" Then KanjyoCDKisyuSyohinTanaoroshidaka = Content.Fields("勘定CD") ElseIf Content.Fields("特別勘定区分") = "DH" Then KanjyoCDKimatsuSyohinTanaoroshidaka = Content.Fields("勘定CD") ElseIf Content.Fields("特別勘定区分") = "DJ" Then KanjyoCDKurikoshiSyohin = Content.Fields("勘定CD") End If Content.MoveNext Loop '繰越商品を削除ここから For jj = 1 To RecordCount If WK_Zandaka(jj)(1) = KanjyoCDKurikoshiSyohin Then WK_Zandaka(ii) = NullValue ShowCount = ShowCount - 1 End If Next '繰越商品を削除ここまで Dim tmp '期首商品棚卸高ここから tmp = ReplaceKanjyo(KanjyoCDKisyuSyohinTanaoroshidaka, KisyuSyohinTanaoroshidaka, 0) '期首商品棚卸高ここまで '期末商品棚卸高ここから tmp = ReplaceKanjyo(KanjyoCDKimatsuSyohinTanaoroshidaka, 0, KimatsuSyohinTanaoroshidaka) '期末商品棚卸高ここまで If bExistSyuseiKinyu = 1 Then tmp = ReplaceKanjyo(KanjyoCDShiire, KityuShiireKingaku(Param2), 0) End If End If ReDim DSP_Zandaka(ShowCount + 1) For jj = 0 To ShowCount DSP_Zandaka(jj) = Array("", "", "", "", "", "", "", "") Next If 1 = 0 Then For jj = 0 To MaxCount - 1 For kk = 0 To 5 Response.write(WK_Zandaka(jj)(kk)) Response.write("-") Next Response.write("
" & vbCrLf) Next Response.write("
" & vbCrLf) Response.write("
" & vbCrLf) Call QuickSort(WK_Zandaka, 0, MaxCount - 1) For jj = 0 To MaxCount - 1 For kk = 0 To 6 Response.write(WK_Zandaka(jj)(kk)) Response.write("-") Next Response.write("
" & vbCrLf) Next End If Dim cc, dd Dim DSP_SyuekiTotal,DSP_HiyoTotal cc = 0 dd = 0 For jj = 0 To MaxCount - 1 If WK_Zandaka(jj)(6) <> "" Then '借方 If WK_Zandaka(jj)(6) = "D" Then '借方 If WK_Zandaka(jj)(3) - WK_Zandaka(jj)(4) <> 0 Then dd = dd + 1 DSP_Zandaka(dd)(5) = WK_Zandaka(jj)(3) - WK_Zandaka(jj)(4) DSP_Zandaka(dd)(1) = WK_Zandaka(jj)(1) DSP_Zandaka(dd)(3) = WK_Zandaka(jj)(2) DSP_HiyoTotal = DSP_HiyoTotal + DSP_Zandaka(dd)(5) End If Else If WK_Zandaka(jj)(4) - WK_Zandaka(jj)(3) <> 0 Then cc = cc + 1 DSP_Zandaka(cc)(6) = WK_Zandaka(jj)(4) - WK_Zandaka(jj)(3) DSP_Zandaka(cc)(2) = WK_Zandaka(jj)(1) DSP_Zandaka(cc)(4) = WK_Zandaka(jj)(2) DSP_SyuekiTotal = DSP_SyuekiTotal + DSP_Zandaka(cc)(6) End If End If End If Next Dim DisplayRow If cc > dd Then DisplayRow = cc Else DisplayRow = dd End If Torihikibi = Param2 Else Set Content = OpenQuery(Query) If Not(Content.BOF Or Content.EOF) Then Torihikibi = SetTimeYYYYMMDD(Content.Fields("取引日")) End IF ShowCount = 0 Do While Not(Content.BOF Or Content.EOF) ShowCount = ShowCount + 1 Content.MoveNext Loop ReDim DSP_Zandaka(ShowCount + 1) For jj = 0 To ShowCount DSP_Zandaka(jj) = Array("", "", "", "", "", "", "", "") Next DisplayRow = ShowCount ii = 0 If Not(Content.BOF) Then Content.MoveFirst End If Do While Not(Content.BOF Or Content.EOF) ii = ii + 1 Param2 = Content.Fields("取引日") DSP_Zandaka(ii)(2) = Content.Fields("貸方勘定CD") DSP_Zandaka(ii)(4) = Content.Fields("貸方勘定名称") DSP_Zandaka(ii)(6) = Content.Fields("貸方金額") DSP_Zandaka(ii)(1) = Content.Fields("借方勘定CD") DSP_Zandaka(ii)(3) = Content.Fields("借方勘定名称") DSP_Zandaka(ii)(5) = Content.Fields("借方金額") Content.MoveNext Loop End If Dim KarikataGokei, KashikataGokei KarikataGokei = 0 KashikataGokei = 0 If PrintFlg = 0 Then %>
<% End If For Page = 1 To MaxPage If Page <> 1 Then Response.Write(PageBreakBefore) End If %>
<% If PrintFlg = 1 Then Response.Write(PrintHeader1(AutoFlg)) End if %>
<% 'If Content.BOF Or Content.EOF Then %> <% 'If ii + 1 > Ubound(DSP_Zandaka) Then %> <% 'If ii + 1 > ShowCount Then %> <% If ii + 1 > DisplayRow Then %> <% End If %>
<% = SetStringInsertSpace(SyoruiMei) %> <% If AutoFlg <> -1 And PrintFlg = 1 Then %><% = Page %>ページ<% End If %>
<% If AutoFlg = - 1 Then %>
自:    年    月    日〜至:    年    月    日
<% Else %>
自: <% = Param1 %>  〜  至: <% = Param2 %>
<% End If %>
<% GB_CSVOutput = GB_CSVOutput & "" GB_CSVOutput = GB_CSVOutput & ",費用" GB_CSVOutput = GB_CSVOutput & ",金額" GB_CSVOutput = GB_CSVOutput & "," GB_CSVOutput = GB_CSVOutput & ",収益" GB_CSVOutput = GB_CSVOutput & ",金額" GB_CSVOutput = GB_CSVOutput & "kaigyooygiakaigyooygiakaigyooygiakaigyooygiak" %>
費用 金額 収益 金額
<% If PrintFlg <> 1 Then %>
<% End If %> <% Dim ii, jj ii = 0 If 1 = 0 Then For jj = 0 To DisplayRow For kk = 0 To 6 Response.write(DSP_Zandaka(jj)(kk)) Response.write("-") Next Response.write("
" & vbCrLf) Next End If jj = 0 For ii = pp + 1 To DisplayRow pp = pp + 1 RowCount = RowCount + 1 If Not(DSP_Zandaka(ii)(1) = "" and DSP_Zandaka(ii)(2) = "") Then jj = jj + 1 If Not(IsNull(DSP_Zandaka(ii)(5))) And DSP_Zandaka(ii)(5) <> "" Then KarikataGokei = KarikataGokei + DSP_Zandaka(ii)(5) End If If Not(IsNull(DSP_Zandaka(ii)(6))) And DSP_Zandaka(ii)(6) <> "" Then KashikataGokei = KashikataGokei + DSP_Zandaka(ii)(6) End If Response.Write("" & vbCrLf) Response.Write("" & vbCrLf) Response.Write("" & vbCrLf) Response.Write("" & vbCrLf) Response.Write("" & vbCrLf) Response.Write("" & vbCrLf) Response.Write("" & vbCrLf) Response.Write("") GB_CSVOutput = GB_CSVOutput & "" & DSP_Zandaka(ii)(1) GB_CSVOutput = GB_CSVOutput & "," & DSP_Zandaka(ii)(3) GB_CSVOutput = GB_CSVOutput & "," & DSP_Zandaka(ii)(5) GB_CSVOutput = GB_CSVOutput & "," & DSP_Zandaka(ii)(2) GB_CSVOutput = GB_CSVOutput & "," & DSP_Zandaka(ii)(4) GB_CSVOutput = GB_CSVOutput & "," & DSP_Zandaka(ii)(6) GB_CSVOutput = GB_CSVOutput & "kaigyooygiakaigyooygiakaigyooygiakaigyooygiak" If (RowCount Mod RowBreakNum = 0) Then Exit For End If End If Next If 1 = 1 Then For jj = RowCount + 1 To Max(18, Max(RowBreakNum, (Int((RowCount - 1) / RowBreakNum) + 1) * RowBreakNum) * PrintFlg) Response.Write("" & vbCrLf) Response.Write("" & vbCrLf) Response.Write("" & vbCrLf) Response.Write("" & vbCrLf) Response.Write("" & vbCrLf) Response.Write("" & vbCrLf) Response.Write("" & vbCrLf) Response.Write("") Next End if %>
" & DSP_Zandaka(ii)(1) & "" & DSP_Zandaka(ii)(3) & "" & ConvIntToMoney(DSP_Zandaka(ii)(5), false, false) & "" & DSP_Zandaka(ii)(2) & "" & DSP_Zandaka(ii)(4) & "" & ConvIntToMoney(DSP_Zandaka(ii)(6), false, false) & "
<% If PrintFlg <> 1 Then %>
<% End If %>
<% GB_CSVOutput = GB_CSVOutput & "" GB_CSVOutput = GB_CSVOutput & "," If KashikataGokei - KarikataGokei > 0 Then GB_CSVOutput = GB_CSVOutput & "当期利益" End If GB_CSVOutput = GB_CSVOutput & "," If KashikataGokei - KarikataGokei > 0 Then GB_CSVOutput = GB_CSVOutput & (KashikataGokei - KarikataGokei) End If GB_CSVOutput = GB_CSVOutput & "," GB_CSVOutput = GB_CSVOutput & "," If KashikataGokei - KarikataGokei < 0 Then GB_CSVOutput = GB_CSVOutput & "当期損失" End If GB_CSVOutput = GB_CSVOutput & "," If KashikataGokei - KarikataGokei < 0 Then GB_CSVOutput = GB_CSVOutput & (KarikataGokei - KashikataGokei) End If GB_CSVOutput = GB_CSVOutput & "kaigyooygiakaigyooygiakaigyooygiakaigyooygiak" %> <% If AutoFlg = - 1 Then %> <% Else %> <% GB_CSVOutput = GB_CSVOutput & "" GB_CSVOutput = GB_CSVOutput & ",費用合計" GB_CSVOutput = GB_CSVOutput & "," If KashikataGokei - KarikataGokei > 0 Then GB_CSVOutput = GB_CSVOutput & KashikataGokei Else GB_CSVOutput = GB_CSVOutput & KarikataGokei End If GB_CSVOutput = GB_CSVOutput & "," GB_CSVOutput = GB_CSVOutput & ",収益合計" GB_CSVOutput = GB_CSVOutput & "," If KashikataGokei - KarikataGokei > 0 Then GB_CSVOutput = GB_CSVOutput & KashikataGokei Else GB_CSVOutput = GB_CSVOutput & KarikataGokei End If GB_CSVOutput = GB_CSVOutput & "kaigyooygiakaigyooygiakaigyooygiakaigyooygiak" %> <% End If %>
  <% If KashikataGokei - KarikataGokei > 0 Then Response.Write("当期利益") End If %> <% If KashikataGokei - KarikataGokei > 0 Then Response.Write(ConvIntToMoney(KashikataGokei - KarikataGokei, false, false)) End If %>   <% If KashikataGokei - KarikataGokei < 0 Then Response.Write("当期損失") End If %> <% If KashikataGokei - KarikataGokei < 0 Then Response.Write(ConvIntToMoney(KarikataGokei - KashikataGokei, false, false)) End If %>
  費用合計   収益合計
  費用合計 <% If KashikataGokei - KarikataGokei > 0 Then Response.Write(ConvIntToMoney(KashikataGokei, false, false)) Else Response.Write(ConvIntToMoney(KarikataGokei, false, false)) End If %>   収益合計 <% If KashikataGokei - KarikataGokei > 0 Then Response.Write(ConvIntToMoney(KashikataGokei, false, false)) Else Response.Write(ConvIntToMoney(KarikataGokei, false, false)) End If %>
<% If PrintFlg = 1 Then Response.Write(PrintFooter()) End If %>
<% ' If (Content.BOF Or Content.EOF) Then ' If ii + 1 > Ubound(DSP_Zandaka) Then ' If ii + 1 > ShowCount Then If ii + 1 > DisplayRow Then Exit For End If Next If PrintFlg = 0 Then %>
<% End if End Function Function ReplaceKanjyo(F_KanjyoCD, F_KarikataKingaku, F_KashikataKingaku) If IsNull(F_KarikataKingaku) Then F_KarikataKingaku = 0 End If If IsNull(F_KashikataKingaku) Then F_KashikataKingaku = 0 End If Dim InsertNo, KurikosiFLG Dim ii, jj Dim Query, Content InsertNo = -1 KurikosiFLG = 0 If F_KarikataKingaku <> 0 OR F_KashikataKingaku <> 0 Then For jj = 1 To MaxCount If WK_Zandaka(jj)(1) = "" Then Exit For End If If WK_Zandaka(jj)(1) > F_KanjyoCD Then If KurikosiFLG = 0 Then For ii = MaxCount - 1 To jj Step -1 WK_Zandaka(ii + 1)(1) = WK_Zandaka(ii)(1) WK_Zandaka(ii + 1)(2) = WK_Zandaka(ii)(2) WK_Zandaka(ii + 1)(3) = WK_Zandaka(ii)(3) WK_Zandaka(ii + 1)(4) = WK_Zandaka(ii)(4) WK_Zandaka(ii + 1)(5) = WK_Zandaka(ii)(5) WK_Zandaka(ii + 1)(6) = WK_Zandaka(ii)(6) Next InsertNo = jj KurikosiFLG = 1 ShowCount = ShowCount + 1 Exit For End If ElseIf WK_Zandaka(jj)(1) = F_KanjyoCD Then 'すでに残高に「期末商品棚卸高」がある場合 KurikosiFLG = 1 InsertNo = jj End If Next If KurikosiFLG = 0 Then InsertNo = jj ShowCount = ShowCount + 1 End If End If If InsertNo <> -1 Then Query = "exec SPM勘定科目取得 '" & GB_SystemCD & "','" & EnshuCD & "', '" & F_KanjyoCD & "'" Set Content = OpenQuery(Query) If Not(Content.BOF Or Content.EOF) Then WK_Zandaka(InsertNo)(6) = Content.Fields("貸借区分") WK_Zandaka(InsertNo)(2) = Content.Fields("勘定名称") WK_Zandaka(InsertNo)(7) = Content.Fields("諸表集計CD") End If WK_Zandaka(InsertNo)(1) = F_KanjyoCD If WK_Zandaka(InsertNo)(5) = "C" Then WK_Zandaka(InsertNo)(3) = 0 WK_Zandaka(InsertNo)(4) = F_KashikataKingaku - F_KarikataKingaku Else WK_Zandaka(InsertNo)(3) = F_KarikataKingaku - F_KashikataKingaku WK_Zandaka(InsertNo)(4) = 0 End If End If End Function %>