to get a personalized navigation.
to get a personalized navigation.
Hi!
I am trying to create a customer payment with two rows , one for an invoice and one for a credit When I do this in the UI it works fine, both the credit and the invoice is closed after I released it
but when I do this using the API I get back an error as seen below.
This image show one invoice and one credit
This image show how I create a payment for both the invoice and credit before release
Image after release
Here is the json I tried with using POST to customerpayment and the response in Postman
{
"referenceNumber": null,
"type": { "value": "Payment" },
"hold": { "value": false },
"applicationDate": { "value": "2022-05-29T00:00:00" },
"applicationPeriod": null,
"paymentRef": { "value": "" },
"customer": { "value": "10002" },
"location": { "value": "Primär" },
"paymentMethod": { "value": "01" },
"cashAccount": { "value": "1940" },
"currency": { "value": "SEK" },
"paymentAmount": { "value": 112 },
"invoiceText": { "value": "Test" },
"branch": null,
"ordersToApply": null,
"paymentLines": [
{
"cashDiscountTaken": null,
"balanceWriteOff": null,
"writeOffReasonCode": null,
"crossRate": null,
"operation": "Insert",
"documentType": { "value": "Invoice" },
"refNbr": {"value":"000224"},
"amountPaid": { "value": 125 }
},
{
"cashDiscountTaken": null,
"balanceWriteOff": null,
"writeOffReasonCode": null,
"crossRate": null,
"operation": "Insert",
"documentType": { "value": "Credit Memo" },
"refNbr": {"value":"000225"},
"amountPaid": { "value": 13 }
}
]
}
Response from VN
{
"message": "VismaId: 6c6eb585-da38-4765-b80d-e9552a8721f8. Error creating payment. Error: AdjdRefNbr '000225' cannot be found in the system."
}
What is missing in my json for doing the same operation in the API as in the UI?
thanks
Thomas
Solved! Go to Solution.
ok thanks
but now I get another problem with balance.
#1. The payed amount should 3000:- (invoice-credit) but that does not work as you see in the response. Visma expect 3250:- which is wrong. if I enter 3250 in the paymentamount it works but the invoice and credit is not closed as it is when in the UI. and the amount payed is wrong.
#2. am I missing some API documentation (besides swagger), how was I suppose to know the that documenttype is "creditnote" ?
{
"referenceNumber": null,
"type": { "value": "Payment" },
"hold": { "value": false },
"applicationDate": { "value": "2022-05-29T00:00:00" },
"applicationPeriod": null,
"paymentRef": { "value": "" },
"customer": { "value": "10002" },
"location": { "value": "Primär" },
"paymentMethod": { "value": "01" },
"cashAccount": { "value": "1940" },
"currency": { "value": "SEK" },
"paymentAmount": { "value": 3000 },
"invoiceText": { "value": "Test" },
"branch": null,
"ordersToApply": null,
"paymentLines": [
{
"cashDiscountTaken": null,
"balanceWriteOff": null,
"writeOffReasonCode": null,
"crossRate": null,
"operation": "Insert",
"documentType": { "value": "Invoice" },
"refNbr": {"value":"000230"},
"amountPaid": { "value": 3125 }
},
{
"cashDiscountTaken": null,
"balanceWriteOff": null,
"writeOffReasonCode": null,
"crossRate": null,
"operation": "Insert",
"documentType": { "value": "CreditNote" },
"refNbr": {"value":"000231"},
"amountPaid": { "value": 125 }
}
]
}
{
"message": "VismaId: fb23bf7d-1817-4a71-9332-f6f2e5bdfc4c. Error creating payment The document is out of the balance. Payment Amount: 3000 does not equals Application Amount: 3250 ."
}
Hi,
For your second question first, all types are available on swagger by clicking on model in the top of the endpoint example box and then expanding the fields until you have reached the field you are looking for:
For your first question, this seems like a bug. It should be take into consideration that adding a credit note to a payment will result in a "negative" line. The current check only seems to add up all values on the lines.
The workaround for now would be to first create the payment with a line with the Invoice and the amount the customer should have paid minus the amount on the credit note, and then update the payment by inserting the credit note and updating the amount paid on the invoice line.
Example, to get the following result:
Since I know that the Invoice needs to have 125 NOK to be closed, and the credit note has a value of 12,5 NOK, I first send a POST request with an amount of (Invoice - CreditNote):
At this point the payment looks like this:
I then send a PUT request to insert the credit note and update the amount paid on the invoice line:
The document is at this point balanced and can be released.
The following example I have created an invoice 000273 with 125:- and a credit with 4:-
If I create a payment in the UI and add both the invoice and the credit and release both the invoice and the credit is closed.
If I do the same in API, The following happens
1. the credit is closed
2. the invoice is open
3. the payment is not released even if I got back OK 200, it is in status Open but release button is not availabe only Void.
POST
https://integration.visma.net/API/controller/api/v1/customerpayment
{
"referenceNumber": null,
"type": { "value": "Payment" },
"hold": { "value": false },
"applicationDate": null,
"applicationPeriod": null,
"paymentRef": null,
"customer": { "value": "10002" },
"location": { "value": "Primär" },
"paymentMethod": null,
"cashAccount": null,
"currency": null,
"paymentAmount": { "value": 125.0 },
"invoiceText": null,
"branch": null,
"ordersToApply": null,
"paymentLines": [
{
"cashDiscountTaken": null,
"balanceWriteOff": null,
"writeOffReasonCode": null,
"crossRate": null,
"operation": "Insert",
"documentType": { "value": "Invoice" },
"refNbr": { "value": "000273" },
"amountPaid": { "value": 125.0 }
}
]
}
PUT
https://integration.visma.net/API/controller/api/v1/customerpayment/400129
{
"referenceNumber": null,
"type": { "value": "Payment" },
"hold": null,
"applicationDate": null,
"applicationPeriod": null,
"paymentRef": null,
"customer": null,
"location": null,
"paymentMethod": null,
"cashAccount": null,
"currency": null,
"paymentAmount": null,
"invoiceText": null,
"branch": null,
"ordersToApply": null,
"paymentLines": [
{
"cashDiscountTaken": null,
"balanceWriteOff": null,
"writeOffReasonCode": null,
"crossRate": null,
"operation": "Insert",
"documentType": { "value": "CreditNote" },
"refNbr": { "value": "000274" },
"amountPaid": { "value": 4.0 }
},
{
"cashDiscountTaken": null,
"balanceWriteOff": null,
"writeOffReasonCode": null,
"crossRate": null,
"operation": "Update",
"documentType": { "value": "Invoice" },
"refNbr": { "value": "000273" },
"amountPaid": { "value": 121.0 }
}
]
}
https://integration.visma.net/API/controller/api/v1/customerpayment/400129/action/release
{ "type": { "value": "Payment" } }
- Why is the balance on the payment 8:-
- Why is the payment not released, I read about the void status in the api doc but do not understand it.
- Why is the invoice closed when I do this in the ui and not using the API.
- Please provide a safe way for me to code this without hickups
Thanks
Hello Again
My example may be wrong, I got it working if I send in the correct amount in the header when doing the PUT.
it is still strange though that the payment is not closed, is it because of the balance i not 0,
should the payment be set to closed ? how to do that?
Document Type should be any of these values:
Invoice, DebitNote, CreditNote, Payment, VoidPayment, Prepayment, Refund, FinCharge, SmallBalanceWo, SmallCreditWo, CashSale, CashReturn, Undefined, NoUpdate
ok thanks, now I get another problem with balance,
#1. what am I doing wrong now? the document is out of balance. (see json), I did try to set the payment amount to 3250 and that worked but the invoice and credit was not closed as in the ui, and the amount paid is not 3250. it is 3250-125=3125
Somehow the system seem to think that the invoice+credit = payed, but should be invoice-credit = payed.
entering minus number in credit note did not work either.
#2. Is there some kind of documentation available for which fields in json that should be sent in (besides swagger) how was I suppose to know that the type of document is named "CreditNote"?
{
"referenceNumber": null,
"type": { "value": "Payment" },
"hold": { "value": false },
"applicationDate": { "value": "2022-05-29T00:00:00" },
"applicationPeriod": null,
"paymentRef": { "value": "" },
"customer": { "value": "10002" },
"location": { "value": "Primär" },
"paymentMethod": { "value": "01" },
"cashAccount": { "value": "1940" },
"currency": { "value": "SEK" },
"paymentAmount": { "value": 3000 },
"invoiceText": { "value": "Test" },
"branch": null,
"ordersToApply": null,
"paymentLines": [
{
"cashDiscountTaken": null,
"balanceWriteOff": null,
"writeOffReasonCode": null,
"crossRate": null,
"operation": "Insert",
"documentType": { "value": "Invoice" },
"refNbr": {"value":"000230"},
"amountPaid": { "value": 3125 }
},
{
"cashDiscountTaken": null,
"balanceWriteOff": null,
"writeOffReasonCode": null,
"crossRate": null,
"operation": "Insert",
"documentType": { "value": "CreditNote" },
"refNbr": {"value":"000231"},
"amountPaid": { "value": 125 }
}
]
}
{
"message": "VismaId: fb23bf7d-1817-4a71-9332-f6f2e5bdfc4c. Error creating payment The document is out of the balance. Payment Amount: 3000 does not equals Application Amount: 3250 ."
}
Copyright © 2022 Visma.com. All rights reserved.