• R/O
  • SSH
  • HTTPS

aoiro: Commit


Commit MetaInfo

Revision120 (tree)
Time2023-03-04 11:37:28
Authorhirukawa_ryo

Log Message

aoiro 1.1.2
次年度の元入金に繰り越す勘定科目の金額がすべて0円の場合は、先頭の勘定科目1つを次年度の元入金として繰り越すようにしました。これによって、現金 0 / 元入金 0 が次年度にも繰り越されるようになりました。従来は次年度は 元入金 0 / 元入金 0 となっていました。

Change Summary

Incremental Difference

--- aoiro/trunk/src/main/java/net/osdn/aoiro/report/BalanceSheet.java (revision 119)
+++ aoiro/trunk/src/main/java/net/osdn/aoiro/report/BalanceSheet.java (revision 120)
@@ -810,6 +810,7 @@
810810 Collections.sort(list, (o1, o2) -> {
811811 return accountTitles.indexOf(o1.getKey()) - accountTitles.indexOf(o2.getKey());
812812 });
813+ Entry<AccountTitle, Amount> reserved = null;
813814 for(Entry<AccountTitle, Amount> e : list) {
814815 AccountTitle accountTitle = e.getKey();
815816 Amount amount = e.getValue();
@@ -823,6 +824,9 @@
823824 }
824825 if(accountTitle.getType() == AccountType.Assets) {
825826 if(amount.getValue() == 0) {
827+ if(reserved == null) {
828+ reserved = e;
829+ }
826830 continue;
827831 } else if(amount.getValue() > 0) {
828832 debtors.add(e);
@@ -833,6 +837,9 @@
833837 }
834838 } else if(accountTitle.getType() == AccountType.Liabilities || accountTitle.getType() == AccountType.Equity) {
835839 if(amount.getValue() == 0) {
840+ if(reserved == null) {
841+ reserved = e;
842+ }
836843 continue;
837844 } else if(amount.getValue() > 0) {
838845 creditors.add(e);
@@ -844,7 +851,19 @@
844851 }
845852 }
846853 AccountTitle capital = AccountTitle.getByDisplayName(new HashSet<>(accountTitles), "元入金");
847- if(capital != null) {
854+ // 期末残高 0 の勘定科目は翌期の元入金に繰り越しませんが、
855+ // 繰り越す勘定科目が 1つもない場合は先頭の勘定科目を翌期の元入金として繰り越します。
856+ if(creditors.size() == 0 && debtors.size() == 0 && reserved != null && capital != null) {
857+ Map.Entry<AccountTitle, Amount> e = Map.entry(capital, new Amount(Creditor.class, 0));
858+ if(reserved.getKey().getType().getNormalBalance() == Debtor.class) {
859+ debtors.add(reserved);
860+ creditors.add(e);
861+ } else {
862+ debtors.add(e);
863+ creditors.add(reserved);
864+ }
865+ } else if(capital != null) {
866+ // 借方・貸方の勘定差異を元入金勘定で埋めます。
848867 Map.Entry<AccountTitle, Amount> e = Map.entry(capital, new Amount(Creditor.class, (debtorsTotal - creditorsTotal)));
849868 if(debtorsTotal >= creditorsTotal) {
850869 creditors.add(e);
Show on old repository browser