bookkeeping

package module
v0.1.1-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2022 License: MIT Imports: 11 Imported by: 0

README

bookkeeping

bookkeeping

System Design

なるべく、設定がなくても目的の出力(B/S, P/L)が得られることを目指す。 総勘定元帳に仕訳を溜め込み、会計の期間で抽出したものをB/S, P/Lの出力ルール通りに計算すれば出力が得られるようにする。

Accounts(勘定科目)

次のコード体系をもたせ、prefixでどのような勘定科目かを見分けることが出来るようにしておく。 B/S, P/Lの出力時にコードでソートすれば良いようにするため。

  • B/S科目
    • 1: 資産
      • 11: 流動資産
        • 111: 現預金
        • 112: 営業債権
        • 113: 棚卸資産
      • 12: 固定資産 
        • 121: 有形固定資産
        • 122: 無形固定資産
    • 2: 負債
      • 21: 流動負債
      • 22: 固定負債
    • 3: 純資産
      • 31: 資本金
      • 32: 資本剰余金
      • 33: 利益剰余金
  • P/L科目
    • 4: 売上高
      • 41: 商品売上高
      • 42: 製品売上高
    • 5: 売上原価
      • 51: 期首棚卸高
      • 52: 仕入高及び製造原価
      • 53: 期末棚卸高
    • 6: 製造原価
      • 61: 材料費
      • 62: 人件費
      • 63: 経費
    • 7: 販売費及び一般管理費
      • 71: 販売費
      • 72: 人件費
      • 73: 経費
    • 8: 営業外損益・特別損益
      • 81: 営業外収益
      • 82: 営業外費用
      • 83: 特別利益
      • 84: 特別損失
    • 9: 法人税等

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CommitHash string
)

Functions

func SumJournal

func SumJournal(jnn ...[]Journal) int

Types

type Account

type Account struct {
	Code   int
	Name   string
	IsBS   bool
	IsLeft bool
}

type BS

type BS struct {
	Date time.Time

	TotalCurrentAssets    int
	TotalNoncurrentAssets int
	TotalAssets           int

	TotalCurrentLiabilities    int
	TotalNoncurrentLiabilities int
	TotalLiabilities           int

	OwnersCapital             int
	RetainedErnings           int
	TotalEquity               int
	TotalLiabilitiesAndEquity int
}

type Bookkeeping

type Bookkeeping struct {
	// contains filtered or unexported fields
}

func NewBookkeeping

func NewBookkeeping(db *DB) *Bookkeeping

func (*Bookkeeping) FetchAc

func (bk *Bookkeeping) FetchAc(opt FetchAcOpts) ([]Account, error)

func (*Bookkeeping) FetchBS

func (bk *Bookkeeping) FetchBS(opt FetchBSOpts) (BS, error)

func (*Bookkeeping) FetchGL

func (bk *Bookkeeping) FetchGL(opts ...FetchGLOpts) (map[int][]Journal, error)

func (*Bookkeeping) FetchPL

func (bk *Bookkeeping) FetchPL(opt FetchPLOpts) (PL, error)

func (*Bookkeeping) Post

func (bk *Bookkeeping) Post(jn []Journal) error

type DB

type DB struct {
	// contains filtered or unexported fields
}

func NewDB

func NewDB(path string) (*DB, error)

func (*DB) Close

func (d *DB) Close() error

func (*DB) Delete

func (d *DB) Delete() error

func (*DB) InitAccounts

func (d *DB) InitAccounts() error

func (*DB) InitSchema

func (d *DB) InitSchema() error

type DBAccounts

type DBAccounts struct {
	// contains filtered or unexported fields
}

func NewDBAccounts

func NewDBAccounts(db *DB) *DBAccounts

func (*DBAccounts) Fetch

func (a *DBAccounts) Fetch(opt DBAccountsFetchOption) ([]Account, error)

func (*DBAccounts) Insert

func (a *DBAccounts) Insert(items ...Account) error

type DBAccountsFetchOption

type DBAccountsFetchOption struct {
	CodePattern        string
	DescriptionPattern string
}

type DBJournals

type DBJournals struct {
	// contains filtered or unexported fields
}

func NewDBJournals

func NewDBJournals(db *DB) *DBJournals

func (*DBJournals) Fetch

func (jn *DBJournals) Fetch(opt DBJournalsFetchOption) ([]Journal, error)

func (*DBJournals) Insert

func (jn *DBJournals) Insert(items ...Journal) error

type DBJournalsFetchOption

type DBJournalsFetchOption struct {
	After  sql.NullTime
	Before sql.NullTime
	Code   []int

	// this may conflict with Code
	CodeRangeFrom int
	// this may conflict with Code
	CodeRangeTo int
}

func (DBJournalsFetchOption) CodeRange

func (opt DBJournalsFetchOption) CodeRange(from, to int) DBJournalsFetchOption

type FetchAcOpts

type FetchAcOpts struct {
	CodeFilter string
	DescFilter string
}

type FetchBSOpts

type FetchBSOpts struct {
	Date time.Time
}

type FetchGLOpts

type FetchGLOpts struct {
	AccountIDList []int
}

type FetchPLOpts

type FetchPLOpts struct {
	Start time.Time
	End   time.Time
}

type Journal

type Journal struct {
	ID          int
	Date        sql.NullTime
	Code        int
	Description string
	Left        int
	Right       int

	Account Account
}

type PL

type PL struct {
	NetSales                            int
	CostSales                           int
	GrossProfit                         int
	OperatingExpences                   int
	OperatingIncome                     int
	NonOperatingIncomes                 int
	NonOperatingExpences                int
	ExtraordinaryIncomes                int
	ExtraordinaryExpences               int
	IncomeBeforeProvisionForIncomeTaxes int
	ProvisionForIncomeTaxes             int
	NetIncome                           int
}

Directories

Path Synopsis
cmd
bk

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL