def _authorize_form_get_invalid_parameters(self, tx, data): invalid_parameters = [] if self.acquirer_reference and data.get('x_trans_id') != self.acquirer_reference: invalid_parameters.append(('Transaction Id', data.get('x_trans_id'), self.acquirer_reference)) # check what is buyed if float_compare(float(data.get('x_amount', '0.0')), tx.amount, 2) != 0: invalid_parameters.append(('Amount', data.get('x_amount'), '%.2f' % tx.amount)) return invalid_parameters
def _transfer_form_get_invalid_parameters(self, cr, uid, tx, data, context=None): invalid_parameters = [] if float_compare(float(data.get('amount', '0.0')), tx.amount, 2) != 0: invalid_parameters.append(('amount', data.get('amount'), '%.2f' % tx.amount)) if data.get('currency') != tx.currency_id.name: invalid_parameters.append(('currency', data.get('currency'), tx.currency_id.name)) return invalid_parameters
def purchase_order_change(self): result = [] if not self.purchase_id: return {} if not self.partner_id: self.partner_id = self.purchase_id.partner_id.id # Keep existing lines. We want to be able to add several PO on the same invoice. for line in self.invoice_line_ids: result.append({ 'purchase_line_id': line.purchase_line_id.id, 'name': line.name, 'origin': line.origin, 'uom_id': line.uom_id.id, 'product_id': line.product_id.id, 'account_id': line.account_id.id, 'price_unit': line.price_unit, 'quantity': line.quantity, 'discount': line.discount, 'account_analytic_id': line.account_analytic_id.id, 'invoice_line_tax_ids': line.invoice_line_tax_ids.ids, }) for line in self.purchase_id.order_line: # Load a PO line only once if line in self.invoice_line_ids.mapped('purchase_line_id'): continue if line.product_id.purchase_method == 'purchase': qty = line.product_qty - line.qty_invoiced else: qty = line.qty_received - line.qty_invoiced if float_compare(qty, 0.0, precision_rounding=line.product_uom.rounding) <= 0: qty = 0.0 taxes = line.taxes_id or line.product_id.supplier_taxes_id invoice_line_tax_ids = self.purchase_id.fiscal_position_id.map_tax(taxes) data = { 'purchase_line_id': line.id, 'name': line.name, 'origin': self.purchase_id.origin, 'uom_id': line.product_uom.id, 'product_id': line.product_id.id, 'account_id': self.env['account.invoice.line'].with_context({'journal_id': self.journal_id.id, 'type': 'in_invoice'})._default_account(), 'price_unit': line.order_id.currency_id.compute(line.price_unit, self.currency_id), 'quantity': qty, 'discount': 0.0, 'account_analytic_id': line.account_analytic_id.id, 'invoice_line_tax_ids': invoice_line_tax_ids.ids } account = self.env['account.invoice.line'].get_invoice_line_account('in_invoice', line.product_id, self.purchase_id.fiscal_position_id, self.env.user.company_id) if account: data['account_id'] = account.id result.append(data) self.invoice_line_ids = False # To avoid duplicates self.invoice_line_ids = result self.purchase_id = False return {}
def _buckaroo_form_get_invalid_parameters(self, cr, uid, tx, data, context=None): invalid_parameters = [] if tx.acquirer_reference and data.get('BRQ_TRANSACTIONS') != tx.acquirer_reference: invalid_parameters.append(('Transaction Id', data.get('BRQ_TRANSACTIONS'), tx.acquirer_reference)) # check what is buyed if float_compare(float(data.get('BRQ_AMOUNT', '0.0')), tx.amount, 2) != 0: invalid_parameters.append(('Amount', data.get('BRQ_AMOUNT'), '%.2f' % tx.amount)) if data.get('BRQ_CURRENCY') != tx.currency_id.name: invalid_parameters.append(('Currency', data.get('BRQ_CURRENCY'), tx.currency_id.name)) return invalid_parameters
def _paypal_form_get_invalid_parameters(self, cr, uid, tx, data, context=None): invalid_parameters = [] if data.get('notify_version')[0] != '3.4': _logger.warning( 'Received a notification from Paypal with version %s instead of 2.6. This could lead to issues when managing it.' % data.get('notify_version') ) if data.get('test_ipn'): _logger.warning( 'Received a notification from Paypal using sandbox' ), # TODO: txn_id: shoudl be false at draft, set afterwards, and verified with txn details if tx.acquirer_reference and data.get('txn_id') != tx.acquirer_reference: invalid_parameters.append(('txn_id', data.get('txn_id'), tx.acquirer_reference)) # check what is buyed if float_compare(float(data.get('mc_gross', '0.0')), (tx.amount + tx.fees), 2) != 0: invalid_parameters.append(('mc_gross', data.get('mc_gross'), '%.2f' % tx.amount)) # mc_gross is amount + fees if data.get('mc_currency') != tx.currency_id.name: invalid_parameters.append(('mc_currency', data.get('mc_currency'), tx.currency_id.name)) if 'handling_amount' in data and float_compare(float(data.get('handling_amount')), tx.fees, 2) != 0: invalid_parameters.append(('handling_amount', data.get('handling_amount'), tx.fees)) # check buyer if tx.payment_method_id and data.get('payer_id') != tx.payment_method_id.acquirer_ref: invalid_parameters.append(('payer_id', data.get('payer_id'), tx.payment_method_id.acquirer_ref)) # check seller if data.get('receiver_id') and tx.acquirer_id.paypal_seller_account and data['receiver_id'] != tx.acquirer_id.paypal_seller_account: invalid_parameters.append(('receiver_id', data.get('receiver_id'), tx.acquirer_id.paypal_seller_account)) if not data.get('receiver_id') or not tx.acquirer_id.paypal_seller_account: # Check receiver_email only if receiver_id was not checked. # In Paypal, this is possible to configure as receiver_email a different email than the business email (the login email) # In eCore, there is only one field for the Paypal email: the business email. This isn't possible to set a receiver_email # different than the business email. Therefore, if you want such a configuration in your Paypal, you are then obliged to fill # the Merchant ID in the Paypal payment acquirer in eCore, so the check is performed on this variable instead of the receiver_email. # At least one of the two checks must be done, to avoid fraudsters. if data.get('receiver_email') != tx.acquirer_id.paypal_email_account: invalid_parameters.append(('receiver_email', data.get('receiver_email'), tx.acquirer_id.paypal_email_account)) return invalid_parameters
def _ogone_form_get_invalid_parameters(self, cr, uid, tx, data, context=None): invalid_parameters = [] # TODO: txn_id: should be false at draft, set afterwards, and verified with txn details if tx.acquirer_reference and data.get('PAYID') != tx.acquirer_reference: invalid_parameters.append(('PAYID', data.get('PAYID'), tx.acquirer_reference)) # check what is bought if float_compare(float(data.get('amount', '0.0')), tx.amount, 2) != 0: invalid_parameters.append(('amount', data.get('amount'), '%.2f' % tx.amount)) if data.get('currency') != tx.currency_id.name: invalid_parameters.append(('currency', data.get('currency'), tx.currency_id.name)) return invalid_parameters
def _authorize_form_get_invalid_parameters(self, tx, data): invalid_parameters = [] if self.acquirer_reference and data.get( 'x_trans_id') != self.acquirer_reference: invalid_parameters.append( ('Transaction Id', data.get('x_trans_id'), self.acquirer_reference)) # check what is buyed if float_compare(float(data.get('x_amount', '0.0')), tx.amount, 2) != 0: invalid_parameters.append( ('Amount', data.get('x_amount'), '%.2f' % tx.amount)) return invalid_parameters
def _sips_form_get_invalid_parameters(self, tx, data): invalid_parameters = [] data = self._sips_data_to_object(data.get('Data')) # TODO: txn_id: should be false at draft, set afterwards, and verified with txn details if tx.acquirer_reference and data.get('transactionReference') != tx.acquirer_reference: invalid_parameters.append(('transactionReference', data.get('transactionReference'), tx.acquirer_reference)) # check what is bought if float_compare(float(data.get('amount', '0.0')) / 100, tx.amount, 2) != 0: invalid_parameters.append(('amount', data.get('amount'), '%.2f' % tx.amount)) if tx.partner_reference and data.get('customerId') != tx.partner_reference: invalid_parameters.append(('customerId', data.get('customerId'), tx.partner_reference)) return invalid_parameters
def _transfer_form_get_invalid_parameters(self, cr, uid, tx, data, context=None): invalid_parameters = [] if float_compare(float(data.get('amount', '0.0')), tx.amount, 2) != 0: invalid_parameters.append( ('amount', data.get('amount'), '%.2f' % tx.amount)) if data.get('currency') != tx.currency_id.name: invalid_parameters.append( ('currency', data.get('currency'), tx.currency_id.name)) return invalid_parameters
def _ogone_form_get_invalid_parameters(self, cr, uid, tx, data, context=None): invalid_parameters = [] # TODO: txn_id: should be false at draft, set afterwards, and verified with txn details if tx.acquirer_reference and data.get( 'PAYID') != tx.acquirer_reference: invalid_parameters.append( ('PAYID', data.get('PAYID'), tx.acquirer_reference)) # check what is bought if float_compare(float(data.get('amount', '0.0')), tx.amount, 2) != 0: invalid_parameters.append( ('amount', data.get('amount'), '%.2f' % tx.amount)) if data.get('currency') != tx.currency_id.name: invalid_parameters.append( ('currency', data.get('currency'), tx.currency_id.name)) return invalid_parameters
def _buckaroo_form_get_invalid_parameters(self, cr, uid, tx, data, context=None): invalid_parameters = [] if tx.acquirer_reference and data.get( 'BRQ_TRANSACTIONS') != tx.acquirer_reference: invalid_parameters.append( ('Transaction Id', data.get('BRQ_TRANSACTIONS'), tx.acquirer_reference)) # check what is buyed if float_compare(float(data.get('BRQ_AMOUNT', '0.0')), tx.amount, 2) != 0: invalid_parameters.append( ('Amount', data.get('BRQ_AMOUNT'), '%.2f' % tx.amount)) if data.get('BRQ_CURRENCY') != tx.currency_id.name: invalid_parameters.append( ('Currency', data.get('BRQ_CURRENCY'), tx.currency_id.name)) return invalid_parameters
def _schedule_hours(self, cr, uid, id, hours, day_dt=None, compute_leaves=False, resource_id=None, default_interval=None, context=None): """ Schedule hours of work, using a calendar and an optional resource to compute working and leave days. This method can be used backwards, i.e. scheduling days before a deadline. :param int hours: number of hours to schedule. Use a negative number to compute a backwards scheduling. :param datetime day_dt: reference date to compute working days. If days is > 0 date is the starting date. If days is < 0 date is the ending date. :param boolean compute_leaves: if set, compute the leaves based on calendar and resource. Otherwise no leaves are taken into account. :param int resource_id: the id of the resource to take into account when computing the leaves. If not set, only general leaves are computed. If set, generic and specific leaves are computed. :param tuple default_interval: if no id, try to return a default working day using default_interval[0] as beginning hour, and default_interval[1] as ending hour. Example: default_interval = (8, 16). Otherwise, a void list of working intervals is returned when id is None. :return tuple (datetime, intervals): datetime is the beginning/ending date of the schedulign; intervals are the working intervals of the scheduling. Note: Why not using rrule.rrule ? Because rrule does not seem to allow getting back in time. """ if day_dt is None: day_dt = datetime.datetime.now() backwards = (hours < 0) hours = abs(hours) intervals = [] remaining_hours = hours * 1.0 iterations = 0 current_datetime = day_dt call_args = dict(compute_leaves=compute_leaves, resource_id=resource_id, default_interval=default_interval, context=context) while float_compare( remaining_hours, 0.0, precision_digits=2) in (1, 0) and iterations < 1000: if backwards: call_args['end_dt'] = current_datetime else: call_args['start_dt'] = current_datetime working_intervals = self.get_working_intervals_of_day( cr, uid, id, **call_args) if id is None and not working_intervals: # no calendar -> consider working 8 hours remaining_hours -= 8.0 elif working_intervals: if backwards: working_intervals.reverse() new_working_intervals = self.interval_schedule_hours( working_intervals, remaining_hours, not backwards) if backwards: new_working_intervals.reverse() res = datetime.timedelta() for interval in working_intervals: res += interval[1] - interval[0] remaining_hours -= (seconds(res) / 3600.0) if backwards: intervals = new_working_intervals + intervals else: intervals = intervals + new_working_intervals # get next day if backwards: current_datetime = datetime.datetime.combine( self.get_previous_day(cr, uid, id, current_datetime, context), datetime.time(23, 59, 59)) else: current_datetime = datetime.datetime.combine( self.get_next_day(cr, uid, id, current_datetime, context), datetime.time()) # avoid infinite loops iterations += 1 return intervals