当前位置: 首页>>代码示例>>PHP>>正文


PHP GetSalesGLAccount函数代码示例

本文整理汇总了PHP中GetSalesGLAccount函数的典型用法代码示例。如果您正苦于以下问题:PHP GetSalesGLAccount函数的具体用法?PHP GetSalesGLAccount怎么用?PHP GetSalesGLAccount使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetSalesGLAccount函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: gltrans

         /*first the cost of sales entry*/
         $SQL = "INSERT INTO gltrans (\r\n\t\t\t\t\t\t\ttype,\r\n\t\t\t\t\t\t\ttypeno,\r\n\t\t\t\t\t\t\ttrandate,\r\n\t\t\t\t\t\t\tperiodno,\r\n\t\t\t\t\t\t\taccount,\r\n\t\t\t\t\t\t\tnarrative,\r\n\t\t\t\t\t\t\tamount\r\n\t\t\t\t\t\t\t)\r\n\t\t\t\t\tVALUES (\r\n\t\t\t\t\t\t10,\r\n\t\t\t\t\t\t" . $InvoiceNo . ",\r\n\t\t\t\t\t\t'" . $DefaultDispatchDate . "',\r\n\t\t\t\t\t\t" . $PeriodNo . ",\r\n\t\t\t\t\t\t" . GetCOGSGLAccount($Area, $OrderLine->StockID, $_SESSION['Items']->DefaultSalesType, $db) . ",\r\n\t\t\t\t\t\t'" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " x " . $OrderLine->QtyDispatched . " @ " . $OrderLine->StandardCost . "',\r\n\t\t\t\t\t\t" . $OrderLine->StandardCost * $OrderLine->QtyDispatched . "\r\n\t\t\t\t\t)";
         $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The cost of sales GL posting could not be inserted because');
         $DbgMsg = _('The following SQL to insert the GLTrans record was used');
         $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
         /*now the stock entry*/
         $StockGLCode = GetStockGLCode($OrderLine->StockID, $db);
         $SQL = "INSERT INTO gltrans (\r\n\t\t\t\t\t\t\ttype,\r\n\t\t\t\t\t\t\ttypeno,\r\n\t\t\t\t\t\t\ttrandate,\r\n\t\t\t\t\t\t\tperiodno,\r\n\t\t\t\t\t\t\taccount,\r\n\t\t\t\t\t\t\tnarrative,\r\n\t\t\t\t\t\t\tamount)\r\n\t\t\t\t\tVALUES (\r\n\t\t\t\t\t\t10,\r\n\t\t\t\t\t\t" . $InvoiceNo . ",\r\n\t\t\t\t\t\t'" . $DefaultDispatchDate . "',\r\n\t\t\t\t\t\t" . $PeriodNo . ",\r\n\t\t\t\t\t\t" . $StockGLCode['stockact'] . ",\r\n\t\t\t\t\t\t'" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " x " . $OrderLine->QtyDispatched . " @ " . $OrderLine->StandardCost . "',\r\n\t\t\t\t\t\t" . -$OrderLine->StandardCost * $OrderLine->QtyDispatched . "\r\n\t\t\t\t\t)";
         $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The stock side of the cost of sales GL posting could not be inserted because');
         $DbgMsg = _('The following SQL to insert the GLTrans record was used');
         $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
     }
     /* end of if GL and stock integrated and standard cost !=0 */
     if ($_SESSION['CompanyRecord']['gllink_debtors'] == 1 and $OrderLine->Price != 0) {
         //Post sales transaction to GL credit sales
         $SalesGLAccounts = GetSalesGLAccount($Area, $OrderLine->StockID, $_SESSION['Items']->DefaultSalesType, $db);
         $SQL = "INSERT INTO gltrans (\r\n\t\t\t\t\t\t\ttype,\r\n\t\t\t\t\t\t\ttypeno,\r\n\t\t\t\t\t\t\ttrandate,\r\n\t\t\t\t\t\t\tperiodno,\r\n\t\t\t\t\t\t\taccount,\r\n\t\t\t\t\t\t\tnarrative,\r\n\t\t\t\t\t\t\tamount\r\n\t\t\t\t\t\t)\r\n\t\t\t\t\tVALUES (\r\n\t\t\t\t\t\t10,\r\n\t\t\t\t\t\t" . $InvoiceNo . ",\r\n\t\t\t\t\t\t'" . $DefaultDispatchDate . "',\r\n\t\t\t\t\t\t" . $PeriodNo . ",\r\n\t\t\t\t\t\t" . $SalesGLAccounts['salesglcode'] . ",\r\n\t\t\t\t\t\t'" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " x " . $OrderLine->QtyDispatched . " @ " . $OrderLine->Price . "',\r\n\t\t\t\t\t\t" . -$OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate'] . "\r\n\t\t\t\t\t)";
         $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The sales GL posting could not be inserted because');
         $DbgMsg = '<br>' . _('The following SQL to insert the GLTrans record was used');
         $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
         if ($OrderLine->DiscountPercent != 0) {
             $SQL = "INSERT INTO gltrans (\r\n\t\t\t\t\t\t\ttype,\r\n\t\t\t\t\t\t\ttypeno,\r\n\t\t\t\t\t\t\ttrandate,\r\n\t\t\t\t\t\t\tperiodno,\r\n\t\t\t\t\t\t\taccount,\r\n\t\t\t\t\t\t\tnarrative,\r\n\t\t\t\t\t\t\tamount\r\n\t\t\t\t\t\t)\r\n\t\t\t\t\t\tVALUES (\r\n\t\t\t\t\t\t\t10,\r\n\t\t\t\t\t\t\t" . $InvoiceNo . ",\r\n\t\t\t\t\t\t\t'" . $DefaultDispatchDate . "',\r\n\t\t\t\t\t\t\t" . $PeriodNo . ",\r\n\t\t\t\t\t\t\t" . $SalesGLAccounts['discountglcode'] . ",\r\n\t\t\t\t\t\t\t'" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " @ " . $OrderLine->DiscountPercent * 100 . "%',\r\n\t\t\t\t\t\t\t" . $OrderLine->Price * $OrderLine->QtyDispatched * $OrderLine->DiscountPercent / $_SESSION['CurrencyRate'] . "\r\n\t\t\t\t\t\t)";
             $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The sales discount GL posting could not be inserted because');
             $DbgMsg = _('The following SQL to insert the GLTrans record was used');
             $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
         }
         /*end of if discount !=0 */
     }
     /*end of if sales integrated with debtors */
 }
 /*Quantity dispatched is more than 0 */
开发者ID:bodi000,项目名称:weberp-cvs,代码行数:31,代码来源:ConfirmDispatch_Invoice.php

示例2: _

             $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The cost of the stock credited GL posting could not be inserted because');
             $DbgMsg = _('The following SQL to insert the GLTrans record was used');
             $Result = DB_query($SQL, $ErrMsg, $DbgMsg, true);
         } else {
             /*the goods are coming back into stock so debit the stock account*/
             $StockGLCode = GetStockGLCode($CreditLine->StockID, $db);
             $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\t\t\tVALUES (11,\n\t\t\t\t\t\t\t\t\t\t\t'" . $CreditNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $SQLCreditDate . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $StockGLCode['stockact'] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['CreditItems' . $identifier]->DebtorNo . " - " . $CreditLine->StockID . " x " . $CreditLine->Quantity . " @ " . $CreditLine->StandardCost . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $CreditLine->StandardCost * $CreditLine->Quantity . "'\n\t\t\t\t\t\t\t\t\t\t\t)";
             $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The stock side (or write off) of the cost of sales GL posting could not be inserted because');
             $DbgMsg = _('The following SQL to insert the GLTrans record was used');
             $Result = DB_query($SQL, $ErrMsg, $DbgMsg, true);
         }
     }
     /* end of if GL and stock integrated and standard cost !=0 */
     if ($_SESSION['CompanyRecord']['gllink_debtors'] == 1 and $CreditLine->Price != 0) {
         //Post sales transaction to GL credit sales
         $SalesGLAccounts = GetSalesGLAccount($Area, $CreditLine->StockID, $_SESSION['CreditItems' . $identifier]->DefaultSalesType, $db);
         $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\t\t\tVALUES (11,\n\t\t\t\t\t\t\t\t\t\t\t'" . $CreditNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $SQLCreditDate . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $SalesGLAccounts['salesglcode'] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['CreditItems' . $identifier]->DebtorNo . " - " . $CreditLine->StockID . " x " . $CreditLine->Quantity . " @ " . $CreditLine->Price . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $CreditLine->Price * $CreditLine->Quantity / $_SESSION['CurrencyRate'] . "'\n\t\t\t\t\t\t\t\t\t\t\t)";
         $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The credit note GL posting could not be inserted because');
         $DbgMsg = _('The following SQL to insert the GLTrans record was used');
         $Result = DB_query($SQL, $ErrMsg, $DbgMsg, true);
         if ($CreditLine->DiscountPercent != 0) {
             $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\t\tVALUES (11,\n\t\t\t\t\t\t\t\t\t\t'" . $CreditNo . "',\n\t\t\t\t\t\t\t\t\t\t'" . $SQLCreditDate . "',\n\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t'" . $SalesGLAccounts['discountglcode'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['CreditItems' . $identifier]->DebtorNo . " - " . $CreditLine->StockID . " @ " . $CreditLine->DiscountPercent * 100 . "%',\n\t\t\t\t\t\t\t\t\t\t'" . -($CreditLine->Price * $CreditLine->Quantity * $CreditLine->DiscountPercent / $_SESSION['CurrencyRate']) . "'\n\t\t\t\t\t\t\t\t\t\t)";
             $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The credit note discount GL posting could not be inserted because');
             $DbgMsg = _('The following SQL to insert the GLTrans record was used');
             $Result = DB_query($SQL, $ErrMsg, $DbgMsg, true);
         }
         /* end of if discount not equal to 0 */
     }
     /*end of if sales integrated with debtors */
 }
 /*Quantity credited is more than 0 */
开发者ID:fgaudenzi,项目名称:webERP-bootstrap,代码行数:31,代码来源:SelectCreditItems.php

示例3: _

 $DbgMsg = _('SQL to count the no of sales analysis records');
 $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
 $myrow = DB_fetch_row($Result);
 if ($myrow[0] > 0) {
     /*Update the existing record that already exists */
     $SQL = "UPDATE salesanalysis\n\t\t\t\t\tSET amt=amt+" . $RecurrOrderLineRow['unitprice'] * $RecurrOrderLineRow['quantity'] / $CurrencyRate . ",\n\t\t\t\t\tqty=qty +" . $RecurrOrderLineRow['quantity'] . ",\n\t\t\t\t\tdisc=disc+" . $RecurrOrderLineRow['discountpercent'] * $RecurrOrderLineRow['unitprice'] * $RecurrOrderLineRow['quantity'] / $CurrencyRate . "\n\t\t\t\t\tWHERE salesanalysis.area='" . $myrow[2] . "'\n\t\t\t\t\tAND salesanalysis.salesperson='" . $myrow[3] . "'\n\t\t\t\t\tAND typeabbrev ='" . $RecurrOrderRow['ordertype'] . "'\n\t\t\t\t\tAND periodno = " . $PeriodNo . "\n\t\t\t\t\tAND cust " . LIKE . " '" . $RecurrOrderRow['debtorno'] . "'\n\t\t\t\t\tAND custbranch " . LIKE . " '" . $RecurrOrderRow['branchcode'] . "'\n\t\t\t\t\tAND stockid " . LIKE . " '" . $RecurrOrderLineRow['stkcode'] . "'\n\t\t\t\t\tAND salesanalysis.stkcategory ='" . $myrow[1] . "'\n\t\t\t\t\tAND budgetoractual=1";
 } else {
     /* insert a new sales analysis record */
     $SQL = "INSERT INTO salesanalysis (\n\t\t\t\t\t\ttypeabbrev,\n\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\tamt,\n\t\t\t\t\t\tcost,\n\t\t\t\t\t\tcust,\n\t\t\t\t\t\tcustbranch,\n\t\t\t\t\t\tqty,\n\t\t\t\t\t\tdisc,\n\t\t\t\t\t\tstockid,\n\t\t\t\t\t\tarea,\n\t\t\t\t\t\tbudgetoractual,\n\t\t\t\t\t\tsalesperson,\n\t\t\t\t\t\tstkcategory\n\t\t\t\t\t\t)\n\t\t\t\t\tSELECT '" . $RecurrOrderRow['ordertype'] . "',\n\t\t\t\t\t\t" . $PeriodNo . ",\n\t\t\t\t\t\t" . $RecurrOrderLineRow['unitprice'] * $RecurrOrderLineRow['quantity'] / $CurrencyRate . ",\n\t\t\t\t\t\t0,\n\t\t\t\t\t\t'" . $RecurrOrderRow['debtorno'] . "',\n\t\t\t\t\t\t'" . $RecurrOrderRow['branchcode'] . "',\n\t\t\t\t\t\t" . $RecurrOrderLineRow['quantity'] . ",\n\t\t\t\t\t\t" . $RecurrOrderLineRow['discountpercent'] * $RecurrOrderLineRow['unitprice'] * $RecurrOrderLineRow['quantity'] / $CurrencyRate . ",\n\t\t\t\t\t\t'" . $RecurrOrderLineRow['stkcode'] . "',\n\t\t\t\t\t\tcustbranch.area,\n\t\t\t\t\t\t1,\n\t\t\t\t\t\tcustbranch.salesman,\n\t\t\t\t\t\tstockmaster.categoryid\n\t\t\t\t\tFROM stockmaster,\n\t\t\t\t\t\tcustbranch\n\t\t\t\t\tWHERE stockmaster.stockid = '" . $RecurrOrderLineRow['stkcode'] . "'\n\t\t\t\t\tAND custbranch.debtorno = '" . $RecurrOrderRow['debtorno'] . "'\n\t\t\t\t\tAND custbranch.branchcode='" . $RecurrOrderRow['branchcode'] . "'";
 }
 $ErrMsg = _('Sales analysis record could not be added or updated because');
 $DbgMsg = _('The following SQL to insert the sales analysis record was used');
 $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
 if ($_SESSION['CompanyRecord']['gllink_debtors'] == 1 && $RecurrOrderLineRow['unitprice'] != 0) {
     //Post sales transaction to GL credit sales
     $SalesGLAccounts = GetSalesGLAccount($Area, $RecurrOrderLineRow['stkcode'], $RecurrOrderRow['ordertype'], $db);
     $SQL = "INSERT INTO gltrans (\n\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\tamount\n\t\t\t\t\t\t)\n\t\t\t\t\tVALUES (\n\t\t\t\t\t\t10,\n\t\t\t\t\t\t" . $InvoiceNo . ",\n\t\t\t\t\t\t'" . $DelDate . "',\n\t\t\t\t\t\t" . $PeriodNo . ",\n\t\t\t\t\t\t" . $SalesGLAccounts['salesglcode'] . ",\n\t\t\t\t\t\t'" . $RecurrOrderRow['debtorno'] . " - " . $RecurrOrderLineRow['stkcode'] . " x " . $RecurrOrderLineRow['quantity'] . " @ " . $RecurrOrderLineRow['unitprice'] . "',\n\t\t\t\t\t\t" . -$RecurrOrderLineRow['unitprice'] * $RecurrOrderLineRow['quantity'] / $CurrencyRate . "\n\t\t\t\t\t)";
     $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The sales GL posting could not be inserted because');
     $DbgMsg = '<BR>' . _('The following SQL to insert the GLTrans record was used');
     $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
     /* Don't care about COGS because it can only be a dummy items being invoiced ... no cost of sales to mess with */
     if ($RecurrOrderLineRow['discountpercent'] != 0) {
         $SQL = "INSERT INTO gltrans (\n\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\tamount\n\t\t\t\t\t\t)\n\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t10,\n\t\t\t\t\t\t\t" . $InvoiceNo . ",\n\t\t\t\t\t\t\t'" . $DelDate . "',\n\t\t\t\t\t\t\t" . $PeriodNo . ",\n\t\t\t\t\t\t\t" . $SalesGLAccounts['discountglcode'] . ",\n\t\t\t\t\t\t\t'" . $RecurrOrderRow['debtorno'] . " - " . $RecurrOrderLineRow['stkcode'] . " @ " . $RecurrOrderLineRow['discountpercent'] * 100 . "%',\n\t\t\t\t\t\t\t" . $RecurrOrderLineRow['unitprice'] * $RecurrOrderLineRow['quantity'] * $RecurrOrderLineRow['discountpercent'] / $CurrencyRate . "\n\t\t\t\t\t\t)";
         $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The sales discount GL posting could not be inserted because');
         $DbgMsg = _('The following SQL to insert the GLTrans record was used');
         $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
     }
     /*end of if discount !=0 */
 }
 /*end of if sales integrated with gl */
 $LineCounter++;
开发者ID:xuxudodo,项目名称:weberp-cvs,代码行数:31,代码来源:RecurringSalesOrdersProcess.php

示例4: CreateCreditNote


//.........这里部分代码省略.........
            $Result = api_DB_query($SQL, $db, '', '', true);
        }
        /*Get the ID of the StockMove... */
        $StkMoveNo = DB_Last_Insert_ID($db, 'stockmoves', 'stkmoveno');
        /*Insert the taxes that applied to this line */
        foreach ($LineTaxes[$LineCounter] as $Tax) {
            $SQL = "INSERT INTO stockmovestaxes (stkmoveno,\n\t\t\t\t\t\t\t\t\ttaxauthid,\n\t\t\t\t\t\t\t\t\ttaxrate,\n\t\t\t\t\t\t\t\t\ttaxcalculationorder,\n\t\t\t\t\t\t\t\t\ttaxontax)\n\t\t\t\t\t\tVALUES ('" . $StkMoveNo . "',\n\t\t\t\t\t\t\t'" . $Tax['TaxAuthID'] . "',\n\t\t\t\t\t\t\t'" . $Tax['TaxRate'] . "',\n\t\t\t\t\t\t\t'" . $Tax['TaxCalculationOrder'] . "',\n\t\t\t\t\t\t\t'" . $Tax['TaxOnTax'] . "')";
            $Result = DB_query($SQL, $db, '', '', true);
        }
        /*Insert Sales Analysis records */
        $SQL = "SELECT COUNT(*),\n\t\t\t\t\t\tsalesanalysis.stkcategory,\n\t\t\t\t\t\tsalesanalysis.area,\n\t\t\t\t\t\tsalesanalysis.salesperson,\n\t\t\t\t\t\tsalesanalysis.periodno,\n\t\t\t\t\t\tsalesanalysis.typeabbrev,\n\t\t\t\t\t\tsalesanalysis.cust,\n\t\t\t\t\t\tsalesanalysis.custbranch,\n\t\t\t\t\t\tsalesanalysis.stockid\n\t\t\t\t\tFROM salesanalysis,\n\t\t\t\t\t\tcustbranch,\n\t\t\t\t\t\tstockmaster\n\t\t\t\t\tWHERE salesanalysis.stkcategory=stockmaster.categoryid\n\t\t\t\t\tAND salesanalysis.stockid=stockmaster.stockid\n\t\t\t\t\tAND salesanalysis.cust=custbranch.debtorno\n\t\t\t\t\tAND salesanalysis.custbranch=custbranch.branchcode\n\t\t\t\t\tAND salesanalysis.area=custbranch.area\n\t\t\t\t\tAND salesanalysis.salesperson=custbranch.salesman\n\t\t\t\t\tAND salesanalysis.typeabbrev ='" . $Header['tpe'] . "'\n\t\t\t\t\tAND salesanalysis.periodno='" . $PeriodNo . "'\n\t\t\t\t\tAND salesanalysis.cust " . LIKE . "  '" . $Header['debtorno'] . "'\n\t\t\t\t\tAND salesanalysis.custbranch  " . LIKE . " '" . $Header['branchcode'] . "'\n\t\t\t\t\tAND salesanalysis.stockid  " . LIKE . " '" . $CN_Line['stockid'] . "'\n\t\t\t\t\tAND salesanalysis.budgetoractual='1'\n\t\t\t\t\tGROUP BY salesanalysis.stockid,\n\t\t\t\t\t\tsalesanalysis.stkcategory,\n\t\t\t\t\t\tsalesanalysis.cust,\n\t\t\t\t\t\tsalesanalysis.custbranch,\n\t\t\t\t\t\tsalesanalysis.area,\n\t\t\t\t\t\tsalesanalysis.periodno,\n\t\t\t\t\t\tsalesanalysis.typeabbrev,\n\t\t\t\t\t\tsalesanalysis.salesperson";
        $Result = api_DB_query($SQL, $db, '', '', true);
        $myrow = DB_fetch_row($Result);
        if ($myrow[0] > 0) {
            /*Update the existing record that already exists */
            $SQL = "UPDATE salesanalysis\n\t\t\t\t\t\tSET amt=amt+" . $CN_Line['price'] * $CN_Line['qty'] / $CN_Header['rate'] . ",\n\t\t\t\t\t\tqty=qty +" . $CN_Line['qty'] . ",\n\t\t\t\t\t\tdisc=disc+" . $CN_Line['discountpercent'] * $CN_Line['price'] * $CN_Line['qty'] / $CN_Header['rate'] . "\n\t\t\t\t\t\tWHERE salesanalysis.area='" . $myrow[2] . "'\n\t\t\t\t\t\tAND salesanalysis.salesperson='" . $myrow[3] . "'\n\t\t\t\t\t\tAND typeabbrev ='" . $Header['tpe'] . "'\n\t\t\t\t\t\tAND periodno = '" . $PeriodNo . "'\n\t\t\t\t\t\tAND cust  " . LIKE . " '" . $Header['debtorno'] . "'\n\t\t\t\t\t\tAND custbranch  " . LIKE . "  '" . $Header['branchcode'] . "'\n\t\t\t\t\t\tAND stockid  " . LIKE . " '" . $CN_Line['stockid'] . "'\n\t\t\t\t\t\tAND salesanalysis.stkcategory ='" . $myrow[1] . "'\n\t\t\t\t\t\tAND budgetoractual='1'";
        } else {
            /* insert a new sales analysis record */
            $SQL = "INSERT INTO salesanalysis (\ttypeabbrev,\n\t\t\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\t\t\tamt,\n\t\t\t\t\t\t\t\t\t\t\t\t\tcost,\n\t\t\t\t\t\t\t\t\t\t\t\t\tcust,\n\t\t\t\t\t\t\t\t\t\t\t\t\tcustbranch,\n\t\t\t\t\t\t\t\t\t\t\t\t\tqty,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdisc,\n\t\t\t\t\t\t\t\t\t\t\t\t\tstockid,\n\t\t\t\t\t\t\t\t\t\t\t\t\tarea,\n\t\t\t\t\t\t\t\t\t\t\t\t\tbudgetoractual,\n\t\t\t\t\t\t\t\t\t\t\t\t\tsalesperson,\n\t\t\t\t\t\t\t\t\t\t\t\t\tstkcategory )\n\t\t\t\t\t\t\t\tSELECT '" . $Header['tpe'] . "',\n\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t'" . $CN_Line['price'] * $CN_Line['qty'] / $CN_Header['rate'] . "',\n\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\t'" . $Header['debtorno'] . "',\n\t\t\t\t\t\t\t\t\t'" . $Header['branchcode'] . "',\n\t\t\t\t\t\t\t\t\t'" . $CN_Line['qty'] . "',\n\t\t\t\t\t\t\t\t\t'" . $CN_Line['discountpercent'] * $CN_Line['price'] * $CN_Line['qty'] / $CN_Header['rate'] . "',\n\t\t\t\t\t\t\t\t\t'" . $CN_Line['stockid'] . "',\n\t\t\t\t\t\t\t\t\tcustbranch.area,\n\t\t\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t\t\tcustbranch.salesman,\n\t\t\t\t\t\t\t\t\tstockmaster.categoryid\n\t\t\t\t\t\t\t\tFROM stockmaster, custbranch\n\t\t\t\t\t\t\t\tWHERE stockmaster.stockid = '" . $CN_Line['stockid'] . "'\n\t\t\t\t\t\t\t\tAND custbranch.debtorno = '" . $Header['debtorno'] . "'\n\t\t\t\t\t\t\t\tAND custbranch.branchcode='" . $Header['branchcode'] . "'";
        }
        $Result = api_DB_query($SQL, $db, '', '', true);
        if ($CompanyRecord['gllink_stock'] == 1 and $StandardCost != 0) {
            /*first the cost of sales entry - GL accounts are retrieved using the function GetCOGSGLAccount from includes/GetSalesTransGLCodes.inc  */
            $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\t\tVALUES (11,\n\t\t\t\t\t\t\t\t\t\t'" . $CreditNoteNo . "',\n\t\t\t\t\t\t\t\t\t\t'" . $Header['trandate'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t'" . GetCOGSGLAccount($CN_Header['area'], $CN_Line['stockid'], $Header['tpe'], $db) . "',\n\t\t\t\t\t\t\t\t\t\t'" . $Header['debtorno'] . " - " . $CN_Line['stockid'] . " x " . $CN_Line['qty'] . " @ " . $StandardCost . "',\n\t\t\t\t\t\t\t\t\t\t'" . $StandardCost * $CN_Line['qty'] . "')";
            $Result = api_DB_query($SQL, $db, '', '', true);
            /*now the stock entry - this is set to the cost act in the case of a fixed asset disposal */
            $StockGLCode = GetStockGLCode($CN_Line['stockid'], $db);
            $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\t\tVALUES (11,\n\t\t\t\t\t\t\t\t\t\t'" . $CreditNoteNo . "',\n\t\t\t\t\t\t\t\t\t\t'" . $Header['trandate'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t'" . $StockGLCode['stockact'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $Header['debtorno'] . " - " . $CN_Line['stockid'] . " x " . $CN_Line['qty'] . " @ " . $StandardCost . "',\n\t\t\t\t\t\t\t\t\t\t'" . -$StandardCost * $CN_Line['qty'] . "')";
            $Result = api_DB_query($SQL, $db, '', '', true);
        }
        /* end of if GL and stock integrated and standard cost !=0  and not an asset */
        if ($CompanyRecord['gllink_debtors'] == 1 and $CN_Line['price'] != 0) {
            //Post sales transaction to GL credit sales
            $SalesGLAccounts = GetSalesGLAccount($CN_Header['area'], $CN_Line['stockid'], $Header['tpe'], $db);
            $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\tamount )\n\t\t\t\t\tVALUES ('11',\n\t\t\t\t\t\t'" . $CreditNoteNo . "',\n\t\t\t\t\t\t'" . $Header['trandate'] . "',\n\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t'" . $SalesGLAccounts['salesglcode'] . "',\n\t\t\t\t\t\t'" . $Header['debtorno'] . " - " . $CN_Line['stockid'] . " x " . $CN_Line['qty'] . " @ " . $CN_Line['price'] . "',\n\t\t\t\t\t\t'" . -$CN_Line['price'] * $CN_Line['qty'] / $CN_Header['rate'] . "'\n\t\t\t\t\t)";
            $Result = api_DB_query($SQL, $db, '', '', true);
            if ($CN_Line['discountpercent'] != 0) {
                $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\tVALUES (11,\n\t\t\t\t\t\t\t\t'" . $CreditNoteNo . "',\n\t\t\t\t\t\t\t\t'" . $Header['trandate'] . "',\n\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t'" . $SalesGLAccounts['discountglcode'] . "',\n\t\t\t\t\t\t\t\t'" . $Header['debtorno'] . " - " . $CN_Line['stockid'] . " @ " . $CN_Line['discountpercent'] * 100 . "%',\n\t\t\t\t\t\t\t\t'" . $CN_Line['price'] * $CN_Line['qty'] * $CN_Line['discountpercent'] / $CN_Header['rate'] . "')";
                $Result = DB_query($SQL, $db, '', '', true);
            }
            /*end of if discount !=0 */
        }
        /*end of if sales integrated with gl */
        $LineCounter++;
        //needed for the array of taxes by line
    }
    /*end of OrderLine loop */
    $TotalCreditLocalCurr = ($TotalFXNetCredit + $TotalFXTax) / $CN_Header['rate'];
    if ($CompanyRecord['gllink_debtors'] == 1) {
        /*Now post the tax to the GL at local currency equivalent */
        if ($CompanyRecord['gllink_debtors'] == 1 and $TaxAuthAmount != 0) {
            /*Loop through the tax authorities array to post each total to the taxauth glcode */
            foreach ($TaxTotals as $Tax) {
                $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\t\tamount )\n\t\t\t\t\t\t\t\t\t\t\tVALUES (11,\n\t\t\t\t\t\t\t\t\t\t\t'" . $CreditNoteNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $Header['trandate'] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $Tax['GLCode'] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $Header['debtorno'] . "-" . $Tax['TaxAuthDescription'] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . -$Tax['FXAmount'] / $CN_Header['rate'] . "' )";
                $Result = api_DB_query($SQL, $db, '', '', true);
            }
        }
        /*Post debtors transaction to GL credit debtors, and debit sales */
        if ($TotalCreditLocalCurr != 0) {
            $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\t\tVALUES ('11',\n\t\t\t\t\t\t\t\t\t\t'" . $CreditNoteNo . "',\n\t\t\t\t\t\t\t\t\t\t'" . $Header['trandate'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t'" . $CompanyRecord['debtorsact'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $Header['debtorno'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $TotalCreditLocalCurr . "')";
            $Result = api_DB_query($SQL, $db, '', '', true);
        }
        EnsureGLEntriesBalance(11, $CreditNoteNo, $db);
    }
    /*end of if Sales and GL integrated */
    /*Now insert the DebtorTrans */
开发者ID:BackupTheBerlios,项目名称:kwamoja,代码行数:67,代码来源:api_debtortransactions.php

示例5: _

 $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The debtor transaction record could not be inserted because');
 $DbgMsg = _('The following SQL to insert the debtor transaction record was used');
 $Result = DB_query($sql, $db, $ErrMsg, $DbgMsg, true);
 for ($i = 0; $i < $_SESSION['Items']['Lines']; $i++) {
     if (isset($_SESSION['Items'][$i]['StockID'])) {
         $SQL = "INSERT INTO stockmoves (\n\t\t\t\t\t\tstockid,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\ttransno,\n\t\t\t\t\t\tloccode,\n\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\tdebtorno,\n\t\t\t\t\t\tbranchcode,\n\t\t\t\t\t\tprd,\n\t\t\t\t\t\treference,\n\t\t\t\t\t\tqty,\n\t\t\t\t\t\tprice,\n\t\t\t\t\t\tshow_on_inv_crds,\n\t\t\t\t\t\tnewqoh\n\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t'" . $_SESSION['Items'][$i]['StockID'] . "',\n\t\t\t\t\t\t 10,\n\t\t\t\t\t\t'" . $InvoiceNo . "',\n\t\t\t\t\t\t'" . $_SESSION['UserStockLocation'] . "',\n\t\t\t\t\t\t'" . FormatDateForSQL($_POST['AdmissionDate']) . "',\n\t\t\t\t\t\t'" . $_POST['PatientNo'] . "',\n\t\t\t\t\t\t'" . $_POST['BranchNo'] . "',\n\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t'" . _('Invoice for radiology test of Patient number') . ' ' . $_POST['PatientNo'] . "',\n\t\t\t\t\t\t-1,\n\t\t\t\t\t\t'" . $_SESSION['Items'][$i]['Price'] . "',\n\t\t\t\t\t\t1,\n\t\t\t\t\t\t0\n\t\t\t\t\t)";
         $BaseStockID = $_SESSION['Items'][$i]['StockID'];
         $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('Stock movement records for') . ' ' . $_POST['StockID'] . ' ' . _('could not be inserted because');
         $DbgMsg = _('The following SQL to insert the stock movement records was used');
         $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
     }
 }
 $SQL = "SELECT salestype\n\t\t\t\tFROM debtorsmaster\n\t\t\t\tWHERE debtorno='" . $_POST['PatientNo'] . "'";
 $Result = DB_query($SQL, $db);
 $myrow = DB_fetch_array($Result);
 $SalesGLAccounts = GetSalesGLAccount('AN', $BaseStockID, $myrow['salestype'], $db);
 $SQL = "INSERT INTO gltrans (\ttype,\n\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\tdefaulttag,\n\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\tVALUES ( 10,\n\t\t\t\t\t\t\t\t\t'" . $InvoiceNo . "',\n\t\t\t\t\t\t\t\t\t'" . FormatDateForSQL($_POST['AdmissionDate']) . "',\n\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t'" . $SalesGLAccounts['salesglcode'] . "',\n\t\t\t\t\t\t\t\t\t'" . $_SESSION['DefaultTag'] . "',\n\t\t\t\t\t\t\t\t\t'" . _('Invoice for radiology test of Patient number') . ' ' . $_POST['PatientNo'] . "',\n\t\t\t\t\t\t\t\t\t'" . -$_SESSION['Items']['Value'] . "')";
 $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The cost of sales GL posting could not be inserted because');
 $DbgMsg = _('The following SQL to insert the GLTrans record was used');
 $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
 $SQL = "INSERT INTO gltrans (\ttype,\n\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\tdefaulttag,\n\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\tamount )\n\t\t\t\t\t\t\t\tVALUES ( 10,\n\t\t\t\t\t\t\t\t\t'" . $InvoiceNo . "',\n\t\t\t\t\t\t\t\t\t'" . FormatDateForSQL($_POST['AdmissionDate']) . "',\n\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t'" . $_SESSION['CompanyRecord']['debtorsact'] . "',\n\t\t\t\t\t\t\t\t\t'" . $_SESSION['DefaultTag'] . "',\n\t\t\t\t\t\t\t\t\t'" . _('Invoice for radiology test of Patient number') . ' ' . $_POST['PatientNo'] . "',\n\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items']['Value'] . "')";
 $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The stock side of the cost of sales GL posting could not be inserted because');
 $DbgMsg = _('The following SQL to insert the GLTrans record was used');
 $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
 if (isset($_POST['SubmitCash'])) {
     $ReceiptNumber = GetNextTransNo(12, $db);
     $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\tdefaulttag,\n\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\t\tVALUES (12,\n\t\t\t\t\t\t\t\t\t\t'" . $ReceiptNumber . "',\n\t\t\t\t\t\t\t\t\t\t'" . FormatDateForSQL($_POST['AdmissionDate']) . "',\n\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_POST['BankAccount'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['DefaultTag'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . _('Payment of radiology test for Patient number') . ' ' . $_POST['PatientNo'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items']['Value'] . "')";
     $DbgMsg = _('The SQL that failed to insert the GL transaction for the bank account debit was');
     $ErrMsg = _('Cannot insert a GL transaction for the bank account debit');
     $result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
     /* Now Credit Debtors account with receipt */
开发者ID:sunilburli,项目名称:webERP-Medical,代码行数:31,代码来源:KCMCRadiology.php

示例6: debtortrans

     $_POST['Received'] = 0;
 } else {
     $_POST['InsuranceRef'] = '';
 }
 $sql = "INSERT INTO debtortrans (\n\t\t\t\ttransno,\n\t\t\t\ttype,\n\t\t\t\tdebtorno,\n\t\t\t\tbranchcode,\n\t\t\t\ttrandate,\n\t\t\t\tinputdate,\n\t\t\t\tprd,\n\t\t\t\torder_,\n\t\t\t\tovamount,\n\t\t\t\tovgst,\n\t\t\t\trate,\n\t\t\t\tinvtext,\n\t\t\t\treference,\n\t\t\t\tshipvia,\n\t\t\t\talloc )\n\t\t\tVALUES (\n\t\t\t\t'" . $InvoiceNo . "',\n\t\t\t\t10,\n\t\t\t\t'" . $_POST['PatientNo'] . "',\n\t\t\t\t'" . $_POST['BranchNo'] . "',\n\t\t\t\t'" . FormatDateForSQL($_POST['AdmissionDate']) . "',\n\t\t\t\t'" . FormatDateForSQL($_POST['AdmissionDate']) . "',\n\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t'" . $OrderNo . "',\n\t\t\t\t'" . $_POST['Price'] . "',\n\t\t\t\t'0',\n\t\t\t\t'1',\n\t\t\t\t'" . _('Invoice for admission of Patient number') . ' ' . $_POST['PatientNo'] . "',\n\t\t\t\t'" . $_POST['InsuranceRef'] . "',\n\t\t\t\t'1',\n\t\t\t\t'" . $_POST['Received'] . "')";
 $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The debtor transaction record could not be inserted because');
 $DbgMsg = _('The following SQL to insert the debtor transaction record was used');
 $Result = DB_query($sql, $db, $ErrMsg, $DbgMsg, true);
 $SQL = "INSERT INTO stockmoves (\n\t\t\t\t\t\tstockid,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\ttransno,\n\t\t\t\t\t\tloccode,\n\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\tdebtorno,\n\t\t\t\t\t\tbranchcode,\n\t\t\t\t\t\tprd,\n\t\t\t\t\t\treference,\n\t\t\t\t\t\tqty,\n\t\t\t\t\t\tprice,\n\t\t\t\t\t\tshow_on_inv_crds,\n\t\t\t\t\t\tnewqoh\n\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t'" . $_POST['StockID'] . "',\n\t\t\t\t\t\t 10,\n\t\t\t\t\t\t'" . $InvoiceNo . "',\n\t\t\t\t\t\t'" . $_SESSION['UserStockLocation'] . "',\n\t\t\t\t\t\t'" . FormatDateForSQL($_POST['AdmissionDate']) . "',\n\t\t\t\t\t\t'" . $_POST['PatientNo'] . "',\n\t\t\t\t\t\t'" . $_POST['BranchNo'] . "',\n\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t'" . _('Invoice for admission of Patient number') . ' ' . $_POST['PatientNo'] . "',\n\t\t\t\t\t\t-1,\n\t\t\t\t\t\t'" . $_POST['Price'] . "',\n\t\t\t\t\t\t1,\n\t\t\t\t\t\t0\n\t\t\t\t\t)";
 $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('Stock movement records for') . ' ' . $_POST['StockID'] . ' ' . _('could not be inserted because');
 $DbgMsg = _('The following SQL to insert the stock movement records was used');
 $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
 $SQL = "SELECT salestype\n\t\t\t\tFROM debtorsmaster\n\t\t\t\tWHERE debtorno='" . $_POST['PatientNo'] . "'";
 $Result = DB_query($SQL, $db);
 $myrow = DB_fetch_array($Result);
 $SalesGLAccounts = GetSalesGLAccount('AN', $_POST['StockID'], $myrow['salestype'], $db);
 $SQL = "INSERT INTO gltrans (\ttype,\n\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\tdefaulttag,\n\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\tVALUES ( 10,\n\t\t\t\t\t\t\t\t\t'" . $InvoiceNo . "',\n\t\t\t\t\t\t\t\t\t'" . FormatDateForSQL($_POST['AdmissionDate']) . "',\n\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t'" . $SalesGLAccounts['salesglcode'] . "',\n\t\t\t\t\t\t\t\t\t'" . $_SESSION['DefaultTag'] . "',\n\t\t\t\t\t\t\t\t\t'" . _('Invoice for admission of Patient number') . ' ' . $_POST['PatientNo'] . "',\n\t\t\t\t\t\t\t\t\t'" . -$_POST['Price'] . "')";
 $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The cost of sales GL posting could not be inserted because');
 $DbgMsg = _('The following SQL to insert the GLTrans record was used');
 $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
 $SQL = "INSERT INTO gltrans (\ttype,\n\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\tdefaulttag,\n\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\tamount )\n\t\t\t\t\t\t\t\tVALUES ( 10,\n\t\t\t\t\t\t\t\t\t'" . $InvoiceNo . "',\n\t\t\t\t\t\t\t\t\t'" . FormatDateForSQL($_POST['AdmissionDate']) . "',\n\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t'" . $_SESSION['CompanyRecord']['debtorsact'] . "',\n\t\t\t\t\t\t\t\t\t'" . $_SESSION['DefaultTag'] . "',\n\t\t\t\t\t\t\t\t\t'" . _('Invoice for admission of Patient number') . ' ' . $_POST['PatientNo'] . "',\n\t\t\t\t\t\t\t\t\t'" . $_POST['Price'] . "')";
 $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The stock side of the cost of sales GL posting could not be inserted because');
 $DbgMsg = _('The following SQL to insert the GLTrans record was used');
 $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
 if (isset($_POST['SubmitCash'])) {
     $ReceiptNumber = GetNextTransNo(12, $db);
     $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\tdefaulttag,\n\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\t\tVALUES (12,\n\t\t\t\t\t\t\t\t\t\t'" . $ReceiptNumber . "',\n\t\t\t\t\t\t\t\t\t\t'" . FormatDateForSQL($_POST['AdmissionDate']) . "',\n\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_POST['BankAccount'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['DefaultTag'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . _('Payment of invoice for admission of Patient number') . ' ' . $_POST['PatientNo'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_POST['Received'] . "')";
     $DbgMsg = _('The SQL that failed to insert the GL transaction for the bank account debit was');
     $ErrMsg = _('Cannot insert a GL transaction for the bank account debit');
     $result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
     /* Now Credit Debtors account with receipt */
开发者ID:sunilburli,项目名称:webERP-Medical,代码行数:31,代码来源:KCMCAdmission.php

示例7: gltrans

         /*first the cost of sales entry*/
         $SQL = "INSERT INTO gltrans (\ttype,\r\n\t\t\t\t\t\t\t\t\t\t\t\ttypeno,\r\n\t\t\t\t\t\t\t\t\t\t\t\ttrandate,\r\n\t\t\t\t\t\t\t\t\t\t\t\tperiodno,\r\n\t\t\t\t\t\t\t\t\t\t\t\taccount,\r\n\t\t\t\t\t\t\t\t\t\t\t\tnarrative,\r\n\t\t\t\t\t\t\t\t\t\t\t\tamount)\r\n\t\t\t\t\t\t\t\t\t\tVALUES ( 11,\r\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $CreditNoteNo . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $ReturnDate . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t'" . GetCOGSGLAccount($Area, $ReturnItemLine->StockID, $_SESSION['Items' . $identifier]->DefaultSalesType, $db) . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->DebtorNo . " - " . $ReturnItemLine->StockID . " x " . -$ReturnItemLine->Quantity . " @ " . $ReturnItemLine->StandardCost . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $ReturnItemLine->StandardCost * -$ReturnItemLine->Quantity . "')";
         $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The cost of sales GL posting could not be inserted because');
         $DbgMsg = _('The following SQL to insert the GLTrans record was used');
         $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
         /*now the stock entry*/
         $StockGLCode = GetStockGLCode($ReturnItemLine->StockID, $db);
         $SQL = "INSERT INTO gltrans (type,\r\n\t\t\t\t\t\t\t\t\t\t\ttypeno,\r\n\t\t\t\t\t\t\t\t\t\t\ttrandate,\r\n\t\t\t\t\t\t\t\t\t\t\tperiodno,\r\n\t\t\t\t\t\t\t\t\t\t\taccount,\r\n\t\t\t\t\t\t\t\t\t\t\tnarrative,\r\n\t\t\t\t\t\t\t\t\t\t\tamount )\r\n\t\t\t\t\t\t\t\t\t\tVALUES ( 11,\r\n\t\t\t\t\t\t\t\t\t\t\t'" . $CreditNoteNo . "',\r\n\t\t\t\t\t\t\t\t\t\t\t'" . $ReturnDate . "',\r\n\t\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\r\n\t\t\t\t\t\t\t\t\t\t\t'" . $StockGLCode['stockact'] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->DebtorNo . " - " . $ReturnItemLine->StockID . " x " . -$ReturnItemLine->Quantity . " @ " . $ReturnItemLine->StandardCost . "',\r\n\t\t\t\t\t\t\t\t\t\t\t'" . $ReturnItemLine->StandardCost * $ReturnItemLine->Quantity . "')";
         $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The stock side of the cost of sales GL posting could not be inserted because');
         $DbgMsg = _('The following SQL to insert the GLTrans record was used');
         $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
     }
     /* end of if GL and stock integrated and standard cost !=0 */
     if ($_SESSION['CompanyRecord']['gllink_debtors'] == 1 and $ReturnItemLine->Price != 0) {
         //Post sales transaction to GL credit sales
         $SalesGLAccounts = GetSalesGLAccount($Area, $ReturnItemLine->StockID, $_SESSION['Items' . $identifier]->DefaultSalesType, $db);
         $SQL = "INSERT INTO gltrans (type,\r\n\t\t\t\t\t\t\t\t\t\t\ttypeno,\r\n\t\t\t\t\t\t\t\t\t\t\ttrandate,\r\n\t\t\t\t\t\t\t\t\t\t\tperiodno,\r\n\t\t\t\t\t\t\t\t\t\t\taccount,\r\n\t\t\t\t\t\t\t\t\t\t\tnarrative,\r\n\t\t\t\t\t\t\t\t\t\t\tamount )\r\n\t\t\t\t\t\t\t\t\t\tVALUES ( 11,\r\n\t\t\t\t\t\t\t\t\t\t\t'" . $CreditNoteNo . "',\r\n\t\t\t\t\t\t\t\t\t\t\t'" . $ReturnDate . "',\r\n\t\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\r\n\t\t\t\t\t\t\t\t\t\t\t'" . $SalesGLAccounts['salesglcode'] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->DebtorNo . " - " . $ReturnItemLine->StockID . " x " . -$ReturnItemLine->Quantity . " @ " . $ReturnItemLine->Price . "',\r\n\t\t\t\t\t\t\t\t\t\t\t'" . $ReturnItemLine->Price * $ReturnItemLine->Quantity / $ExRate . "')";
         $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The sales GL posting could not be inserted because');
         $DbgMsg = '<br />' . _('The following SQL to insert the GLTrans record was used');
         $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
         if ($ReturnItemLine->DiscountPercent != 0) {
             $SQL = "INSERT INTO gltrans (type,\r\n\t\t\t\t\t\t\t\t\t\t\t\ttypeno,\r\n\t\t\t\t\t\t\t\t\t\t\t\ttrandate,\r\n\t\t\t\t\t\t\t\t\t\t\t\tperiodno,\r\n\t\t\t\t\t\t\t\t\t\t\t\taccount,\r\n\t\t\t\t\t\t\t\t\t\t\t\tnarrative,\r\n\t\t\t\t\t\t\t\t\t\t\t\tamount )\r\n\t\t\t\t\t\t\t\t\t\t\t\tVALUES ( 11,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $CreditNoteNo . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $ReturnDate . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $SalesGLAccounts['discountglcode'] . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->DebtorNo . " - " . $ReturnItemLine->StockID . " @ " . $ReturnItemLine->DiscountPercent * 100 . "%',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . -($ReturnItemLine->Price * $ReturnItemLine->Quantity * $ReturnItemLine->DiscountPercent / $ExRate) . "')";
             $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The sales discount GL posting could not be inserted because');
             $DbgMsg = _('The following SQL to insert the GLTrans record was used');
             $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
         }
         /*end of if discount !=0 */
     }
     /*end of if sales integrated with debtors */
 }
 /*end of OrderLine loop */
开发者ID:BackupTheBerlios,项目名称:kwamoja,代码行数:31,代码来源:CounterReturns.php


注:本文中的GetSalesGLAccount函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。