Exemple #1
0
 function __construct($supplierId, $amount)
 {
     $this->supplierId = $supplierId;
     //$this->amount = $amount; - Money class
     //$this->description = "Balance brought forward";
     $txtype = new SupplierInvoice($supplierId, 'Purchases Balance B/F invoice');
     parent::__construct($amount, "Purchases balance brought forward", $txtype);
 }
Exemple #2
0
 public function __construct()
 {
     if (isset($_POST['operation'])) {
         $operation = $_POST['operation'];
         if ($operation == 'addEmployee') {
             if (isset($_POST['name']) && isset($_POST['tel']) && isset($_POST['department']) && isset($_POST['position']) && isset($_POST['salary'])) {
                 $name = $_POST['name'];
                 $mobile = $_POST['tel'];
                 $email = $_POST['email'];
                 $address = $_POST['address'];
                 $gender = $_POST['gender'];
                 $department = $_POST['department'];
                 $position = $_POST['position'];
                 $salary = $_POST['salary'];
                 $this->createEmployee($name, $mobile, $email, $address, $gender, $department, $position, $salary);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'editEmployee') {
             if (isset($_POST['id']) && isset($_POST['name']) && isset($_POST['tel']) && isset($_POST['department']) && isset($_POST['position']) && isset($_POST['salary'])) {
                 $employeeid = $_POST['id'];
                 $name = $_POST['name'];
                 $mobile = $_POST['tel'];
                 $email = $_POST['email'];
                 $address = $_POST['address'];
                 $gender = $_POST['gender'];
                 $department = $_POST['department'];
                 $position = $_POST['position'];
                 $salary = $_POST['salary'];
                 $this->updateEmployee($employeeid, $name, $mobile, $email, $address, $gender, $department, $position, $salary);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'deleteEmployee') {
             if (isset($_POST['id'])) {
                 $employeeid = $_POST['id'];
                 $this->deleteEmployee($employeeid);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'postAllowance') {
             if (isset($_POST['id']) && isset($_POST['date']) && isset($_POST['ledger']) && isset($_POST['amount']) && isset($_POST['descr'])) {
                 $empid = $_POST['id'];
                 $date = $_POST['date'];
                 $ledger = $_POST['ledger'];
                 $amount = $_POST['amount'];
                 $descr = $_POST['descr'];
                 $this->postAllowance($empid, $date, $ledger, $amount, $descr);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'postOvertime') {
             if (isset($_POST['id']) && isset($_POST['date']) && isset($_POST['rate']) && isset($_POST['hours']) && isset($_POST['descr'])) {
                 $empid = $_POST['id'];
                 $date = $_POST['date'];
                 $rate = $_POST['rate'];
                 $hours = $_POST['hours'];
                 $descr = $_POST['descr'];
                 $this->postOvertime($empid, $date, $rate, $hours, $descr);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'payAdvance') {
             if (isset($_POST['id']) && isset($_POST['date']) && isset($_POST['amount']) && isset($_POST['ledger']) && isset($_POST['mode']) && isset($_POST['voucher']) && isset($_POST['descr'])) {
                 $empid = $_POST['id'];
                 $date = $_POST['date'];
                 $amount = $_POST['amount'];
                 $descr = $_POST['descr'];
                 $ledger = $_POST['ledger'];
                 $mode = $_POST['mode'];
                 $voucher = $_POST['voucher'];
                 $this->payAdvance($empid, $date, $amount, $ledger, $mode, $voucher, $descr);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'previewPayroll') {
             if (isset($_POST['month'])) {
                 $month = $_POST['month'];
                 $this->previewPayroll($month);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'commitPayroll') {
             if (isset($_POST['month'])) {
                 $month = $_POST['month'];
                 $this->commitPayroll($month);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'paySalary') {
             if (isset($_POST['employee']) && isset($_POST['slip']) && isset($_POST['ledger']) && isset($_POST['mode']) && isset($_POST['amount']) && isset($_POST['voucher'])) {
                 if ($_POST['ledger'] != 101) {
                     if (FinancialTransaction::VoucherInUse($_POST['voucher'])) {
                         echo 0;
                         exit;
                     }
                 }
                 $empid = $_POST['employee'];
                 $slip = $_POST['slip'];
                 $ledger = $_POST['ledger'];
                 $mode = $_POST['mode'];
                 $voucher = $_POST['voucher'];
                 $amount = $_POST['amount'];
                 $this->paySalary($empid, $slip, $ledger, $mode, $voucher, $amount);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'findEmployeeEntries') {
             if (isset($_POST['employee'])) {
                 $employee = $_POST['employee'];
                 $dates = $_POST['dates'];
                 $all = $_POST['vall'];
                 $this->findEmployeeEntries($employee, $dates, $all);
             } else {
                 echo 0;
             }
         } else {
             echo 0;
         }
     } elseif (isset($_GET['employees'])) {
         $this->getEmployees();
     } elseif (isset($_GET['employee']) && isset($_GET['empid'])) {
         $this->getEmployee($_GET['empid']);
     } elseif (isset($_GET['unclearedslips']) && isset($_GET['empid'])) {
         $this->getUnclearedPayslips($_GET['empid']);
     } elseif (isset($_GET['exemployees'])) {
         $this->getExEmployees();
     } else {
         echo 0;
     }
 }
 function __construct($entries, $amount, $description, $classifier)
 {
     //$this->status = $status;
     $this->txentries = $entries;
     $txtype = new DirectPosting($entries, $amount, $classifier);
     parent::__construct(new Money(floatval($amount), Currency::Get('KES')), $description, $txtype);
 }
 function __construct(Money $amount, $description, TransactionType $invoicingMethod)
 {
     //$ttype === posting protocol/rule
     parent::__construct($amount, $description, $invoicingMethod);
 }
Exemple #5
0
 public function __construct()
 {
     if (isset($_POST['operation'])) {
         $operation = $_POST['operation'];
         if ($operation == 'postQuoteInvoice') {
             if (isset($_POST['client']) && isset($_POST['purpose']) && isset($_POST['quotes'])) {
                 $clientid = $_POST['client'];
                 $scope = $_POST['purpose'];
                 $discount = $_POST['discount'];
                 if (isset($_POST['quotes'])) {
                     $quotes = $_POST['quotes'];
                 } else {
                     $quotes = [];
                 }
                 $this->postQuoteInvoice($clientid, $scope, $quotes, $discount);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'postGenInvoice') {
             if (isset($_POST['client']) && isset($_POST['scope']) && isset($_POST['items'])) {
                 $clientid = $_POST['client'];
                 $scope = $_POST['scope'];
                 $items = $_POST['items'];
                 $discount = $_POST['discount'];
                 $this->postGenInvoice($clientid, $scope, $items, $discount);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'issueCrNote') {
             if (isset($_POST['client']) && isset($_POST['invoice']) && isset($_POST['descr']) && isset($_POST['items'])) {
                 $clientid = $_POST['client'];
                 $invoice = $_POST['invoice'];
                 $items = $_POST['items'];
                 $descr = $_POST['descr'];
                 $this->issueCrNote($clientid, $invoice, $items, $descr);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'issueCashCrNote') {
             if (isset($_POST['client']) && isset($_POST['invoice']) && isset($_POST['descr']) && isset($_POST['credit'])) {
                 $clientid = $_POST['client'];
                 $invoice = $_POST['invoice'];
                 $credit = $_POST['credit'];
                 $descr = $_POST['descr'];
                 $this->issueCashCrNote($clientid, $invoice, $credit, $descr);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'receivePayment') {
             if (isset($_POST['client']) && isset($_POST['mode']) && isset($_POST['amount']) && isset($_POST['category']) && isset($_POST['voucher'])) {
                 if ($_POST['mode'] != 101) {
                     if (FinancialTransaction::VoucherInUse($_POST['voucher'])) {
                         echo 0;
                         exit;
                     }
                 }
                 $clientid = $_POST['client'];
                 $account = $_POST['mode'];
                 $category = $_POST['category'];
                 $amount = $_POST['amount'];
                 $descr = $_POST['descr'];
                 $voucher = $_POST['voucher'];
                 $this->receivePayment($clientid, $category, $account, $amount, $voucher, $descr);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'createLedger') {
             if (isset($_POST['name']) && isset($_POST['type']) && isset($_POST['group']) && isset($_POST['category'])) {
                 $name = $_POST['name'];
                 $type = $_POST['type'];
                 $group = $_POST['group'];
                 $category = $_POST['category'];
                 $subaccount = $_POST['subaccount'];
                 $this->createLedger($name, $type, $group, $category, $subaccount);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'deleteLedger') {
             if (isset($_POST['lid'])) {
                 $this->deleteLedger($_POST['lid']);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'postTransaction') {
             if (isset($_POST['entries']) && isset($_POST['descr']) && isset($_POST['amount'])) {
                 $entries = $_POST['entries'];
                 $descr = $_POST['descr'];
                 $amount = $_POST['amount'];
                 $this->postTransaction($entries, $amount, $descr);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'findEntries') {
             if (isset($_POST['param']) && isset($_POST['value'])) {
                 $param = $_POST['param'];
                 $value = $_POST['value'];
                 $this->findEntries($param, $value);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'reverseTX') {
             if (isset($_POST['txid'])) {
                 $txid = $_POST['txid'];
                 $this->reverseTX($txid);
             } else {
                 echo 2;
             }
         } elseif ($operation == 'processClaim') {
             if (isset($_POST['account']) && isset($_POST['voucher']) && isset($_POST['items'])) {
                 if ($_POST['account'] != 101) {
                     if (FinancialTransaction::VoucherInUse($_POST['voucher'])) {
                         echo 0;
                         exit;
                     }
                 }
                 $ledgerId = $_POST['account'];
                 $voucherId = $_POST['voucher'];
                 $items = $_POST['items'];
                 $details = "Payment of expense claims. Voucher Id: " . $voucherId . ", Project Id: " . $_POST['project'];
                 $this->processClaim($ledgerId, $voucherId, $items, $details);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'postExpense') {
             if (isset($_POST['context']) && isset($_POST['credit']) && isset($_POST['debit']) && isset($_POST['amount']) && isset($_POST['voucher']) && isset($_POST['descr'])) {
                 if ($_POST['credit'] != 101) {
                     if (FinancialTransaction::VoucherInUse($_POST['voucher'])) {
                         echo 0;
                         exit;
                     }
                 }
                 $party = $_POST['context'];
                 if ($party == 'office') {
                     $party = 0;
                 } else {
                     $party == intval($party);
                 }
                 $credit = $_POST['credit'];
                 $debit = $_POST['debit'];
                 $amount = $_POST['amount'];
                 $voucher = $_POST['voucher'];
                 $descr = $_POST['descr'];
                 $this->postExpense($party, $credit, $debit, $amount, $voucher, $descr);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'injectCapital') {
             if (isset($_POST['credit']) && isset($_POST['debit']) && isset($_POST['amount']) && isset($_POST['descr'])) {
                 $credit = $_POST['credit'];
                 $debit = $_POST['debit'];
                 $amount = $_POST['amount'];
                 $descr = $_POST['descr'];
                 $this->injectCapital($credit, $debit, $amount, $descr);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'postC2BBankTx') {
             if (isset($_POST['action']) && isset($_POST['account']) && isset($_POST['voucher']) && isset($_POST['amount']) && isset($_POST['descr'])) {
                 if (FinancialTransaction::VoucherInUse($_POST['voucher'])) {
                     echo 0;
                     exit;
                 }
                 $this->postC2BBankTx($_POST['action'], $_POST['account'], $_POST['voucher'], $_POST['amount'], $_POST['descr']);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'postB2BBankTx') {
             if (isset($_POST['account1']) && isset($_POST['account2']) && isset($_POST['voucher']) && isset($_POST['amount']) && isset($_POST['descr'])) {
                 if (FinancialTransaction::VoucherInUse($_POST['voucher'])) {
                     echo 0;
                     exit;
                 }
                 $this->postB2BBankTx($_POST['account1'], $_POST['account2'], $_POST['voucher'], $_POST['amount'], $_POST['descr']);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'findClientEntries') {
             if (isset($_POST['client']) && isset($_POST['category'])) {
                 $client = $_POST['client'];
                 $category = $_POST['category'];
                 $dates = $_POST['dates'];
                 $all = $_POST['vall'];
                 $this->findClientEntries($client, $category, $dates, $all);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'checkauth') {
             $this->check_auth();
         } else {
             echo 0;
         }
     } elseif (isset($_GET['banks'])) {
         $this->getBanks();
     } elseif (isset($_GET['noncashbanks'])) {
         $this->getNonCashBanks();
     } elseif (isset($_GET['allLedgers'])) {
         $this->getLedgers();
     } elseif (isset($_GET['purchaseLedgers'])) {
         $this->getPurchaseLedgers();
     } elseif (isset($_GET['ledgerName'])) {
         $this->getLedgerByName($_GET['ledgerName']);
     } elseif (isset($_GET['ledgerType'])) {
         $this->getLedgerType($_GET['ledgerType']);
     } elseif (isset($_GET['invoices']) && isset($_GET['clientid'])) {
         $this->getClientInvoices($_GET['clientid']);
     } else {
         echo 0;
     }
 }
 /**
  * This method performs a financial transaction against this payment object.
  * 
  * @throws jmsPaymentApprovalExpiredException
  * @throws jmsPaymentCommunicationException
  * @throws jmsPaymentFinancialException
  * @throws jmsPaymentFunctionNotSupportedException
  * @throws jmsPaymentTimeoutException
  * @throws jmsPaymentUserActionRequiredException
  * @param mixed $transaction One of the FinancialTransaction::TYPE_* constants,
  *                           or an instance of FinancialTransaction
  * @return void
  */
 public final function performTransaction($transaction)
 {
     if (is_string($transaction)) {
         $transaction = FinancialTransaction::create($transaction, $this);
     }
     if (!$transaction instanceof FinancialTransaction) {
         throw new InvalidArgumentException(sprintf('"%s" must inherit from FinancialTransaction.', get_class($transaction)));
     }
     // for now, only transactions which are NEW or PENDING can be executed
     // against this payment
     if ($transaction->isInFinalState() === true) {
         throw new LogicException('The given transaction is already in a final state.');
     }
     // check if this payment is in a final state. If so, no transactions can be
     // performed against it.
     if ($this->isInFinalState()) {
         throw new LogicException('This payment is in a final state; no transactions' . ' can be performed against it.');
     }
     // verify that the transaction belongs to this payment
     if ($transaction->Payment !== $this) {
         throw new InvalidArgumentException('The given transaction already belongs to another payment.');
     }
     $event = $this->dispatchEvent(new jmsPaymentTransactionEvent(self::EVENT_PRE_TRANSACTION, $this, $transaction));
     if ($event->isPreventDefault() === true) {
         $transaction->state = FinancialTransaction::STATE_CANCELED;
         $transaction->save();
         throw new jmsPaymentFinancialException('The transaction was prevented by one of the listeners.');
     }
     $transaction->execute();
     // TODO: Consider dispatching an event for transactions which do not
     //       complete successfully. Maybe split into EVENT_POST_SUCCESSFUL_TRANSACTION
     //       and EVENT_POST_UNSUCCESSFUL_TRANSACTION?
     $this->dispatchEvent(new jmsPaymentTransactionEvent(self::EVENT_POST_TRANSACTION, $this, $transaction));
 }
Exemple #7
0
 function __construct($id, $clientId, $projectId, $voucherNo, $amount, $ledgerId, $descr, $status)
 {
     $this->id = $id;
     $this->clientId = $clientId;
     $this->projectId = intval($projectId);
     $this->voucherNo = $voucherNo;
     $this->ledgerId = $ledgerId;
     $this->status = $status;
     $txtype = new SalesReceipt($ledgerId, $clientId);
     parent::__construct(new Money(floatval($amount), Currency::Get('KES')), $descr, $txtype);
     $this->update();
 }
Exemple #8
0
 function __construct($id, $partyId, $month, $amount, $type, $effect, $ledgerId, $descr, $txtype, $table)
 {
     $this->id = $id;
     $this->partyId = $partyId;
     $this->month = $month;
     $this->ledgerId = $ledgerId;
     $this->type = $type;
     $this->effect = $effect;
     parent::__construct(new Money(floatval($amount), Currency::Get('KES')), $descr, $txtype);
     $this->table = $table;
     $this->update();
 }
Exemple #9
0
 public function __construct()
 {
     if (isset($_POST['operation'])) {
         $operation = $_POST['operation'];
         if ($operation == 'addSupplier') {
             if (isset($_POST['name']) && isset($_POST['tel'])) {
                 $name = $_POST['name'];
                 $person = $_POST['person'];
                 $mobile = $_POST['tel'];
                 $email = $_POST['email'];
                 $address = $_POST['address'];
                 $bal = $_POST['bal'];
                 $this->createSupplier($name, $person, $mobile, $email, $address, $bal);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'editSupplier') {
             if (isset($_POST['id']) && isset($_POST['name']) && isset($_POST['tel'])) {
                 $supplierid = $_POST['id'];
                 $name = $_POST['name'];
                 $person = $_POST['person'];
                 $mobile = $_POST['tel'];
                 $email = $_POST['email'];
                 $address = $_POST['address'];
                 $this->updateSupplier($supplierid, $name, $person, $mobile, $email, $address);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'deleteSupplier') {
             if (isset($_POST['id'])) {
                 $supplierid = $_POST['id'];
                 $this->deleteSupplier($supplierid);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'genPurchOrder') {
             if (isset($_POST['supplier']) && isset($_POST['date']) && isset($_POST['items'])) {
                 $supplierid = $_POST['supplier'];
                 $date = $_POST['date'];
                 if (isset($_POST['items'])) {
                     $items = $_POST['items'];
                 } else {
                     $items = [];
                 }
                 $this->generatePurchaseOrder($supplierid, $date, $items);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'postGenPurchase') {
             if (isset($_POST['supplier']) && isset($_POST['invno']) && isset($_POST['date']) && isset($_POST['items'])) {
                 $supplierid = $_POST['supplier'];
                 $invno = $_POST['invno'];
                 $date = $_POST['date'];
                 $items = $_POST['items'];
                 $this->postGenPurchase($supplierid, $invno, $date, $items);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'postOrderPurchase') {
             if (isset($_POST['supplier']) && isset($_POST['invno']) && isset($_POST['date']) && isset($_POST['items'])) {
                 $supplierid = $_POST['supplier'];
                 $invno = $_POST['invno'];
                 $date = $_POST['date'];
                 $items = $_POST['items'];
                 $this->postOrderPurchase($supplierid, $invno, $date, $items);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'makePaymentGRN') {
             if (isset($_POST['supplier']) && isset($_POST['account']) && isset($_POST['mode']) && isset($_POST['amount']) && isset($_POST['payments']) && isset($_POST['voucher']) && isset($_POST['descr'])) {
                 if ($_POST['account'] != 101) {
                     if (FinancialTransaction::VoucherInUse($_POST['voucher'])) {
                         echo 0;
                         exit;
                     }
                 }
                 $supplierid = $_POST['supplier'];
                 $amount = $_POST['amount'];
                 $account = $_POST['account'];
                 $mode = $_POST['mode'];
                 $voucher = $_POST['voucher'];
                 $payments = $_POST['payments'];
                 $descr = $_POST['descr'];
                 $this->makePaymentGRN($supplierid, $amount, $account, $mode, $voucher, $payments, $descr);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'makePayment') {
             if (isset($_POST['context']) && isset($_POST['scope']) && isset($_POST['supplier']) && isset($_POST['account']) && isset($_POST['mode']) && isset($_POST['amount']) && isset($_POST['descr']) && isset($_POST['voucher'])) {
                 if ($_POST['account'] != 101) {
                     if (FinancialTransaction::VoucherInUse($_POST['voucher'])) {
                         echo 0;
                         exit;
                     }
                 }
                 $party = $_POST['context'];
                 if ($party == 'office') {
                     $party = 0;
                 } else {
                     $party == intval($party);
                 }
                 $scope = $_POST['scope'];
                 if ($scope == 'office') {
                     $scope = 0;
                 } else {
                     $scope == intval($scope);
                 }
                 $supplierid = $_POST['supplier'];
                 $amount = $_POST['amount'];
                 $account = $_POST['account'];
                 $mode = $_POST['mode'];
                 $voucher = $_POST['voucher'];
                 $descr = $_POST['descr'];
                 $this->makePayment($party, $scope, $supplierid, $amount, $account, $mode, $voucher, $descr);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'findSupplierEntries') {
             if (isset($_POST['supplier']) && isset($_POST['category'])) {
                 $supplier = $_POST['supplier'];
                 $category = $_POST['category'];
                 $dates = $_POST['dates'];
                 $all = $_POST['vall'];
                 $this->findSupplierEntries($supplier, $category, $dates, $all);
             } else {
                 echo 0;
             }
         } elseif ($operation == 'logout') {
             $this->logout();
         } elseif ($operation == 'checkauth') {
             $this->check_auth();
         } else {
             echo 0;
         }
     } elseif (isset($_GET['pending'])) {
         $this->getPending();
     } elseif (isset($_GET['suppliers'])) {
         $this->getSuppliers();
     } elseif (isset($_GET['porders']) && isset($_GET['supplierid'])) {
         $this->getPurchaseOrders($_GET['supplierid']);
     } elseif (isset($_GET['porder']) && isset($_GET['orderid'])) {
         $this->getPurchaseOrder($_GET['orderid']);
     } elseif (isset($_GET['unclearedinvoices']) && isset($_GET['supplier'])) {
         $this->getUnclearedInvoices($_GET['supplier']);
     } elseif (isset($_GET['supplier']) && isset($_GET['supplierid'])) {
         $this->getSupplier($_GET['supplierid']);
     } else {
         echo 0;
     }
 }