Function – FindAccount

Lasă un comentariu

25 Februarie 2015 de liviustoica55


public static server container findAccount(Common _common)
{
LedgerJournalACType foundAccountType;
LedgerJournalAC foundAccount;
BankCustVendPaymModeBankAccounts custVendPaymModeBankAccounts;
CustVendTrans custVendTrans;
LedgerJournalTrans ledgerJournalTrans;
ModuleCustVend moduleCustVend;
PaymMode paymMode;
CurrencyCode currencyCode;
DimensionDefault dimensionDefault;
boolean otherLJT;

void getLedgerJournalTransValues()
{
paymMode = ledgerJournalTrans.PaymMode;
currencyCode = ledgerJournalTrans.CurrencyCode;
dimensionDefault = ledgerJournalTrans.DefaultDimension;
}

void getCustVendTransValues()
{
paymMode = custVendTrans.PaymMode;
currencyCode = custVendTrans.CurrencyCode;
dimensionDefault = custVendTrans.DefaultDimension;
}

switch (_common.TableId)
{
case tablenum(LedgerJournalTrans):
ledgerJournalTrans = _common;
switch (ledgerJournalTrans.ledgerJournalTable().JournalType)
{
case LedgerJournalType::Payment: //Vendor payment
moduleCustVend = ModuleCustVend::Vend;
getLedgerJournalTransValues();
break;
case LedgerJournalType::CustPayment: //Customer payment
moduleCustVend = ModuleCustVend::Cust;
getLedgerJournalTransValues();
break;
case LedgerJournalType::Approval,
LedgerJournalType::PurchaseLedger,
LedgerJournalType::VendInvoicePool,
LedgerJournalType::VendInvoicePoolNotPosted,
LedgerJournalType::VendInvoiceRegister,
LedgerJournalType::VendPaymRemittance,
LedgerJournalType::VendPromissoryNoteDraw,
LedgerJournalType::VendPromissoryNoteRedraw,
LedgerJournalType::VendPromissoryNoteSettle :
moduleCustVend = ModuleCustVend::Vend;
getLedgerJournalTransValues();
otherLJT = true;
break;
case LedgerJournalType::CustBillOfExchangeAccept,
LedgerJournalType::CustBillOfExchangeDraw,
LedgerJournalType::CustBillOfExchangeProtest,
LedgerJournalType::CustBillOfExchangeRedraw,
LedgerJournalType::CustBillOfExchangeSettle,
LedgerJournalType::CustPayment,
LedgerJournalType::CustPaymRemittance :
moduleCustVend = ModuleCustVend::Cust;
getLedgerJournalTransValues();
otherLJT = true;
break;
default :
throw error(Error::wrongUseOfFunction(funcname()));
}
break;
case tablenum(CustTrans):
moduleCustVend = ModuleCustVend::Cust;
custVendTrans = _common;
getCustVendTransValues();
break;
case tablenum(VendTrans):
moduleCustVend = ModuleCustVend::Vend;
custVendTrans = _common;
getCustVendTransValues();
break;
default:
throw error(Error::wrongUseOfFunction(funcname()));
//break;
}

if (paymMode)
{
switch (moduleCustVend)
{
case ModuleCustVend::Vend:
if (otherLJT)
{
foundAccount = DimensionStorage::getMainAccountFromLedgerDimension(VendPaymModeTable::find(paymMode).offsetLedgerDimension()).MainAccountId;
foundAccountType = VendPaymModeTable::find(paymMode).paymACType();
}
else
{
custVendPaymModeBankAccounts = BankVendPaymModeBankAccounts::findByPaymModeDimCurrency(paymMode,dimensionDefault,currencyCode);
if (custVendPaymModeBankAccounts.RecId)
{
foundAccount = custVendPaymModeBankAccounts.BankAccountID;
foundAccountType = LedgerJournalACType::Bank;
}
else
{
foundAccount = DimensionStorage::getMainAccountFromLedgerDimension(VendPaymModeTable::find(paymMode).offsetLedgerDimension()).MainAccountId;
foundAccountType = VendPaymModeTable::find(paymMode).paymACType();
}
}
break;
case ModuleCustVend::Cust:
if (otherLJT)
{
foundAccount = DimensionStorage::getMainAccountFromLedgerDimension(CustPaymModeTable::find(paymMode).offsetLedgerDimension()).MainAccountId;
foundAccountType = CustPaymModeTable::find(paymMode).paymACType();
}
else
{
custVendPaymModeBankAccounts = BankCustPaymModeBankAccounts::findByPaymModeCurrency(paymMode,dimensionDefault,currencyCode);
if (custVendPaymModeBankAccounts.RecId)
{
foundAccount = custVendPaymModeBankAccounts.BankAccountID;
foundAccountType = LedgerJournalACType::Bank;
}
else
{
foundAccount = DimensionStorage::getMainAccountFromLedgerDimension(CustPaymModeTable::find(paymMode).offsetLedgerDimension()).MainAccountId;
foundAccountType = CustPaymModeTable::find(paymMode).paymACType();
}
}
break;
default:
break;
}
}

if (!foundAccount)
{
foundAccountType = LedgerJournalACType::Ledger;
foundAccount = ”;
}

return [foundAccountType, foundAccount];
}

Lasă un răspuns

Completează mai jos detaliile despre tine sau dă clic pe un icon pentru autentificare:

Logo WordPress.com

Comentezi folosind contul tău WordPress.com. Dezautentificare / Schimbă )

Poză Twitter

Comentezi folosind contul tău Twitter. Dezautentificare / Schimbă )

Fotografie Facebook

Comentezi folosind contul tău Facebook. Dezautentificare / Schimbă )

Fotografie Google+

Comentezi folosind contul tău Google+. Dezautentificare / Schimbă )

Conectare la %s

%d blogeri au apreciat asta: