Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update to mapping, starting to refactor createBillingAgreements

  • Loading branch information...
commit 57baa2f8cd96f7cbabaabb1afb08398d49593f6e 1 parent f1006b9
@iampersistent iampersistent authored
View
22 lib/Vespolina/Billing/Manager/BillingManager.php
@@ -51,27 +51,19 @@ public function createBillingAgreements(OrderInterface $order)
{
/** @var $item */
foreach ($order->getItems() as $item) {
+
+ $pricingSet = $item->getPricing();
+ if ($pricingSet->get)
+ $startDate = new \DateTime('now');
+
$billingAgreement = new BillingAgreement();
$billingAgreement
->setPaymentGateway($order->getAttribute('payment_gateway'))
->setPartner($order->getOwner())
->setInitialBillingDate(new \DateTime('now'))
- ->setBillingAmount($item->getNetValue())
- ->setOrder($order)
+ ->setBillingAmount()
+ ->setOrderItem($item)
;
-
- // buying a monthly license
- if ($item->getAttribute('type_of_product')) {
- $billingAgreement
- ->setBillingCycles(30)
- ->setNextBillingDate(new \DateTime('next month'))
- ;
- } else { // case of the upgrade to pro account
- $billingAgreement
- ->setBillingCycles(365)
- ->setNextBillingDate(new \DateTime('next year'))
- ;
- }
}
return array();
View
12 lib/Vespolina/Billing/Mapping/BillingAgreement.orm.xml
@@ -9,11 +9,16 @@
<generator strategy="AUTO" />
</id>
+ <field name="active" type="boolean" />
<field name="billingAmount" type="float" />
<field name="billingCycles" type="integer" />
<field name="billingInterval" type="string" />
+ <field name="createdAt" type="datetime" />
<field name="initialBillingDate" type="datetime" />
+ <field name="nextBillingDate" type="datetime" />
<field name="paymentGateway" type="string" />
+ <field name="processedCycles" type="integer" />
+ <field name="updatedAt" type="datetime" />
<one-to-one field="partner" target-entity="Vespolina\Entity\Partner\PartnerInterface">
<join-column name="partner_id" referenced-column-name="id" />
@@ -21,5 +26,12 @@
<many-to-one field="order" target-entity="Vespolina\Entity\Order\OrderInterface" inversed-by="billingAgreements">
<join-column name="order_id" referenced-column-name="id" />
</many-to-one>
+ <one-to-one field="orderItem" target-entity="Vespolina\Entity\Order\ItemInterface">
+ </one-to-one>
+
+ <lifecycle-callbacks>
+ <lifecycle-callback type="prePersist" method="autoSetCreatedAt" />
+ <lifecycle-callback type="preUpdate" method="autoSetUpdatedAt" />
+ </lifecycle-callbacks>
</entity>
</doctrine-mapping>
View
6 tests/Manager/BillingManagerTest.php
@@ -14,4 +14,10 @@ public function test()
// submit current bill to CC
// create licenses when CC is approved
}
+
+ public function testCreateBillingAgreements()
+ {
+ $this->
+ $this->markTestIncomplete('test for non-recurring items in order');
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.