• R/O
  • SSH
  • HTTPS

aoiro: Commit


Commit MetaInfo

Revisão17 (tree)
Hora2018-08-19 21:34:07
Autorhirukawa_ryo

Mensagem de Log

* aoiro 0.3.0 法人決算に対応しました。社員資本等変動計算書への対応はまだできていません。

Mudança Sumário

Diff

--- aoiro/trunk/default/個人/勘定科目.yml (revision 16)
+++ aoiro/trunk/default/個人/勘定科目.yml (revision 17)
@@ -9,7 +9,7 @@
99 負債: [支払手形, 買掛金, 借入金, 未払金, 前受金, 預り金,
1010 貸倒引当金,
1111 事業主借]
12- 資本: [元入金]
12+ 純資産: [元入金]
1313 収益: [売上, 雑収入,
1414 期末商品棚卸高]
1515 費用: [仕入,
@@ -79,7 +79,6 @@
7979 預り金: [預り金]
8080 貸倒引当金: [貸倒引当金]
8181 事業主借: [事業主借]
82- 資本:
82+ 純資産:
8383 元入金: [元入金]
8484 控除前の所得金額: [控除前の所得金額]
85-
--- aoiro/trunk/default/法人/勘定科目.yml (revision 16)
+++ aoiro/trunk/default/法人/勘定科目.yml (revision 17)
@@ -4,13 +4,11 @@
44 受取手形, 売掛金, 有価証券,
55 前払金, 貸付金,
66 商品,
7- 建物, 建物附属設備, 機械装置, 車両運搬具, 工具器具備品, 土地,
8- 事業主貸]
7+ 建物, 建物附属設備, 機械装置, 車両運搬具, 工具器具備品, 土地]
98 負債: [支払手形, 買掛金, 借入金, 未払金, 前受金, 預り金,
109 貸倒引当金,
11- 事業主借,
1210 未払費用]
13- 資本: [資本金, 元入金]
11+ 純資産: [資本金, 繰越利益剰余金]
1412 収益: [売上, 雑収入,
1513 期末商品棚卸高,
1614 受取利息]
@@ -24,37 +22,22 @@
2422 役員報酬, 法定福利費]
2523
2624 損益計算書:
27- 青色申告特別控除前の所得金額:
28- 売上金額 (雑収入を含む): [売上, 雑収入]
25+ 売上総利益:
26+ 売上高: [売上, 雑収入]
2927 売上原価:
3028 期首商品棚卸高: [期首商品棚卸高]
3129 仕入金額: [仕入]
3230 期末商品棚卸高: [期末商品棚卸高]
33- 経費:
34- 役員報酬: [役員報酬]
35- 法定福利費: [法定福利費]
36- 租税公課: [租税公課]
37- 荷造運賃: [荷造運賃]
38- 水道光熱費: [水道光熱費]
39- 旅費交通費: [旅費交通費]
40- 通信費: [通信費]
41- 広告宣伝費: [広告宣伝費]
42- 接待交際費: [接待交際費]
43- 損害保険料: [損害保険料]
44- 修繕費: [修繕費]
45- 消耗品費: [消耗品費]
46- 減価償却費: [減価償却費]
47- 福利厚生費: [福利厚生費]
48- 給料賃金: [給料賃金]
49- 外注工賃: [外注工賃]
50- 給料賃金: [給料賃金]
51- 外注工賃: [外注工賃]
52- 利子割引料: [利子割引料]
53- 地代家賃: [地代家賃]
54- 貸倒金: [貸倒金]
55- 支払手数料: [支払手数料]
56- 会議費: [会議費]
57- 雑費: [雑費]
31+ 営業利益:
32+ 販売費及び一般管理費: [役員報酬, 法定福利費]
33+ 経常利益:
34+ 営業外収益: [受取利息]
35+ 営業外費用:
36+ 税引前当期純利益:
37+ 特別利益:
38+ 特別損失:
39+ 当期純利益:
40+ 法人税、住民税及び事業税等:
5841
5942 貸借対照表:
6043 資産:
@@ -74,7 +57,6 @@
7457 車両運搬具: [車両運搬具]
7558 工具器具備品: [工具器具備品]
7659 土地: [土地]
77- 事業主貸: [事業主貸]
7860 負債:
7961 未払費用: [未払費用]
8062 支払手形: [支払手形]
@@ -84,9 +66,7 @@
8466 前受金: [前受金]
8567 預り金: [預り金]
8668 貸倒引当金: [貸倒引当金]
87- 資本:
69+ 純資産:
8870 資本金: [資本金]
89- 事業主借: [事業主借]
90- 元入金: [元入金]
91- 控除前の所得金額: [控除前の所得金額]
71+ 繰越利益剰余金: [繰越利益剰余金]
9272
--- aoiro/trunk/src/main/java/net/osdn/aoiro/AccountSettlement.java (revision 16)
+++ aoiro/trunk/src/main/java/net/osdn/aoiro/AccountSettlement.java (revision 17)
@@ -58,64 +58,62 @@
5858 //家事按分
5959 if(proportionalDivisions != null) {
6060 AccountTitle ownersDrawing = AccountTitle.getByDisplayName(accountTitles, "事業主貸");
61- if(ownersDrawing == null) {
62- throw new IllegalArgumentException("勘定科目に事業主貸が定義されていないため家事按分ができませんでした。");
63- }
64-
65- List<Debtor> debtors = new ArrayList<Debtor>();
66- List<Creditor> creditors = new ArrayList<Creditor>();
67-
68- for(ProportionalDivision proportionalDivision : proportionalDivisions) {
69- int debtorTotal = 0;
70- int creditorTotal = 0;
71- for(int i = 0; i < journalEntries.size(); i++) {
72- JournalEntry entry = journalEntries.get(i);
73- for(Debtor debtor : entry.getDebtors()) {
74- if(debtor.getAccountTitle().equals(proportionalDivision.getAccountTitle())) {
75- debtorTotal += debtor.getAmount();
61+ if(ownersDrawing != null) {
62+ List<Debtor> debtors = new ArrayList<Debtor>();
63+ List<Creditor> creditors = new ArrayList<Creditor>();
64+
65+ for(ProportionalDivision proportionalDivision : proportionalDivisions) {
66+ int debtorTotal = 0;
67+ int creditorTotal = 0;
68+ for(int i = 0; i < journalEntries.size(); i++) {
69+ JournalEntry entry = journalEntries.get(i);
70+ for(Debtor debtor : entry.getDebtors()) {
71+ if(debtor.getAccountTitle().equals(proportionalDivision.getAccountTitle())) {
72+ debtorTotal += debtor.getAmount();
73+ }
7674 }
75+ for(Creditor creditor : entry.getCreditors()) {
76+ if(creditor.getAccountTitle().equals(proportionalDivision.getAccountTitle())) {
77+ creditorTotal += creditor.getAmount();
78+ }
79+ }
7780 }
78- for(Creditor creditor : entry.getCreditors()) {
79- if(creditor.getAccountTitle().equals(proportionalDivision.getAccountTitle())) {
80- creditorTotal += creditor.getAmount();
81+ if(debtorTotal > creditorTotal) {
82+ double total = (debtorTotal - creditorTotal) * (1.0 - proportionalDivision.getBusinessRatio());
83+ int intTotal = (int)Math.floor(total);
84+ if(intTotal != 0) {
85+ creditors.add(new Creditor(proportionalDivision.getAccountTitle(), intTotal));
8186 }
87+ } else if(creditorTotal > debtorTotal) {
88+ double total = (creditorTotal - debtorTotal) * (1.0 - proportionalDivision.getBusinessRatio());
89+ int intTotal = (int)Math.floor(total);
90+ if(intTotal != 0) {
91+ debtors.add(new Debtor(proportionalDivision.getAccountTitle(), intTotal));
92+ }
8293 }
8394 }
84- if(debtorTotal > creditorTotal) {
85- double total = (debtorTotal - creditorTotal) * (1.0 - proportionalDivision.getBusinessRatio());
86- int intTotal = (int)Math.floor(total);
87- if(intTotal != 0) {
88- creditors.add(new Creditor(proportionalDivision.getAccountTitle(), intTotal));
95+ if(debtors.size() > 0) {
96+ int creditorTotal = 0;
97+ for(Debtor debtor : debtors) {
98+ creditorTotal += debtor.getAmount();
8999 }
90- } else if(creditorTotal > debtorTotal) {
91- double total = (creditorTotal - debtorTotal) * (1.0 - proportionalDivision.getBusinessRatio());
92- int intTotal = (int)Math.floor(total);
93- if(intTotal != 0) {
94- debtors.add(new Debtor(proportionalDivision.getAccountTitle(), intTotal));
100+ Creditor creditor = new Creditor(ownersDrawing, creditorTotal);
101+ JournalEntry entry = new JournalEntry(date, "家事按分", debtors, Arrays.asList(creditor));
102+ journalEntries.add(entry);
103+ }
104+ if(creditors.size() > 0) {
105+ int debtorTotal = 0;
106+ for(Creditor creditor : creditors) {
107+ debtorTotal += creditor.getAmount();
95108 }
109+ Debtor debtor = new Debtor(ownersDrawing, debtorTotal);
110+ JournalEntry entry = new JournalEntry(date, "家事按分", Arrays.asList(debtor), creditors);
111+ journalEntries.add(entry);
96112 }
97- }
98- if(debtors.size() > 0) {
99- int creditorTotal = 0;
100- for(Debtor debtor : debtors) {
101- creditorTotal += debtor.getAmount();
113+ if(out != null && (debtors.size() > 0 || creditors.size() > 0)) {
114+ out.println(" 家事按分の振替が完了しました。");
102115 }
103- Creditor creditor = new Creditor(ownersDrawing, creditorTotal);
104- JournalEntry entry = new JournalEntry(date, "家事按分", debtors, Arrays.asList(creditor));
105- journalEntries.add(entry);
106116 }
107- if(creditors.size() > 0) {
108- int debtorTotal = 0;
109- for(Creditor creditor : creditors) {
110- debtorTotal += creditor.getAmount();
111- }
112- Debtor debtor = new Debtor(ownersDrawing, debtorTotal);
113- JournalEntry entry = new JournalEntry(date, "家事按分", Arrays.asList(debtor), creditors);
114- journalEntries.add(entry);
115- }
116- if(out != null && (debtors.size() > 0 || creditors.size() > 0)) {
117- out.println(" 家事按分の振替が完了しました。");
118- }
119117 }
120118
121119 //収益勘定科目
@@ -130,8 +128,8 @@
130128 //負債勘定科目
131129 Set<AccountTitle> liabilitiesAccountTitles = new LinkedHashSet<AccountTitle>();
132130
133- //資本勘定科目
134- Set<AccountTitle> equityAccountTitles = new LinkedHashSet<AccountTitle>();
131+ //純資産勘定科目
132+ Set<AccountTitle> netAssetsAccountTitles = new LinkedHashSet<AccountTitle>();
135133
136134 //使用されている収益勘定科目と費用勘定科目を抽出します。
137135 for(JournalEntry entry : journalEntries) {
@@ -167,8 +165,8 @@
167165
168166 //int incomeSummaryCreditorGrandTotal = 0;
169167 //int incomeSummaryDebtorGrandTotal = 0;
170- //利益剰余金
171- int retainedEarnings = 0;
168+ //損益
169+ int incomeSummary = 0;
172170
173171 //全ての収益勘定残高を損益勘定へ振替します。
174172 {
@@ -203,7 +201,7 @@
203201 creditors.add(creditor);
204202 creditorsTotal += (-total);
205203 }
206- retainedEarnings += total;
204+ incomeSummary += total;
207205 }
208206 //損益勘定仕訳
209207 if(debtors.size() > 0) {
@@ -258,7 +256,7 @@
258256 debtors.add(debtor);
259257 debtorsTotal += (-total);
260258 }
261- retainedEarnings -= total;
259+ incomeSummary -= total;
262260 }
263261 //損益勘定仕訳
264262 if(creditors.size() > 0) {
@@ -303,23 +301,31 @@
303301
304302 //損益勘定の差額を資本振替します。
305303 {
306- //FIXME: 個人事業主と法人で資本の勘定科目が違うよ。個人は所得、法人は利益剰余金かな?
307-
308- if(retainedEarnings == 0) {
304+ if(incomeSummary == 0) {
309305 //損益勘定の差額が 0 のときは振替仕訳を作成しません。
310- } else if(retainedEarnings > 0) {
306+ } else if(incomeSummary > 0) {
311307 //借方
312- Debtor debtor = new Debtor(AccountTitle.INCOME_SUMMARY, +retainedEarnings);
308+ Debtor debtor = new Debtor(AccountTitle.INCOME_SUMMARY, +incomeSummary);
313309 //貸方
314- Creditor creditor = new Creditor(AccountTitle.RETAINED_EARNINGS, +retainedEarnings);
310+ Creditor creditor;
311+ if(isSoloProprietorship) {
312+ creditor = new Creditor(AccountTitle.PRETAX_INCOME, +incomeSummary);
313+ } else {
314+ creditor = new Creditor(AccountTitle.RETAINED_EARNINGS, +incomeSummary);
315+ }
315316 //仕訳
316317 JournalEntry entry = new JournalEntry(date, "損益の資本振替", Arrays.asList(debtor), Arrays.asList(creditor));
317318 journalEntries.add(entry);
318- } else if(retainedEarnings < 0) {
319+ } else if(incomeSummary < 0) {
319320 //借方
320- Debtor debtor = new Debtor(AccountTitle.RETAINED_EARNINGS, -retainedEarnings);
321+ Debtor debtor;
322+ if(isSoloProprietorship) {
323+ debtor = new Debtor(AccountTitle.PRETAX_INCOME, -incomeSummary);
324+ } else {
325+ debtor = new Debtor(AccountTitle.RETAINED_EARNINGS, -incomeSummary);
326+ }
321327 //貸方
322- Creditor creditor = new Creditor(AccountTitle.INCOME_SUMMARY, -retainedEarnings);
328+ Creditor creditor = new Creditor(AccountTitle.INCOME_SUMMARY, -incomeSummary);
323329 //仕訳
324330 JournalEntry entry = new JournalEntry(date, "損益の資本振替", Arrays.asList(debtor), Arrays.asList(creditor));
325331 journalEntries.add(entry);
@@ -451,21 +457,21 @@
451457 }
452458 }
453459
454- //使用されている資本勘定科目を抽出します。
460+ //使用されている純資産勘定科目を抽出します。
455461 for(JournalEntry entry : journalEntries) {
456462 for(Creditor creditor : entry.getCreditors()) {
457- if(creditor.getAccountTitle().getType() == AccountType.Equity) {
458- equityAccountTitles.add(creditor.getAccountTitle());
463+ if(creditor.getAccountTitle().getType() == AccountType.NetAssets) {
464+ netAssetsAccountTitles.add(creditor.getAccountTitle());
459465 }
460466 }
461467 for(Debtor debtor : entry.getDebtors()) {
462- if(debtor.getAccountTitle().getType() == AccountType.Equity) {
463- equityAccountTitles.add(debtor.getAccountTitle());
468+ if(debtor.getAccountTitle().getType() == AccountType.NetAssets) {
469+ netAssetsAccountTitles.add(debtor.getAccountTitle());
464470 }
465471 }
466472 }
467473
468- //資本の残高振替
474+ //純資産の残高振替
469475 {
470476 List<Debtor> debtors = new ArrayList<Debtor>();
471477 int debtorsTotal = 0;
@@ -472,7 +478,7 @@
472478 List<Creditor> creditors = new ArrayList<Creditor>();
473479 int creditorsTotal = 0;
474480
475- for(AccountTitle accountTitle : equityAccountTitles) {
481+ for(AccountTitle accountTitle : netAssetsAccountTitles) {
476482 int total = 0;
477483 List<JournalEntry> entries = getJournalEntriesByAccount(journalEntries, accountTitle);
478484 for(JournalEntry entry : entries) {
@@ -506,7 +512,7 @@
506512 //貸方
507513 Creditor creditor = new Creditor(AccountTitle.BALANCE, debtorsTotal);
508514 //仕訳
509- JournalEntry incomeSummaryEntry = new JournalEntry(date, "資本の残高振替", debtors, Arrays.asList(creditor));
515+ JournalEntry incomeSummaryEntry = new JournalEntry(date, "純資産の残高振替", debtors, Arrays.asList(creditor));
510516 journalEntries.add(incomeSummaryEntry);
511517 }
512518 if(creditors.size() > 0) {
@@ -513,11 +519,11 @@
513519 //借方
514520 Debtor debtor = new Debtor(AccountTitle.BALANCE, creditorsTotal);
515521 //仕訳
516- JournalEntry incomeSummaryEntry = new JournalEntry(date, "資本の残高振替", Arrays.asList(debtor), creditors);
522+ JournalEntry incomeSummaryEntry = new JournalEntry(date, "純資産の残高振替", Arrays.asList(debtor), creditors);
517523 journalEntries.add(incomeSummaryEntry);
518524 }
519525 if(out != null) {
520- out.println(" 資本の残高振替が完了しました。");
526+ out.println(" 純資産の残高振替が完了しました。");
521527 }
522528 }
523529 }
--- aoiro/trunk/src/main/java/net/osdn/aoiro/loader/yaml/YamlAccountTitlesLoader.java (revision 16)
+++ aoiro/trunk/src/main/java/net/osdn/aoiro/loader/yaml/YamlAccountTitlesLoader.java (revision 17)
@@ -26,6 +26,7 @@
2626 settlementAccountTitleByDisplayName.put(AccountTitle.INCOME_SUMMARY.getDisplayName(), AccountTitle.INCOME_SUMMARY);
2727 settlementAccountTitleByDisplayName.put(AccountTitle.BALANCE.getDisplayName(), AccountTitle.BALANCE);
2828 settlementAccountTitleByDisplayName.put(AccountTitle.RETAINED_EARNINGS.getDisplayName(), AccountTitle.RETAINED_EARNINGS);
29+ settlementAccountTitleByDisplayName.put(AccountTitle.PRETAX_INCOME.getDisplayName(), AccountTitle.PRETAX_INCOME);
2930 }
3031
3132 /** 勘定科目リスト */
@@ -65,9 +66,9 @@
6566 accountTitleByDisplayName.put(displayName, accountTitle);
6667 }
6768 @SuppressWarnings("unchecked")
68- List<String> equity = (List<String>)map.get("資本");
69- for(String displayName : equity) {
70- AccountTitle accountTitle = new AccountTitle(AccountType.Equity, displayName);
69+ List<String> netAssets = (List<String>)map.get("純資産");
70+ for(String displayName : netAssets) {
71+ AccountTitle accountTitle = new AccountTitle(AccountType.NetAssets, displayName);
7172 accountTitles.add(accountTitle);
7273 accountTitleByDisplayName.put(displayName, accountTitle);
7374 }
@@ -94,11 +95,8 @@
9495 Node<List<AccountTitle>, Amount> plRoot = new Node<List<AccountTitle>, Amount>(-1, "損益計算書");
9596 retrieve(plRoot, map);
9697
97- if(plRoot.getChildren().size() == 1) {
98- this.plRoot = plRoot.getChildren().get(0);
99- } else {
100- throw new IllegalArgumentException("損益計算書の直下に複数の要素があります。");
101- }
98+ this.plRoot = plRoot;
99+
102100 //dump(0, plRoot);
103101 }
104102
--- aoiro/trunk/src/main/java/net/osdn/aoiro/model/AccountTitle.java (revision 16)
+++ aoiro/trunk/src/main/java/net/osdn/aoiro/model/AccountTitle.java (revision 17)
@@ -16,11 +16,12 @@
1616 /** 決算勘定「残高」です。資産と負債がこの損益勘定に振り替えられます。*/
1717 public static AccountTitle BALANCE = new AccountTitle(AccountType.Assets, "残高", true);
1818
19- /** 決算勘定「控除前の所得金額」です。*/
20- public static AccountTitle RETAINED_EARNINGS = new AccountTitle(AccountType.Equity, "控除前の所得金額", true);
21- //public static AccountTitle RETAINED_EARNINGS = new AccountTitle(AccountType.Equity, new ArrayList<String>(), "繰越利益剰余金");
22-
19+ /** 決算勘定「繰越利益剰余金」です。収益-費用で算出されます。法人で使用する勘定科目です。*/
20+ public static AccountTitle RETAINED_EARNINGS = new AccountTitle(AccountType.NetAssets, "繰越利益剰余金", true);
2321
22+ /** 決算勘定「控除前の所得金額」です。収益-費用で算出されます。個人事業主で使用する勘定科目です。*/
23+ public static AccountTitle PRETAX_INCOME = new AccountTitle(AccountType.NetAssets, "控除前の所得金額", true);
24+
2425 /** 種類 */
2526 private AccountType type;
2627
--- aoiro/trunk/src/main/java/net/osdn/aoiro/model/AccountType.java (revision 16)
+++ aoiro/trunk/src/main/java/net/osdn/aoiro/model/AccountType.java (revision 17)
@@ -11,8 +11,8 @@
1111 /** 負債 */
1212 Liabilities(Creditor.class),
1313
14- /** 資本 */
15- Equity(Creditor.class),
14+ /** 純資産 */
15+ NetAssets(Creditor.class),
1616
1717 /** 収益 */
1818 Revenue(Creditor.class),
@@ -28,7 +28,7 @@
2828
2929 /** この勘定の通常のバランスを返します。
3030 * Assets(資産)、Expense(費用)は借方(Debtor.class)を返し、借方で増加、貸方で減少する勘定です。
31- * Liabilities(負債)、Equity(資本)、収益(Revenue)は貸方(Creditor.class)を返し、借方で減少、貸方で増加する勘定です。
31+ * Liabilities(負債)、NetAssets(純資産)、収益(Revenue)は貸方(Creditor.class)を返し、借方で減少、貸方で増加する勘定です。
3232 *
3333 * @return 通常バランスが借方の場合、Debtor.class を返します。通常バランスが貸方の場合、Creditor.class を返します。
3434 */
--- aoiro/trunk/src/main/java/net/osdn/aoiro/model/Amount.java (revision 16)
+++ aoiro/trunk/src/main/java/net/osdn/aoiro/model/Amount.java (revision 17)
@@ -5,7 +5,7 @@
55 * 金額がマイナスに転じても借方、貸方が変わることはありません。
66 *
77 */
8-public class Amount {
8+public class Amount implements Cloneable {
99
1010 private Class<? extends Account> normalBalance;
1111 private int value;
@@ -85,6 +85,10 @@
8585 this.value -= amount;
8686 }
8787
88+ public Amount clone() {
89+ return new Amount(normalBalance, value);
90+ }
91+
8892 @Override
8993 public String toString() {
9094 StringBuilder sb = new StringBuilder();
--- aoiro/trunk/src/main/java/net/osdn/aoiro/model/JournalEntry.java (revision 16)
+++ aoiro/trunk/src/main/java/net/osdn/aoiro/model/JournalEntry.java (revision 17)
@@ -105,7 +105,6 @@
105105 return false;
106106 }
107107 //個人事業主の場合は貸方に元入金を含む仕訳を開始仕訳として扱います。
108- //FIXME: 法人の場合の開始仕訳への対応を追加する必要があります。
109108 for(Debtor debtor : debtors) {
110109 String displayName = debtor.getAccountTitle().getDisplayName();
111110 if(displayName.equals("元入金")) {
@@ -118,6 +117,13 @@
118117 return true;
119118 }
120119 }
120+
121+ //摘要が「前期繰越」となっている場合は開始仕訳として扱います。
122+ //個人事業主、法人いずれの場合も開始仕訳として認識されます。
123+ if(description.equals("前期繰越")) {
124+ return true;
125+ }
126+
121127 return false;
122128 }
123129
--- aoiro/trunk/src/main/java/net/osdn/aoiro/model/Node.java (revision 16)
+++ aoiro/trunk/src/main/java/net/osdn/aoiro/model/Node.java (revision 17)
@@ -5,6 +5,7 @@
55
66 public class Node<K, V> {
77
8+ private boolean isSubTotal;
89 private int level;
910 private String name;
1011 private K key;
@@ -26,6 +27,14 @@
2627 this.value = value;
2728 }
2829
30+ public boolean isSubTotal() {
31+ return isSubTotal;
32+ }
33+
34+ public void setSubTotal(boolean b) {
35+ this.isSubTotal = b;
36+ }
37+
2938 public int getLevel() {
3039 return level;
3140 }
--- aoiro/trunk/src/main/java/net/osdn/aoiro/report/BalanceSheet.java (revision 16)
+++ aoiro/trunk/src/main/java/net/osdn/aoiro/report/BalanceSheet.java (revision 17)
@@ -42,6 +42,7 @@
4242
4343 private Node<List<AccountTitle>, Amount[]> bsRoot;
4444 private List<JournalEntry> journalEntries;
45+ private boolean isSoloProprietorship;
4546 private Date openingDate;
4647 private Date closingDate;
4748 private Map<AccountTitle, Amount> openingBalances = new HashMap<AccountTitle, Amount>();
@@ -56,6 +57,7 @@
5657 public BalanceSheet(Node<List<AccountTitle>, Amount[]> bsRoot, List<JournalEntry> journalEntries, boolean isSoloProprietorship) throws IOException {
5758 this.bsRoot = bsRoot;
5859 this.journalEntries = journalEntries;
60+ this.isSoloProprietorship = isSoloProprietorship;
5961
6062 this.openingDate = AccountSettlement.getOpeningDate(journalEntries, isSoloProprietorship);
6163 this.closingDate = AccountSettlement.getClosingDate(journalEntries, isSoloProprietorship);
@@ -156,7 +158,7 @@
156158 assetsList = getList(child);
157159 } else if(child.getName().equals("負債")) {
158160 liabilitiesList = getList(child);
159- } else if(child.getName().equals("資本")) {
161+ } else if(child.getName().equals("純資産")) {
160162 equityList = getList(child);
161163 }
162164 }
@@ -344,7 +346,7 @@
344346 }
345347 y += ROW_HEIGHT;
346348 }
347- //資本(純資産)
349+ //純資産(資本)
348350 y = (rows - equityList.size()) * ROW_HEIGHT;
349351 printData.add("\t\\line " + String.format("87.7 %.2f -0 %.2f", y, y));
350352 for(int i = 1; i < equityList.size(); i++) {
@@ -390,7 +392,7 @@
390392 }
391393 }
392394 if(liabilitiesList.size() > 0 || equityList.size() > 0) {
393- //合計(負債、資本)
395+ //合計(負債、純資産)
394396 String displayName = "合計";
395397 int openingAmount = 0;
396398 int closingAmount = 0;
@@ -458,39 +460,6 @@
458460 List<Entry<AccountTitle, Amount>> creditors = new ArrayList<Entry<AccountTitle, Amount>>();
459461 int creditorsTotal = 0;
460462
461- for(Entry<AccountTitle, Amount> e : closingBalances.entrySet()) {
462- AccountTitle accountTitle = e.getKey();
463- Amount amount = e.getValue();
464- if(accountTitle.getDisplayName().equals("事業主貸") || accountTitle.getDisplayName().equals("事業主借")) {
465- continue;
466- }
467- if(accountTitle.getType() == AccountType.Assets) {
468- if(amount.getValue() == 0) {
469- continue;
470- } else if(amount.getValue() > 0) {
471- debtors.add(e);
472- debtorsTotal += amount.getValue();
473- } else {
474- creditors.add(e);
475- creditorsTotal -= amount.getValue();
476- }
477- } else if(accountTitle.getType() == AccountType.Liabilities) {
478- if(amount.getValue() == 0) {
479- continue;
480- } else if(amount.getValue() > 0) {
481- creditors.add(e);
482- creditorsTotal += amount.getValue();
483- } else {
484- debtors.add(e);
485- debtorsTotal -= amount.getValue();
486- }
487- }
488- }
489-
490- if(debtors.size() == 0 && creditors.size() == 0) {
491- return "";
492- }
493-
494463 StringBuilder sb = new StringBuilder();
495464 DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
496465 Calendar calendar = Calendar.getInstance();
@@ -497,37 +466,119 @@
497466 calendar.setTime(this.closingDate);
498467 calendar.add(Calendar.DATE, 1);
499468
500- if(debtors.size() > 0) {
501- sb.append("- 日付: " + df.format(calendar.getTime()) + "\r\n");
502- sb.append(" 摘要: 元入金\r\n");
503- sb.append(" 借方: [ ");
504- for(int i = 0; i < debtors.size(); i++) {
505- AccountTitle accountTitle = debtors.get(i).getKey();
506- Amount amount = debtors.get(i).getValue();
507- sb.append("{勘定科目: " + accountTitle.getDisplayName() + ", 金額: " + amount.getValue() + "}");
508- if(i + 1 < debtors.size()) {
509- sb.append(", ");
469+ if(isSoloProprietorship) {
470+ //個人事業主の場合は、事業主貸(資産)、事業主借(負債)、所得金額(純資産)が次期の元入金に加算されます。
471+ //事業主貸、事業主借を除く資産と負債を集計して次期開始仕訳を作成します。
472+ //相手勘定科目はすべて元入金になります。
473+ for(Entry<AccountTitle, Amount> e : closingBalances.entrySet()) {
474+ AccountTitle accountTitle = e.getKey();
475+ Amount amount = e.getValue();
476+ if(accountTitle.getDisplayName().equals("事業主貸") || accountTitle.getDisplayName().equals("事業主借")) {
477+ continue;
510478 }
479+ if(accountTitle.getType() == AccountType.Assets) {
480+ if(amount.getValue() == 0) {
481+ continue;
482+ } else if(amount.getValue() > 0) {
483+ debtors.add(e);
484+ debtorsTotal += amount.getValue();
485+ } else {
486+ creditors.add(e);
487+ creditorsTotal -= amount.getValue();
488+ }
489+ } else if(accountTitle.getType() == AccountType.Liabilities) {
490+ if(amount.getValue() == 0) {
491+ continue;
492+ } else if(amount.getValue() > 0) {
493+ creditors.add(e);
494+ creditorsTotal += amount.getValue();
495+ } else {
496+ debtors.add(e);
497+ debtorsTotal -= amount.getValue();
498+ }
499+ }
511500 }
512- sb.append(" ]\r\n");
513- sb.append(" 貸方: [ {勘定科目: 元入金, 金額: " + debtorsTotal + "} ]\r\n");
514- sb.append("\r\n");
515- }
516- if(creditors.size() > 0) {
517- sb.append("- 日付: " + df.format(calendar.getTime()) + "\r\n");
518- sb.append(" 摘要: 元入金\r\n");
519- sb.append(" 借方: [ {勘定科目: 元入金, 金額: " + creditorsTotal + "} ]\r\n");
520- sb.append(" 貸方: [ ");
521- for(int i = 0; i < creditors.size(); i++) {
522- AccountTitle accountTitle = creditors.get(i).getKey();
523- Amount amount = creditors.get(i).getValue();
524- sb.append("{勘定科目: " + accountTitle.getDisplayName() + ", 金額: " + amount.getValue() + "}");
525- if(i + 1 < creditors.size()) {
526- sb.append(", ");
501+ if(debtors.size() > 0) {
502+ sb.append("- 日付: " + df.format(calendar.getTime()) + "\r\n");
503+ sb.append(" 摘要: 元入金\r\n");
504+ sb.append(" 借方: [ ");
505+ for(int i = 0; i < debtors.size(); i++) {
506+ AccountTitle accountTitle = debtors.get(i).getKey();
507+ Amount amount = debtors.get(i).getValue();
508+ sb.append("{勘定科目: " + accountTitle.getDisplayName() + ", 金額: " + Math.abs(amount.getValue()) + "}");
509+ if(i + 1 < debtors.size()) {
510+ sb.append(", ");
511+ }
527512 }
513+ sb.append(" ]\r\n");
514+ sb.append(" 貸方: [ {勘定科目: 元入金, 金額: " + debtorsTotal + "} ]\r\n");
515+ sb.append("\r\n");
528516 }
529- sb.append(" ]\r\n");
530- sb.append("\r\n");
517+ if(creditors.size() > 0) {
518+ sb.append("- 日付: " + df.format(calendar.getTime()) + "\r\n");
519+ sb.append(" 摘要: 元入金\r\n");
520+ sb.append(" 借方: [ {勘定科目: 元入金, 金額: " + creditorsTotal + "} ]\r\n");
521+ sb.append(" 貸方: [ ");
522+ for(int i = 0; i < creditors.size(); i++) {
523+ AccountTitle accountTitle = creditors.get(i).getKey();
524+ Amount amount = creditors.get(i).getValue();
525+ sb.append("{勘定科目: " + accountTitle.getDisplayName() + ", 金額: " + Math.abs(amount.getValue()) + "}");
526+ if(i + 1 < creditors.size()) {
527+ sb.append(", ");
528+ }
529+ }
530+ sb.append(" ]\r\n");
531+ sb.append("\r\n");
532+ }
533+ } else {
534+ //法人の場合は資産、負債、純資産をすべて繰り越します。
535+ for(Entry<AccountTitle, Amount> e : closingBalances.entrySet()) {
536+ AccountTitle accountTitle = e.getKey();
537+ Amount amount = e.getValue();
538+ if(accountTitle.getType() == AccountType.Assets) {
539+ if(amount.getValue() == 0) {
540+ continue;
541+ } else if(amount.getValue() > 0) {
542+ debtors.add(e);
543+ } else {
544+ creditors.add(e);
545+ }
546+ } else if(accountTitle.getType() == AccountType.Liabilities || accountTitle.getType() == AccountType.NetAssets) {
547+ if(amount.getValue() == 0) {
548+ continue;
549+ } else if(amount.getValue() > 0) {
550+ creditors.add(e);
551+ } else {
552+ debtors.add(e);
553+ }
554+ }
555+ }
556+
557+ if(debtors.size() > 0 && creditors.size() > 0) {
558+ sb.append("- 日付: " + df.format(calendar.getTime()) + "\r\n");
559+ sb.append(" 摘要: 前期繰越\r\n");
560+ sb.append(" 借方: [ ");
561+ for(int i = 0; i < debtors.size(); i++) {
562+ AccountTitle accountTitle = debtors.get(i).getKey();
563+ Amount amount = debtors.get(i).getValue();
564+ sb.append("{勘定科目: " + accountTitle.getDisplayName() + ", 金額: " + Math.abs(amount.getValue()) + "}");
565+ if(i + 1 < debtors.size()) {
566+ sb.append(", ");
567+ }
568+ }
569+ sb.append(" ]\r\n");
570+ sb.append(" 貸方: [ ");
571+ for(int i = 0; i < creditors.size(); i++) {
572+ AccountTitle accountTitle = creditors.get(i).getKey();
573+ Amount amount = creditors.get(i).getValue();
574+ sb.append("{勘定科目: " + accountTitle.getDisplayName() + ", 金額: " + Math.abs(amount.getValue()) + "}");
575+ if(i + 1 < creditors.size()) {
576+ sb.append(", ");
577+ }
578+ }
579+ sb.append(" ]\r\n");
580+ sb.append("\r\n");
581+ }
531582 }
532583
533584 //期末商品棚卸高 を 期首商品棚卸高として開始仕訳に追加します。
--- aoiro/trunk/src/main/java/net/osdn/aoiro/report/GeneralLedger.java (revision 16)
+++ aoiro/trunk/src/main/java/net/osdn/aoiro/report/GeneralLedger.java (revision 17)
@@ -41,6 +41,7 @@
4141 this.accountTitles = new ArrayList<AccountTitle>(accountTitles);
4242 this.accountTitles.add(AccountTitle.INCOME_SUMMARY);
4343 this.accountTitles.add(AccountTitle.RETAINED_EARNINGS);
44+ this.accountTitles.add(AccountTitle.PRETAX_INCOME);
4445 this.accountTitles.add(AccountTitle.BALANCE);
4546
4647 this.entries = journalEntries;
@@ -198,7 +199,7 @@
198199 printData.add("\t\t\\font serif 10");
199200 printData.add("\t\t\\align center right");
200201 printData.add("\t\t\\text 前頁繰越");
201- //仮または貸
202+ //借または貸
202203 printData.add("\t\t\\box " + String.format("135 %.2f 8 %.2f", currentRow * ROW_HEIGHT, ROW_HEIGHT));
203204 printData.add("\t\t\\font serif 10");
204205 printData.add("\t\t\\align center");
@@ -235,13 +236,18 @@
235236 printData.add("\t\t\\box " + String.format("17.5 %.2f 49.5 %.2f", currentRow * ROW_HEIGHT, ROW_HEIGHT));
236237 printData.add("\t\t\\font serif 9");
237238 printData.add("\t\t\\align center left");
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());
239+ if(entry.isOpening() && entry.getDescription().equals("前期繰越")) {
240+ //開始仕訳の摘要が「前期繰越」となっている場合は相手勘定科目ではなく摘要を印字します。
241+ printData.add("\t\t\\text " + entry.getDescription());
242+ } else {
243+ printData.add("\t\t\\text " + counterpartAccount.getAccountTitle().getDisplayName());
244+ //摘要欄に勘定科目だけではなく仕訳摘要も印字します。ただし、締切仕訳や仕訳摘要と勘定科目が同じ場合は印字しません。
245+ if(!entry.isClosing()
246+ && !entry.getDescription().equals(account.getAccountTitle().getDisplayName())
247+ && !entry.getDescription().equals(counterpartAccount.getAccountTitle().getDisplayName())) {
248+ printData.add("\t\t\\font serif 6");
249+ printData.add("\t\t\\text / " + entry.getDescription());
250+ }
245251 }
246252
247253 //仕丁
@@ -258,7 +264,7 @@
258264 printData.add("\t\t\\font serif 10");
259265 printData.add("\t\t\\align center right");
260266 printData.add("\t\t\\text " + String.format("%,d", counterpartAccount.getAmount()));
261- //資産、費用の場合は増加、負債、資本、収益の場合は減少
267+ //資産、費用の場合は増加、負債、純資産、収益の場合は減少
262268 if(account.getAccountTitle().getType().getNormalBalance() == Debtor.class) {
263269 accountTitleTotal += counterpartAccount.getAmount();
264270 } else {
@@ -273,7 +279,7 @@
273279 printData.add("\t\t\\font serif 10");
274280 printData.add("\t\t\\align center right");
275281 printData.add("\t\t\\text " + String.format("%,d", counterpartAccount.getAmount()));
276- //負債、資本、収益の場合は増加、資産、費用の場合は減少
282+ //負債、純資産、収益の場合は増加、資産、費用の場合は減少
277283 if(account.getAccountTitle().getType().getNormalBalance() == Creditor.class) {
278284 accountTitleTotal += counterpartAccount.getAmount();
279285 } else {
@@ -282,7 +288,7 @@
282288 creditorTotal += counterpartAccount.getAmount();
283289 }
284290
285- //仮または貸
291+ //借または貸
286292 AccountType type = account.getAccountTitle().getType();
287293 if(type.getNormalBalance() == Debtor.class) {
288294 sign = (accountTitleTotal >= 0) ? "借" : "貸";
@@ -383,7 +389,21 @@
383389 public List<Account> getCounterpartAccounts(JournalEntry entry, Account account) {
384390 List<Account> counterpartAccounts = new ArrayList<Account>(); //相手勘定科目
385391
386- if(account.getAccountTitle().isClosing()) {
392+ if(account.getAccountTitle().getDisplayName().equals("元入金")) {
393+ if(account instanceof Debtor) {
394+ if(entry.getCreditors().size() == 1) {
395+ counterpartAccounts.add(new Creditor(entry.getCreditors().get(0).getAccountTitle(), account.getAmount()));
396+ } else {
397+ counterpartAccounts.addAll(entry.getCreditors());
398+ }
399+ } else if(account instanceof Creditor) {
400+ if(entry.getDebtors().size() == 1) {
401+ counterpartAccounts.add(new Debtor(entry.getDebtors().get(0).getAccountTitle(), account.getAmount()));
402+ } else {
403+ counterpartAccounts.addAll(entry.getDebtors());
404+ }
405+ }
406+ } else if(account.getAccountTitle().isClosing()) {
387407 //決算勘定の場合は相手勘定科目を諸口としてまとめずにすべて出力します。
388408 if(account instanceof Debtor) {
389409 if(entry.getCreditors().size() == 1) {
--- aoiro/trunk/src/main/java/net/osdn/aoiro/report/ProfitAndLoss.java (revision 16)
+++ aoiro/trunk/src/main/java/net/osdn/aoiro/report/ProfitAndLoss.java (revision 17)
@@ -91,7 +91,8 @@
9191 retrieve(plRoot, journalEntries);
9292
9393 //リスト作成
94- list = getList(plRoot);
94+ list = createList(plRoot);
95+ //list = getList(plRoot);
9596
9697 //月別集計
9798 monthlyTotals = getMonthlyTotals(journalEntries);
@@ -133,11 +134,27 @@
133134 return amount;
134135 }
135136
136- protected List<Node<List<AccountTitle>, Amount>> getList(Node<List<AccountTitle>, Amount> node) {
137+ protected List<Node<List<AccountTitle>, Amount>> createList(Node<List<AccountTitle>, Amount> plRoot) {
137138 List<Node<List<AccountTitle>, Amount>> list = new ArrayList<Node<List<AccountTitle>, Amount>>();
139+
140+ Amount cumulativeAmount = new Amount(Creditor.class, 0);
141+ for(Node<List<AccountTitle>, Amount> topLevelNode : plRoot.getChildren()) {
142+ cumulativeAmount.increase(topLevelNode.getValue());
143+ topLevelNode.setValue(cumulativeAmount.clone());
144+ topLevelNode.setSubTotal(true);
145+ for(Node<List<AccountTitle>, Amount> childNode : topLevelNode.getChildren()) {
146+ list.addAll(getSubList(childNode));
147+ }
148+ list.add(topLevelNode);
149+ }
150+ return list;
151+ }
152+
153+ protected List<Node<List<AccountTitle>, Amount>> getSubList(Node<List<AccountTitle>, Amount> node) {
154+ List<Node<List<AccountTitle>, Amount>> list = new ArrayList<Node<List<AccountTitle>, Amount>>();
138155 list.add(node);
139156 for(Node<List<AccountTitle>, Amount> child : node.getChildren()) {
140- list.addAll(getList(child));
157+ list.addAll(getSubList(child));
141158 }
142159 return list;
143160 }
@@ -257,7 +274,7 @@
257274 printData.add("\t\\line-style thin dot");
258275
259276 double y = 0.0;
260- for(int i = 1; i < list.size(); i++) {
277+ for(int i = 0; i < list.size(); i++) {
261278 Node<List<AccountTitle>, Amount> node = list.get(i);
262279
263280 Amount amount = node.getValue();
@@ -268,11 +285,16 @@
268285 }
269286 */
270287
271- if(i >= 2) {
288+ if(i >= 1) {
289+ if(node.isSubTotal()) {
290+ printData.add("\t\\line-style thin solid");
291+ } else {
292+ printData.add("\t\\line-style thin dot");
293+ }
272294 printData.add("\t\\line " + String.format("0 %.2f 95 %.2f", y, y));
273295 }
274296
275- if(node.getLevel() == 1) {
297+ if(node.getLevel() == 0 || (plRoot.getChildren().size() == 1 && node.getLevel() == 1)) {
276298 printData.add("\t\t\\font serif 10 bold");
277299 } else {
278300 printData.add("\t\t\\font serif 10");
@@ -295,17 +317,18 @@
295317 }
296318 printData.add("\t\\line-style thin solid");
297319 if(y > 0) {
320+ printData.add("\t\\line " + String.format("0 %.2f 95 %.2f", y - ROW_HEIGHT, y - ROW_HEIGHT));
298321 printData.add("\t\\line " + String.format("0 %.2f 95 %.2f", y, y));
299- printData.add("\t\\line " + String.format("0 %.2f 95 %.2f", y + ROW_HEIGHT, y + ROW_HEIGHT));
300- printData.add("\t\\line " + String.format("0 %.2f 95 %.2f", y + ROW_HEIGHT + 0.4, y + ROW_HEIGHT + 0.4));
322+ printData.add("\t\\line " + String.format("0 %.2f 95 %.2f", y + 0.4, y + 0.4));
301323 }
302324 printData.add("\t\\box 0 0 -0 -0");
303- printData.add("\t\\line " + String.format("63 31.2 63 %.2f", 37 + y + ROW_HEIGHT));
325+ printData.add("\t\\line " + String.format("63 31.2 63 %.2f", 37 + y));
304326 printData.add("\t\\line-style thin dot");
305- printData.add("\t\\line " + String.format(" 0 30.8 0 %.2f", 37 + y + ROW_HEIGHT + 0.4));
306- printData.add("\t\\line " + String.format("95 30.8 95 %.2f", 37 + y + ROW_HEIGHT + 0.4));
327+ printData.add("\t\\line " + String.format(" 0 30.8 0 %.2f", 37 + y + 0.4));
328+ printData.add("\t\\line " + String.format("95 30.8 95 %.2f", 37 + y + 0.4));
307329 printData.add("\t\\box 0 37 -0 -0");
308330
331+ /*
309332 //合計 (青色申告特別控除前の所得金額)
310333 {
311334 String displayName = list.get(0).getName();
@@ -323,6 +346,7 @@
323346 printData.add("\t\t\\align center right");
324347 printData.add("\t\t\\text " + formatMoney(amountValue));
325348 }
349+ */
326350
327351 //月別
328352 Amount salesTotal = null;
Show on old repository browser