当前位置: 首页>>代码示例>>PHP>>正文


PHP Receipt::setEarlyPaymentDiscount方法代码示例

本文整理汇总了PHP中Receipt::setEarlyPaymentDiscount方法的典型用法代码示例。如果您正苦于以下问题:PHP Receipt::setEarlyPaymentDiscount方法的具体用法?PHP Receipt::setEarlyPaymentDiscount怎么用?PHP Receipt::setEarlyPaymentDiscount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Receipt的用法示例。


在下文中一共展示了Receipt::setEarlyPaymentDiscount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: initReceipt

 function initReceipt($payment, $taxType)
 {
     $receipt = new Receipt();
     $receipt->setReceiptDate(date("Y-m-d", strtotime("now")));
     $receipt->setReceivedFrom($payment->getOwnerID());
     $receipt->setTaxType($taxType);
     if ($payment->getDueID() != "") {
         $due = $this->captureDueDetails($payment->getDueID());
     } else {
         if ($payment->getBacktaxTDID() != "") {
             $due = $this->captureBacktaxTDDetails($payment->getBacktaxTDID(), $payment->getDueType());
         } else {
             // should not get here.
             // cannot establish taxDue and thus a proper receipt.
             // exit("error. payment has no dueID / backtaxTDID associated. cannot establish receipts");
         }
     }
     switch ($taxType) {
         case "basic":
             $receipt->setTaxDue(un_number_format($due->getBasicTax()));
             break;
         case "sef":
             $receipt->setTaxDue(un_number_format($due->getSefTax()));
             break;
         case "idle":
             $receipt->setTaxDue(un_number_format($due->getIdleTax()));
             break;
     }
     // use: basicAdvancedPaymentDiscount = (advancedPaymentDiscount/taxDue)(basicTax)
     $advancedPaymentDiscount = un_number_format($payment->getAdvancedPaymentDiscount()) / un_number_format($payment->getTaxDue());
     $advancedPaymentDiscount = $advancedPaymentDiscount * un_number_format($receipt->getTaxDue());
     $receipt->setAdvancedPaymentDiscount($advancedPaymentDiscount);
     // use: basicEarlyPaymentDiscount = (earlyPaymentDiscount/taxDue)(basicTax)
     $earlyPaymentDiscount = un_number_format($payment->getEarlyPaymentDiscount()) / un_number_format($payment->getTaxDue());
     $earlyPaymentDiscount = $earlyPaymentDiscount * un_number_format($receipt->getTaxDue());
     $receipt->setEarlyPaymentDiscount($earlyPaymentDiscount);
     // if amountPaidForQuartersForTaxType > 0 use
     // use: basicPenalty = (penalty/balanceDue)(basicTax)
     // else
     // use: basicPenalty = (penalty/taxDue)(basicTax)
     if ($amountPaidForQuartersForTaxType > 0) {
         $penalty = un_number_format($payment->getPenalty()) / un_number_format($payment->getBalanceDue());
         $penalty = $penalty * un_number_format($receipt->getTaxDue());
     } else {
         $penalty = un_number_format($payment->getPenalty()) / un_number_format($payment->getTaxDue());
         $penalty = $penalty * un_number_format($receipt->getTaxDue());
     }
     $receipt->setPenalty($penalty);
     $receipt->setAmnesty($payment->getAmnesty());
     // use:
     // basicBalanceDue = basicTax
     // ** if discount > 0 : basicBalanceDue = basicTax - [basicEarlyPaymentDiscount or basicAdvancedPaymentDiscount]
     // ** if amnesty is true : basicBalanceDue += basicPenalty
     // basicBalance Due = basicBalanceDue - paidBasic
     $balanceDue = $receipt->getTaxDue();
     if ($receipt->getAdvancedPaymentDiscount() > 0) {
         $balanceDue = $receipt->getTaxDue() - $receipt->getAdvancedPaymentDiscount();
     } else {
         if ($receipt->getEarlyPaymentDiscount() > 0) {
             $balanceDue = $receipt->getTaxDue() - $receipt->getEarlyPaymentDiscount();
         }
     }
     if ($receipt->getAmnesty() != "true") {
         $balanceDue = $balanceDue + un_number_format($receipt->getPenalty());
     }
     $paidTotals = $this->getPaidTotals($payment->getDueID(), $payment->getBacktaxTDID(), $payment->getDueType(), $taxType);
     // if Due Type is "Annual" and previous "Quarter" payments have been made, adjust the Tax Due:
     // this is for reverted annual payments from quarterly mode
     if (is_a($due, "Due")) {
         if ($due->getDueType() == "Annual") {
             $amountPaidForQuartersForTaxType = $this->getAmountPaidForQuarters($due, $taxType);
         }
         if ($amountPaidForQuartersForTaxType > 0) {
             $paidTotals = $amountPaidForQuartersForTaxType;
         }
     }
     $balanceDue = $balanceDue - $paidTotals;
     $receipt->setBalanceDue($balanceDue);
     // use: basicAmountPaid = (basicBalanceDue/balanceDue)(amountPaid)
     $amountPaid = un_number_format($receipt->getBalanceDue()) / un_number_format($payment->getBalanceDue());
     $amountPaid = $amountPaid * un_number_format($payment->getAmountPaid());
     $receipt->setAmountPaid($amountPaid);
     return $receipt;
 }
开发者ID:armic,项目名称:erpts,代码行数:84,代码来源:PaymentReceiptDetails.php


注:本文中的Receipt::setEarlyPaymentDiscount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。