app/Actions/Billing/GenerateInvoice.php
/**
     * Creates bill. Note we are passing updatedSubscription and that's because we want to have next subscriptions bill
     * as we are taking advance fees from members
     * @param $subscription
     * @param $updatedSubscription
     * @return mixed
     */
Creates bill. Note we are passing updatedSubscription and that's because we want to have next subscriptions bill
as we are taking advance fees from members
@param $subscription
@param $updatedSubscription
@return mixed
Creates bill . Note we are passing updatedSubscription and that ' s because we want to have next subscriptions bill as we are taking advance fees from members @param $subscription @param $updatedSubscription @return mixed
public static function createBillingEntry(
        $subscription,
        $updatedSubscription
    ) {
        $todaysDate = Carbon::now();
        $todaysDateString = $todaysDate->toDateString();
        $billDueDate = $todaysDate->addDays(7);
        $billDueDateString = $billDueDate->toDateString();
        $billNumber = BillingServices::generateBillNumber();
        $finanicalYear = CommonServices::getFinancialYear();
        $previousOutstandingAmount =
            $subscription["account"]["outstanding_payment"];
        $accountID = $subscription["account_id"];
        $planFees = $updatedSubscription["plan"]["fee"];
        $planID = $updatedSubscription["plan_id"];
        $billingPeriod =
            $updatedSubscription->start_date .
            "-" .
            $updatedSubscription->end_date;
        self::$commandObject->info("Bill entry created");
        return Billing::create([
            "bill_number" => $billNumber,
            "account_id" => $accountID,
            "status_code" => 0, 
            "bill_issued_date" => $todaysDateString,
            "bill_due_date" => $billDueDateString,
            "bill_amount" => $planFees + $previousOutstandingAmount, 
            "prev_due_amount" => $previousOutstandingAmount, 
            "plan_id" => $planID, 
            "financial_year" => $finanicalYear,
            "billing_period" => $billingPeriod,
        ]);
    }
public static function createBillingEntry ( $ subscription , $ updatedSubscription ) { $ todaysDate = Carbon :: now ( ) ; $ todaysDateString = $ todaysDate -> toDateString ( ) ; $ billDueDate = $ todaysDate -> addDays ( 7 ) ; $ billDueDateString = $ billDueDate -> toDateString ( ) ; $ billNumber = BillingServices :: generateBillNumber ( ) ; $ finanicalYear = CommonServices :: getFinancialYear ( ) ; $ previousOutstandingAmount = $ subscription [ " account " ] [ " outstanding_payment " ] ; $ accountID = $ subscription [ " account_id " ] ; $ planFees = $ updatedSubscription [ " plan " ] [ " fee " ] ; $ planID = $ updatedSubscription [ " plan_id " ] ; $ billingPeriod = $ updatedSubscription -> start_date . " - " . $ updatedSubscription -> end_date ; self :: $ commandObject -> info ( " Bill entry created " ) ; return Billing :: create ( [ " bill_number " => $ billNumber , " account_id " => $ accountID , " status_code " => 0 , " bill_issued_date " => $ todaysDateString , " bill_due_date " => $ billDueDateString , " bill_amount " => $ planFees + $ previousOutstandingAmount , " prev_due_amount " => $ previousOutstandingAmount , " plan_id " => $ planID , " financial_year " => $ finanicalYear , " billing_period " => $ billingPeriod , ] ) ; }
Creates bill.
Creates bill .
// bill due date 7 days from bill generation date //account related details //plan related details //unpaid status code // total amount // from account table // from subscription table