bimpf

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Provides functionality to validate and import Bimpf json dumps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Customer

type Customer struct {
	Id           int       `json:"id"`
	SbId         string    `json:"sb_id"`
	Name         string    `json:"name"`
	Comment      string    `json:"comment"`
	NcFolderName string    `json:"nc_folder_name"`
	Recipient1   string    `json:"recipient_1"`
	Recipient2   string    `json:"recipient_2"`
	Recipient3   string    `json:"recipient_3"`
	Recipient4   string    `json:"recipient_4"`
	Email        string    `json:"email"`
	Projects     []Project `json:"projects"`
}

Customer reassembles the structure of a Customer TimeUnit in a Bimpf json dump file.

func (Customer) Conditions

func (c Customer) Conditions() util.Conditions

Conditions returns the validation conditions.

func (Customer) Convert

func (c Customer) Convert() schema.Party

Convert returns the customers as a acc Party.

func (Customer) String

func (c Customer) String() string

String returns a human readable representation of the element.

func (Customer) Type

func (c Customer) Type() string

Type returns a string with the type name of the element.

func (Customer) Validate

func (c Customer) Validate() util.ValidateResults

Validate the element and return the result.

type Customers

type Customers []Customer

Customers represents a slice of Customer slices

func (Customers) ConvertExpenses

func (c Customers) ConvertExpenses(folderPrefix string, parties schema.Parties, bimpfEmployees Employees) schema.Expenses

ConvertExpenses cycles trough the Customers and returns all expenses found as a acc Expenses. As the expenses in Bimpf only contain a relative path to receipts the nextcloud prefix has to be provided.

func (Customers) ConvertInvoices

func (c Customers) ConvertInvoices(folderPrefix string, parties schema.Parties) schema.Invoices

ConvertInvoices cycles trough the Customers and returns all invoices found as a acc Invoice. As the expenses in Bimpf only contain a relative path to receipts the nextcloud prefix has to be provided.

type Document

type Document struct {
	Id           int    `json:"id"`
	SbId         string `json:"sb_id"`
	Name         string `json:"name"`
	Description  string `json:"description"`
	Path         string `json:"path"`
	CustomerId   int    `json:"customer_id"`
	CustomerName string `json:"customer_name"`
	ProjectId    int    `json:"project_id"`
	ProjectName  string `json:"project_name"`
	SendDate     string `json:"send_date"`
	DaysOfGrace  int    `json:"days_of_grace"`
	IsStalled    bool   `json:"is_stalled"`
}

Document reassembles the structure of a Doc in a Bimpf json dump file.

func (Document) Conditions

func (d Document) Conditions() util.Conditions

Conditions returns the validation conditions.

func (Document) ConvertAsInvoice

func (d Document) ConvertAsInvoice(pathPrefix, customerId, projectName string, parties schema.Parties) schema.Invoice

ConvertAsInvoice converts the document to a Bimpf Invoice. Amount is set to -1 as Bimpf does not provide such information.

func (Document) String

func (d Document) String() string

String returns a human readable representation of the element.

func (Document) Type

func (d Document) Type() string

Type returns a string with the type name of the element.

func (Document) Validate

func (d Document) Validate() util.ValidateResults

Validate the element and return the result.

type Dump

type Dump struct {
	TimeUnits []TimeUnit `json:"time_units"`
	Customers Customers  `json:"customers"`
	Employees Employees  `json:"employees"`
	Expenses  []Expense  `json:"expenses"`
}

Dump reassembles the structure of a Bimpf json dump file.

func OpenDump

func OpenDump(path string) *Dump

func (Dump) Convert

func (d Dump) Convert(outputFolder, bimpfFolder string) schema.Schema

Convert returns the bimpf dump as an Acc struct. Needs a project path and a Nextcloud Bimpf folder path.

func (Dump) Validate

func (d Dump) Validate() util.ValidateResults

Validate the element and return the result.

func (Dump) ValidateAndReport

func (d Dump) ValidateAndReport(path string)

ValidateAndReportProject validates the bimpf dump and saves the report to the given path.

type Employee

type Employee struct {
	Id        int    `json:"id"`
	SbId      string `json:"sb_id"`
	FirstName string `json:"first_name"`
	Name      string `json:"name"`
	Username  string `json:"username"`
}

Employee reassembles the structure of a Employee in a Bimpf json dump file.

func (Employee) Conditions

func (e Employee) Conditions() util.Conditions

Conditions returns the validation conditions.

func (Employee) Convert

func (e Employee) Convert() schema.Party

Convert returns the employee as a acc Party.

func (Employee) String

func (e Employee) String() string

String returns a human readable representation of the Employee.

func (Employee) Type

func (e Employee) Type() string

Type returns a string with the type name of the element.

func (Employee) Validate

func (e Employee) Validate() util.ValidateResults

Validate the element and return the result.

type Employees

type Employees []Employee

func (Employees) ById

func (e Employees) ById(id int) (*Employee, error)

type Expense

type Expense struct {
	Id                 int     `json:"id"`
	SbId               string  `json:"sb_id"`
	Name               string  `json:"name"`
	Comment            string  `json:"comment"`
	Path               string  `json:"path"`
	Amount             float64 `json:"amount"`
	DateOfAccrual      string  `json:"date_of_accrual"`
	AdvancedByEmployee bool    `json:"advance_by_employee"`
	PaidByCustomer     bool    `json:"paid_by_customer"`
	IsPaid             bool    `json:"is_paid"`
	Billable           bool    `json:"billable"`
	EmployeeId         int     `json:"advanced_employee"`
}

Expense reassembles the structure of a Expense in a Bimpf json dump file.

func (Expense) Conditions

func (e Expense) Conditions() util.Conditions

Conditions returns the validation conditions.

func (Expense) Convert

func (e Expense) Convert(pathPrefix, obligedCustomerId, project string, parties schema.Parties, bimpfEmployees Employees) schema.Expense

Convert returns the bimpf Expense as a acc Expense. As the path in the Bimpf Expense structure is not absolute (is relative to project folder in a nextcloud folder), a folder prefix is needed.

func (Expense) String

func (e Expense) String() string

String returns a human readable representation of the element.

func (Expense) Type

func (e Expense) Type() string

Type returns a string with the type name of the element.

func (Expense) Validate

func (e Expense) Validate() util.ValidateResults

Validate the element and return the result.

type Project

type Project struct {
	Id           int        `json:"id"`
	SbId         string     `json:"sb_id"`
	Name         string     `json:"name"`
	NcFolderName string     `json:"nc_folder_name"`
	CustomerId   int        `json:"customer"`
	CustomerName string     `json:"customer_name"`
	IsArchived   bool       `json:"is_archived"`
	Quotes       []Document `json:"quotes"`
	Invoices     []Document `json:"invoices"`
	Reminders    []Document `json:"reminders"`
	Expenses     []Expense  `json:"expenses"`
}

Project reassembles the structure of a Project in a Bimpf json dump files.

func (Project) Conditions

func (p Project) Conditions() util.Conditions

Conditions returns the validation conditions.

func (Project) ShortDescription

func (p Project) ShortDescription() string

ShortDescription returns the SbId and the name as a string

func (Project) String

func (p Project) String() string

String returns a human readable representation of the element.

func (Project) Type

func (p Project) Type() string

Type returns a string with the type name of the element.

func (Project) Validate

func (p Project) Validate() []util.ValidateResult

Validate the element and return the result.

type Projects

type Projects []Project

Projects is a slice of projects.

type TimeUnit

type TimeUnit struct {
	Id          int    `json:"id"`
	Description string `json:"description"`
	StartDate   string `json:"start_date"`
	StartTime   string `json:"start_time"`
	EndDate     string `json:"end_date"`
	EndTime     string `json:"end_time"`
	Billable    bool   `json:"billable"`
}

TimeUnit reassembles the structure of a TimeUnit in a Bimpf json dump file.

func (TimeUnit) Conditions

func (t TimeUnit) Conditions() util.Conditions

Conditions returns the validation conditions.

func (TimeUnit) String

func (t TimeUnit) String() string

String returns a human readable representation of the element.

func (TimeUnit) Type

func (t TimeUnit) Type() string

Type returns a string with the type name of the element.

func (TimeUnit) Validate

func (t TimeUnit) Validate() util.ValidateResults

Validate the element and return the result.

Jump to

Keyboard shortcuts

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