public static function TransferArrears($supplierid, $amount) { $supplier = Supplier::GetSupplier($supplierid); $descr = "Purchases Arrears B/F"; $pid = 0; $discount = 0; $orders = null; $datetime = new DateTime(); $ledger = Account::GetAccount('Purchases', 'ledgers'); $invoice = PurchaseInvoice::CreateInvoice($supplier, $pid, $orders, 0, $descr, $datetime->format('d/m/Y')); $invoice->addToInvoice(PurchaseInvoiceLine::Create($invoice->id, 'Balances brought forward', 1, $amount->amount, 0, 0, $ledger->ledgerId)); if ($invoice->generate()) { return new PurchaseTX($invoice, 'Purchases Arrears B/F Invoice'); } else { Logger::Log('PurchaseTx', 'Failed', 'Purchases arrears B/F invoice transaction with id:' . $invoice->id . ' and tx id:' . $this->transactionId . ' could not be completed'); return false; } }
function __construct() { parent::__construct(); //provider //name - electronic payment - paypal $this->drAccounts[] = Account::GetAccount('PayPal', 'ledgers'); $this->drRatios[] = 1; $this->crAccounts[] = Account::GetAccount('Sales Revenue', 'ledgers'); $this->crRatios[] = 1; //this info should originate from the database, insert ignore protocol included //$this->code = self::GetCode('PayPal'); //parent::__construct(); }
function __construct($clientId, $invoiceType) { parent::__construct($invoiceType); if ($invoiceType == 'Credit Note') { $this->crAccounts[] = Account::GetAccountByNo($clientId, 'clients', 'Debtors'); $this->crRatios[] = 1; $this->drAccounts[] = Account::GetAccount('Sales', 'ledgers'); $this->drRatios[] = 1; } else { $this->drAccounts[] = Account::GetAccountByNo($clientId, 'clients', 'Debtors'); $this->drRatios[] = 1; $this->crAccounts[] = Account::GetAccount('Sales', 'ledgers'); $this->crRatios[] = 1; } }
function __construct($clientId, $name) { parent::__construct($name); $this->drAccounts[] = Account::GetAccountByNo($clientId, 'clients', 'Debtors'); $this->drRatios[] = 1; $this->crAccounts[] = Account::GetAccount('Sales', 'ledgers'); $this->crRatios[] = 1; }
public static function RecoverAdvance($empid, $month) { try { $employee = Employee::GetEmployee(intval($empid)); $descr = "Advance recovered from " . $month . " salary."; //$d = explode('/', $date); //$month = $d[1].'/'.$d[2]; $sql2 = 'SELECT * FROM advances_and_loans WHERE party_id = ' . $empid . ' and type = "Salary Advance" ORDER BY id DESC LIMIT 0,1'; $entry = DatabaseHandler::GetRow($sql2); if (!empty($entry)) { $amount = $entry['balance']; } else { $amount = 0.0; } $amount = floatval($amount); if ($amount != 0.0) { $ledger = Account::GetAccount('PAYROLL'); $sql = 'INSERT INTO advances_and_loans (party_id, month, type, effect, amount, ledger_id, balance, description) VALUES (' . $employee->id . ', "' . $month . '", "Salary Advance", "cr", ' . $amount . ', ' . $ledger->ledgerId . ', 0.00, "Advance recovered from ' . $month . ' salary.")'; DatabaseHandler::Execute($sql); $sqlb = 'SELECT * FROM payroll_entries WHERE party_id = ' . $empid . ' ORDER BY id DESC LIMIT 0,1'; $latest = DatabaseHandler::GetRow($sqlb); $ladgerac = Account::GetAccount('LOANS AND ADVANCES'); $sqla = 'INSERT INTO payroll_entries (party_id, month, type, effect, amount, ledger_id,description) VALUES (' . $employee->id . ', "' . $month . '", "Salary Advance", "dr", ' . $amount . ', ' . $ladgerac->ledgerId . ', "Salary Advance for ' . $month . '.")'; DatabaseHandler::Execute($sqla); $sql2 = 'SELECT * FROM payroll_entries WHERE party_id = ' . $empid . ' ORDER BY id DESC LIMIT 0,1'; $entry = DatabaseHandler::GetRow($sql2); Logger::Log('Payroll', 'Passed', 'Salary advance for employee id: ' . $employee->id . ' for ' . $month . ' recovered'); //return new PayrollTX($payment, 'Salary Payment'); $txtype = AdvancesAndLoans::Recover($ledger->ledgerId, 'Advance Recovery'); $tx = PayrollTX::Initialize($entry, $txtype, 'payroll_entries'); $tx->post(); $sql = 'UPDATE advances_and_loans SET tx_id = ' . $tx->transactionId . ', user = "******", datetime = "' . $tx->date . '", stamp = ' . $tx->stamp . ' WHERE id = ' . $latest['id']; DatabaseHandler::Execute($sql); } else { } } catch (Exception $e) { Logger::Log('Payroll', 'Failed', 'Salary advance for employee id: ' . $employee->id . ' for ' . $month . ' could not be recovered'); } }