
--
-- Table structure for table `web_title`
--

CREATE TABLE `web_title` (
  `acct_id` int NOT NULL AUTO_INCREMENT,
  `acct_name` varchar(250) CHARACTER SET latin1 DEFAULT NULL,
  PRIMARY KEY (`acct_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `web_title`
--

INSERT INTO `web_title` VALUES (1,'Nizami Group of Companies');

--
-- Final view structure for view `v_approval`
--

/*!50001 DROP VIEW IF EXISTS `v_approval`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`pwwatmno`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_approval` AS select distinct `m`.`VOUCHER_ID` AS `voucher_id`,`m`.`VOUCHER_DATE` AS `voucher_date`,`m`.`POSTED` AS `posted`,`m`.`COMP_ID` AS `comp_id`,`m`.`YEAR_ID` AS `year_id`,concat(`n`.`ACCT_NAME`,'-',`m`.`ACCT_ID`) AS `acct_name`,`d`.`amount` AS `amount`,`vd`.`d_acct_name` AS `d_acct_name`,`vd`.`d_acct_id` AS `d_acct_id`,`vd`.`particulars` AS `particulars` from (((`voucher` `m` left join `nom` `n` on((`m`.`ACCT_ID` = `n`.`ACCT_ID`))) left join (select `m`.`COMP_ID` AS `comp_id`,`m`.`YEAR_ID` AS `year_id`,`m`.`VOUCHER_ID` AS `voucher_id`,`n`.`ACCT_NAME` AS `d_acct_name`,`n`.`ACCT_ID` AS `d_acct_id`,`m`.`PARTICULARS` AS `particulars` from (`voucherdet` `m` left join `nom` `n` on((`m`.`ACCT_ID` = `n`.`ACCT_ID`))) where (substr(`m`.`LINEITEM`,-(1)) <> '.') group by `m`.`COMP_ID`,`m`.`YEAR_ID`,`m`.`VOUCHER_ID`) `vd` on(((`m`.`VOUCHER_ID` = `vd`.`voucher_id`) and (`m`.`COMP_ID` = `vd`.`comp_id`) and (`m`.`YEAR_ID` = `vd`.`year_id`)))) left join (select `voucherdet`.`COMP_ID` AS `comp_id`,`voucherdet`.`YEAR_ID` AS `year_id`,`voucherdet`.`VOUCHER_ID` AS `voucher_id`,sum(`voucherdet`.`debit`) AS `amount` from `voucherdet` group by `voucherdet`.`COMP_ID`,`voucherdet`.`YEAR_ID`,`voucherdet`.`VOUCHER_ID`) `d` on(((`m`.`VOUCHER_ID` = `d`.`voucher_id`) and (`m`.`COMP_ID` = `d`.`comp_id`) and (`m`.`YEAR_ID` = `d`.`year_id`)))) where ((1 = 1) and (`m`.`approved` is null) and (substr(`m`.`VOUCHER_ID`,1,2) in ('CP','JV')) and (`vd`.`d_acct_id` like '401000%')) order by `m`.`VOUCHER_DATE` desc,`m`.`VOUCHER_ID` desc */;

--
-- Final view structure for view `v_approval_detail`
--

/*!50001 DROP VIEW IF EXISTS `v_approval_detail`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`pwwatmno`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_approval_detail` AS select `m`.`VOUCHER_DATE` AS `voucher_date`,`d`.`COMP_ID` AS `comp_id`,`d`.`YEAR_ID` AS `year_id`,`d`.`VOUCHER_ID` AS `voucher_id`,`d`.`ACCT_ID` AS `acct_id`,`d`.`LINEITEM` AS `lineitem`,`n`.`ACCT_NAME` AS `acct_name`,`d`.`PARTICULARS` AS `particulars`,`d`.`debit` AS `amount` from ((`voucher` `m` left join `voucherdet` `d` on(((`m`.`COMP_ID` = `d`.`COMP_ID`) and (`m`.`YEAR_ID` = `d`.`YEAR_ID`) and (`m`.`VOUCHER_ID` = `d`.`VOUCHER_ID`)))) left join `nom` `n` on((`d`.`ACCT_ID` = `n`.`ACCT_ID`))) where ((1 = 1) and (substr(`d`.`LINEITEM`,-(1)) <> '.') and (substr(`m`.`VOUCHER_ID`,1,2) in ('CP','JV')) and (`d`.`ACCT_ID` like '401000%')) order by (`d`.`LINEITEM` / 1) */;

--
-- Final view structure for view `v_company`
--

/*!50001 DROP VIEW IF EXISTS `v_company`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`pwwatmno`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_company` AS select `company`.`comp_id` AS `comp_id`,`company`.`COMP_NAME` AS `comp_name` from `company` union all select '00' AS `00`,`system`.`comp_name` AS `comp_name` from `system` */;

--
-- Final view structure for view `v_cost_centre`
--

/*!50001 DROP VIEW IF EXISTS `v_cost_centre`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`pwwatmno`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_cost_centre` AS select `nom`.`ACCT_ID` AS `acct_id`,`nom`.`ACCT_NAME` AS `acct_name` from `nom` where ((substr(`nom`.`ACCT_ID`,1,2) = '99') and (length(`nom`.`ACCT_ID`) = 10)) */;

--
-- Final view structure for view `v_current_qty`
--

/*!50001 DROP VIEW IF EXISTS `v_current_qty`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`pwwatmno`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_current_qty` AS select `v`.`comp_id` AS `comp_id`,`v`.`stock_code` AS `stock_code`,sum((ifnull(`v`.`db_qty`,0) - ifnull(`v`.`cr_qty`,0))) AS `bal_qty` from `v_stk` `v` where ((1 = 1) and ((`v`.`db_qty` is not null) or (`v`.`cr_qty` is not null))) group by `v`.`comp_id`,`v`.`stock_code` */;

--
-- Final view structure for view `v_current_stock`
--

/*!50001 DROP VIEW IF EXISTS `v_current_stock`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`pwwatmno`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_current_stock` AS select `l`.`comp_id` AS `comp_id`,`d`.`stock_code` AS `stock_code`,`i`.`description` AS `stock_name`,`d`.`qty` AS `db_qty`,0 AS `cr_qty`,`m`.`loc_id` AS `loc_id` from ((((`pl_invoice` `m` left join `pl_invoicedet` `d` on(((`m`.`comp_id` = `d`.`comp_id`) and (`m`.`year_id` = `d`.`year_id`) and (`m`.`voucher_id` = `d`.`voucher_id`)))) left join `nom` `p` on((`m`.`acct_id` = `p`.`ACCT_ID`))) left join `item` `i` on((`d`.`stock_code` = `i`.`stock_code`))) left join `location` `l` on((`m`.`loc_id` = `l`.`loc_id`))) union all select `l`.`comp_id` AS `comp_id`,`d`.`stock_code` AS `stock_code`,`i`.`description` AS `stock_name`,0 AS `db_qty`,`d`.`qty` AS `cr_qty`,`m`.`loc_id` AS `loc_id` from ((((`sl_invoice` `m` left join `sl_invoicedet` `d` on(((`m`.`comp_id` = `d`.`comp_id`) and (`m`.`year_id` = `d`.`year_id`) and (`m`.`voucher_id` = `d`.`voucher_id`)))) left join `nom` `p` on((`m`.`acct_id` = `p`.`ACCT_ID`))) left join `item` `i` on((`d`.`stock_code` = `i`.`stock_code`))) left join `location` `l` on((`m`.`loc_id` = `l`.`loc_id`))) union all select `m`.`comp_id` AS `comp_id`,`d`.`stock_code` AS `stock_code`,`i`.`description` AS `stock_name`,0 AS `db_qty`,`d`.`qty` AS `cr_qty`,`m`.`loc_id` AS `loc_id` from (((`stk_trans` `m` left join `stk_transdet` `d` on(((`m`.`comp_id` = `d`.`comp_id`) and (`m`.`year_id` = `d`.`year_id`) and (`m`.`voucher_id` = `d`.`voucher_id`)))) left join `nom` `p` on((`m`.`acct_id` = `p`.`ACCT_ID`))) left join `item` `i` on((`d`.`stock_code` = `i`.`stock_code`))) union all select `m`.`to_comp_id` AS `comp_id`,`d`.`stock_code` AS `stock_code`,`i`.`description` AS `stock_name`,`d`.`qty` AS `db_qty`,0 AS `cr_qty`,`m`.`loc_id` AS `loc_id` from (((`stk_trans` `m` left join `stk_transdet` `d` on(((`m`.`comp_id` = `d`.`comp_id`) and (`m`.`year_id` = `d`.`year_id`) and (`m`.`voucher_id` = `d`.`voucher_id`)))) left join `v_party` `p` on((`m`.`acct_id` = `p`.`acct_id`))) left join `item` `i` on((`d`.`stock_code` = `i`.`stock_code`))) union all select `l`.`comp_id` AS `comp_id`,`d`.`stock_code` AS `stock_code`,concat(convert(`i`.`description` using utf8mb3),convert(if((ifnull(`i`.`specs`,'') = ''),'',concat('-',`i`.`specs`)) using utf8mb3)) AS `stock_name`,`d`.`qty` AS `db_qty`,0 AS `cr_qty`,`m`.`loc_id` AS `loc_id` from ((((`sl_return` `m` left join `sl_returndet` `d` on(((`m`.`comp_id` = `d`.`comp_id`) and (`m`.`year_id` = `d`.`year_id`) and (`m`.`voucher_id` = `d`.`voucher_id`)))) left join `nom` `p` on((`m`.`acct_id` = `p`.`ACCT_ID`))) left join `item` `i` on((`d`.`stock_code` = `i`.`stock_code`))) left join `location` `l` on((`m`.`loc_id` = `l`.`loc_id`))) where (`m`.`posted` = 'on') union all select `m`.`comp_id` AS `comp_id`,`b`.`stock_code` AS `stock_code`,`i`.`description` AS `stock_name`,`b`.`qty` AS `db_qty`,0 AS `cr_qty`,`b`.`loc_id` AS `loc_id` from ((((`mo` `m` left join `mo_batch` `b` on(((`m`.`comp_id` = `b`.`comp_id`) and (`m`.`year_id` = `b`.`year_id`) and (`m`.`voucher_id` = `b`.`voucher_id`)))) left join `item` `i` on((`b`.`stock_code` = `i`.`stock_code`))) left join `mo_issue_det` `m_i_d` on(((`b`.`comp_id` = `m_i_d`.`comp_id`) and (`b`.`year_id` = `m_i_d`.`year_id`) and (`b`.`voucher_id` = `m_i_d`.`voucher_id`) and (`b`.`lineitem` = `m_i_d`.`lineitem`)))) left join `item` `i2` on((`m_i_d`.`stock_code` = `i2`.`stock_code`))) where (`m`.`posted` = 'on') union all select `m`.`comp_id` AS `comp_id`,`m`.`stock_code` AS `stock_code`,`i`.`description` AS `stock_name`,`m`.`qty` AS `db_qty`,0 AS `cr_qty`,`m`.`loc_id` AS `loc_id` from (`mo` `m` left join `item` `i` on((`m`.`stock_code` = `i`.`stock_code`))) where (`m`.`posted` = 'on') union all select `m`.`comp_id` AS `comp_id`,`d2`.`stock_code` AS `stock_code`,`i2`.`description` AS `stock_name`,0 AS `db_qty`,`d2`.`qty` AS `cr_qty`,`d2`.`loc_id` AS `loc_id` from ((((`mo` `m` left join `item` `i` on((`m`.`stock_code` = `i`.`stock_code`))) left join `mo_issue` `d` on(((`m`.`comp_id` = `d`.`comp_id`) and (`m`.`year_id` = `d`.`year_id`) and (`m`.`voucher_id` = `d`.`voucher_id`)))) left join `mo_issue_det` `d2` on(((`d`.`comp_id` = `d2`.`comp_id`) and (`d`.`year_id` = `d2`.`year_id`) and (`d`.`voucher_id` = `d2`.`voucher_id`) and (`d`.`ser_no` = `d2`.`ser_no`)))) left join `item` `i2` on((`d2`.`stock_code` = `i2`.`stock_code`))) where (`m`.`posted` = 'on') */;

--
-- Final view structure for view `v_grp_item`
--

/*!50001 DROP VIEW IF EXISTS `v_grp_item`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`pwwatmno`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_grp_item` AS select 'KT' AS `comp_id`,`item`.`stock_code` AS `stock_code`,`item`.`description` AS `description`,`item`.`p_rate` AS `p_rate`,`item`.`s_rate` AS `s_rate` from `item` union all select 'BT' AS `comp_id`,`item`.`stock_code` AS `stock_code`,`item`.`description` AS `description`,`item`.`p_rate` AS `p_rate`,`item`.`s_rate` AS `s_rate` from `item` union all select 'IT' AS `comp_id`,`item`.`stock_code` AS `stock_code`,`item`.`description` AS `description`,`item`.`p_rate` AS `p_rate`,`item`.`s_rate` AS `s_rate` from `item` */;

--
-- Final view structure for view `v_item`
--

/*!50001 DROP VIEW IF EXISTS `v_item`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`pwwatmno`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_item` AS select `i`.`stock_code` AS `stock_code`,ifnull(`i`.`party_stock_code`,'') AS `party_stock_code`,concat(`i`.`stock_code`,convert(if(((`i`.`party_stock_code` is null) or (`i`.`party_stock_code` = '')),'','-') using latin1),ifnull(`i`.`party_stock_code`,'')) AS `item_code`,`i`.`description` AS `description`,`i`.`s_rate` AS `s_rate`,`i`.`p_rate` AS `p_rate`,`i`.`cat_id` AS `cat_id`,`i`.`unit` AS `unit`,`u`.`unit_name` AS `unit_name`,`i`.`msrp` AS `msrp`,`i`.`dealer_rate` AS `dealer_rate` from ((`item` `i` left join `prod_cat` `c` on((`i`.`cat_id` = `c`.`CAT_ID`))) left join `units` `u` on((`i`.`unit` = `u`.`unit`))) */;

--
-- Final view structure for view `v_item_bal`
--

/*!50001 DROP VIEW IF EXISTS `v_item_bal`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`pwwatmno`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_item_bal` AS select `i`.`stock_code` AS `stock_code`,concat(convert(`i`.`description` using utf8mb3),'-',convert(`c`.`COMP_NAME` using utf8mb3),'-',round(`v`.`bal_qty`,0)) AS `description`,`i`.`s_rate` AS `s_rate`,`i`.`p_rate` AS `p_rate`,`v`.`bal_qty` AS `bal_qty` from ((`item` `i` left join `v_current_qty` `v` on((`i`.`stock_code` = `v`.`stock_code`))) left join `company` `c` on((`v`.`comp_id` = `c`.`comp_id`))) */;

--
-- Final view structure for view `v_nom`
--

/*!50001 DROP VIEW IF EXISTS `v_nom`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`pwwatmno`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_nom` AS select `n`.`ACCT_ID` AS `acct_id`,concat(`n`.`ACCT_NAME`,convert(if((ifnull(`n`.`address`,'') = ''),'',', ') using latin1),ifnull(`n`.`address`,''),convert(if((ifnull(`n`.`city`,'') = ''),'',', ') using latin1),ifnull(`n`.`city`,'')) AS `acct_name`,`n`.`reg_id` AS `reg_id`,`n`.`COMP_ID` AS `comp_id`,`n`.`is_inactive` AS `is_inactive` from `nom` `n` where (`n`.`is_inactive` <> 'Y') */;

--
-- Final view structure for view `v_p_vouchers`
--

/*!50001 DROP VIEW IF EXISTS `v_p_vouchers`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`pwwatmno`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_p_vouchers` AS select `m`.`loc_id` AS `loc_id`,`m`.`comp_id` AS `comp_id`,`m`.`year_id` AS `year_id`,concat('PL',`m`.`voucher_id`) AS `voucher_id`,`m`.`voucher_date` AS `voucher_date`,`m`.`bill_no` AS `bill_no`,`m`.`acct_id` AS `party_id`,`p`.`acct_name` AS `party_name`,`d`.`lineitem` AS `lineitem`,`d`.`stock_code` AS `stock_code`,`i`.`description` AS `stock_name`,`d`.`rate` AS `rate`,`d`.`qty` AS `db_qty`,`d`.`itemtot` AS `db_amt`,0 AS `cr_qty`,0 AS `cr_amt`,`d`.`itemtot` AS `cost_amt`,`m`.`sp_id` AS `sp_id`,`s`.`acct_name` AS `sp_name`,`d`.`particulars` AS `particulars`,NULL AS `staxp`,NULL AS `stax`,NULL AS `add_staxp`,NULL AS `add_stax`,NULL AS `color_id`,NULL AS `size_id`,`d`.`disc_amt` AS `disc_amt`,`m`.`post_date` AS `post_date`,'' AS `limit_rate`,`d`.`bouns_qty` AS `bouns_qty` from ((((`pl_invoice` `m` left join `pl_invoicedet` `d` on(((`m`.`comp_id` = `d`.`comp_id`) and (`m`.`year_id` = `d`.`year_id`) and (`m`.`voucher_id` = `d`.`voucher_id`)))) left join `v_party` `p` on((`m`.`acct_id` = `p`.`acct_id`))) left join `item` `i` on((`d`.`stock_code` = `i`.`stock_code`))) left join `sp` `s` on((`m`.`sp_id` = `s`.`acct_id`))) union all select `m`.`loc_id` AS `loc_id`,`m`.`comp_id` AS `comp_id`,`m`.`year_id` AS `year_id`,concat('SL',`m`.`voucher_id`) AS `voucher_id`,`m`.`voucher_date` AS `voucher_date`,`m`.`bill_no` AS `bill_no`,`m`.`acct_id` AS `party_id`,`p`.`acct_name` AS `party_name`,`d`.`lineitem` AS `lineitem`,`d`.`stock_code` AS `stock_code`,`i`.`description` AS `stock_name`,`d`.`rate` AS `rate`,0 AS `db_qty`,0 AS `db_amt`,`d`.`qty` AS `cr_qty`,`d`.`itemtot` AS `cr_amt`,(`d`.`qty` * `d`.`avg_rate`) AS `cost_amt`,`m`.`sp_id` AS `sp_id`,`s`.`acct_name` AS `sp_name`,`d`.`particulars` AS `particulars`,NULL AS `staxp`,NULL AS `stax`,NULL AS `add_staxp`,NULL AS `add_stax`,NULL AS `color_id`,NULL AS `size_id`,`d`.`disc_amt` AS `disc_amt`,`m`.`post_date` AS `post_date`,`d`.`limit_rate` AS `limit_rate`,`d`.`bouns_qty` AS `bouns_qty` from ((((`sl_invoice` `m` left join `sl_invoicedet` `d` on(((`m`.`comp_id` = `d`.`comp_id`) and (`m`.`year_id` = `d`.`year_id`) and (`m`.`voucher_id` = `d`.`voucher_id`)))) left join `v_party` `p` on((`m`.`acct_id` = `p`.`acct_id`))) left join `item` `i` on((`d`.`stock_code` = `i`.`stock_code`))) left join `sp` `s` on((`m`.`sp_id` = `s`.`acct_id`))) union all select `m`.`loc_id` AS `loc_id`,`m`.`comp_id` AS `comp_id`,`m`.`year_id` AS `year_id`,concat('RT',`m`.`voucher_id`) AS `voucher_id`,`m`.`voucher_date` AS `voucher_date`,`m`.`bill_no` AS `bill_no`,`m`.`acct_id` AS `party_id`,`p`.`acct_name` AS `party_name`,`d`.`lineitem` AS `lineitem`,`d`.`stock_code` AS `stock_code`,`i`.`description` AS `stock_name`,`d`.`rate` AS `rate`,`d`.`qty` AS `db_qty`,`d`.`itemtot` AS `db_amt`,0 AS `cr_qty`,0 AS `cr_amt`,(`d`.`qty` * `d`.`avg_rate`) AS `cost_amt`,`m`.`sp_id` AS `sp_id`,`s`.`acct_name` AS `sp_name`,`d`.`particulars` AS `particulars`,NULL AS `staxp`,NULL AS `stax`,NULL AS `add_staxp`,NULL AS `add_stax`,NULL AS `color_id`,NULL AS `size_id`,`d`.`disc_amt` AS `disc_amt`,`m`.`post_date` AS `post_date`,'' AS `limit_rate`,'' AS `Name_exp_90` from ((((`sl_return` `m` left join `sl_returndet` `d` on(((`m`.`comp_id` = `d`.`comp_id`) and (`m`.`year_id` = `d`.`year_id`) and (`m`.`voucher_id` = `d`.`voucher_id`)))) left join `v_party` `p` on((`m`.`acct_id` = `p`.`acct_id`))) left join `item` `i` on((`d`.`stock_code` = `i`.`stock_code`))) left join `sp` `s` on((`m`.`sp_id` = `s`.`acct_id`))) union all select `m`.`loc_id` AS `loc_id`,`m`.`comp_id` AS `comp_id`,`m`.`year_id` AS `year_id`,concat('ST',`m`.`voucher_id`) AS `voucher_id`,`m`.`voucher_date` AS `voucher_date`,`m`.`bill_no` AS `bill_no`,'0021' AS `party_id`,'STOCK TRANSFER' AS `party_name`,`d`.`lineitem` AS `lineitem`,`d`.`stock_code` AS `stock_code`,`i`.`description` AS `stock_name`,`d`.`rate` AS `rate`,0 AS `db_qty`,0 AS `db_amt`,`d`.`qty` AS `cr_qty`,`d`.`itemtot` AS `cr_amt`,`d`.`itemtot` AS `cost_amt`,`m`.`sp_id` AS `sp_id`,`s`.`acct_name` AS `sp_name`,`d`.`particulars` AS `particulars`,NULL AS `staxp`,NULL AS `stax`,NULL AS `add_staxp`,NULL AS `add_stax`,NULL AS `color_id`,NULL AS `size_id`,`d`.`disc_amt` AS `disc_amt`,`m`.`post_date` AS `post_date`,'' AS `limit_rate`,'' AS `Name_exp_120` from ((((`stk_trans` `m` left join `stk_transdet` `d` on(((`m`.`comp_id` = `d`.`comp_id`) and (`m`.`year_id` = `d`.`year_id`) and (`m`.`voucher_id` = `d`.`voucher_id`)))) left join `v_party` `p` on((`m`.`acct_id` = `p`.`acct_id`))) left join `item` `i` on((`d`.`stock_code` = `i`.`stock_code`))) left join `sp` `s` on((`m`.`sp_id` = `s`.`acct_id`))) union all select `m`.`loc_id` AS `loc_id`,`m`.`to_comp_id` AS `comp_id`,`m`.`year_id` AS `year_id`,`m`.`voucher_id` AS `voucher_id`,`m`.`voucher_date` AS `voucher_date`,`m`.`bill_no` AS `bill_no`,'0021' AS `party_id`,'STOCK TRANSFER' AS `party_name`,`d`.`lineitem` AS `lineitem`,`d`.`stock_code` AS `stock_code`,`i`.`description` AS `stock_name`,`d`.`rate` AS `rate`,`d`.`qty` AS `db_qty`,`d`.`itemtot` AS `db_amt`,0 AS `cr_qty`,0 AS `cr_amt`,NULL AS `cost_amt`,`m`.`sp_id` AS `sp_id`,`s`.`acct_name` AS `sp_name`,`d`.`particulars` AS `particulars`,NULL AS `staxp`,NULL AS `stax`,NULL AS `add_staxp`,NULL AS `add_stax`,NULL AS `color_id`,NULL AS `size_id`,`d`.`disc_amt` AS `disc_amt`,`m`.`post_date` AS `post_date`,'' AS `limit_rate`,'' AS `Name_exp_150` from ((((`stk_trans` `m` left join `stk_transdet` `d` on(((`m`.`comp_id` = `d`.`comp_id`) and (`m`.`year_id` = `d`.`year_id`) and (`m`.`voucher_id` = `d`.`voucher_id`)))) left join `v_party` `p` on((`m`.`acct_id` = `p`.`acct_id`))) left join `item` `i` on((`d`.`stock_code` = `i`.`stock_code`))) left join `sp` `s` on((`m`.`sp_id` = `s`.`acct_id`))) union all select NULL AS `loc_id`,`v`.`comp_id` AS `comp_id`,`v`.`year_id` AS `year_id`,`v`.`voucher_id` AS `voucher_id`,`v`.`voucher_date` AS `voucher_date`,`v`.`inv_no` AS `bill_no`,`v`.`acct_id` AS `party_id`,`p`.`acct_name` AS `party_name`,`v`.`lineitem` AS `lineitem`,NULL AS `stock_code`,NULL AS `stock_name`,NULL AS `rate`,NULL AS `db_qty`,`v`.`credit` AS `db_amt`,NULL AS `cr_qty`,`v`.`debit` AS `cr_amt`,NULL AS `cost_amt`,NULL AS `sp_id`,NULL AS `sp_name`,`v`.`particulars` AS `particulars`,NULL AS `staxp`,NULL AS `stax`,NULL AS `add_staxp`,NULL AS `add_stax`,NULL AS `color_id`,NULL AS `size_id`,NULL AS `disc_amt`,`v`.`post_date` AS `post_date`,'' AS `limit_rate`,'' AS `Name_exp_180` from (`v_vouchers` `v` left join `v_party` `p` on((`v`.`acct_id` = `p`.`acct_id`))) where (substr(`v`.`voucher_id`,3,2) not in ('PL','SL','ST','RT')) union all select `v`.`loc_id` AS `loc_id`,`v`.`comp_id` AS `comp_id`,`v`.`year_id` AS `year_id`,concat('PL',`v`.`voucher_id`) AS `voucher_id`,`v`.`voucher_date` AS `voucher_date`,`v`.`inv_no` AS `bill_no`,`v`.`acct_id` AS `party_id`,`p`.`acct_name` AS `party_name`,NULL AS `lineitem`,NULL AS `stock_code`,NULL AS `stock_name`,NULL AS `rate`,NULL AS `db_qty`,NULL AS `db_amt`,NULL AS `cr_qty`,`v`.`disc_amt` AS `cr_amt`,NULL AS `cost_amt`,NULL AS `sp_id`,NULL AS `sp_name`,'Discount' AS `particulars`,NULL AS `staxp`,NULL AS `stax`,NULL AS `add_staxp`,NULL AS `add_stax`,NULL AS `color_id`,NULL AS `size_id`,NULL AS `disc_amt`,`v`.`post_date` AS `post_date`,'' AS `limit_rate`,'' AS `Name_exp_210` from (`pl_invoice` `v` left join `v_party` `p` on((`v`.`acct_id` = `p`.`acct_id`))) where (`v`.`disc_amt` <> 0) union all select `v`.`loc_id` AS `loc_id`,`v`.`comp_id` AS `comp_id`,`v`.`year_id` AS `year_id`,concat('SL',`v`.`voucher_id`) AS `voucher_id`,`v`.`voucher_date` AS `voucher_date`,`v`.`inv_no` AS `bill_no`,`v`.`acct_id` AS `party_id`,`p`.`acct_name` AS `party_name`,NULL AS `lineitem`,NULL AS `stock_code`,NULL AS `stock_name`,NULL AS `rate`,NULL AS `db_qty`,`v`.`disc_amt` AS `db_amt`,NULL AS `cr_qty`,NULL AS `cr_amt`,NULL AS `cost_amt`,NULL AS `sp_id`,NULL AS `sp_name`,'Discount' AS `particulars`,NULL AS `staxp`,NULL AS `stax`,NULL AS `add_staxp`,NULL AS `add_stax`,NULL AS `color_id`,NULL AS `size_id`,NULL AS `disc_amt`,`v`.`post_date` AS `post_date`,'' AS `limit_rate`,'' AS `Name_exp_240` from (`sl_invoice` `v` left join `v_party` `p` on((`v`.`acct_id` = `p`.`acct_id`))) where (`v`.`disc_amt` <> 0) union all select `v`.`loc_id` AS `loc_id`,`v`.`comp_id` AS `comp_id`,`v`.`year_id` AS `year_id`,concat('SL',`v`.`voucher_id`) AS `voucher_id`,`v`.`voucher_date` AS `voucher_date`,`v`.`inv_no` AS `bill_no`,`v`.`acct_id` AS `party_id`,`p`.`acct_name` AS `party_name`,NULL AS `lineitem`,NULL AS `stock_code`,NULL AS `stock_name`,NULL AS `rate`,NULL AS `db_qty`,NULL AS `db_amt`,NULL AS `cr_qty`,`v`.`dc_amt` AS `cr_amt`,NULL AS `cost_amt`,NULL AS `sp_id`,NULL AS `sp_name`,'Freight Charges' AS `particulars`,NULL AS `staxp`,NULL AS `stax`,NULL AS `add_staxp`,NULL AS `add_stax`,NULL AS `color_id`,NULL AS `size_id`,NULL AS `disc_amt`,`v`.`post_date` AS `post_date`,'' AS `limit_rate`,'' AS `Name_exp_240` from (`sl_invoice` `v` left join `v_party` `p` on((`v`.`acct_id` = `p`.`acct_id`))) where (`v`.`dc_amt` <> 0) */;

--
-- Final view structure for view `v_party`
--

/*!50001 DROP VIEW IF EXISTS `v_party`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`pwwatmno`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_party` AS select `n`.`ACCT_ID` AS `acct_id`,`n`.`ACCT_NAME` AS `acct_name`,`n`.`ur_acct_name` AS `ur_acct_name`,(case when (substr(`n`.`ACCT_ID`,1,6) = `s`.`creditor_id`) then 'S' when (substr(`n`.`ACCT_ID`,1,6) = `s`.`debtor_id`) then 'C' when (substr(`n`.`ACCT_ID`,1,6) = `s`.`cash_id`) then 'PT' when (substr(`n`.`ACCT_ID`,1,6) = `s`.`stock_id`) then 'P' else 'O' end) AS `party_type`,`n`.`city` AS `city`,`n`.`reg_id` AS `reg_id`,`n`.`sp_id` AS `sp_id`,`n`.`address` AS `address`,`n`.`phone` AS `phone`,`n`.`cnic` AS `cnic`,`n`.`ntn` AS `ntn`,`n`.`stax_no` AS `stax_no`,`n`.`COMP_ID` AS `comp_id` from (`nom` `n` join `system` `s`) where ((substr(`n`.`ACCT_ID`,1,6) in (`s`.`creditor_id`,`s`.`debtor_id`,`s`.`cash_id`)) and (length(`n`.`ACCT_ID`) = 10)) */;

--
-- Final view structure for view `v_party_bal`
--

/*!50001 DROP VIEW IF EXISTS `v_party_bal`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`pwwatmno`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_party_bal` AS select `v`.`ACCT_ID` AS `acct_id`,`n`.`acct_name` AS `acct_name`,sum(round((ifnull(`v`.`debit`,0) - ifnull(`v`.`credit`,0)),0)) AS `o_bal` from ((`voucherdet` `v` join `v_party` `n` on((`v`.`ACCT_ID` = `n`.`acct_id`))) left join `company` `c` on((`v`.`COMP_ID` = `c`.`comp_id`))) where ((1 = 1) and (`v`.`ACCT_ID` like '261000%') and (`n`.`acct_name` is not null) and (`v`.`ACCT_ID` not in ('2610000462','2610000463','2610000464','2610000804','2610001191','2610000790','2610001116','2610000886','2610001164','2610000789'))) group by `v`.`ACCT_ID`,`n`.`acct_name` having (`o_bal` > 0) order by sum(round((ifnull(`v`.`debit`,0) - ifnull(`v`.`credit`,0)),0)) desc */;

--
-- Final view structure for view `v_party_city`
--

/*!50001 DROP VIEW IF EXISTS `v_party_city`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`pwwatmno`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_party_city` AS select 1 AS `city` */;

--
-- Final view structure for view `v_stk`
--

/*!50001 DROP VIEW IF EXISTS `v_stk`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`pwwatmno`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_stk` AS select 1 AS `voucher_order`,`m`.`loc_id` AS `loc_id`,`l`.`comp_id` AS `comp_id`,`m`.`year_id` AS `year_id`,concat('PL',`m`.`voucher_id`) AS `voucher_id`,`m`.`voucher_date` AS `voucher_date`,if(((`m`.`bill_date` is null) or (`m`.`bill_date` = '1970-01-01')),`m`.`voucher_date`,`m`.`bill_date`) AS `bill_date`,`m`.`acct_id` AS `party_id`,`p`.`ACCT_NAME` AS `party_name`,`d`.`lineitem` AS `lineitem`,`d`.`stock_code` AS `stock_code`,`i`.`description` AS `stock_name`,`d`.`rate` AS `rate`,(`d`.`qty` + ifnull(`d`.`bouns_qty`,0)) AS `db_qty`,`d`.`itemtot` AS `db_amt`,0 AS `cr_qty`,0 AS `cr_amt`,`m`.`comp_id` AS `v_comp_id` from ((((`pl_invoice` `m` left join `pl_invoicedet` `d` on(((`m`.`comp_id` = `d`.`comp_id`) and (`m`.`year_id` = `d`.`year_id`) and (`m`.`voucher_id` = `d`.`voucher_id`)))) left join `nom` `p` on((`m`.`acct_id` = `p`.`ACCT_ID`))) left join `item` `i` on((`d`.`stock_code` = `i`.`stock_code`))) left join `location` `l` on((`m`.`loc_id` = `l`.`loc_id`))) union all select 1 AS `voucher_order`,`m`.`loc_id` AS `loc_id`,`l`.`comp_id` AS `comp_id`,`m`.`year_id` AS `year_id`,concat('PR',`m`.`voucher_id`) AS `voucher_id`,`m`.`voucher_date` AS `voucher_date`,if(((`m`.`bill_date` is null) or (`m`.`bill_date` = '1970-01-01')),`m`.`voucher_date`,`m`.`bill_date`) AS `bill_date`,`m`.`acct_id` AS `party_id`,`p`.`ACCT_NAME` AS `party_name`,`d`.`lineitem` AS `lineitem`,`d`.`stock_code` AS `stock_code`,`i`.`description` AS `stock_name`,`d`.`rate` AS `rate`,0 AS `db_qty`,0 AS `db_amt`,`d`.`qty` AS `cr_qty`,`d`.`itemtot` AS `cr_amt`,`m`.`comp_id` AS `v_comp_id` from ((((`pl_return` `m` left join `pl_returndet` `d` on(((`m`.`comp_id` = `d`.`comp_id`) and (`m`.`year_id` = `d`.`year_id`) and (`m`.`voucher_id` = `d`.`voucher_id`)))) left join `nom` `p` on((`m`.`acct_id` = `p`.`ACCT_ID`))) left join `item` `i` on((`d`.`stock_code` = `i`.`stock_code`))) left join `location` `l` on((`m`.`loc_id` = `l`.`loc_id`))) union all select 2 AS `voucher_order`,`m`.`loc_id` AS `loc_id`,`l`.`comp_id` AS `comp_id`,`m`.`year_id` AS `year_id`,concat('SL',`m`.`voucher_id`) AS `voucher_id`,`m`.`voucher_date` AS `voucher_date`,if(((`m`.`bill_date` is null) or (`m`.`bill_date` = '1970-01-01')),`m`.`voucher_date`,`m`.`bill_date`) AS `bill_date`,`m`.`acct_id` AS `party_id`,`p`.`ACCT_NAME` AS `party_name`,`d`.`lineitem` AS `lineitem`,`d`.`stock_code` AS `stock_code`,`i`.`description` AS `stock_name`,`d`.`avg_rate` AS `rate`,0 AS `db_qty`,0 AS `db_amt`,(`d`.`qty` + ifnull(`d`.`bouns_qty`,0)) AS `cr_qty`,(`d`.`avg_rate` * `d`.`qty`) AS `cr_amt`,`m`.`comp_id` AS `v_comp_id` from ((((`sl_invoice` `m` left join `sl_invoicedet` `d` on(((`m`.`comp_id` = `d`.`comp_id`) and (`m`.`year_id` = `d`.`year_id`) and (`m`.`voucher_id` = `d`.`voucher_id`)))) left join `nom` `p` on((`m`.`acct_id` = `p`.`ACCT_ID`))) left join `item` `i` on((`d`.`stock_code` = `i`.`stock_code`))) left join `location` `l` on((`m`.`loc_id` = `l`.`loc_id`))) where (concat(`m`.`year_id`,`m`.`voucher_id`) not in ('18145','18148','18080002')) union all select 3.1 AS `voucher_order`,`m`.`loc_id` AS `loc_id`,`m`.`comp_id` AS `comp_id`,`m`.`year_id` AS `year_id`,concat('ST',`m`.`voucher_id`) AS `voucher_id`,`m`.`voucher_date` AS `voucher_date`,`m`.`voucher_date` AS `bill_date`,'0021' AS `party_id`,'STOCK TRANSFER' AS `party_name`,`d`.`lineitem` AS `lineitem`,`d`.`stock_code` AS `stock_code`,`i`.`description` AS `stock_name`,`d`.`rate` AS `rate`,0 AS `db_qty`,0 AS `db_amt`,`d`.`qty` AS `cr_qty`,`d`.`itemtot` AS `cr_amt`,`m`.`comp_id` AS `v_comp_id` from (((`stk_trans` `m` left join `stk_transdet` `d` on(((`m`.`comp_id` = `d`.`comp_id`) and (`m`.`year_id` = `d`.`year_id`) and (`m`.`voucher_id` = `d`.`voucher_id`)))) left join `nom` `p` on((`m`.`acct_id` = `p`.`ACCT_ID`))) left join `item` `i` on((`d`.`stock_code` = `i`.`stock_code`))) union all select 3.2 AS `voucher_order`,`m`.`to_loc_id` AS `loc_id`,`m`.`to_comp_id` AS `comp_id`,`m`.`year_id` AS `year_id`,`m`.`voucher_id` AS `voucher_id`,`m`.`voucher_date` AS `voucher_date`,`m`.`voucher_date` AS `bill_date`,'0021' AS `party_id`,'STOCK TRANSFER' AS `party_name`,`d`.`lineitem` AS `lineitem`,`d`.`stock_code` AS `stock_code`,`i`.`description` AS `stock_name`,`d`.`rate` AS `rate`,`d`.`qty` AS `db_qty`,`d`.`itemtot` AS `db_amt`,0 AS `cr_qty`,0 AS `cr_amt`,`m`.`comp_id` AS `v_comp_id` from (((`stk_trans` `m` left join `stk_transdet` `d` on(((`m`.`comp_id` = `d`.`comp_id`) and (`m`.`year_id` = `d`.`year_id`) and (`m`.`voucher_id` = `d`.`voucher_id`)))) left join `v_party` `p` on((`m`.`acct_id` = `p`.`acct_id`))) left join `item` `i` on((`d`.`stock_code` = `i`.`stock_code`))) union all select 3.4 AS `voucher_order`,`m`.`loc_id` AS `loc_id`,`l`.`comp_id` AS `comp_id`,`m`.`year_id` AS `year_id`,concat('RT',`m`.`voucher_id`) AS `voucher_id`,`m`.`voucher_date` AS `voucher_date`,`m`.`voucher_date` AS `bill_date`,`m`.`acct_id` AS `party_id`,`p`.`ACCT_NAME` AS `party_name`,`d`.`lineitem` AS `lineitem`,`d`.`stock_code` AS `stock_code`,concat(convert(`i`.`description` using utf8mb3),convert(if((ifnull(`i`.`specs`,'') = ''),'',concat('-',`i`.`specs`)) using utf8mb3)) AS `stock_name`,`d`.`rate` AS `rate`,`d`.`qty` AS `db_qty`,(`d`.`itemtot` - ifnull(`d`.`stax`,0)) AS `db_amt`,0 AS `cr_qty`,0 AS `cr_amt`,`m`.`comp_id` AS `v_comp_id` from ((((`sl_return` `m` left join `sl_returndet` `d` on(((`m`.`comp_id` = `d`.`comp_id`) and (`m`.`year_id` = `d`.`year_id`) and (`m`.`voucher_id` = `d`.`voucher_id`)))) left join `nom` `p` on((`m`.`acct_id` = `p`.`ACCT_ID`))) left join `item` `i` on((`d`.`stock_code` = `i`.`stock_code`))) left join `location` `l` on((`m`.`loc_id` = `l`.`loc_id`))) where (`m`.`posted` = 'on') union all select 1.2 AS `voucher_order`,`b`.`loc_id` AS `loc_id`,`m`.`comp_id` AS `comp_id`,`m`.`year_id` AS `year_id`,concat('FG',`m`.`voucher_id`) AS `voucher_id`,`m`.`voucher_date` AS `voucher_date`,`m`.`voucher_date` AS `voucher_date`,NULL AS `party_id`,concat('Production: ',if((convert(substr(`b`.`batch_date`,-(8)) using utf8mb4) = '00:00:00'),' ',convert(date_format(`b`.`batch_date`,'%h:%i %p') using utf8mb4))) AS `party_name`,`b`.`ser_no` AS `lineitem`,`b`.`stock_code` AS `stock_code`,`i`.`description` AS `stock_name`,((((`i`.`pack_size` * `b`.`qty`) / `i2`.`pack_size`) * `m_i_d`.`rate`) / `b`.`qty`) AS `rate`,`b`.`qty` AS `db_qty`,(((((`i`.`pack_size` * `b`.`qty`) / `i2`.`pack_size`) * `m_i_d`.`rate`) / `b`.`qty`) * `b`.`qty`) AS `db_amt`,0 AS `cr_qty`,0 AS `cr_amt`,`m`.`comp_id` AS `v_comp_id` from ((((`mo` `m` left join `mo_batch` `b` on(((`m`.`comp_id` = `b`.`comp_id`) and (`m`.`year_id` = `b`.`year_id`) and (`m`.`voucher_id` = `b`.`voucher_id`)))) left join `item` `i` on((`b`.`stock_code` = `i`.`stock_code`))) left join `mo_issue_det` `m_i_d` on(((`b`.`comp_id` = `m_i_d`.`comp_id`) and (`b`.`year_id` = `m_i_d`.`year_id`) and (`b`.`voucher_id` = `m_i_d`.`voucher_id`) and (`b`.`lineitem` = `m_i_d`.`lineitem`)))) left join `item` `i2` on((`m_i_d`.`stock_code` = `i2`.`stock_code`))) where (`m`.`posted` = 'on') union all select 1.2 AS `voucher_order`,`m`.`loc_id` AS `loc_id`,`m`.`comp_id` AS `comp_id`,`m`.`year_id` AS `year_id`,concat('CO',`m`.`voucher_id`) AS `voucher_id`,`m`.`voucher_date` AS `voucher_date`,`m`.`voucher_date` AS `voucher_date`,NULL AS `party_id`,concat('Jaam:',convert(`f_mo_issue_products`(`m`.`comp_id`,`m`.`year_id`,`m`.`voucher_id`) using utf8mb4)) AS `party_name`,1 AS `lineitem`,`m`.`stock_code` AS `stock_code`,`i`.`description` AS `stock_name`,`m`.`rate` AS `rate`,`m`.`qty` AS `db_qty`,`m`.`amount` AS `db_amt`,0 AS `cr_qty`,0 AS `cr_amt`,`m`.`comp_id` AS `v_comp_id` from (`mo` `m` left join `item` `i` on((`m`.`stock_code` = `i`.`stock_code`))) where (`m`.`posted` = 'on') union all select 2.2 AS `voucher_order`,`d2`.`loc_id` AS `loc_id`,`m`.`comp_id` AS `comp_id`,`m`.`year_id` AS `year_id`,concat('CO',`m`.`voucher_id`) AS `voucher_id`,`d`.`voucher_date` AS `voucher_date`,`d`.`voucher_date` AS `voucher_date`,NULL AS `party_id`,concat(if((`m`.`stock_code` = ''),'Grinding:','Converted'),convert(`f_mo_products`(`d`.`comp_id`,`m`.`year_id`,`m`.`voucher_id`) using utf8mb4)) AS `party_name`,`d2`.`lineitem` AS `lineitem`,`d2`.`stock_code` AS `stock_code`,`i2`.`description` AS `stock_name`,`d2`.`rate` AS `rate`,0 AS `db_qty`,0 AS `db_amt`,`d2`.`qty` AS `cr_qty`,`d2`.`itemtot` AS `cr_amt`,`m`.`comp_id` AS `v_comp_id` from ((((`mo` `m` left join `item` `i` on((`m`.`stock_code` = `i`.`stock_code`))) left join `mo_issue` `d` on(((`m`.`comp_id` = `d`.`comp_id`) and (`m`.`year_id` = `d`.`year_id`) and (`m`.`voucher_id` = `d`.`voucher_id`)))) left join `mo_issue_det` `d2` on(((`d`.`comp_id` = `d2`.`comp_id`) and (`d`.`year_id` = `d2`.`year_id`) and (`d`.`voucher_id` = `d2`.`voucher_id`) and (`d`.`ser_no` = `d2`.`ser_no`)))) left join `item` `i2` on((`d2`.`stock_code` = `i2`.`stock_code`))) where (`m`.`posted` = 'on') */;

--
-- Final view structure for view `v_supplier_bal`
--

/*!50001 DROP VIEW IF EXISTS `v_supplier_bal`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`pwwatmno`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_supplier_bal` AS select `v`.`ACCT_ID` AS `acct_id`,`n`.`acct_name` AS `acct_name`,sum(round((ifnull(`v`.`debit`,0) - ifnull(`v`.`credit`,0)),0)) AS `o_bal` from ((`voucherdet` `v` join `v_party` `n` on((`v`.`ACCT_ID` = `n`.`acct_id`))) left join `company` `c` on((`v`.`COMP_ID` = `c`.`comp_id`))) where ((1 = 1) and (`v`.`ACCT_ID` like '131000%') and (`n`.`acct_name` is not null)) group by `v`.`ACCT_ID`,`n`.`acct_name` having (`o_bal` > 0) order by sum(round((ifnull(`v`.`debit`,0) - ifnull(`v`.`credit`,0)),0)) desc */;

--
-- Final view structure for view `v_system`
--

/*!50001 DROP VIEW IF EXISTS `v_system`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`pwwatmno`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_system` AS select `system`.`comp_name` AS `comp_name`,`system`.`cash_id` AS `cash_id`,`system`.`bank_id` AS `bank_id`,`system`.`creditor_id` AS `creditor_id`,`system`.`stax_id` AS `stax_id`,`system`.`dc_id` AS `dc_id`,`system`.`disc_id` AS `disc_id`,`system`.`debtor_id` AS `debtor_id`,`system`.`adv_id` AS `adv_id`,`system`.`db_id` AS `db_id`,`system`.`ret_id` AS `ret_id`,`system`.`sec_id` AS `sec_id`,`system`.`stax_id_sl` AS `stax_id_sl`,`system`.`dc_id_sl` AS `dc_id_sl`,`system`.`disc_id_sl` AS `disc_id_sl`,`system`.`adv_id_sl` AS `adv_id_sl`,`system`.`db_id_sl` AS `db_id_sl`,`system`.`ret_id_sl` AS `ret_id_sl`,`system`.`sec_id_sl` AS `sec_id_sl`,`system`.`stock_id` AS `stock_id`,`system`.`turnover_id` AS `turnover_id`,`system`.`cogs_id` AS `cogs_id`,`system`.`sed_id` AS `sed_id`,`system`.`sed_id_sl` AS `sed_id_sl`,`system`.`hide_taxes` AS `hide_taxes`,`system`.`date_from` AS `date_from`,`system`.`date_to` AS `date_to`,`system`.`ait_id` AS `ait_id`,`system`.`cdi_id` AS `cdi_id`,`system`.`date_close` AS `date_close`,`system`.`email` AS `email`,`system`.`qty_decimal` AS `qty_decimal`,`system`.`fed_id` AS `fed_id`,`system`.`fed_id_sl` AS `fed_id_sl`,`system`.`stock_transfer_id` AS `stock_transfer_id`,`system`.`login_page` AS `login_page`,`system`.`sale_form` AS `sale_form`,`system`.`qty_decimals` AS `qty_decimals`,`system`.`rate_decimals` AS `rate_decimals`,`system`.`voucher_print` AS `voucher_print`,`system`.`jv_print` AS `jv_print`,`system`.`purchase_print` AS `purchase_print`,`system`.`sale_print` AS `sale_print`,`system`.`amt_decimals` AS `amt_decimals`,`system`.`sale_inv_no_lbl` AS `sale_inv_no_lbl`,`system`.`lbl_sl_invoice_dc_amt` AS `lbl_sl_invoice_dc_amt`,`system`.`staxp` AS `staxp`,`system`.`sms` AS `sms`,`system`.`cs` AS `cs`,`system`.`l2` AS `l2`,`system`.`dc_print` AS `dc_print`,`system`.`lbl_sl_invoice_customer_name` AS `lbl_sl_invoice_customer_name`,`system`.`user_rep_days` AS `user_rep_days` from `system` */;

--
-- Final view structure for view `v_vouchers`
--

/*!50001 DROP VIEW IF EXISTS `v_vouchers`*/;

--
-- Final view structure for view `v_vouchers_pdc`
--

/*!50001 DROP VIEW IF EXISTS `v_vouchers_pdc`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`pwwatmno`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_vouchers_pdc` AS select (case when (substr(`v`.`VOUCHER_ID`,1,2) = 'SL') then concat('Sales-',`v`.`COMP_ID`) when (substr(`v`.`VOUCHER_ID`,1,2) = 'PL') then concat('Purchase-',`v`.`COMP_ID`) when (substr(`v`.`VOUCHER_ID`,1,2) = 'CP') then concat('Cash Payment-',`v`.`COMP_ID`) when (substr(`v`.`VOUCHER_ID`,1,2) = 'CR') then concat('Cash Receipt-',`v`.`COMP_ID`) when (substr(`v`.`VOUCHER_ID`,1,2) = 'BP') then concat('Bank Payment-',`v`.`COMP_ID`) when (substr(`v`.`VOUCHER_ID`,1,2) = 'BR') then concat('Bank Receipt-',`v`.`COMP_ID`) when (substr(`v`.`VOUCHER_ID`,1,2) = 'JV') then concat('Journal-',`v`.`COMP_ID`) when (substr(`v`.`VOUCHER_ID`,1,2) = 'ST') then concat('Stock Transfer-',`v`.`COMP_ID`) else '' end) AS `voucher_type`,(case when (substr(`v`.`VOUCHER_ID`,1,2) = 'SL') then 1 when (substr(`v`.`VOUCHER_ID`,2,1) = 'R') then 2 when (substr(`v`.`VOUCHER_ID`,2,1) = 'P') then 3 when (substr(`v`.`VOUCHER_ID`,1,2) = 'PL') then 4 when (substr(`v`.`VOUCHER_ID`,1,2) = 'JV') then 5 else 9 end) AS `voucher_order`,`v`.`COMP_ID` AS `comp_id`,concat(`v`.`COMP_ID`,`v`.`VOUCHER_ID`,'/',`vd`.`LINEITEM`) AS `voucher_id`,NULL AS `inv_no`,NULL AS `description`,`v`.`VOUCHER_DATE` AS `voucher_date`,`v`.`ACCT_ID_CS_1` AS `acct_id_cs_1`,`v`.`ACCT_ID_CS_2` AS `acct_id_cs_2`,`vd`.`LINEITEM` AS `lineitem`,`vd`.`ACCT_ID` AS `acct_id`,`vd`.`ACCT_ID_CS` AS `acct_id_cs`,if((`vd`.`credit` < 0),-(`vd`.`credit`),if((`vd`.`debit` > 0),`vd`.`debit`,0)) AS `debit`,if((`vd`.`debit` < 0),-(`vd`.`debit`),if((`vd`.`credit` > 0),`vd`.`credit`,0)) AS `credit`,`n`.`ACCT_NAME` AS `acct_name`,concat((case when (`n3`.`ACCT_NAME` is not null) then concat(trim(`n3`.`ACCT_NAME`),'/') when (`n4`.`ACCT_NAME` is not null) then concat(trim(`n4`.`ACCT_NAME`),'/') when ((`n2`.`ACCT_NAME` is not null) and (`n3`.`ACCT_NAME` is null)) then concat(trim(`n2`.`ACCT_NAME`),'/') else '' end),ifnull(`vd`.`PARTICULARS`,''),if((`vd`.`CHQ_NO` <> ''),concat(' Chq#',`vd`.`CHQ_NO`),''),convert(if((`vd`.`CHQ_DATE` <> '0000-00-00'),concat(' Dated: ',convert(date_format(`vd`.`CHQ_DATE`,'%d-%m-%y') using utf8mb4)),'') using latin1),convert(if((`vd`.`chq_clr_date` <> '0000-00-00'),concat(' Cleared On: ',convert(date_format(`vd`.`chq_clr_date`,'%d-%m-%y') using utf8mb4)),'') using latin1)) AS `particulars`,`v`.`POSTED` AS `posted`,`v`.`post_date` AS `post_date`,`vd`.`mode_id` AS `mode_id`,`vd`.`CHQ_NO` AS `chq_no`,`vd`.`CHQ_DATE` AS `chq_date`,`vd`.`chq_clr_date` AS `chq_clr_date` from (((((`voucher` `v` left join `voucherdet` `vd` on(((`v`.`VOUCHER_ID` = `vd`.`VOUCHER_ID`) and (`v`.`COMP_ID` = `vd`.`COMP_ID`) and (`v`.`YEAR_ID` = `vd`.`YEAR_ID`)))) left join `nom` `n` on((`vd`.`ACCT_ID` = `n`.`ACCT_ID`))) left join `nom` `n2` on((`vd`.`ACCT_ID_CS` = `n2`.`ACCT_ID`))) left join `nom` `n3` on((`v`.`ACCT_ID_CS_1` = `n3`.`ACCT_ID`))) left join `nom` `n4` on((`v`.`ACCT_ID_CS_2` = `n4`.`ACCT_ID`))) where ((`v`.`POSTED` = 'on') and (0 <> if((`vd`.`CHQ_DATE` <> '0000-00-00'),(`vd`.`chq_clr_date` = '0000-00-00'),(1 = 2)))) */;


