feat(crm): allow updating invoice terms via oo

Needed to put issuer NIE in Bedingungen without a full recreate.
This commit is contained in:
2026-08-06 13:35:08 +01:00
parent 7f35b0e910
commit 31c556d34c
2 changed files with 18 additions and 10 deletions
+7 -4
View File
@@ -160,14 +160,14 @@ Example:
func invoiceUpdateCmd() *cobra.Command { func invoiceUpdateCmd() *cobra.Command {
var opportunityID int64 var opportunityID int64
var description, po string var description, po, terms string
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "update INVOICE_ID", Use: "update INVOICE_ID",
Short: "Update invoice (opportunity link, notes, PO)", Short: "Update invoice (opportunity link, notes, PO, terms)",
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
if opportunityID == 0 && !cmd.Flags().Changed("description") && !cmd.Flags().Changed("po") { if opportunityID == 0 && !cmd.Flags().Changed("description") && !cmd.Flags().Changed("po") && !cmd.Flags().Changed("terms") {
return fmt.Errorf("set --opportunity and/or --description and/or --po") return fmt.Errorf("set --opportunity and/or --description and/or --po and/or --terms")
} }
c, err := newOO(cmd) c, err := newOO(cmd)
if err != nil { if err != nil {
@@ -180,6 +180,8 @@ func invoiceUpdateCmd() *cobra.Command {
DescriptionSet: cmd.Flags().Changed("description"), DescriptionSet: cmd.Flags().Changed("description"),
PurchaseOrder: po, PurchaseOrder: po,
PurchaseOrderSet: cmd.Flags().Changed("po"), PurchaseOrderSet: cmd.Flags().Changed("po"),
Terms: terms,
TermsSet: cmd.Flags().Changed("terms"),
}) })
if err != nil { if err != nil {
return err return err
@@ -191,6 +193,7 @@ func invoiceUpdateCmd() *cobra.Command {
cmd.Flags().Int64Var(&opportunityID, "opportunity", 0, "CRM opportunity/deal id to link") cmd.Flags().Int64Var(&opportunityID, "opportunity", 0, "CRM opportunity/deal id to link")
cmd.Flags().StringVar(&description, "description", "", "invoice notes (Notizen); use \\n for line breaks") cmd.Flags().StringVar(&description, "description", "", "invoice notes (Notizen); use \\n for line breaks")
cmd.Flags().StringVar(&po, "po", "", "purchase order number") cmd.Flags().StringVar(&po, "po", "", "purchase order number")
cmd.Flags().StringVar(&terms, "terms", "", "payment terms / footer (Bedingungen)")
return cmd return cmd
} }
+5
View File
@@ -124,6 +124,8 @@ type UpdateInvoiceParams struct {
DescriptionSet bool DescriptionSet bool
PurchaseOrder string PurchaseOrder string
PurchaseOrderSet bool PurchaseOrderSet bool
Terms string
TermsSet bool
} }
// UpdateInvoice PUTs a full invoice body (OnlyOffice requires complete payload). // UpdateInvoice PUTs a full invoice body (OnlyOffice requires complete payload).
@@ -206,6 +208,9 @@ func (c *Client) UpdateInvoice(ctx context.Context, id string, p UpdateInvoicePa
if p.PurchaseOrderSet { if p.PurchaseOrderSet {
body["purchaseOrderNumber"] = p.PurchaseOrder body["purchaseOrderNumber"] = p.PurchaseOrder
} }
if p.TermsSet {
body["terms"] = p.Terms
}
if p.EntityID != 0 { if p.EntityID != 0 {
body["entityId"] = p.EntityID body["entityId"] = p.EntityID
body["entityType"] = p.EntityType body["entityType"] = p.EntityType