bcmath for arbitrary precision
This commit is contained in:
		@@ -104,17 +104,9 @@ class CreateDocumentTransaction extends Job
 | 
				
			|||||||
        $total_amount = $this->model->amount - $this->model->paid;
 | 
					        $total_amount = $this->model->amount - $this->model->paid;
 | 
				
			||||||
        unset($this->model->reconciled);
 | 
					        unset($this->model->reconciled);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // For amount cover integer
 | 
					        $compare = bccomp($amount, $total_amount, $this->currency->precision);
 | 
				
			||||||
        $multiplier = 1;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for ($i = 0; $i < $this->currency->precision; $i++) {
 | 
					        if ($compare === 1) {
 | 
				
			||||||
            $multiplier *= 10;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $amount_check = (int) ($amount * $multiplier);
 | 
					 | 
				
			||||||
        $total_amount_check = (int) ($total_amount * $multiplier);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if ($amount_check > $total_amount_check) {
 | 
					 | 
				
			||||||
            $error_amount = $total_amount;
 | 
					            $error_amount = $total_amount;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if ($this->model->currency_code != $this->request['currency_code']) {
 | 
					            if ($this->model->currency_code != $this->request['currency_code']) {
 | 
				
			||||||
@@ -139,7 +131,7 @@ class CreateDocumentTransaction extends Job
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            throw new \Exception($message);
 | 
					            throw new \Exception($message);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $this->model->status = ($amount_check == $total_amount_check) ? 'paid' : 'partial';
 | 
					            $this->model->status = ($compare === 0) ? 'paid' : 'partial';
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user