You should keep types of fields corresponding to what they are intended for.
Price, taxes and total should be Number.
Price unit may be a reference to Currencies catalog (you have not mentioned its type in your description)
Item should be a reference to Items catalog.
Next, the filling. You should understand where the data to be filled is stored. If it is not in the information register, as I suggested, then the simplier way is to store it in Items catalog, but in that case you have only current values.
If you store price in Items catalog as an attribute, you can get this value by using a dot. Note, that it is fine to get only 1 value, if you need to get more, you must use a query as a dot operator in this case performs a query, so when the item is changed you can set the price from the item, that was set.
The last thing is that you should perform this calculation on server. The OnChange handler calls a procedure with &AtServer directive. To call a server (requests to the database can be performed on server only), you need to add a procedure with &AtServer directive and call it from the client one:
Code |
---|
&AtClient
Procedure ItemsItemOnChange(Item)
ItemsItemOnChangeAtServer();
EndProcedure
&AtServer
Procedure ItemsItemOnChangeAtServer()
Row = Object.Items[Items.Items.CurrentRow];
If Row.Quantity = 0 Then
Row.Quantity = 1;
EndIf;
Row.Price = Row.Item.Price;
Row.Total = Row.Price * Row.Quantity;
EndProcedure |
I have attached an example for you.
P.S.: It would be better to rename CatalogItem catalog name into Items and InvoiceItems tabular section into Items too.