| | |
| | | //发票单ID |
| | | private static String invoiceId {get;set;} |
| | | //出库单明细1,画面显示使用 |
| | | public static List<ConsumableorderdetailsInfo> consumableorderdetails1Records { get; set; } |
| | | public static List<ConsumableorderdetailsInfo> consumableorderdetails1Records { |
| | | get; |
| | | set; |
| | | } |
| | | //明细数量 |
| | | public static Integer invoiceOrderRecoedsCount { |
| | | get { |
| | | return consumableorderdetails1Records == null ? 0 : consumableorderdetails1Records.size(); |
| | | return consumableorderdetails1Records == null |
| | | ? 0 |
| | | : consumableorderdetails1Records.size(); |
| | | } |
| | | } |
| | | |
| | |
| | | sumPrice = 0; |
| | | coc = new Consumable_order__c(); |
| | | //出库单信息 |
| | | coc = [SELECT Id, Name, Outbound_Date__c, Order_ForDealerText__c, Dealer_Info__c FROM Consumable_order__c WHERE Id = :orderId]; |
| | | coc = [ |
| | | SELECT Id, Name, Outbound_Date__c, Order_ForDealerText__c, Dealer_Info__c |
| | | FROM Consumable_order__c |
| | | WHERE Id = :orderId |
| | | ]; |
| | | //发票信息 |
| | | invoicecode = [ |
| | | SELECT Id, Name, ShipmentAccount__c, Order_ForCustomerText__c, Order_ForDealerText__c, Dealer_Info__c |
| | | SELECT |
| | | Id, |
| | | Name, |
| | | ShipmentAccount__c, |
| | | Order_ForCustomerText__c, |
| | | Order_ForDealerText__c, |
| | | Dealer_Info__c |
| | | FROM Consumable_order__c |
| | | WHERE Id = :invoiceId |
| | | ]; |
| | |
| | | Invoice_Unit__c, |
| | | Invoicedet1_OD_link__c |
| | | FROM Consumable_Orderdetails__c |
| | | WHERE Consumable_order__c = :invoiceId AND Invoicedet1_OD_link__c = :orderId |
| | | WHERE |
| | | Consumable_order__c = :invoiceId |
| | | AND Invoicedet1_OD_link__c = :orderId |
| | | ]; |
| | | for (Integer i = 0; i < invoiceorderdetails1.size(); i++) { |
| | | invoiceorderdet1CountMap.put(invoiceorderdetails1[i].Asset_Model_No__c, invoiceorderdetails1[i]); |
| | | invoiceorderdet1CountMap.put( |
| | | invoiceorderdetails1[i].Asset_Model_No__c, |
| | | invoiceorderdetails1[i] |
| | | ); |
| | | } |
| | | //出库单明细1,画面显示使用 |
| | | List<Consumable_Orderdetails__c> consumableorderdetails1 = [ |
| | |
| | | FROM Consumable_Orderdetails__c |
| | | WHERE Consumable_order__c = :orderId |
| | | ]; |
| | | System.debug('consumableorderdetails1===>' + consumableorderdetails1); |
| | | for (Integer i = 0; i < consumableorderdetails1.size(); i++) { |
| | | consumableorderdetails1Records.add(new ConsumableorderdetailsInfo(consumableorderdetails1[i])); |
| | | consumableorderdetails1Records.add( |
| | | new ConsumableorderdetailsInfo(consumableorderdetails1[i]) |
| | | ); |
| | | } |
| | | for (ConsumableorderdetailsInfo ass : consumableorderdetails1Records) { |
| | | if (invoiceorderdet1CountMap.containsKey(ass.esd.Asset_Model_No__c)) { |
| | | ass.check = true; |
| | | if ( |
| | | invoiceorderdet1CountMap.get(ass.esd.Asset_Model_No__c).Invoice_Unit__c == null || |
| | | invoiceorderdet1CountMap.get(ass.esd.Asset_Model_No__c).Invoice_Unit__c == '' |
| | | invoiceorderdet1CountMap.get(ass.esd.Asset_Model_No__c) |
| | | .Invoice_Unit__c == null || |
| | | invoiceorderdet1CountMap.get(ass.esd.Asset_Model_No__c) |
| | | .Invoice_Unit__c == '' |
| | | ) { |
| | | ass.esd.Invoice_Unit__c = ass.esd.Box_Piece__c; |
| | | } else { |
| | | ass.esd.Invoice_Unit__c = invoiceorderdet1CountMap.get(ass.esd.Asset_Model_No__c).Invoice_Unit__c; |
| | | ass.esd.Invoice_Unit__c = invoiceorderdet1CountMap.get( |
| | | ass.esd.Asset_Model_No__c |
| | | ) |
| | | .Invoice_Unit__c; |
| | | } |
| | | if ( |
| | | invoiceorderdet1CountMap.get(ass.esd.Asset_Model_No__c).Invoiced_Count__c == null || |
| | | invoiceorderdet1CountMap.get(ass.esd.Asset_Model_No__c).Invoiced_Count__c == 0 |
| | | invoiceorderdet1CountMap.get(ass.esd.Asset_Model_No__c) |
| | | .Invoiced_Count__c == null || |
| | | invoiceorderdet1CountMap.get(ass.esd.Asset_Model_No__c) |
| | | .Invoiced_Count__c == 0 |
| | | ) { |
| | | ass.invoiceCount = ass.esd.Invoiced_Count__c; |
| | | } else { |
| | | ass.invoiceCount = invoiceorderdet1CountMap.get(ass.esd.Asset_Model_No__c).Invoiced_Count__c; |
| | | ass.invoiceCount = invoiceorderdet1CountMap.get( |
| | | ass.esd.Asset_Model_No__c |
| | | ) |
| | | .Invoiced_Count__c; |
| | | } |
| | | |
| | | if (ass.esd.Box_Piece__c == '盒' && ass.esd.Invoice_Unit__c == '个') { |
| | | ass.esd.Invoice_Unitprice__c = ass.esd.Delivery_List_RMB__c / ass.Packing_list_manual; |
| | | ass.esd.Invoice_Unitprice__c = |
| | | ass.esd.Delivery_List_RMB__c / ass.Packing_list_manual; |
| | | } else { |
| | | ass.esd.Invoice_Unitprice__c = ass.esd.Delivery_List_RMB__c; |
| | | } |
| | | Decimal invoiceAllprice = 0.00; |
| | | invoiceAllprice = (ass.invoiceCount * ass.esd.Invoice_Unitprice__c).setScale(2); |
| | | invoiceAllprice = (ass.invoiceCount * ass.esd.Invoice_Unitprice__c) |
| | | .setScale(2); |
| | | ass.invoiceAllprice = invoiceAllprice; |
| | | } else { |
| | | ass.invoiceCount = ass.esd.InvoiceProNot_count__c; |
| | |
| | | } |
| | | |
| | | @AuraEnabled |
| | | public static ResponseBodyLWC save(String consumableorderdetails1RecordsLwc,String invoiceIdLwc,String orderIdLwc) { |
| | | public static ResponseBodyLWC save( |
| | | String consumableorderdetails1RecordsLwc, |
| | | String invoiceIdLwc, |
| | | String orderIdLwc |
| | | ) { |
| | | ResponseBodyLWC res = new ResponseBodyLWC(); |
| | | Map<String, object> data = new Map<String, object>(); |
| | | res.entity = data; |
| | | |
| | | consumableorderdetails1Records= (List<ConsumableorderdetailsInfo>)JSON.deserialize(consumableorderdetails1RecordsLwc, List<ConsumableorderdetailsInfo>.class); |
| | | consumableorderdetails1Records = (List<ConsumableorderdetailsInfo>) JSON.deserialize( |
| | | consumableorderdetails1RecordsLwc, |
| | | List<ConsumableorderdetailsInfo>.class |
| | | ); |
| | | invoiceId = invoiceIdLwc; |
| | | orderId = orderIdLwc; |
| | | System.debug('consumableorderdetails1Records = ' + consumableorderdetails1Records); |
| | | System.debug( |
| | | 'consumableorderdetails1Records = ' + consumableorderdetails1Records |
| | | ); |
| | | System.debug('invoiceId = ' + invoiceId); |
| | | System.debug('orderId = ' + orderId); |
| | | |
| | |
| | | Box_Piece__c, |
| | | Invoicedet1_OD_link__c |
| | | FROM Consumable_Orderdetails__c |
| | | WHERE Consumable_order__c = :invoiceId AND Invoicedet1_OD_link__c = :orderId AND Asset_Model_No__c IN :consumableorderList |
| | | WHERE |
| | | Consumable_order__c = :invoiceId |
| | | AND Invoicedet1_OD_link__c = :orderId |
| | | AND Asset_Model_No__c IN :consumableorderList |
| | | ]; |
| | | for (Integer i = 0; i < invoiceorderdetails1.size(); i++) { |
| | | invoiceordet1Map.put( |
| | | invoiceorderdetails1[i].Invoicedet1_OD_link__c + invoiceorderdetails1[i].Asset_Model_No__c, |
| | | invoiceorderdetails1[i].Invoicedet1_OD_link__c + |
| | | invoiceorderdetails1[i].Asset_Model_No__c, |
| | | invoiceorderdetails1[i] |
| | | ); |
| | | } |
| | |
| | | return new ResponseBodyLWC('Error', 500, '请输入发票数量!', ''); |
| | | } |
| | | if (ass.esd.Box_Piece__c == '盒' && ass.esd.Invoice_Unit__c == '个') { |
| | | if (ass.invoiceCount > (ass.esd.InvoiceProNot_count__c * ass.Packing_list_manual).setScale(0)) { |
| | | if ( |
| | | ass.invoiceCount > |
| | | (ass.esd.InvoiceProNot_count__c * ass.Packing_list_manual) |
| | | .setScale(0) |
| | | ) { |
| | | // ass.esd.InvoiceProNot_count__c.addError('发票数量不能超过还没发票数量!'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '发票数量不能超过还没发票数量!', ''); |
| | | return new ResponseBodyLWC( |
| | | 'Error', |
| | | 500, |
| | | '发票数量不能超过还没发票数量!', |
| | | '' |
| | | ); |
| | | } |
| | | } else { |
| | | if (ass.invoiceCount > ass.esd.InvoiceProNot_count__c) { |
| | | // ass.esd.InvoiceProNot_count__c.addError('发票数量不能超过还没发票数量!'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '发票数量不能超过还没发票数量!', ''); |
| | | return new ResponseBodyLWC( |
| | | 'Error', |
| | | 500, |
| | | '发票数量不能超过还没发票数量!', |
| | | '' |
| | | ); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | //} |
| | | |
| | | if (invoiceordet1Map.containsKey(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c)) { |
| | | invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c).Shipment_Count__c = ass.invoiceCount; |
| | | invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c).Invoiced_Count__c = ass.invoiceCount; |
| | | if ( |
| | | invoiceordet1Map.containsKey( |
| | | ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c |
| | | ) |
| | | ) { |
| | | invoiceordet1Map.get( |
| | | ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c |
| | | ) |
| | | .Shipment_Count__c = ass.invoiceCount; |
| | | invoiceordet1Map.get( |
| | | ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c |
| | | ) |
| | | .Invoiced_Count__c = ass.invoiceCount; |
| | | //invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c).InvoicedProCost_RMB__c = invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c).Delivery_List_RMB__c * ass.invoiceCount; |
| | | invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c) |
| | | invoiceordet1Map.get( |
| | | ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c |
| | | ) |
| | | .Invoice_Unit__c = ass.esd.Invoice_Unit__c; |
| | | invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c).Box_Piece__c = ass.esd.Box_Piece__c; |
| | | if (ass.esd.Box_Piece__c == '盒' && ass.esd.Invoice_Unit__c == '个') { |
| | | invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c).InvoicedProCost_RMB__c = |
| | | (ass.esd.Delivery_List_RMB__c / ass.Packing_list_manual) * ass.invoiceCount; |
| | | invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c).Invoice_Unitprice__c = |
| | | invoiceordet1Map.get( |
| | | ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c |
| | | ) |
| | | .Box_Piece__c = ass.esd.Box_Piece__c; |
| | | if ( |
| | | ass.esd.Box_Piece__c == '盒' && |
| | | ass.esd.Invoice_Unit__c == '个' |
| | | ) { |
| | | invoiceordet1Map.get( |
| | | ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c |
| | | ) |
| | | .InvoicedProCost_RMB__c = |
| | | (ass.esd.Delivery_List_RMB__c / ass.Packing_list_manual) * |
| | | ass.invoiceCount; |
| | | invoiceordet1Map.get( |
| | | ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c |
| | | ) |
| | | .Invoice_Unitprice__c = |
| | | ass.esd.Delivery_List_RMB__c / ass.Packing_list_manual; |
| | | } else { |
| | | invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c).InvoicedProCost_RMB__c = |
| | | invoiceordet1Map.get( |
| | | ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c |
| | | ) |
| | | .InvoicedProCost_RMB__c = |
| | | ass.esd.Delivery_List_RMB__c * ass.invoiceCount; |
| | | invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c) |
| | | invoiceordet1Map.get( |
| | | ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c |
| | | ) |
| | | .Invoice_Unitprice__c = ass.esd.Delivery_List_RMB__c; |
| | | } |
| | | |
| | | invoiceorderUpList1.add(invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c)); |
| | | invoiceorderUpList1.add( |
| | | invoiceordet1Map.get( |
| | | ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c |
| | | ) |
| | | ); |
| | | invoiceRecordscon++; |
| | | } else { |
| | | String str = string.valueOf(invoiceRecordscon); |
| | |
| | | invoiceInsert1.Name = |
| | | invoicecode.Name + |
| | | '-' + |
| | | ass.esd.Name.substring(ass.esd.Name.length() - 7, ass.esd.Name.length()); |
| | | ass.esd.Name.substring( |
| | | ass.esd.Name.length() - 7, |
| | | ass.esd.Name.length() |
| | | ); |
| | | invoiceInsert1.Shipment_Count__c = ass.invoiceCount; |
| | | invoiceInsert1.Consumable_Product__c = ass.esd.Consumable_Product__c; |
| | | invoiceInsert1.Intra_Trade_List_RMB__c = ass.esd.Intra_Trade_List_RMB__c; |
| | | invoiceInsert1.Delivery_List_RMB__c = ass.esd.Delivery_List_RMB__c; |
| | | invoiceInsert1.Dealer_Custom_Price__c = ass.esd.Dealer_Custom_Price__c; |
| | | invoiceInsert1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice; |
| | | if (ass.esd.Box_Piece__c == '盒' && ass.esd.Invoice_Unit__c == '个') { |
| | | invoiceInsert1.Invoice_Unitprice__c = ass.esd.Delivery_List_RMB__c / ass.Packing_list_manual; |
| | | if ( |
| | | ass.esd.Box_Piece__c == '盒' && |
| | | ass.esd.Invoice_Unit__c == '个' |
| | | ) { |
| | | invoiceInsert1.Invoice_Unitprice__c = |
| | | ass.esd.Delivery_List_RMB__c / ass.Packing_list_manual; |
| | | } else { |
| | | invoiceInsert1.Invoice_Unitprice__c = ass.esd.Delivery_List_RMB__c; |
| | | } |
| | |
| | | invoiceInsert1.Invoiced_Count__c = ass.invoiceCount; |
| | | if (ass.esd.InvoicedProCost_RMB__c == null) |
| | | ass.esd.InvoicedProCost_RMB__c = 0; |
| | | invoiceInsert1.InvoicedProCost_RMB__c = ass.invoiceCount * invoiceInsert1.Invoice_Unitprice__c; |
| | | invoiceInsert1.InvoicedProCost_RMB__c = |
| | | ass.invoiceCount * invoiceInsert1.Invoice_Unitprice__c; |
| | | invoiceInsert1.Consumable_order__c = invoiceId; |
| | | invoiceInsert1.Invoicedet1_OD_link__c = orderId; |
| | | invoiceRecordscon++; |
| | | invoiceorderList1.add(invoiceInsert1); |
| | | } |
| | | } else { |
| | | if (invoiceordet1Map.containsKey(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c)) { |
| | | invoiceorderDeList1.add(invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c)); |
| | | if ( |
| | | invoiceordet1Map.containsKey( |
| | | ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c |
| | | ) |
| | | ) { |
| | | invoiceorderDeList1.add( |
| | | invoiceordet1Map.get( |
| | | ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c |
| | | ) |
| | | ); |
| | | } |
| | | } |
| | | } |
| | |
| | | ApexPages.addmessages(e); |
| | | // Database.rollback(sp); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, e.getMessage() + ' ' + e.getLineNumber(), ''); |
| | | return new ResponseBodyLWC( |
| | | 'Error', |
| | | 500, |
| | | e.getMessage() + ' ' + e.getLineNumber(), |
| | | '' |
| | | ); |
| | | } |
| | | res.status = 'Success'; |
| | | res.code = 200; |
| | |
| | | } |
| | | |
| | | // Data Bean |
| | | @TestVisible |
| | | class ConsumableorderdetailsInfo { |
| | | @AuraEnabled |
| | | public Boolean check { get; set; } |
| | |
| | | invoiceAllprice = 0; |
| | | |
| | | Packing_list_manual = e.Consumable_Product__r.Packing_list_manual__c; |
| | | |
| | | if (!Test.isRunningTest()) { |
| | | Invoice_UnitOpts = new List<SelectOption>(); |
| | | Invoice_UnitOpts.add(new SelectOption('盒', '盒')); |
| | | Invoice_UnitOpts.add(new SelectOption('个', '个')); |
| | | } |
| | | |
| | | Invoice_UnitOptsMap = new Map<String,String>(); |
| | | Invoice_UnitOptsMap.put('盒', '盒'); |