forked from onepica/avatax
/
Queue.php
130 lines (117 loc) · 3 KB
/
Queue.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
/**
* OnePica_AvaTax
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0), a
* copy of which is available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category OnePica
* @package OnePica_AvaTax
* @author OnePica Codemaster <codemaster@onepica.com>
* @copyright Copyright (c) 2009 One Pica, Inc.
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*
* @method OnePica_AvaTax_Model_Records_Mysql4_Queue _getResource()
*/
/**
* Queue model
*
* @category OnePica
* @package OnePica_AvaTax
* @author OnePica Codemaster <codemaster@onepica.com>
*/
class OnePica_AvaTax_Model_Records_Queue extends Mage_Core_Model_Abstract
{
/**
* Invoice type
*/
const QUEUE_TYPE_INVOICE = 'Invoice';
/**
* Credit memo type
*/
const QUEUE_TYPE_CREDITMEMEO = 'Credit memo';
/**
* Pending status
*/
const QUEUE_STATUS_PENDING = 'Pending';
/**
* Retry status
*/
const QUEUE_STATUS_RETRY = 'Retry pending';
/**
* Failed status
*/
const QUEUE_STATUS_FAILED = 'Failed';
/**
* Complete status
*/
const QUEUE_STATUS_COMPLETE = 'Complete';
/**
* Unbalanced status
*/
const QUEUE_STATUS_UNBALANCED = 'Unbalanced';
/**
* Internal constructor
*/
protected function _construct()
{
parent::_construct();
$this->_init('avatax_records/queue');
}
/**
* Set entity
*
* @param Mage_Sales_Model_Order_Invoice|Mage_Sales_Model_Order_Creditmemo $object
* @return $this
*/
public function setEntity($object)
{
$this->setEntityId($object->getId());
$this->setEntityIncrementId($object->getIncrementId());
$this->setStoreId($object->getStoreId());
return $this;
}
/**
* Get type options
*
* @return array
*/
public function getTypeOptions()
{
return array(
self::QUEUE_TYPE_INVOICE => self::QUEUE_TYPE_INVOICE,
self::QUEUE_TYPE_CREDITMEMEO => self::QUEUE_TYPE_CREDITMEMEO
);
}
/**
* Get status options
*
* @return array
*/
public function getStatusOptions()
{
return array(
self::QUEUE_STATUS_PENDING => self::QUEUE_STATUS_PENDING,
self::QUEUE_STATUS_RETRY => self::QUEUE_STATUS_RETRY,
self::QUEUE_STATUS_FAILED => self::QUEUE_STATUS_FAILED,
self::QUEUE_STATUS_COMPLETE => self::QUEUE_STATUS_COMPLETE,
self::QUEUE_STATUS_UNBALANCED => self::QUEUE_STATUS_UNBALANCED
);
}
/**
* Load invoice by increment id
*
* @param int $incrementId
* @return $this
*/
public function loadInvoiceByIncrementId($incrementId)
{
$this->_getResource()->loadInvoiceByIncrementId($this, $incrementId);
$this->_afterLoad();
$this->setOrigData();
return $this;
}
}