Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Sts\CmsOrder\BO;
- use Sts\PleafCore\BusinessFunction;
- use Sts\PleafCore\CoreException;
- use DB;
- use Log;
- use Sts\CmsCommon\Helpers\TaskSalesValidation;
- use Sts\PleafCore\Util\ValidationUtil;
- /**
- * @author Sulfano Agus Fikri, 28/08/2018
- * @in
- * - userId
- * - customerId
- * - status
- * @out
- * - invoiceCustomerList []
- */
- class GetInvoiceCustomerList implements BusinessFunction {
- public function getDescription(){
- return "Digunakan untuk mendapatkan daftar invoice customer";
- }
- public function execute($dto){
- \Log::info('GetInvoiceCustomerList');
- \log::debug($dto);
- ValidationUtil::valNumber($dto, "userId");
- ValidationUtil::valNumber($dto, "customerId");
- TaskSalesValidation::valCustomerId($dto['customerId']);
- TaskSalesValidation::valSalesmanId($dto['userId']);
- $status = $dto['status'];
- $date = $dto['date'];
- $params=[
- "customerId"=>$dto['customerId']
- ];
- if($status != NULL AND $status != ''){
- TaskSalesValidation::valStatusOrder($dto['status']);
- $params['date'] = $date;
- }
- $query = "
- SELECT A.partner_id, A.doc_no, A.doc_date, A.due_date, SUM(D.amount - D.payment_amount) as receivables_amount
- FROM fi_invoice_ar A
- INNER JOIN fi_invoice_ar_balance D ON A.invoice_ar_id = D.invoice_ar_id
- INNER JOIN m_partner B ON A.partner_id = B.partner_id
- INNER JOIN t_user C ON B.partner_code = C.username
- WHERE C.user_id = :customerId
- AND D.flg_payment = 'N'
- ";
- if($status != NULL AND $status != ''){
- if($status == 'F'){
- $query .= " AND A.due_date <= :date";
- }else if($status == 'R'){
- $query .= " AND A.due_date > :date";
- }else{
- throw new CoreException(_STATUS_ORDER_NOT_VALID);
- }
- }
- $query .= " GROUP BY A.partner_id, A.doc_no, A.doc_date, A.due_date
- ORDER BY A.doc_no DESC";
- $invoiceCustomerList = DB::select($query, $params);
- return [
- "invoiceCustomerList" => $invoiceCustomerList,
- ];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement