mig

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

格式版本

編號 敘述 版本 是否實作 備註
A0101 B2B 開立發票 3.2.1, 4.0
A0102 B2B 發票接收確認 3.2.1, 4.0
A0201 B2B 作廢發票 3.2.1, 4.0
A0202 B2B 作廢發票接收確認 3.2.1, 4.0
A0301 B2B 開立折讓 3.2.1, 4.0
A0302 B2B 折讓接收確認 3.2.1, 4.0
A0401 B2B 開立發票(存證) 3.2.1 4.0 刪除, 改用 F0401
A0501 B2B 作廢發票(存證) 3.2.1 4.0 刪除, 改用 F0501
A0601 B2B 退回發票(存證) 3.2.1 4.0 刪除
B0101 B2B 開立折讓單 3.2.1, 4.0
B0102 B2B 折讓單接收確認 3.2.1, 4.0
B0201 B2B 作廢折讓單 3.2.1, 4.0
B0202 B2B 作廢折讓單接收確認 3.2.1, 4.0
B0401 B2B 折讓通知單存證 3.2.1 4.0 刪除, 改用 G0401
B0501 B2B 作廢折讓通知單存證 3.2.1 4.0 刪除, 改用 G0501
C0401 B2C 開立發票 3.2.1 4.0 刪除, 改用 F0401
C0501 B2C 作廢發票 3.2.1 4.0 刪除, 改用 F0501
C0701 B2C 註銷發票 3.2.1 4.0 刪除, 改用 C0701
D0401 平台存證開立折讓證明單/傳送折讓證明單通知 3.2.1 4.0 刪除, 改用 G0401
D0501 B2C 作廢折讓 3.2.1 4.0 刪除, 改用 G0501
E0401 分支機構配號檔 3.2.1, 4.0
E0402 空白未使用字軌檔 3.2.1, 4.0
E0501 營業人電子發票配號檔 3.2.1, 4.0
E0502 營業人進項發票檔 4.0 尚未 4.0 新增
E0503 營業人進項折讓檔 4.0 尚未 4.0 新增
E0504 中獎清冊檔 4.0 尚未 4.0 新增
F0401 平台存證開立發票訊息 4.0 尚未 4.0 新增
F0501 平台存證作廢發票訊息 4.0 尚未 4.0 新增
F0701 平台存證註銷發票訊息 4.0 尚未 4.0 新增
G0401 平台存證開立折讓證明單訊息 4.0 尚未 4.0 新增
G0501 平台存證作廢折讓證明單訊息 4.0 尚未 4.0 新增

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type A0101InvoiceAmount

type A0101InvoiceAmount struct {
	InvoiceAmount
}

func (*A0101InvoiceAmount) Validate

func (block *A0101InvoiceAmount) Validate() error

type A0101InvoiceDetail

type A0101InvoiceDetail struct {
	Text        string                `xml:",chardata"`
	ProductItem []*InvoiceProductItem `xml:"ProductItem"`
}

func (*A0101InvoiceDetail) FillSequenceNumber

func (block *A0101InvoiceDetail) FillSequenceNumber()

func (*A0101InvoiceDetail) Validate

func (block *A0101InvoiceDetail) Validate() error

type A0101InvoiceMain

type A0101InvoiceMain struct {
	InvoiceMain
}

A0101InvoiceMain represents the main information of an A0101 invoice.

func (*A0101InvoiceMain) Validate

func (block *A0101InvoiceMain) Validate() error

Validate checks the validity of the A0101InvoiceMain block.

type AllowanceProductItem

type AllowanceProductItem struct {
	ProductItem

	OriginalInvoiceDate     string `xml:"OriginalInvoiceDate"`
	OriginalInvoiceNumber   string `xml:"OriginalInvoiceNumber"`
	OriginalSequenceNumber  string `xml:"OriginalSequenceNumber,omitempty"`
	OriginalDescription     string `xml:"OriginalDescription"`
	AllowanceSequenceNumber string `xml:"AllowanceSequenceNumber"`

	TaxType TaxTypeEnum `xml:"TaxType"`
}

func (*AllowanceProductItem) Validate

func (item *AllowanceProductItem) Validate() error

type Buyer

type Buyer struct {
	RoleDescription
}

func NewBuyer

func NewBuyer() *Buyer

func (*Buyer) Validate

func (buyer *Buyer) Validate() error

type C0401Invoice

type C0401Invoice struct {
	XMLName xml.Name `xml:"Invoice"`
	Text    string   `xml:",chardata"`
	Xmlns   string   `xml:"xmlns,attr"`

	Main    *C0401InvoiceMain   `xml:"Main"`
	Details *C0401InvoiceDetail `xml:"Details"`
	Amount  *C0401InvoiceAmount `xml:"Amount"`
}

func NewC0401Invoice

func NewC0401Invoice(b []byte) (*C0401Invoice, error)

type C0401InvoiceAmount

type C0401InvoiceAmount struct {
	InvoiceAmount

	FreeTaxSalesAmount string `xml:"FreeTaxSalesAmount"`
	ZeroTaxSalesAmount string `xml:"ZeroTaxSalesAmount"`
}

Deprecated in Mig 4.0

type C0401InvoiceDetail

type C0401InvoiceDetail struct {
	Text        string                `xml:",chardata"`
	ProductItem []*InvoiceProductItem `xml:"ProductItem"`
}

Deprecated in Mig 4.0

type C0401InvoiceMain

type C0401InvoiceMain struct {
	InvoiceMain

	CarrierType       string `xml:"CarrierType,omitempty"`
	CarrierId1        string `xml:"CarrierId1,omitempty"`
	CarrierId2        string `xml:"CarrierId2,omitempty"`
	PrintMark         string `xml:"PrintMark"`
	NPOBAN            string `xml:"NPOBAN,omitempty"`
	RandomNumber      string `xml:"RandomNumber,omitempty"`
	BondedAreaConfirm string `xml:"BondedAreaConfirm,omitempty"`
}

C0401InvoiceMain represents the main information of a C0401 invoice.

func (*C0401InvoiceMain) Validate

func (block *C0401InvoiceMain) Validate() error

Validate checks the validity of the C0401InvoiceMain block.

type DonateMarkEnum

type DonateMarkEnum string

DonateMarkEnum 捐贈註記 (表 4-11)

const (
	// 非捐贈發票
	DonateMarkNo DonateMarkEnum = "0"
	// 捐贈發票
	DonateMarkYes DonateMarkEnum = "1"
)

func (DonateMarkEnum) Validate

func (t DonateMarkEnum) Validate() error

Validate 檢查捐贈註記是否符合規範

type F0401Invoice

type F0401Invoice struct {
	XMLName xml.Name `xml:"Invoice"`
	Text    string   `xml:",chardata"`
	Xmlns   string   `xml:"xmlns,attr"`

	Main    *F0401InvoiceMain   `xml:"Main"`
	Details *F0401InvoiceDetail `xml:"Details"`
	Amount  *F0401InvoiceAmount `xml:"Amount"`
}

func NewF0401Invoice

func NewF0401Invoice(seller *Seller, buyer *Buyer, details []*F0401ProductItem) (*F0401Invoice, error)

NewF0401Invoice 會回傳一個新的F0401發票,輸入參數有賣方資訊 (seller) 與買方資訊 (buyer)以及發票明細

Example
// 這是一個範例
// 這個範例是用來展示如何使用 NewF0401Invoice 來建立一個 F0401 發票物件
// 這個範例會建立一個空的 F0401 發票物件

// 首先,我們需要建立賣方資訊
seller := NewSeller()
seller.Identifier = "12345678"
seller.Name = "網路書店"
seller.Address = "台北市中正區和平西路一段 1 號"
seller.PersonInCharge = "王小明"
seller.EmailAddress = "wang@example.com"

// 接著,我們需要建立買方資訊
buyer := NewBuyer()
buyer.Identifier = "87654321"
buyer.Name = "網路購物者"
buyer.Address = "台北市信義區信義路五段 7 號"
buyer.PersonInCharge = "陳小美"
buyer.EmailAddress = "mei@example.com"

// 最後,我們需要建立發票明細
details := []*F0401ProductItem{}
item := NewF0401ProductItem("網紅小遙")
item.RelateNumber = "A1234567890"
item.Quantity = "1"
item.Unit = "個"
item.UnitPrice = "105"
item.Amount = "105"
details = append(details, item)

item = NewF0401ProductItem("30m USB 3.0 延長線")
item.RelateNumber = "A1234567891"
item.Quantity = "2"
item.Unit = "條"
item.UnitPrice = "210"
item.Amount = "420"
details = append(details, item)

// 現在,我們可以使用 NewF0401Invoice 來建立一個 F0401 發票物件
invoice, err := NewF0401Invoice(seller, buyer, details)
if err != nil {
	fmt.Println(err)
	return
}
invoice.Main.InvoiceNumber = "QQ18927486"
invoice.SetDateAndTime(time.Date(2024, 3, 2, 11, 39, 40, 0, time.Local))
invoice.Details.FillSequenceNumber()
invoice.FillAmount()

// 最後,我們可以檢查這個發票是否符合規範
if err := invoice.Validate(); err != nil {
	fmt.Println(err)
	return
}

// Output:
f, err := invoice.Bytes()
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(string(f))

// 這個範例會輸出一個符合 F0401 發票規範的 XML 字串
Output:

func (*F0401Invoice) Bytes

func (f *F0401Invoice) Bytes() ([]byte, error)

func (*F0401Invoice) FillAmount

func (invoice *F0401Invoice) FillAmount() error

FillAmount 會根據發票明細填入 SalesAmount, TaxAmount, TotalAmount SalesAmount 為明細的金額加總 當此發票為 B2B 發票時,TaxAmount 為 SalesAmount * TaxRate (四捨五入至整數) 當此發票為 B2C 發票時,TaxAmount 為 0 TotalAmount 為 SalesAmount + TaxAmount

func (*F0401Invoice) IsB2C

func (invoice *F0401Invoice) IsB2C() bool

IsB2C 會回傳發票是否為B2C發票,判斷根據 (表 4-7 BAN 資料元規格)

func (*F0401Invoice) SetDateAndTime

func (invoice *F0401Invoice) SetDateAndTime(t time.Time)

func (*F0401Invoice) Validate

func (invoice *F0401Invoice) Validate() error

type F0401InvoiceAmount

type F0401InvoiceAmount struct {
	InvoiceAmount

	FreeTaxSalesAmount string `xml:"FreeTaxSalesAmount"`
	ZeroTaxSalesAmount string `xml:"ZeroTaxSalesAmount"`
}

func (*F0401InvoiceAmount) Validate

func (block *F0401InvoiceAmount) Validate() error

type F0401InvoiceDetail

type F0401InvoiceDetail struct {
	Text        string              `xml:",chardata"`
	ProductItem []*F0401ProductItem `xml:"ProductItem"`
}

func (*F0401InvoiceDetail) FillSequenceNumber

func (block *F0401InvoiceDetail) FillSequenceNumber()

func (*F0401InvoiceDetail) Validate

func (block *F0401InvoiceDetail) Validate() error

type F0401InvoiceMain

type F0401InvoiceMain struct {
	InvoiceMain

	CarrierType       string `xml:"CarrierType,omitempty"`
	CarrierId1        string `xml:"CarrierId1,omitempty"`
	CarrierId2        string `xml:"CarrierId2,omitempty"`
	PrintMark         string `xml:"PrintMark"`
	NPOBAN            string `xml:"NPOBAN,omitempty"`
	RandomNumber      string `xml:"RandomNumber,omitempty"`
	BondedAreaConfirm string `xml:"BondedAreaConfirm,omitempty"`
}

F0401InvoiceMain represents the main information of an F0401 invoice.

func (*F0401InvoiceMain) Validate

func (block *F0401InvoiceMain) Validate() error

Validate checks the validity of the F0401InvoiceMain block.

type F0401ProductItem

type F0401ProductItem struct {
	InvoiceProductItem
}

func NewF0401ProductItem

func NewF0401ProductItem(description string) *F0401ProductItem

func (*F0401ProductItem) Validate

func (item *F0401ProductItem) Validate() error

type InvoiceAmount

type InvoiceAmount struct {
	Text                   string      `xml:",chardata"`
	SalesAmount            string      `xml:"SalesAmount"`
	TaxType                TaxTypeEnum `xml:"TaxType"`
	TaxRate                string      `xml:"TaxRate"`
	TaxAmount              string      `xml:"TaxAmount"`
	TotalAmount            string      `xml:"TotalAmount"`
	DiscountAmount         string      `xml:"DiscountAmount,omitempty"`
	OriginalCurrencyAmount string      `xml:"OriginalCurrencyAmount,omitempty"`
	ExchangeRate           string      `xml:"ExchangeRate,omitempty"`
	Currency               string      `xml:"Currency,omitempty"`
}

func (*InvoiceAmount) Validate

func (block *InvoiceAmount) Validate() error

type InvoiceMain

type InvoiceMain struct {
	InvoiceNumber string  `xml:"InvoiceNumber"`
	InvoiceDate   string  `xml:"InvoiceDate"`
	InvoiceTime   string  `xml:"InvoiceTime"`
	Seller        *Seller `xml:"Seller"`
	Buyer         *Buyer  `xml:"Buyer"`

	BuyerRemark           string `xml:"BuyerRemark,omitempty"`
	MainRemark            string `xml:"MainRemark,omitempty"`
	CustomerClearanceMark string `xml:"CustomerClearanceMark,omitempty"`
	Category              string `xml:"Category,omitempty"`
	RelateNumber          string `xml:"RelateNumber,omitempty"`

	InvoiceType InvoiceTypeEnum `xml:"InvoiceType"`
	GroupMark   string          `xml:"GroupMark,omitempty"`
	DonateMark  DonateMarkEnum  `xml:"DonateMark"`

	ZeroTaxRateReason string `xml:"ZeroTaxRateReason,omitempty"`
	Reserved1         string `xml:"Reserved1,omitempty"`
	Reserved2         string `xml:"Reserved2,omitempty"`
}

InvoiceMain represents the main information of an invoice.

func (*InvoiceMain) Validate

func (block *InvoiceMain) Validate() error

Validate checks the validity of the InvoiceMain block.

type InvoiceProductItem

type InvoiceProductItem struct {
	ProductItem

	Description string `xml:"Description"`

	TaxType TaxTypeEnum `xml:"TaxType"`

	SequenceNumber string `xml:"SequenceNumber"`
	Remark         string `xml:"Remark,omitempty"`
	RelateNumber   string `xml:"RelateNumber,omitempty"`
}

func (*InvoiceProductItem) Validate

func (item *InvoiceProductItem) Validate() error

type InvoiceTypeEnum

type InvoiceTypeEnum string

InvoiceTypeEnum 電子發票類別 (表 4-4)

const (
	// 一般稅額計算之電子發票
	InvoiceTypeGeneral InvoiceTypeEnum = "07"
	// 特種稅額計算之電子發票
	InvoiceTypeSpecial InvoiceTypeEnum = "08"
)

func (InvoiceTypeEnum) Validate

func (t InvoiceTypeEnum) Validate() error

Validate 檢查發票類別是否符合規範

type ProductItem

type ProductItem struct {
	Text      string `xml:",chardata"`
	Quantity  string `xml:"Quantity"`
	Unit      string `xml:"Unit,omitempty"`
	UnitPrice string `xml:"UnitPrice"`

	Amount string `xml:"Amount"`
}

func (*ProductItem) Validate

func (item *ProductItem) Validate() error

type RoleDescription

type RoleDescription struct {
	Identifier      string `xml:"Identifier"`
	Name            string `xml:"Name"`
	Address         string `xml:"Address,omitempty"`
	PersonInCharge  string `xml:"PersonInCharge,omitempty"`
	TelephoneNumber string `xml:"TelephoneNumber,omitempty"`
	FacsimileNumber string `xml:"FacsimileNumber,omitempty"`
	EmailAddress    string `xml:"EmailAddress,omitempty"`
	CustomerNumber  string `xml:"CustomerNumber,omitempty"`
	RoleRemark      string `xml:"RoleRemark,omitempty"`
}

func (*RoleDescription) Validate

func (item *RoleDescription) Validate() error

Validate 檢查賣方資料是否符合規範

type Seller

type Seller struct {
	RoleDescription
}

func NewSeller

func NewSeller() *Seller

func (*Seller) Validate

func (seller *Seller) Validate() error

type TaxTypeEnum

type TaxTypeEnum string
const (
	// 應稅
	TaxTypeTaxable TaxTypeEnum = "1"
	// 零稅率
	TaxTypeZeroRated TaxTypeEnum = "2"
	// 免稅
	TaxTypeFreeTax TaxTypeEnum = "3"
	// 應稅(特種稅率)
	TaxTypeTaxableSpecial TaxTypeEnum = "4"
	// 混合應稅與免稅或零稅率 (限訊息 F0401 使用)
	TaxTypeMixed TaxTypeEnum = "9"
)

func (TaxTypeEnum) Validate

func (t TaxTypeEnum) Validate() error

Jump to

Keyboard shortcuts

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