Revisão | 5 (tree) |
---|---|
Hora | 2018-01-21 21:29:11 |
Autor | hirukawa_ryo |
* aoiro 0.1.2
総勘定元帳の摘要欄に勘定科目だけではなく仕訳摘要も印字するようにしました。
@@ -25,104 +25,110 @@ | ||
25 | 25 | |
26 | 26 | public class Main { |
27 | 27 | |
28 | - public static void main(String[] args) throws Exception { | |
29 | - | |
30 | - Logger.getLogger("org.apache").setLevel(Level.SEVERE); | |
31 | - | |
32 | - if(args.length == 0) { | |
33 | - System.out.println("Usage: aoiro.exe <仕訳データファイル>"); | |
34 | - pause(); | |
35 | - return; | |
36 | - } | |
37 | - | |
38 | - String filename = args[0]; | |
39 | - File journalEntryFile = new File(filename); | |
40 | - if(!journalEntryFile.exists() || journalEntryFile.isDirectory()) { | |
41 | - System.err.println("ファイルが見つかりません: " + journalEntryFile.getAbsolutePath()); | |
42 | - pause(); | |
43 | - return; | |
44 | - } | |
45 | - | |
46 | - boolean isSoloProprietorship = isSoloProprietorship(journalEntryFile); | |
47 | - File defaultDir = new File(Util.getApplicationDirectory(), "default"); | |
48 | - if(isSoloProprietorship) { | |
49 | - System.out.println("次のデータファイルを使用して、個人決算処理を実行します。"); | |
50 | - defaultDir = new File(defaultDir, "個人"); | |
51 | - } else { | |
52 | - System.out.println("次のデータファイルを使用して、法人決算処理を実行します。"); | |
53 | - defaultDir = new File(defaultDir, "法人"); | |
54 | - } | |
55 | - File inputDir = journalEntryFile.getParentFile(); | |
56 | - | |
57 | - File accountTitlesFile = getAccountTitleFile(inputDir, defaultDir); | |
58 | - if(accountTitlesFile == null) { | |
59 | - System.err.println("ファイルが見つかりません: 勘定科目.yml"); | |
60 | - pause(); | |
61 | - return; | |
62 | - } | |
63 | - | |
64 | - File proportionalDivisionsFile = getProportionalDivisionsFile(inputDir, defaultDir); | |
65 | - if(proportionalDivisionsFile == null) { | |
66 | - System.err.println("ファイルが見つかりません: 家事按分.yml"); | |
67 | - pause(); | |
68 | - return; | |
69 | - } | |
70 | - | |
71 | - System.out.println(" (1) 勘定科目 | " + accountTitlesFile.getAbsolutePath()); | |
72 | - YamlAccountTitlesLoader accountTitlesLoader = new YamlAccountTitlesLoader(accountTitlesFile); | |
73 | - List<AccountTitle> accountTitles = accountTitlesLoader.getAccountTitles(); | |
74 | - | |
75 | - System.out.println(" (2) 家事按分 | " + proportionalDivisionsFile.getAbsolutePath()); | |
76 | - YamlProportionalDivisionsLoader proportionalDivisionsLoader = new YamlProportionalDivisionsLoader(proportionalDivisionsFile, accountTitles); | |
77 | - List<ProportionalDivision> proportionalDivisions = proportionalDivisionsLoader.getProportionalDivisions(); | |
78 | - | |
79 | - YamlJournalsLoader journalsLoader = new YamlJournalsLoader(journalEntryFile, accountTitles); | |
80 | - List<JournalEntry> journalEntries = journalsLoader.getJournalEntries(); | |
81 | - System.out.println(" (3) 仕訳 | " + journalEntryFile.getAbsolutePath() + " (" + journalEntries.size() + "件)"); | |
28 | + public static void main(String[] args) { | |
29 | + try { | |
30 | + Logger.getLogger("org.apache").setLevel(Level.SEVERE); | |
31 | + | |
32 | + if(args.length == 0) { | |
33 | + System.out.println("Usage: aoiro.exe <仕訳データファイル>"); | |
34 | + pause(); | |
35 | + return; | |
36 | + } | |
37 | + | |
38 | + String filename = args[0]; | |
39 | + File journalEntryFile = new File(filename); | |
40 | + if(!journalEntryFile.exists() || journalEntryFile.isDirectory()) { | |
41 | + System.err.println("ファイルが見つかりません: " + journalEntryFile.getAbsolutePath()); | |
42 | + pause(); | |
43 | + return; | |
44 | + } | |
45 | + | |
46 | + boolean isSoloProprietorship = isSoloProprietorship(journalEntryFile); | |
47 | + File defaultDir = new File(Util.getApplicationDirectory(), "default"); | |
48 | + if(isSoloProprietorship) { | |
49 | + System.out.println("次のデータファイルを使用して、個人決算処理を実行します。"); | |
50 | + defaultDir = new File(defaultDir, "個人"); | |
51 | + } else { | |
52 | + System.out.println("次のデータファイルを使用して、法人決算処理を実行します。"); | |
53 | + defaultDir = new File(defaultDir, "法人"); | |
54 | + } | |
55 | + File inputDir = journalEntryFile.getParentFile(); | |
56 | + | |
57 | + File accountTitlesFile = getAccountTitleFile(inputDir, defaultDir); | |
58 | + if(accountTitlesFile == null) { | |
59 | + System.err.println("ファイルが見つかりません: 勘定科目.yml"); | |
60 | + pause(); | |
61 | + return; | |
62 | + } | |
63 | + | |
64 | + File proportionalDivisionsFile = getProportionalDivisionsFile(inputDir, defaultDir); | |
65 | + if(proportionalDivisionsFile == null) { | |
66 | + System.err.println("ファイルが見つかりません: 家事按分.yml"); | |
67 | + pause(); | |
68 | + return; | |
69 | + } | |
70 | + | |
71 | + System.out.println(" (1) 勘定科目 | " + accountTitlesFile.getAbsolutePath()); | |
72 | + YamlAccountTitlesLoader accountTitlesLoader = new YamlAccountTitlesLoader(accountTitlesFile); | |
73 | + List<AccountTitle> accountTitles = accountTitlesLoader.getAccountTitles(); | |
74 | + | |
75 | + System.out.println(" (2) 家事按分 | " + proportionalDivisionsFile.getAbsolutePath()); | |
76 | + YamlProportionalDivisionsLoader proportionalDivisionsLoader = new YamlProportionalDivisionsLoader(proportionalDivisionsFile, accountTitles); | |
77 | + List<ProportionalDivision> proportionalDivisions = proportionalDivisionsLoader.getProportionalDivisions(); | |
78 | + | |
79 | + YamlJournalsLoader journalsLoader = new YamlJournalsLoader(journalEntryFile, accountTitles); | |
80 | + List<JournalEntry> journalEntries = journalsLoader.getJournalEntries(); | |
81 | + System.out.println(" (3) 仕訳 | " + journalEntryFile.getAbsolutePath() + " (" + journalEntries.size() + "件)"); | |
82 | 82 | |
83 | - System.out.println(""); | |
84 | - | |
85 | - //決算 | |
86 | - System.out.println("決算処理を実行しています . . ."); | |
87 | - AccountSettlement accountSettlement = new AccountSettlement(accountTitles); | |
88 | - accountSettlement.setPrintStream(System.out); | |
89 | - accountSettlement.addClosingEntries(journalEntries, proportionalDivisions); | |
90 | - | |
91 | - System.out.println(""); | |
92 | - System.out.println("帳簿を作成しています . . ."); | |
93 | - | |
94 | - GeneralJournal generalJournal = new GeneralJournal(journalEntries); | |
95 | - GeneralLedger generalLedger = new GeneralLedger(accountTitles, journalEntries); | |
83 | + System.out.println(""); | |
84 | + | |
85 | + //決算 | |
86 | + System.out.println("決算処理を実行しています . . ."); | |
87 | + AccountSettlement accountSettlement = new AccountSettlement(accountTitles); | |
88 | + accountSettlement.setPrintStream(System.out); | |
89 | + accountSettlement.addClosingEntries(journalEntries, proportionalDivisions); | |
90 | + | |
91 | + System.out.println(""); | |
92 | + System.out.println("帳簿を作成しています . . ."); | |
93 | + | |
94 | + GeneralJournal generalJournal = new GeneralJournal(journalEntries); | |
95 | + GeneralLedger generalLedger = new GeneralLedger(accountTitles, journalEntries); | |
96 | 96 | |
97 | - generalJournal.writeTo(new File("仕訳帳.pdf")); | |
98 | - System.out.println(" 仕訳帳.pdf を出力しました。"); | |
99 | - | |
100 | - generalLedger.writeTo(new File("総勘定元帳.pdf")); | |
101 | - System.out.println(" 総勘定元帳.pdf を出力しました。"); | |
102 | - | |
103 | - //損益計算書 | |
104 | - Node<List<AccountTitle>, Amount> plRoot = accountTitlesLoader.getProfitAndLossRoot(); | |
105 | - ProfitAndLoss pl = new ProfitAndLoss(plRoot, journalEntries); | |
106 | - pl.writeTo(new File("損益計算書.pdf")); | |
107 | - System.out.println(" 損益計算書.pdf を出力しました。"); | |
108 | - | |
109 | - //貸借対照表 | |
110 | - Node<List<AccountTitle>, Amount[]> bsRoot = accountTitlesLoader.getBalanceSheetRoot(); | |
111 | - BalanceSheet bs = new BalanceSheet(bsRoot, journalEntries); | |
112 | - bs.writeTo(new File("貸借対照表.pdf")); | |
113 | - System.out.println(" 貸借対照表.pdf を出力しました。"); | |
97 | + generalJournal.writeTo(new File("仕訳帳.pdf")); | |
98 | + System.out.println(" 仕訳帳.pdf を出力しました。"); | |
99 | + | |
100 | + generalLedger.writeTo(new File("総勘定元帳.pdf")); | |
101 | + System.out.println(" 総勘定元帳.pdf を出力しました。"); | |
102 | + | |
103 | + //損益計算書 | |
104 | + Node<List<AccountTitle>, Amount> plRoot = accountTitlesLoader.getProfitAndLossRoot(); | |
105 | + ProfitAndLoss pl = new ProfitAndLoss(plRoot, journalEntries); | |
106 | + pl.writeTo(new File("損益計算書.pdf")); | |
107 | + System.out.println(" 損益計算書.pdf を出力しました。"); | |
108 | + | |
109 | + //貸借対照表 | |
110 | + Node<List<AccountTitle>, Amount[]> bsRoot = accountTitlesLoader.getBalanceSheetRoot(); | |
111 | + BalanceSheet bs = new BalanceSheet(bsRoot, journalEntries); | |
112 | + bs.writeTo(new File("貸借対照表.pdf")); | |
113 | + System.out.println(" 貸借対照表.pdf を出力しました。"); | |
114 | 114 | |
115 | - //繰越処理 | |
116 | - System.out.println(""); | |
117 | - System.out.println("繰越処理を実行しています . . ."); | |
118 | - | |
119 | - //開始仕訳 | |
120 | - bs.createOpeningJournalEntries(new File("翌年度の開始仕訳.yml")); | |
121 | - System.out.println(" 翌年度の開始仕訳.yml を出力しました。"); | |
115 | + //繰越処理 | |
116 | + System.out.println(""); | |
117 | + System.out.println("繰越処理を実行しています . . ."); | |
118 | + | |
119 | + //開始仕訳 | |
120 | + bs.createOpeningJournalEntries(new File("次年度の開始仕訳.yml")); | |
121 | + System.out.println(" 次年度の開始仕訳.yml を出力しました。"); | |
122 | 122 | |
123 | - //終了 | |
124 | - System.out.println(""); | |
125 | - System.out.println("すべての処理が終了しました。"); | |
123 | + //終了 | |
124 | + System.out.println(""); | |
125 | + System.out.println("すべての処理が終了しました。"); | |
126 | + pause(); | |
127 | + | |
128 | + } catch(Exception e) { | |
129 | + e.printStackTrace(); | |
130 | + pause(); | |
131 | + } | |
126 | 132 | } |
127 | 133 | |
128 | 134 | private static File getAccountTitleFile(File inputDir, File defaultDir) { |
@@ -230,9 +236,12 @@ | ||
230 | 236 | return false; |
231 | 237 | } |
232 | 238 | |
233 | - private static void pause() throws IOException { | |
234 | - System.out.println("続行するには何かキーを押してください . . ."); | |
235 | - System.in.read(); | |
239 | + private static void pause() { | |
240 | + System.out.println("続行するにはEnterキーを押してください . . ."); | |
241 | + try { | |
242 | + System.in.read(); | |
243 | + } catch(IOException e) { | |
244 | + e.printStackTrace(); | |
245 | + } | |
236 | 246 | } |
237 | - | |
238 | 247 | } |
@@ -236,6 +236,13 @@ | ||
236 | 236 | printData.add("\t\t\\font serif 9"); |
237 | 237 | printData.add("\t\t\\align center left"); |
238 | 238 | printData.add("\t\t\\text " + counterpartAccount.getAccountTitle().getDisplayName()); |
239 | + //摘要欄に勘定科目だけではなく仕訳摘要も印字します。ただし、締切仕訳や仕訳摘要と勘定科目が同じ場合は印字しません。 | |
240 | + if(!entry.isClosing() | |
241 | + && !entry.getDescription().equals(account.getAccountTitle().getDisplayName()) | |
242 | + && !entry.getDescription().equals(counterpartAccount.getAccountTitle().getDisplayName())) { | |
243 | + printData.add("\t\t\\font serif 6"); | |
244 | + printData.add("\t\t\\text / " + entry.getDescription()); | |
245 | + } | |
239 | 246 | |
240 | 247 | //仕丁 |
241 | 248 | if(account.getJournalPageNumber() >= 1) { |