daily pastebin goal
47%
SHARE
TWEET

Untitled

a guest Dec 14th, 2018 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. namespace Sts\CmsOrder\BO;
  4.  
  5. use Sts\PleafCore\BusinessFunction;
  6. use Sts\PleafCore\CoreException;
  7. use DB;
  8. use Log;
  9. use Sts\CmsCommon\Helpers\TaskSalesValidation;
  10. use Sts\PleafCore\Util\ValidationUtil;
  11. /**
  12. * @author Sulfano Agus Fikri, 28/08/2018
  13. * @in
  14. * - userId
  15. * - customerId
  16. * - status
  17. * @out
  18. * - invoiceCustomerList []
  19. */
  20.  
  21. class GetInvoiceCustomerList implements BusinessFunction {
  22.  
  23.     public function getDescription(){
  24.         return "Digunakan untuk mendapatkan daftar invoice customer";
  25.     }
  26.  
  27.     public function execute($dto){
  28.         \Log::info('GetInvoiceCustomerList');          
  29.         \log::debug($dto);
  30.        
  31.         ValidationUtil::valNumber($dto, "userId");
  32.         ValidationUtil::valNumber($dto, "customerId");
  33.         TaskSalesValidation::valCustomerId($dto['customerId']);
  34.         TaskSalesValidation::valSalesmanId($dto['userId']);
  35.        
  36.         $status     = $dto['status'];    
  37.         $date     = $dto['date'];    
  38.  
  39.         $params=[
  40.             "customerId"=>$dto['customerId']    
  41.         ];
  42.  
  43.  
  44.         if($status != NULL AND $status != ''){
  45.             TaskSalesValidation::valStatusOrder($dto['status']);  
  46.             $params['date'] = $date;
  47.         }                
  48.          
  49.    
  50.         $query = "
  51.             SELECT  A.partner_id, A.doc_no, A.doc_date, A.due_date, SUM(D.amount - D.payment_amount) as receivables_amount
  52.            FROM fi_invoice_ar A
  53.            INNER JOIN fi_invoice_ar_balance D ON A.invoice_ar_id = D.invoice_ar_id
  54.            INNER JOIN m_partner B ON A.partner_id = B.partner_id
  55.            INNER JOIN t_user C ON B.partner_code = C.username
  56.            WHERE C.user_id = :customerId
  57.            AND D.flg_payment = 'N'
  58.            
  59.        ";                                                
  60.        
  61.         if($status != NULL AND $status != ''){
  62.             if($status == 'F'){
  63.                 $query .= " AND A.due_date <= :date";
  64.             }else if($status == 'R'){
  65.                 $query .= " AND A.due_date > :date";
  66.             }else{
  67.                 throw new CoreException(_STATUS_ORDER_NOT_VALID);
  68.             }
  69.            
  70.         }  
  71.  
  72.         $query .= " GROUP BY A.partner_id, A.doc_no, A.doc_date, A.due_date
  73.                    ORDER BY A.doc_no DESC";
  74.        
  75.         $invoiceCustomerList = DB::select($query, $params);
  76.        
  77.         return [
  78.             "invoiceCustomerList"   => $invoiceCustomerList,
  79.          ];
  80.     }
  81. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top