Esempio n. 1
0
        if ($s->check(true, $token, "CREATE_NOTE")) {
            $o->updatedby = $xoopsUser->getVar('uid');
            //get current uid
            if (!$pl->createDebitCreditNoteLine($o->debitcreditnote_id, $o->adddebitcreditnotelineqty)) {
                $log->showLog(1, 'Fail to add debitcreditnoteline, you may try to add more debitcreditnote 
				line after form refresh');
            }
            $o->itemqty = $o->getLineCount($o->debitcreditnote_id);
            $pl->updateDebitCreditNoteLine();
            if ($o->updateDebitCreditNote()) {
                //if data save successfully
                if ($o->iscomplete == 1) {
                    $itemqty = $o->getLineCount($o->debitcreditnote_id);
                    $pl->updateTotalAmt($o->debitcreditnote_id, $cur, $o->currency_id, $itemqty);
                    include_once "class/AccountsAPI.php";
                    $accapi = new AccountsAPI();
                    /*
                    	if($o->documenttype==1){
                    		$amt1=$o->amt;
                    		$amt2=$o->amt*-1;
                    		$originalamt1=$o->originalamt;
                    		$originalamt2=$o->originalamt*-1;
                    		$documentname="debit note";
                    
                    		}
                    	elseif($o->documenttype==2){
                    		$amt1=$o->amt*-1;
                    		$amt2=$o->amt;
                    		$originalamt1=$o->originalamt*-1;
                    		$originalamt2=$o->originalamt;
                    		$documentname="credit note";
 public function posting()
 {
     include "../simbiz/class/AccountsAPI.php";
     $multiply = 1;
     if ($this->issotrx == 1) {
         $multiply = -1;
     }
     $acc = new AccountsAPI();
     global $defaultcurrency_id, $defaultorganization_id, $userid, $taxaccount_id, $xoopsUser;
     $documentnoarray = array($this->sppayment_prefix . $this->document_no);
     $totaltransactionamt = $this->subtotal;
     $accountsarray = array($this->bpartneraccounts_id);
     $amtarray = array($this->subtotal * $multiply);
     $currencyarray = array($defaultcurrency_id);
     $conversionarray = array(1);
     $originalamtarray = array($this->subtotal * $multiply);
     $bpartnerarray = array($this->bpartner_id);
     $linetypearray = array(0);
     $transtypearray = array("");
     $chequenoarray = array("");
     $linedesc = array($this->description);
     $orgarray = array($this->organization_id);
     $track1array = array($this->track1_id);
     $track2array = array($this->track2_id);
     $track3array = array($this->track3_id);
     $sql = "SELECT pl.invoice_id,concat(i.spinvoice_prefix,i.document_no) as invoice_no,pl.chequeno,\n        pl.amt,pl.branch_id,pl.track1_id,pl.track2_id,pl.track3_id,pl.accounts_id\n        from sim_simbiz_paymentline pl\n        inner join sim_simbiz_invoice i on pl.invoice_id=i.invoice_id\n        where payment_id={$this->payment_id}";
     $query = $this->xoopsDB->query($sql);
     $this->log->showLog(4, "Posting payment with SQL:  {$sql}");
     //$taxaccount_id=
     //declare 2nd line and above as creditor
     while ($row = $this->xoopsDB->fetchArray($query)) {
         array_push($documentnoarray, $this->sppayment_prefix . $this->document_no);
         array_push($accountsarray, $row['accounts_id']);
         array_push($amtarray, $row['amt'] * -1 * $multiply);
         array_push($currencyarray, $defaultcurrency_id);
         array_push($conversionarray, 1);
         array_push($originalamtarray, $row['amt'] * -1 * $multiply);
         array_push($bpartnerarray, 0);
         array_push($linetypearray, 1);
         array_push($transtypearray, "");
         array_push($chequenoarray, $row['chequeno']);
         array_push($linedesc, "Payment ({$this->sppayment_prefix}{$this->document_no}), from {$this->bpartner_name}");
         array_push($orgarray, $row['branch_id']);
         array_push($track1array, $row['track1_id']);
         array_push($track2array, $row['track2_id']);
         array_push($track3array, $row['track3_id']);
     }
     //        $a=array($uid,
     //            $this->document_date,
     //            "simbiz",
     //            "Payment: $this->sppayment_prefix$this->document_no",
     //            $this->description,
     //            $this->localamt,
     //               $documentnoarray,
     //		$accountsarray,
     //            $amtarray,
     //            $currencyarray,
     //            $conversionarray,
     //            $originalamtarray,
     //            $bpartnerarray,
     //            $transtypearray,
     //            $linetypearray,
     //		$chequenoarray,
     //            "",
     //            1,
     //            "",
     //            $orgarray,
     //            $track1array,
     //            $track2array,
     //            $track3array);
     $uname = $xoopsUser->getVar('uname');
     if ($acc->PostBatch($userid, $this->document_date, "simbiz", "Payment {$this->sppayment_prefix}{$this->document_no}", "Post from Simbiz: Payment ({$this->sppayment_prefix}{$this->document_no}), from {$uname}", $this->subtotal, $documentnoarray, $accountsarray, $amtarray, $currencyarray, $conversionarray, $originalamtarray, $bpartnerarray, $transtypearray, $linetypearray, $chequenoarray, $linedesc, 1, "", $orgarray, $track1array, $track2array, $track3array)) {
         $this->batch_id = $acc->resultbatch_id;
         $this->xoopsDB->query("update sim_simbiz_payment set batch_id={$acc->resultbatch_id},iscomplete=1 where payment_id={$this->payment_id}");
         return true;
     } else {
         return false;
     }
 }
Esempio n. 3
0
\t\t//alert(self.parent.document.getElementById('divbpartner').innerHTML);
\t\tself.parent.document.getElementById('divbpartner').innerHTML="{$bpartnerctrl}";

\t\tif({$acc->account_type} == 2 || {$acc->account_type} ==3)
\t\tself.parent.document.getElementById('bpartnerID').innerHTML="";
\t\t//\tself.parent.document.getElementById('bpartner_id').value=0;

\t\tself.parent.changePaidFrom(self.parent.document.frmPaymentVoucher.bpartner_id);
\t</script>
EOF;
        break;
    case "reactivate":
        if ($o->fetchPaymentVoucher($o->paymentvoucher_id)) {
            $o->iscomplete = 0;
            include_once "class/AccountsAPI.php";
            $accapi = new AccountsAPI();
            $result = $accapi->reverseBatch($o->batch_id);
            if ($result) {
                $o->iscomplete = 0;
                $o->batch_id = 0;
                $o->updatePaymentVoucher();
                redirect_header("paymentvoucher.php?action=edit&paymentvoucher_id={$o->paymentvoucher_id}", $pausetime, "Record reactivated, transaction in accounts is reversed.");
            } else {
                redirect_header("paymentvoucher.php?action=edit&paymentvoucher_id={$o->paymentvoucher_id}", $pausetime, "<b style='color:red'>PaymentVoucher can't reactivated due to internal error.</b>");
            }
        }
        break;
    case "refreshaccountsto":
        $accounts_id = $_POST['accounts_id'];
        $line = $_POST['line'];
        include_once "class/Accounts.php";
Esempio n. 4
0
     if ($o->fetchPayment($_POST['payment_id'])) {
         if ($o->posting()) {
             echo "<result><status>1</status><detail><msg>Record post successfully.</msg></detail></result>";
         } else {
             echo "<result><status>0</status><detail><msg>Error, you cannot post record</msg></detail></result>";
         }
     } else {
         echo "<result><status>0</status><detail><msg>Error, you cannot post record due to cannot fetch payment from database</msg></detail></result>";
     }
     die;
     break;
 case "reactivate":
     $payment_id = $_POST['payment_id'];
     if ($o->fetchPayment($payment_id)) {
         include "../simbiz/class/AccountsAPI.php";
         $acc = new AccountsAPI();
         if ($acc->reverseBatch($o->batch_id)) {
             $o->iscomplete = 0;
             if ($xoopsDB->query("update sim_simbiz_payment set iscomplete=0 where payment_id=" . $payment_id)) {
                 $arr = array("status" => 1);
             } else {
                 $arr = array("status" => 0, "msg" => "cannot update payment status to not complete, probably due to sql error");
             }
         } else {
             $arr = array("status" => 0, "msg" => "Cannot reverse transaction, probably due to financial year issue");
         }
     } else {
         $arr = array("status" => 0, "msg" => "Cannot reverse transaction, fetch sql error");
     }
     echo json_encode($arr);
     die;
Esempio n. 5
0
 public function posting()
 {
     include "../simbiz/class/AccountsAPI.php";
     $multiply = 1;
     if ($this->issotrx == 0) {
         $multiply = -1;
     }
     $acc = new AccountsAPI();
     global $defaultcurrency_id, $defaultorganization_id, $userid, $taxaccount_id, $xoopsUser;
     $documentnoarray = array($this->spinvoice_prefix . $this->document_no);
     $totaltransactionamt = $this->localamt;
     $accountsarray = array($this->bpartneraccounts_id);
     $amtarray = array($this->localamt * $multiply);
     $currencyarray = array($defaultcurrency_id);
     $conversionarray = array(1);
     $originalamtarray = array($this->localamt * $multiply);
     $bpartnerarray = array($this->bpartner_id);
     $linetypearray = array(0);
     $transtypearray = array("");
     $chequenoarray = array("");
     $linedesc = array($this->description);
     $orgarray = array($this->organization_id);
     $track1array = array($this->track1_id);
     $track2array = array($this->track2_id);
     $track3array = array($this->track3_id);
     $rowgettaxaccount = $this->xoopsDB->fetchArray($this->xoopsDB->query("Select accounts_id from sim_simbiz_accounts where account_type=9"));
     $taxaccount_id = $rowgettaxaccount['accounts_id'];
     $sql = "SELECT * from sim_simbiz_invoiceline where invoice_id={$this->invoice_id}";
     $query = $this->xoopsDB->query($sql);
     $totalgstamt = 0;
     //$taxaccount_id=
     //declare 2nd line and above as creditor
     while ($row = $this->xoopsDB->fetchArray($query)) {
         array_push($documentnoarray, $this->spinvoice_prefix . $this->document_no);
         array_push($accountsarray, $row['accounts_id']);
         array_push($amtarray, $row['amt'] * -1 * $multiply);
         array_push($currencyarray, $defaultcurrency_id);
         array_push($conversionarray, 1);
         array_push($originalamtarray, $row['amt'] * -1 * $multiply);
         array_push($bpartnerarray, 0);
         array_push($linetypearray, 1);
         array_push($transtypearray, "");
         array_push($chequenoarray, "");
         array_push($linedesc, $row['subject']);
         array_push($orgarray, $row['branch_id']);
         array_push($track1array, $row['track1_id']);
         array_push($track2array, $row['track2_id']);
         array_push($track3array, $row['track3_id']);
         $totalgstamt += $row['gstamt'];
     }
     if ($totalgstamt != 0) {
         array_push($documentnoarray, $this->spinvoice_prefix . $this->document_no);
         array_push($accountsarray, $taxaccount_id);
         array_push($amtarray, $totalgstamt * -1 * $multiply);
         array_push($currencyarray, $defaultcurrency_id);
         array_push($conversionarray, 1);
         array_push($originalamtarray, $totalgstamt * -1 * $multiply);
         array_push($bpartnerarray, 0);
         array_push($transtypearray, "");
         array_push($linetypearray, 1);
         array_push($chequenoarray, "");
         array_push($linedesc, "Tax");
         array_push($orgarray, $this->organization_id);
         array_push($track1array, 0);
         array_push($track2array, 0);
         array_push($track3array, 0);
     }
     //        $a=array($uid,
     //            $this->document_date,
     //            "simbiz",
     //            "Invoice: $this->spinvoice_prefix$this->document_no",
     //            $this->description,
     //            $this->localamt,
     //               $documentnoarray,
     //		$accountsarray,
     //            $amtarray,
     //            $currencyarray,
     //            $conversionarray,
     //            $originalamtarray,
     //            $bpartnerarray,
     //            $transtypearray,
     //            $linetypearray,
     //		$chequenoarray,
     //            "",
     //            1,
     //            "",
     //            $orgarray,
     //            $track1array,
     //            $track2array,
     //            $track3array);
     $uname = $xoopsUser->getVar('uname');
     if ($acc->PostBatch($userid, $this->document_date, "simbiz", "Invoice {$this->spinvoice_prefix}{$this->document_no}", "Post from Simbiz: Invoice ({$this->spinvoice_prefix}{$this->document_no}), from {$uname}", $this->localamt, $documentnoarray, $accountsarray, $amtarray, $currencyarray, $conversionarray, $originalamtarray, $bpartnerarray, $transtypearray, $linetypearray, $chequenoarray, $linedesc, 1, "", $orgarray, $track1array, $track2array, $track3array)) {
         $this->batch_id = $acc->resultbatch_id;
         $this->xoopsDB->query("update sim_simbiz_invoice set batch_id={$acc->resultbatch_id},iscomplete=1 where invoice_id={$this->invoice_id}");
         return true;
     } else {
         return false;
     }
 }
Esempio n. 6
0
\talert("Retain earning posted! batch no:{$newbatchno}");
        self.parent.document.getElementById("divperiod{$financialyearline_id}").innerHTML="<A href='batch.php?action=view&batch_id={$api->resultbatch_id}'> Amount: {$amt} (Posted as Batch No: {$newbatchno})</A>";

\t
\t</script>
EOF;
        break;
    case "repost":
        $batch_id = $_POST['batch_id'];
        $batchno = $_POST['batchno'];
        $newamt = $_POST['newamt'] * -1;
        $financialyearline_id = $_POST['financialyearline_id'];
        $reactivateresult = "failed";
        include "class/AccountsAPI.php";
        $api = new AccountsAPI();
        if ($batch_id > 0) {
            if ($api->reActivateBatch($batch_id)) {
                $arraytrans_id = $l->getRetainEarningTransaction($batch_id);
                $trans1 = $arraytrans_id[0];
                $trans2 = $arraytrans_id[1];
                if ($api->updateTransactionAmount($batch_id, $newamt, $arraytrans_id, array($newamt, $newamt * -1))) {
                    $reactivateresult = "success";
                }
            }
        }
        $newamt = $newamt * -1;
        if ($newamt == 0) {
            $newamt = 0;
        }
        echo <<<EOF