sync

package
v0.0.0-...-ad2e321 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareInvoiceCategories

func CompareInvoiceCategories(first model.InvoiceCategory, second model.InvoiceCategory) bool

CompareInvoiceCategories returns true if the given entities are considered the same in all properties.

func MergeWithInvoiceCategory

func MergeWithInvoiceCategory(current entity.Category, category model.InvoiceCategory) entity.Category

MergeWithInvoiceCategory writes compatible fields of an existing model.InvoiceCategory into the given entity.Category.

The entity.Category.Target field is only set if the model.InvoiceCategory.ID is non-zero.
The entity.Category.Source field is only set if model.InvoiceCategory.Name is non-empty string.

func ToInvoiceCategory

func ToInvoiceCategory(category entity.Category) (model.InvoiceCategory, error)

ToInvoiceCategory writes compatible fields of an existing entity.Category into the given model.InvoiceCategory.

The model.InvoiceCategory.ID is only set if the entity.Category.Target is a non-empty string.
The model.InvoiceCategory.Name field is only set if entity.Category.Source is non-empty string.

Errors are returned if entity.Category.Target is not numeric or if parsing entity.Category.Source fails.

Types

type InvoiceCategoryReconciler

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

InvoiceCategoryReconciler synchronizes various reporting facts with Odoo API.

func NewInvoiceCategoryReconciler

func NewInvoiceCategoryReconciler(odoo *model.Odoo) *InvoiceCategoryReconciler

NewInvoiceCategoryReconciler constructor.

func (*InvoiceCategoryReconciler) Reconcile

Reconcile synchronizes model.InvoiceCategory in Odoo based on the given entity.Category according to the following rules:

  • If entity.Category.Target is empty then it will create a new model.InvoiceCategory and set entity.Category.Target to the ID returned by Odoo.
  • If entity.Category.Target has a value then it will search for a matching model.InvoiceCategory:
  • If not found, it will return an error.
  • If found and model.InvoiceCategory is up-to-date, it will return without error (noop).
  • If found and model.InvoiceCategory has other properties than desired, the model.InvoiceCategory is updated/reset.

Reconcile implements erp.CategoryReconciler. Note: A logger is retrieved from logr.FromContextOrDiscard.

Jump to

Keyboard shortcuts

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