invoice

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2022 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteInvoice added in v1.0.0

func DeleteInvoice(id primitive.ObjectID) error

Delete invoice from DB

func DeleteTransport added in v1.0.0

func DeleteTransport(id primitive.ObjectID) error

Delete transport vehicle from DB

func DeleteTransporter added in v1.0.0

func DeleteTransporter(id primitive.ObjectID) error

Delete transporter from DB

func ModifyInvoice added in v1.0.0

func ModifyInvoice(id primitive.ObjectID, ni Invoice) error

modify invoice in DB

func ModifyTransport added in v1.0.0

func ModifyTransport(id primitive.ObjectID, nt Transport) error

modify transport in DB

func ModifyTransporter added in v1.0.0

func ModifyTransporter(id primitive.ObjectID, nt Transporter) error

modify transporter in DB

func SaveInvoice added in v1.0.0

func SaveInvoice(i Invoice) (primitive.ObjectID, error)

add invoice to db

func SaveTransport added in v1.0.0

func SaveTransport(t *Transport) (primitive.ObjectID, error)

add transport vehicle to db

func SaveTransporter added in v1.0.0

func SaveTransporter(t Transporter) (primitive.ObjectID, error)

add transporter to db

Types

type Invoice

type Invoice struct {
	Id            primitive.ObjectID `bson:"_id,omitempty" json:"Id"` // not the same as invoice number
	InvoiceNumber int                `bson:"InvoiceNumber" json:"InvoiceNumber"`
	CreatedAt     time.Time          `bson:"CreatedAt" json:"CreatedAt"`
	LastUpdated   time.Time          `bson:"LastUpdated,omitempty" json:"LastUpdated"`
	Recipient     client.Client      `bson:"Recipient" json:"Recipient"`
	Paid          bool               `bson:"Paid" json:"Paid"`
	TransactionId string             `bson:"TransactionId" json:"TransactionId"`
	Transport     Transport          `bson:"Transport" json:"Transport"`
	// user can apply a discount on the whole invoice
	// TODO: float64 isn't the best for this
	DiscountPercentage float64 `bson:"DiscountPercentage" json:"DiscountPercentage"`
	/* client may have multiple shipping
	 * addresses but invoice only has one.
	 * Empty ShippingAddress means shipping
	 * address same as billing address
	 */
	BillingAddress  client.Address     `bson:"BillingAddress" json:"BillingAddress"`
	ShippingAddress client.Address     `bson:"ShippingAddress,omitempty" json:"ShippingAddress"`
	Items           []item.InvoiceItem `bson:"Items" json:"Items"`
	// user can attach notes to the invoice
	// frontend decides if recipient sees this or not
	Note string `bson:"Note" json:"Note"`

	/* Invoices can be drafts
	 * I personally like this functionality
	 * because we can constantly save the
	 * invoice to the DB as a draft
	 * and if OpenBills crashes or is disconnected
	 * we still have the progress
	 */
	Draft bool `bson:"Draft" json:"Draft"`
}
The *legendary* Invoice struct
* Each Recipient, Item in invoice, Address
* every detail that can change in the future is
* saved in the database so even if values change
* the invoice will have the old details
*
* The _id of the items/recipients will also be stored
* so user can look at the new values of those fields
* if needed. This system is better because if
* item is deleted from the Db it won't mess
* up the invoice collection
*
* Things like IGST, CGST, Discount, Quantity, etc
* should be calculated on runtime.
*
* usually an invoice would store the currency
* for payment. OpenBills does NOT support
* international billing. The Db will hold the config
* for the default currency, etc.

TODO: add place of supply

func GetInvoices added in v0.0.2

func GetInvoices(filter bson.M) ([]Invoice, error)

GetInvoices queries the database and * returns invoices based on the given filter * if filter is nil every invoice is returned

type Transport

type Transport struct {
	Id              primitive.ObjectID `bson:"_id,omitempty" json:"Id"`
	Transporter     Transporter        `bson:"Transporter,omitempty" json:"Transporter"`
	VehicleNum      string             `bson:"VehicleNum" json:"VehicleNum"`
	Note            string             `bson:"Note" json:"Note"`
	TransportMethod string             `bson:"TransportMethod" json:"TransportMethod"`
}

transport vehicle details

func GetTransports added in v0.0.2

func GetTransports(filter bson.M) ([]Transport, error)

type Transporter

type Transporter struct {
	Id    primitive.ObjectID `bson:"_id,omitempty" json:"Id"`
	Name  string             `bson:"Name" json:"Name"`
	GSTIN string             `bson:"GSTIN" json:"GSTIN"`
	// Issued ID for the transporter if any
	TransporterId string `bson:"TransporterId,omitempty" json:"TransporterId"`
}

Transporter details can be stored in * the DB. That is decided by the frontend. * You can optionally store Transporter * and Transport details which are often used

func GetTransporters added in v0.0.2

func GetTransporters(filter bson.M) ([]Transporter, error)

Jump to

Keyboard shortcuts

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