×

Party Management

As the transaction, its own unique number identifies the Party instance, but unlike to the transaction, this number is unique for the whole client, not
only for the current fiscal year. The origin for these numbers is controlled by the system in the same way as the document number for transactions.
 
Example Code

Find Party
You need to load all parties via Load Party() method, in order to be able to find a specific party via findParty() method.
Find the code sample below.
 
Find a party
    
        public void API_FindParty()
        {
            errorcode = manager.LoadParties();
            // Add error handling here 

            int PartyNumber = 1050;

            IParty oParty = null;
            errorcode = manager.FindParty(PartyNumber, out oParty);
            // Add error handling here 

            int partyID  = oParty.ID;
            int partyNum = oParty.PartyNum;
            IPerson partyPerson = oParty.Person;

            // and so on
        }
    
  
Find a party
    
UNDER CONSTRUCTION
    
  
 
Create a Party with creditor or debtor
The example below indicates the way how a party with a debtor can be created. A creditor can be added the same way as a debtor.
Before you can create a debtor or a creditor that is linked to party (by partyFID) you need to save the party.
 
Create a party
    
        public void API_CreateParty()
        {
            errorcode = manager.LoadParties();
            state = Helper.ViewErrorMessage(errorcode, manager);
            Assert.AreEqual(true, state.passed, state.message);

            IParty party = new Party();

            int partyNo = Helper.FindPartyByName(manager, "Hunki2000");
            if (partyNo != 0)
            {
                errorcode = manager.FindParty(partyNo, out party);
                state = Helper.ViewErrorMessage(errorcode, manager);
                Assert.AreEqual(true, state.passed, state.message);

                errorcode = manager.DeleteParty(party);
                state = Helper.ViewErrorMessage(errorcode, manager);
                Assert.AreEqual(true, state.passed, state.message);
            }

            // errorcode = manager.FindParty(10520, out party);

            // Add some party details
            party = new Party();
            party.PartyNum = 10520;
            party.Name = "Hunki2000";
            party.ShortName = "H2000";
            party.FreePartyNum = "Hunki_1000";

            // Add person details
            party.Person.JobTitle = "Dr.";
            party.Person.FirstName = "Cavin";
            party.Person.MiddleName = "M";
            party.Person.LastName = "Matters";

            // and so on

            errorcode = manager.SaveParty(party);
            state = Helper.ViewErrorMessage(errorcode, manager);
            Assert.AreEqual(true, state.passed, state.message);

            errorcode = manager.LoadParties();
            state = Helper.ViewErrorMessage(errorcode, manager);
            Assert.AreEqual(true, state.passed, state.message);

            int PartyNumber = 10520;

            IParty oParty = null;
            errorcode = manager.FindParty(PartyNumber, out oParty);
            state = Helper.ViewErrorMessage(errorcode, manager);
            Assert.AreEqual(true, state.passed, state.message);

            int partyID = oParty.ID;
            int partyNum = oParty.PartyNum;
            IPerson partyPerson = oParty.Person;

            // and so on

            // Create Debtor
            Debtor debitor = new Debtor();
            debitor.PartyFID = party.ID;
            debitor.Person.FirstName = "Debitor name";

            // set payment term
            errorcode = manager.LoadPayTerms();
            state = Helper.ViewErrorMessage(errorcode, manager);
            Assert.AreEqual(true, state.passed, state.message);

            // for convenience reasons Payterm type 8 has been added directly
            IData data = manager.PayTerms;
            PayTerm currentPayTerm = (PayTerm)data.GetItem(8);

            if (currentPayTerm.DueDays == 0)
            {
                debitor.PayTermFID = currentPayTerm.ID;
            }

            // create transaction method
            errorcode = manager.LoadAccounts();
            state = Helper.ViewErrorMessage(errorcode, manager);
            Assert.AreEqual(true, state.passed, state.message);

            String tmAccountCode = "1100";
            IAccount account = manager.FindAccount(tmAccountCode);

            PayMethod payMethod = new PayMethod();
            payMethod.Name = "PayMethod 1";
            payMethod.AccountFID = account.ID;

            /*
             * ESR = 1
             * RoterESBank = 2
             * RoterESPost = 3
             * RoterESTreuhand = 4
             * LSV = 5
             * Manual = 6
             * Postmandant = 7
             * Fremdwauhrung = 8
             * IBAN = 9
             */

            payMethod.PayTypeFID = 5;

            /*
             * 2 = Debtor
             * 3 = Creditor
             */
            payMethod.PersonRoleFID = 2;
            debitor.PayMethods.Add(payMethod);

            errorcode = manager.SaveDebtor(debitor);
            state = Helper.ViewErrorMessage(errorcode, manager);
            Assert.AreEqual(true, state.passed, state.message);
        }
    
  
Create a party
    
UNDER CONSTRUCTION
    
  
 
Read creditor or debtor details of a Party
Find the code sample below, if you need to retrieve creditor or debtor information of a party.
 
Get creditor/debtor details of a party
    
        public void API_Get_DebtorCreditorDetails()
        {
            errorcode = manager.LoadParties();
            state = Helper.ViewErrorMessage(errorcode, manager);
            int partyNo = 1019;


            IData parties = manager.Parties;
            bool isDebtor = false;
            bool isCreditor = false;

            foreach (IParty AdrParty in parties)
            {
                isDebtor = AdrParty.IsHaveDebtor;
                isCreditor = AdrParty.IsHaveCreditor;

                if (isDebtor && isCreditor)
                {
                    int adrPartyID = AdrParty.ID;
                    int adrPartyNum = AdrParty.PartyNum;

                    IParty party = null;
                    errorcode = manager.FindParty(adrPartyNum, out party);
                    state = Helper.ViewErrorMessage(errorcode, manager);

                    ICreditor partyCreditor = party.Creditor;

                    String freecode = partyCreditor.FreeCode;
                    String ourcusNum = partyCreditor.OurCustomerNum;

                    IPerson creditorPerson = partyCreditor.Person;

                    // Do the same for Debtor
                    IDebtor partyDebtor = party.Debtor;
                }

                if (isDebtor & !isCreditor)
                {
                    int adrPartyID = AdrParty.ID;
                    int adrPartyNum = AdrParty.PartyNum;

                    // if (adrPartyNum == partyNo)
                    if (adrPartyNum == 1000)
                    {
                        IParty oParty = null;
                        errorcode = manager.FindParty(adrPartyNum, out oParty);
                        state = Helper.ViewErrorMessage(errorcode, manager);

                        IDebtor partyDebtor = oParty.Debtor;
                        int payMethodFID = partyDebtor.PayMethodFID;
                        IData payMethods = partyDebtor.PayMethods;
                        int payTermFID = partyDebtor.PayTermFID;

                        // And so on ...
                    }
                }
            }
        }
    
  
Get creditor/debtor details of a party
    
UNDER CONSTRUCTION