When you have a Quote and add a new line item, either via a button in the user interface or via a Quote header calculation logic, the Quote line logic is executed twice. The first time with api.currentItem() returning null and the second time with api.currentItem() returning the whole line. Why is that so?
The reason is that the system needs to evaluate the inputs created for the line. So the system calls the Quote line logic twice: