mirror of
https://github.com/internetee/registry.git
synced 2025-05-28 09:51:03 +02:00
Merge branch 'story/105852786-directo' into staging
This commit is contained in:
commit
f755bc29d3
1 changed files with 6 additions and 6 deletions
|
@ -2,7 +2,7 @@ class Directo < ActiveRecord::Base
|
|||
belongs_to :item, polymorphic: true
|
||||
|
||||
def self.send_receipts
|
||||
new_trans = Invoice.where(invoice_type: "DEB", in_directo: false)
|
||||
new_trans = Invoice.where(invoice_type: "DEB", in_directo: false).where.not(cancelled_at: nil)
|
||||
new_trans.find_in_batches(batch_size: 10).each do |group|
|
||||
mappers = {} # need them as no direct connection between invoice
|
||||
builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
|
||||
|
@ -22,10 +22,10 @@ class Directo < ActiveRecord::Base
|
|||
"CustomerCode"=> invoice.buyer.try(:directo_handle)
|
||||
){
|
||||
xml.line(
|
||||
"ProductID"=> Setting.directo_receipt_product_name,
|
||||
"Quantity" => 1,
|
||||
"UnitPriceWoVAT" =>ActionController::Base.helpers.number_with_precision(invoice.sum_cache/(1+invoice.vat_prc), precision: 2, separator: "."),
|
||||
"ProductName" => invoice.description
|
||||
"ProductID" => Setting.directo_receipt_product_name,
|
||||
"Quantity" => 1,
|
||||
"UnitPriceWoVAT" => ActionController::Base.helpers.number_with_precision(invoice.sum_cache/(1+invoice.vat_prc), precision: 2, separator: "."),
|
||||
"ProductName" => invoice.description
|
||||
)
|
||||
}
|
||||
end
|
||||
|
@ -41,7 +41,7 @@ class Directo < ActiveRecord::Base
|
|||
def self.dump_result_to_db mappers, xml
|
||||
Nokogiri::XML(xml).css("Result").each do |res|
|
||||
obj = mappers[res.attributes["docid"].value.to_i]
|
||||
obj.directo_records.first_or_create!(response: res.as_json.to_h)
|
||||
obj.directo_records.create!(response: res.as_json.to_h)
|
||||
obj.update_columns(in_directo: true)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue