Topic: Anatomy of adding 1 Supplier
Taking the sql backup diffs between before and after adding a single Supplier, the following sequence of SQL statements are observed (Assumed TB_PREF=3_):
SET @Supplier := "Finger Chips Intl.";
SET @SuppShort := "FCI";
SET @Contact := "Jackson";
SET @Phone := "568974521";
SET @EMail := "supplier1@example.com";
SET @Website := "http://www.fci.com";
SET @Address := "Alpha Street,\nGladystown - 654543";
SET @GST := "8954587411";
SET @DefCurr := (SELECT `value` FROM `3_sys_prefs` WHERE `name`="curr_default" AND `category`="setup.company");
SET @CredAc := (SELECT `value` FROM `3_sys_prefs` WHERE `name`="creditors_act" AND `category`="glsetup.purchase");
SET @PayDsctAc := (SELECT `value` FROM `3_sys_prefs` WHERE `name`="pyt_discount_act" AND `category`="glsetup.purchase");
INSERT INTO `3_suppliers` VALUES
(NULL, @Supplier, @SuppShort, @Address, '', @Phone, '', '', @Website, '', @DefCurr, '4', '0', '0', '0', '1', '0', '', @CredAc, @PayDsctAc, '', '0');
SET @SupplierID := (SELECT LAST_INSERT_ID());
INSERT INTO `3_crm_persons` VALUES
(NULL, @SuppShort, @Contact, NULL, @Address, @GST, NULL, NULL, @EMail, NULL, '', '0');
SET @PersonID := (SELECT LAST_INSERT_ID());
INSERT INTO `3_crm_contacts` VALUES
(NULL, @PersonID, 'supplier', 'general', @SupplierID);
Here, first a Supplier is created.
Then a Person is created.
Finally, this new Person is assigned to the new Supplier as a Contact.
The above can be useful for bulk importing of suppliers from disparate systems.