Payment Management
IPayment represents the manual payment entity of Topal. It contains IPaymentDetail lists. To pay some invoice you have to use one of two methods: PayInvoice - add
payment with amounts based on invoice balance so after payment invoice balance will be zero. PayInvoiceCustom – allow to pay custom amount of invoice. One manual
payment could contain more than one invoice but these invoices should be linked to the same party and to same person role of a party (debtor/creditor). Each payment
is a transaction. So it is necessary to fill transaction properties such a document date. After payment created and invoice paid, you can call SavePayment method
of IManager.
Example Code
public void API_CreatePayment()
{
string msg = string.Empty;
ErrorState state = new ErrorState();
int errorcode = 0;
/* Logon to Topal Server and set current client*/
LogOnSystem system = new LogOnSystem();
Credentials defaultcredentials = new Credentials();
IManager manager = system.LogOn(defaultcredentials);
/* Initial parameter definition for payments */
int invoiceNum = 1029;
String paymentAccCode = "1020";
errorcode = manager.LoadTransactions();
Assert.AreEqual(true, state.passed, state.message);
/* create Invoice */
IInvoice invoice = new Invoice();
errorcode = manager.FindInvoice(invoiceNum, true, out invoice); // if debtor = true, creditor = false
state = Helper.ViewErrorMessage(errorcode, manager);
Assert.AreEqual(true, state.passed, state.message);
errorcode = manager.LoadAccounts();
state = Helper.ViewErrorMessage(errorcode, manager);
Assert.AreEqual(true, state.passed, state.message);
IAccount account = new Account();
account.ID = manager.FindAccountID(paymentAccCode);
invoice.Text = "Uhren Meier AG / 1029 / new Text ";
errorcode = manager.SaveInvoice(invoice);
state = Helper.ViewErrorMessage(errorcode, manager);
Assert.AreEqual(true, state.passed, state.message);
/* create Payment */
IPayment payment = new Payment();
payment.PayInvoice(invoice);
payment.AccountFID = account.ID;
DateTime date = DateTime.Today;
payment.Transaction.DocDate = new DateTime(date.Year, date.Month, date.Day);
// save payment
errorcode = manager.SaveManualPayment(payment);
state = Helper.ViewErrorMessage(errorcode, manager);
if (errorcode != 0)
{
Helper.createNewFiscalYear(manager);
manager.LoadFiscalYears(manager.Client);
errorcode = manager.SaveManualPayment(payment);
state = Helper.ViewErrorMessage(errorcode, manager);
Assert.AreEqual(true, state.passed, state.message);
}
}
UNDER CONSTRUCTION
public void API_CreatePayment_with_Invoice()
{
String paymentAccCode = "1020";
errorcode = manager.LoadTransactions();
errorcode = manager.LoadAccounts();
state = Helper.ViewErrorMessage(errorcode, manager);
Assert.AreEqual(true, state.passed, "LoadTransactions: " + state.message);
IInvoice invoice = createInvoice(manager);
errorcode = manager.FindInvoice(invoice.InvoiceNum, true, out invoice); // if debtor = true, creditor = false
errorcode = manager.LoadAccounts();
state = Helper.ViewErrorMessage(errorcode, manager);
Assert.AreEqual(true, state.passed, "LoadAccounts: " + state.message);
IAccount account = new Account();
account.ID = manager.FindAccountID(paymentAccCode);
IPayment payment = new Payment();
payment.PayInvoice(invoice);
payment.AccountFID = account.ID;
DateTime date = DateTime.Today;
payment.Transaction.DocDate = new DateTime(date.Year, date.Month, date.Day);
// save payment
errorcode = manager.SaveManualPayment(payment);
state = Helper.ViewErrorMessage(errorcode, manager);
if (errorcode != 0)
{
Helper.createNewFiscalYear(manager);
manager.LoadFiscalYears(manager.Client);
errorcode = manager.SaveManualPayment(payment);
state = Helper.ViewErrorMessage(errorcode, manager);
Assert.AreEqual(true, state.passed, state.message);
}
}
UNDER CONSTRUCTION
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 ...
}
}
}
}
UNDER CONSTRUCTION