My Products
Help
AntonZ
CONTRIBUTOR ***

Setting status of CustomerInvoice when creating it through API

by AntonZ

Hi 

Our customers earn interest and fees from our collection system, and we are registering those interests and fees as customerinvoices against accounts 3900 and 8050 (or some other accounts selected by customer)

E.g. 

Invoice of kr 1000
Payment by debtor of kr 1150 directly to Visma.NET (through bank) 
Interest and fee voucher created by us through API kr 150

This works, but the invoice voucher we create comes as "Balanced" and needs to be closed manually.

Two questions: 

We dont want to post these invoices as "Balanced" status, but as "Open". Any way to do this through API? 

We want to auto close the invoice(-s), payment(-s) and interest/fee vouchers when we post interest/fee voucher. Any way to trigger auto-closing of open vouchers when the interest/fee come in through API, so our customer doesnt have to do this manually? 

4 REPLIES 4
Accepted solution
AntonZ
CONTRIBUTOR ***

by AntonZ

Hi Magnus! 

We have another issue also related to interest/fee voucher creation in Visma.NET

This time its account specific, as it works fine for one of our customers, but does not work for the other. 

We suspect its some setting in Visma.NET that isnt active in account that gives error, but we havent been able to figure it out. 

Here is the error message we get: 

{"message":"VismaId: f948dfa5-350c-49c7-bdf9-5e40729a2804. Error creating document. Error: TaxCategoryID '0' cannot be found in the system."}

 
Is this what we must do? 

1. Check the customers Vat Zone
- Get /controller/api/v1/customer/{customerNumber}
2. Get the Vat zones applicable Vat Id's
-Get /controller/api/v1/vatZone/{vatZoneId}
3. Get the invoice lines Vat categories applicable Vat Id's
-Get /controller/api/v1/vatCategory/{taxCategoryId}
4. The Vat Id needs to be a value found in both lists.
- Get /controller/api/v1/vat/{vatId}

Can you point us towards where to set up the Visma.NET account so its possible to export to it? 

AntonZ
CONTRIBUTOR ***

by AntonZ

Hi Magnus 

I dont see how screenshots and screenId's are relevant here. We do not want to perform any actions in UI, we want to post the vouchers to Visma.NET through the API in a way that ensures the least amount of manual work in Visma.NET. Hence, we want to post it as "Open" in Visma.NET and not "Balanced" as we do now, and ideally we aim to auto-close the related vouchers in Visma.NET when we post it so our created invoice and the pre-existing invoice/payments (which comes out as sum 0) all gets "Avsluttet" / "Lukket" status in Kundeinformasjon Reskontro in Visma.NET without our customer having to manually set "Open" status, match and close the vouchers. 

So first thing to figure out is can we post an invoice through API to Visma.NET and set it with status "Open" instead of "Balanced" when we create the invoice voucher through the API? 

We use CustomerInvoiceV2 endpoint to post invoices

 
data that we post:
{
  "invoiceLines": [
    {
      "operation": "Insert",
      "description": {
        "value": "Gebyrinntekt fra Kredin.no"
      },
      "quantity": {
        "value": 1
      },
      "manualAmountInCurrency": {
        "value": 3261
      },
      "accountNumber": {
        "value": "3900"
      }
    },
    {
      "operation": "Insert",
      "description": {
        "value": "Renteinntekt fra Kredin.no"
      },
      "quantity": {
        "value": 1
      },
      "manualAmountInCurrency": {
        "value": 1356.51
      },
      "accountNumber": {
        "value": "8050"
      }
    }
  ],
  "sendToAutoInvoice": {
    "value": false
  },
  "customerNumber": {
    "value": "10001"
  },
  "documentDate": {
    "value": "2021-05-01T00:00:00Z"
  },
  "invoiceText": {
    "value": "Rente- og/eller gebyrinntekt fra saksnr. 21190 i Kredin.no"
  }
}
data, that was created in Visma.NET after posting and fetched from CustomerInvoice endpoint
{
  "creditTerms": {
    "id": "14",
    "description": "14 dager netto"
  },
  "documentDueDate": "2021-05-15T00:00:00",
  "cashDiscountDate": "2021-05-01T00:00:00",
  "exchangeRate": 1,
  "attachments": [],
  "taxDetails": [
    {
      "taxId": "3",
      "vatRate": 25,
      "taxableAmount": 4617.51,
      "vatAmount": 1154.38
    }
  ],
  "invoiceLines": [
    {
      "lineNumber": 1,
      "description": "Gebyrinntekt fra Kredin.no",
      "quantity": 1,
      "unitPrice": 0,
      "unitPriceInCurrency": 0,
      "manualAmount": 3261,
      "manualAmountInCurrency": 3261,
      "amount": 3261,
      "amountInCurrency": 3261,
      "account": {
        "type": "Income",
        "number": "3900",
        "description": "Andre driftsrel. inntekter avg.pliktig"
      },
      "vatCode": {
        "id": "3",
        "description": "Utgående mva, høy sats"
      },
      "discountPercent": 0,
      "discountAmount": 0,
      "discountAmountInCurrency": 0,
      "manualDiscount": false,
      "subaccount": {
        "subaccountNumber": "0",
        "subaccountId": 1083,
        "description": "Ingen",
        "lastModifiedDateTime": "2019-04-10T12:27:20.48",
        "active": true,
        "segments": [
          {
            "segmentId": 1,
            "segmentDescription": "Avdeling",
            "segmentValue": "0",
            "segmentValueDescription": "None"
          }
        ]
      },
      "deferralSchedule": 0,
      "branchNumber": {
        "number": "1",
        "name": "Firmanavn AS"
      }
    },
    {
      "lineNumber": 2,
      "description": "Renteinntekt fra Kredin.no",
      "quantity": 1,
      "unitPrice": 0,
      "unitPriceInCurrency": 0,
      "manualAmount": 1356.51,
      "manualAmountInCurrency": 1356.51,
      "amount": 1356.51,
      "amountInCurrency": 1356.51,
      "account": {
        "type": "Income",
        "number": "8050",
        "description": "Annen renteinntekt"
      },
      "vatCode": {
        "id": "3",
        "description": "Utgående mva, høy sats"
      },
      "discountPercent": 0,
      "discountAmount": 0,
      "discountAmountInCurrency": 0,
      "manualDiscount": false,
      "subaccount": {
        "subaccountNumber": "0",
        "subaccountId": 1083,
        "description": "Ingen",
        "lastModifiedDateTime": "2019-04-10T12:27:20.48",
        "active": true,
        "segments": [
          {
            "segmentId": 1,
            "segmentDescription": "Avdeling",
            "segmentValue": "0",
            "segmentValueDescription": "None"
          }
        ]
      },
      "deferralSchedule": 0,
      "branchNumber": {
        "number": "1",
        "name": "Firmanavn AS"
      }
    }
  ],
  "sendToAutoInvoice": false,
  "roundingDiff": 0,
  "customerVatZone": {
    "id": "01",
    "description": "Salg innenlands, avgiftspliktig"
  },
  "hold": false,
  "discountTotal": 0,
  "discountTotalInCurrency": 0,
  "detailTotal": 4617.51,
  "detailTotalInCurrency": 4617.51,
  "vatTaxableTotal": 4617.51,
  "vatTaxableTotalInCurrency": 4617.51,
  "vatExemptTotal": 0,
  "vatExemptTotalInCurrency": 0,
  "paymentReference": "100010000592",
  "dontPrint": true,
  "dontEmail": false,
  "customer": {
    "number": "10001",
    "name": "Regnskaps Companiet AS"
  },
  "documentType": "Invoice",
  "referenceNumber": "000059",
  "postPeriod": "052021",
  "financialPeriod": "202105",
  "documentDate": "2021-05-01T00:00:00",
  "origInvoiceDate": "2021-05-01T00:00:00",
  "status": "Balanced",
  "currencyId": "NOK",
  "amount": 5771.89,
  "amountInCurrency": 5771.89,
  "balance": 5771.89,
  "balanceInCurrency": 5771.89,
  "cashDiscount": 0,
  "cashDiscountInCurrency": 0,
  "paymentMethod": {
    "id": "1",
    "description": "Innlandsbetalinger"
  },
  "invoiceText": "Rente- og/eller gebyrinntekt fra saksnr. 21190 i Kredin.no",
  "lastModifiedDateTime": "2022-02-08T15:52:45.043",
  "createdDateTime": "2022-02-08T15:52:45.043",
  "note": "",
  "vatTotal": 1154.38,
  "vatTotalInCurrency": 1154.38,
  "location": {
    "countryId": "NO",
    "id": "Main",
    "name": "Primary location"
  },
  "branchNumber": {
    "number": "1",
    "name": "Firmanavn AS"
  },
  "cashAccount": "1910",
  "project": {
    "id": "X",
    "description": "Non-Project Code."
  },
  "account": {
    "type": "Asset",
    "number": "1500",
    "description": "Kundefordringer"
  },
  "subaccount": {
    "subaccountNumber": "0",
    "subaccountId": 1083,
    "description": "Ingen",
    "lastModifiedDateTime": "2019-04-10T12:27:20.48",
    "active": true,
    "segments": [
      {
        "segmentId": 1,
        "segmentDescription": "Avdeling",
        "segmentValue": "0",
        "segmentValueDescription": "None"
      }
    ]
  },
  "metadata": {
    "totalCount": 3,
    "maxPageSize": 1000
  }
}
status field of newly created invoice
"status": "Balanced",

How it looks in Visma.NET after creation
https://ibb.co/2YHhZbS


Looking forward to your reply 

Accepted solution
Magnus Johnsen
VISMA

by Magnus Johnsen

Hi,

We meant that we wanted your process that you are currently doing today in the UI to reach the end result you want.

To start with, for the invoice to have the status "open", you need to release it.

1. Post the invoice

2. Get the invoiceNumber from the location response header:

2022-02-09 19_02_51-Postman.png

2. Call the release action with the documentNumber:

Post /controller/api/v1/customerinvoice/{invoiceNumber}/action/release

When the payments/vouchers applied to the document has a sum of 0, the invoice should have it's status set to closed automatically. Is this not happening in your customers company?

by Magnus Johnsen

Hi,

Could you please elaborate on how you do, what you would like to do today via the UI?

Please include screenshots as well as screenId's and we'll take a look at it.

Thank you.