コード例 #1
0
ファイル: DomainSCM.php プロジェクト: xander-mbaka/momentum
 public function submit()
 {
     if ($this->prepare()) {
         $voucher = TransactionProcessor::ProcessPayment($this);
         if ($voucher) {
             //payment has gone trough;
             $supplier = Supplier::GetSupplier($this->supplierId);
             $grns = PurchaseInvoice::GetUnclearedInvoices($this->supplierId);
             if ($supplier->balance->amount > 0) {
                 $amount = $this->amount->amount;
             } else {
                 //if supplier has a prepayment (-ve ba)
                 $amount = $this->amount->amount - $supplier->balance->amount;
             }
             $paidamt = floatval(0.0);
             $credgrn = '';
             foreach ($grns as $grn) {
                 if ($amount - $paidamt >= $grn->balance->amount) {
                     $paidamt = $paidamt + $grn->balance->amount;
                     $grn->credit(floatval($grn->balance->amount));
                     $credgrn .= $grn->id . ',';
                 } elseif ($amount - $paidamt < $grn->balance->amount && $amount - $paidamt > 0.0) {
                     $grn->credit(floatval($amount - $paidamt));
                     $credgrn .= $grn->id . ',';
                     $paidamt = $paidamt + ($amount - $paidamt);
                 } elseif ($amount == $paidamt) {
                     break;
                 }
             }
             $this->status = 1;
             $this->updateParticulars($credgrn);
             return $voucher;
         } else {
             return false;
         }
     }
     //make the journal entry based on the invoicing TX
     //Cr - Sales
     //Dr - Debtors [A/C Receivable]
     //Dr - Taxes Collectable
 }
コード例 #2
0
 public function submit()
 {
     if ($this->prepare()) {
         $voucher = TransactionProcessor::ProcessPayment($this);
         if ($voucher) {
             //payment has gone trough;
             if ($this->projectId != 0) {
                 $project = Project::GetProject($this->projectId);
                 $project->credit($this->amount);
             }
             $this->status = 1;
             $this->updateStatus();
             return $voucher;
         } else {
             return false;
         }
     }
     //make the journal entry based on the invoicing TX
     //Cr - Sales
     //Dr - Debtors [A/C Receivable]
     //Dr - Taxes Collectable
 }