Use company for student invoices

Home > Finance > Manage Invoicees > Edit Invoicee

I will have no parents, no families.

Can I get the SQL statement to:

Change Send Invoices To to “Company”
Set Company Name = “Self”
Company Contact Person = “Self” or student’s full name
Company Address = student’s address if set
Company Emails = student’s email

Maybe an option to use a spreadsheet to generate lines of SQL commands

Hi Tieku,

Here is a command you could use to accomplish what you’re looking for, feel free to modify it as needed. It will only run once per student because it checks if the default Family has been changed.

`UPDATE gibbonFinanceInvoicee 
JOIN gibbonPerson ON (gibbonFinanceInvoicee.gibbonPersonID=gibbonPerson.gibbonPersonID)
SET invoiceTo="Company", companyName="Self", companyContact="Self", companyAddress=CONCAT(gibbonPerson.address1, " ", gibbonPerson.address1District, " ", gibbonPerson.address1Country), companyEmail=gibbonPerson.email, companyAll='Y'
WHERE invoiceTo="Family";`
```

Thanks Sandra,

This looked better in the end:

`UPDATE gibbonFinanceInvoicee 
JOIN gibbonPerson ON (gibbonFinanceInvoicee.gibbonPersonID=gibbonPerson.gibbonPersonID)
SET invoiceTo="Company", companyName="Student", companyContact=CONCAT(gibbonPerson.firstName," ", gibbonPerson.surname), companyAddress=CONCAT(gibbonPerson.address1, " ", gibbonPerson.address1District, " ", gibbonPerson.address1Country), companyPhone=gibbonPerson.phone1, companyEmail=gibbonPerson.email, companyAll='Y'
WHERE invoiceTo="Family";	`
```



And then I used String Replacement to change Company to Student.