X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=reporting%2Frep305.php;h=8b71e0fb37fdee4812068dc8a139cfa09981a3be;hb=17b390efcf904072b02ec866b2a427490471a260;hp=0ebcbb2d080ecf41510be6a9c729dae11ea8ea4d;hpb=91d635a76eb6cee80c284239ec7c85fd0165a089;p=fa-stable.git diff --git a/reporting/rep305.php b/reporting/rep305.php index 0ebcbb2d..8b71e0fb 100644 --- a/reporting/rep305.php +++ b/reporting/rep305.php @@ -33,7 +33,7 @@ function getTransactions($from, $to) { $from = date2sql($from); $to = date2sql($to); - + $sql = "SELECT ".TB_PREF."grn_batch.id batch_no, ".TB_PREF."grn_batch.supplier_id, ".TB_PREF."purch_order_details.*, @@ -53,7 +53,7 @@ function getTransactions($from, $to) AND ".TB_PREF."grn_batch.delivery_date>='$from' AND ".TB_PREF."grn_batch.delivery_date<='$to' ORDER BY ".TB_PREF."stock_master.stock_id, ".TB_PREF."grn_batch.delivery_date"; - + return db_query($sql,"No transactions were returned"); } @@ -63,6 +63,7 @@ function getSuppInvDetails($grn_item_id) $sql = "SELECT ".TB_PREF."supp_invoice_items.supp_trans_no inv_no, ".TB_PREF."supp_invoice_items.quantity inv_qty, + ".TB_PREF."supp_trans.rate, IF (".TB_PREF."supp_trans.tax_included = 1, ".TB_PREF."supp_invoice_items.unit_price - ".TB_PREF."supp_invoice_items.unit_tax, ".TB_PREF."supp_invoice_items.unit_price) inv_price FROM ".TB_PREF."grn_items, ".TB_PREF."supp_trans, ".TB_PREF."supp_invoice_items WHERE ".TB_PREF."grn_items.id = ".TB_PREF."supp_invoice_items.grn_item_id @@ -86,13 +87,15 @@ function print_grn_valuation() $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $comments = $_POST['PARAM_2']; - $destination = $_POST['PARAM_3']; + $orientation = $_POST['PARAM_3']; + $destination = $_POST['PARAM_4']; if ($destination) include_once($path_to_root . "/reporting/includes/excel_report.inc"); else include_once($path_to_root . "/reporting/includes/pdf_report.inc"); - $dec = user_price_dec(); + $orientation = ($orientation ? 'L' : 'P'); + $dec = user_price_dec(); $cols = array(0, 75, 225, 260, 295, 330, 370, 410, 455, 515); $headers = array(_('Stock ID'), _('Description'), _('PO No'), _('GRN')."#", _('Inv')."#", _('Qty'), _('Inv Price'), _('PO Price'), _('Total')); @@ -102,7 +105,9 @@ function print_grn_valuation() $params = array( 0 => $comments, 1 => array('text' => _('Period'),'from' => $from, 'to' => $to)); - $rep = new FrontReport(_('GRN Valuation Report'), "GRNValuationReport", user_pagesize()); + $rep = new FrontReport(_('GRN Valuation Report'), "GRNValuationReport", user_pagesize(), 9, $orientation); + if ($orientation == 'L') + recalculate_cols($cols); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); @@ -127,9 +132,6 @@ function print_grn_valuation() } $stock_id = $trans['item_code']; } - $curr = get_supplier_currency($trans['supplier_id']); - $rate = get_exchange_rate_from_home_currency($curr, sql2date($trans['delivery_date'])); - $trans['std_cost_unit'] *= $rate; $rep->NewLine(); $rep->TextCol(0, 1, $trans['item_code']); @@ -137,13 +139,13 @@ function print_grn_valuation() $rep->TextCol(2, 3, $trans['order_no']); $qdec = get_qty_dec($trans['item_code']); $rep->TextCol(3, 4, $trans['batch_no']); - + if ($trans['quantity_inv']) { $suppinv = getSuppInvDetails($trans['grn_item_id']); while ($inv=db_fetch($suppinv)) { - $inv['inv_price'] *= $rate; + $inv['inv_price'] *= $inv['rate']; $rep->TextCol(4, 5, $inv['inv_no']); $rep->AmountCol(5, 6, $inv['inv_qty'], $qdec); $rep->AmountCol(6, 7, $inv['inv_price'], $dec); @@ -156,9 +158,12 @@ function print_grn_valuation() $grandtotal += $amt; } } - + if ($trans['qty_recd'] - $trans['quantity_inv'] !=0 ) { + $curr = get_supplier_currency($trans['supplier_id']); + $rate = get_exchange_rate_from_home_currency($curr, sql2date($trans['delivery_date'])); + $trans['unit_price'] *= $rate; $rep->TextCol(4, 5, "--"); $rep->AmountCol(5, 6, $trans['qty_recd'] - $trans['quantity_inv'], $qdec); $rep->AmountCol(7, 8, $trans['unit_price'], $dec); @@ -189,4 +194,3 @@ function print_grn_valuation() $rep->End(); } -?> \ No newline at end of file